Skip to content

Commit

Permalink
FirstCommit
Browse files Browse the repository at this point in the history
  • Loading branch information
zzxxiansheng committed Jan 28, 2024
1 parent f81c0dd commit d9cf419
Show file tree
Hide file tree
Showing 22 changed files with 1,137 additions and 1 deletion.
8 changes: 8 additions & 0 deletions eventmesh-dashboard-console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>5.1.2.RELEASE</version>
</dependency>


</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface EmLog {

String OprType() default "";

String OprTarget() default "";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.entity;

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class GroupEntity {
private Long id;

private Long clusterId;

private String name;

private Integer memberCount;


private String members;

private Integer type;

private String state;

private Timestamp createTime;

private Timestamp updateTime;



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.entity;

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class GroupMemberEntity {
private Long id;

private Long clusterId;

private String topicName;

private String groupName;

private String eventMeshUser;

private String state;

private Timestamp createTime;

private Timestamp updateTime;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.entity;

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class LogEntity {

private Long id;

private Long clusterId;

private String operationType;

private String operationTarget;

private Integer status;

private String description;

private Timestamp createTime;

private Timestamp endTime;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.entity;

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class TopicEntity {
private Long id;

private Long clusterId;

private String topicName;

private String runtimeId;

private String storageId;

private Long retentionMs;

private Integer type;

private String description;

private Timestamp createTime;

private Timestamp updateTime;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.log;

import org.apache.eventmesh.dashboard.console.annotation.EmLog;
import org.apache.eventmesh.dashboard.console.entity.LogEntity;
import org.apache.eventmesh.dashboard.console.log.service.LogService;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.sql.Timestamp;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Service;
import org.springframework.util.ClassUtils;

@Aspect
@Service
public class OprLog implements Ordered {

private int order = LOWEST_PRECEDENCE - 1000; // Specify the order of execution

@Autowired
private LogService logService;

@Pointcut("within(org.apache.eventmesh.dashboard.console.service..*)")
public void pointCut() {
}

@Around("pointCut()")
public Object logStart(ProceedingJoinPoint joinPoint) throws Throwable {
LogEntity logEntity = new LogEntity();
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
Method mostSpecificMethod = ClassUtils.getMostSpecificMethod(method, joinPoint.getTarget().getClass());
EmLog declaredAnnotation = mostSpecificMethod.getAnnotation(EmLog.class);
//Get the Emlog annotation on the method
if (declaredAnnotation != null) {
//It is a method of operation
logEntity.setOperationType(declaredAnnotation.OprType());
logEntity.setOperationType(declaredAnnotation.OprTarget());
Object[] args = joinPoint.getArgs();
Object model = args[0];
//Obtaining the Input Parameter of the Operation Method (Specified as the First)
Field clusterPhyId = model.getClass().getDeclaredField("clusterId");
clusterPhyId.setAccessible(true);
Long opClusterPhyId = (Long) clusterPhyId.get(model);
String opDescription = model.toString();
logEntity.setClusterId(opClusterPhyId);
logEntity.setDescription(opDescription);
//The clusterId is obtained from the parameter object, and the operation is described as the object itself
logEntity.setStatus(1);
logEntity.setCreateTime(new Timestamp(System.currentTimeMillis()));
logService.addLog(logEntity);
Object proceed = joinPoint.proceed();
if (proceed == null) {
//An exception occurred with the target method
logEntity.setStatus(3);
logEntity.setEndTime(new Timestamp(System.currentTimeMillis()));
Integer integer1 = logService.updateLog(logEntity);
return proceed;
} else {
//The target approach is successful
logEntity.setEndTime(new Timestamp(System.currentTimeMillis()));
logEntity.setStatus(2);
Integer integer1 = logService.updateLog(logEntity);
return proceed;
}
} else {
//It is not part of the operation method
return joinPoint.proceed();
}
}

@Override
public int getOrder() {
return order;
}
}
Loading

0 comments on commit d9cf419

Please sign in to comment.