-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f81c0dd
commit d9cf419
Showing
22 changed files
with
1,137 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...hboard-console/src/main/java/org/apache/eventmesh/dashboard/console/annotation/EmLog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ""; | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
...oard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...onsole/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupMemberEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...hboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
||
} |
50 changes: 50 additions & 0 deletions
50
...oard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/TopicEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
100 changes: 100 additions & 0 deletions
100
...sh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.