-
Notifications
You must be signed in to change notification settings - Fork 642
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [ISSUE #5137] update connector runtime v2 module * fix checkStyle error
- Loading branch information
Showing
13 changed files
with
872 additions
and
141 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...common/src/main/java/org/apache/eventmesh/common/remote/request/ReportMonitorRequest.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,38 @@ | ||
/* | ||
* 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.common.remote.request; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.ToString; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@ToString | ||
public class ReportMonitorRequest extends BaseRemoteRequest { | ||
private String taskID; | ||
private String jobID; | ||
private String address; | ||
private String connectorStage; | ||
private String transportType; | ||
private long totalReqNum; | ||
private long totalTimeCost; | ||
private long maxTimeCost; | ||
private long avgTimeCost; | ||
private double tps; | ||
} |
80 changes: 80 additions & 0 deletions
80
.../src/main/java/org/apache/eventmesh/openconnect/api/monitor/AbstractConnectorMonitor.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,80 @@ | ||
/* | ||
* 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.openconnect.api.monitor; | ||
|
||
import java.util.concurrent.atomic.AtomicLong; | ||
import java.util.concurrent.atomic.LongAdder; | ||
|
||
import lombok.Getter; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@Getter | ||
public abstract class AbstractConnectorMonitor implements Monitor { | ||
|
||
private final String taskId; | ||
private final String jobId; | ||
private final String ip; | ||
private final LongAdder totalRecordNum; | ||
private final LongAdder totalTimeCost; | ||
protected final AtomicLong startTime; | ||
private final AtomicLong maxTimeCost; | ||
private long averageTime = 0; | ||
private double tps = 0; | ||
|
||
public AbstractConnectorMonitor(String taskId, String jobId, String ip) { | ||
this.taskId = taskId; | ||
this.jobId = jobId; | ||
this.ip = ip; | ||
this.totalRecordNum = new LongAdder(); | ||
this.totalTimeCost = new LongAdder(); | ||
this.startTime = new AtomicLong(System.currentTimeMillis()); | ||
this.maxTimeCost = new AtomicLong(); | ||
} | ||
|
||
@Override | ||
public synchronized void recordProcess(long timeCost) { | ||
totalRecordNum.increment(); | ||
totalTimeCost.add(timeCost); | ||
maxTimeCost.updateAndGet(max -> Math.max(max, timeCost)); | ||
} | ||
|
||
@Override | ||
public synchronized void recordProcess(int recordCount, long timeCost) { | ||
totalRecordNum.add(recordCount); | ||
totalTimeCost.add(timeCost); | ||
maxTimeCost.updateAndGet(max -> Math.max(max, timeCost)); | ||
} | ||
|
||
@Override | ||
public synchronized void printMetrics() { | ||
long totalRecords = totalRecordNum.sum(); | ||
long totalCost = totalTimeCost.sum(); | ||
averageTime = totalRecords > 0 ? totalCost / totalRecords : 0; | ||
long elapsedTime = (System.currentTimeMillis() - startTime.get()) / 1000; // in seconds | ||
tps = elapsedTime > 0 ? (double) totalRecords / elapsedTime : 0; | ||
|
||
log.info("========== Metrics =========="); | ||
log.info("TaskId: {}|JobId: {}|ip: {}", taskId, jobId, ip); | ||
log.info("Total records: {}", totalRecordNum); | ||
log.info("Total time (ms): {}", totalTimeCost); | ||
log.info("Max time per record (ms): {}", maxTimeCost); | ||
log.info("Average time per record (ms): {}", averageTime); | ||
log.info("TPS: {}", tps); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/api/monitor/Monitor.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,30 @@ | ||
/* | ||
* 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.openconnect.api.monitor; | ||
|
||
/** | ||
* Monitor Interface. | ||
* All monitors should implement this interface. | ||
*/ | ||
public interface Monitor { | ||
void recordProcess(long timeCost); | ||
|
||
void recordProcess(int recordCount, long timeCost); | ||
|
||
void printMetrics(); | ||
} |
34 changes: 34 additions & 0 deletions
34
...nect-java/src/main/java/org/apache/eventmesh/openconnect/api/monitor/MonitorRegistry.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,34 @@ | ||
/* | ||
* 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.openconnect.api.monitor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import lombok.Getter; | ||
|
||
public class MonitorRegistry { | ||
|
||
@Getter | ||
private static final List<Monitor> monitors = new ArrayList<>(); | ||
|
||
public static void registerMonitor(Monitor monitor) { | ||
monitors.add(monitor); | ||
} | ||
|
||
} |
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
Oops, something went wrong.