Merge branch 'master' of https://github.com/apache/incubator-skywalking into master-5.0
This commit is contained in:
commit
df67393bff
11
README.md
11
README.md
|
|
@ -8,7 +8,7 @@ microservices, cloud native and container-based (Docker, K8s, Mesos) architectur
|
|||
Underlying technology is a distributed tracing system.
|
||||
|
||||
[](https://travis-ci.org/apache/incubator-skywalking)
|
||||
[](https://coveralls.io/github/apache/incubator-skywalking?branch=master)
|
||||
[](https://twitter.com/AsfSkyWalking)
|
||||
[](https://gitter.im/openskywalking/Lobby)
|
||||
[](http://opentracing.io)
|
||||
|
||||
|
|
@ -22,12 +22,13 @@ Underlying technology is a distributed tracing system.
|
|||
* Pure Java server implementation, provide RESTful and gRPC services. Compatibility with other language agents/SDKs.
|
||||
* The UI released on [skywalking-ui](https://github.com/apache/incubator-skywalking-ui)
|
||||
|
||||
# Architecture
|
||||
<img src="https://skywalkingtest.github.io/page-resources/3.2.5%2b_architecture.jpg"/>
|
||||
|
||||
# Document
|
||||
[](docs/README.md) [](docs/README_ZH.md)
|
||||
[](docs/README.md) [](docs/README_ZH.md)
|
||||
|
||||
# 5.x Architecture
|
||||
<img src="https://skywalkingtest.github.io/page-resources/5.0/architecture.png"/>
|
||||
|
||||
# Code of conduct
|
||||
This project adheres to the Contributor Covenant [code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to wusheng@apache.org.
|
||||
|
||||
# Screenshots
|
||||
|
|
|
|||
12
README_ZH.md
12
README_ZH.md
|
|
@ -7,7 +7,7 @@ Apache SkyWalking | [English](README.md)
|
|||
其核心是个分布式追踪系统。
|
||||
|
||||
[](https://travis-ci.org/apache/incubator-skywalking)
|
||||
[](https://coveralls.io/github/apache/incubator-skywalking?branch=master)
|
||||
[](https://twitter.com/AsfSkyWalking)
|
||||
[](https://gitter.im/openskywalking/Lobby)
|
||||
[](http://opentracing.io)
|
||||
|
||||
|
|
@ -24,12 +24,14 @@ Apache SkyWalking | [English](README.md)
|
|||
* UI工程请查看 [skywalking-ui](https://github.com/apache/incubator-skywalking-ui)
|
||||
* 中文QQ群:392443393
|
||||
|
||||
# Architecture
|
||||
<img src="https://skywalkingtest.github.io/page-resources/3.2.5%2b_architecture.jpg"/>
|
||||
|
||||
# Document
|
||||
[](docs/README.md) [](docs/README_ZH.md)
|
||||
[](docs/README.md) [](docs/README_ZH.md)
|
||||
|
||||
|
||||
# 5.x Architecture
|
||||
<img src="https://skywalkingtest.github.io/page-resources/5.0/architecture.png"/>
|
||||
|
||||
# code of conduct
|
||||
This project adheres to the Contributor Covenant [code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to wusheng@apache.org.
|
||||
|
||||
# Screenshots
|
||||
|
|
|
|||
|
|
@ -60,6 +60,11 @@
|
|||
<artifactId>jvm-define</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>metric-define</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>register-define</artifactId>
|
||||
|
|
|
|||
|
|
@ -23,10 +23,12 @@ import org.apache.skywalking.apm.collector.agent.grpc.define.AgentGRPCModule;
|
|||
import org.apache.skywalking.apm.collector.agent.grpc.provider.handler.ApplicationRegisterServiceHandler;
|
||||
import org.apache.skywalking.apm.collector.agent.grpc.provider.handler.InstanceDiscoveryServiceHandler;
|
||||
import org.apache.skywalking.apm.collector.agent.grpc.provider.handler.JVMMetricsServiceHandler;
|
||||
import org.apache.skywalking.apm.collector.agent.grpc.provider.handler.NetworkAddressRegisterServiceHandler;
|
||||
import org.apache.skywalking.apm.collector.agent.grpc.provider.handler.ServiceNameDiscoveryServiceHandler;
|
||||
import org.apache.skywalking.apm.collector.agent.grpc.provider.handler.TraceSegmentServiceHandler;
|
||||
import org.apache.skywalking.apm.collector.agent.grpc.provider.handler.naming.AgentGRPCNamingHandler;
|
||||
import org.apache.skywalking.apm.collector.agent.grpc.provider.handler.naming.AgentGRPCNamingListener;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.AnalysisMetricModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.AnalysisSegmentParserModule;
|
||||
import org.apache.skywalking.apm.collector.cluster.ClusterModule;
|
||||
import org.apache.skywalking.apm.collector.cluster.service.ModuleListenerService;
|
||||
|
|
@ -86,7 +88,7 @@ public class AgentModuleGRPCProvider extends ModuleProvider {
|
|||
}
|
||||
|
||||
@Override public String[] requiredModules() {
|
||||
return new String[] {ClusterModule.NAME, NamingModule.NAME, GRPCManagerModule.NAME, AnalysisSegmentParserModule.NAME};
|
||||
return new String[] {ClusterModule.NAME, NamingModule.NAME, GRPCManagerModule.NAME, AnalysisSegmentParserModule.NAME, AnalysisMetricModule.NAME};
|
||||
}
|
||||
|
||||
private void addHandlers(Server gRPCServer) {
|
||||
|
|
@ -95,5 +97,6 @@ public class AgentModuleGRPCProvider extends ModuleProvider {
|
|||
gRPCServer.addHandler(new ServiceNameDiscoveryServiceHandler(getManager()));
|
||||
gRPCServer.addHandler(new JVMMetricsServiceHandler(getManager()));
|
||||
gRPCServer.addHandler(new TraceSegmentServiceHandler(getManager()));
|
||||
gRPCServer.addHandler(new NetworkAddressRegisterServiceHandler(getManager()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,15 +18,14 @@
|
|||
|
||||
package org.apache.skywalking.apm.collector.agent.grpc.provider.handler;
|
||||
|
||||
import com.google.protobuf.ProtocolStringList;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.AnalysisRegisterModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.service.IApplicationIDService;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.server.grpc.GRPCHandler;
|
||||
import org.apache.skywalking.apm.network.proto.ApplicationMappings;
|
||||
import org.apache.skywalking.apm.network.proto.Application;
|
||||
import org.apache.skywalking.apm.network.proto.ApplicationMapping;
|
||||
import org.apache.skywalking.apm.network.proto.ApplicationRegisterServiceGrpc;
|
||||
import org.apache.skywalking.apm.network.proto.Applications;
|
||||
import org.apache.skywalking.apm.network.proto.KeyWithIntegerValue;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -44,19 +43,17 @@ public class ApplicationRegisterServiceHandler extends ApplicationRegisterServic
|
|||
applicationIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IApplicationIDService.class);
|
||||
}
|
||||
|
||||
@Override public void batchRegister(Applications request, StreamObserver<ApplicationMappings> responseObserver) {
|
||||
@Override
|
||||
public void applicationCodeRegister(Application request, StreamObserver<ApplicationMapping> responseObserver) {
|
||||
logger.debug("register application");
|
||||
ProtocolStringList applicationCodes = request.getApplicationCodesList();
|
||||
|
||||
ApplicationMappings.Builder builder = ApplicationMappings.newBuilder();
|
||||
for (int i = 0; i < applicationCodes.size(); i++) {
|
||||
String applicationCode = applicationCodes.get(i);
|
||||
int applicationId = applicationIDService.getOrCreate(applicationCode);
|
||||
ApplicationMapping.Builder builder = ApplicationMapping.newBuilder();
|
||||
String applicationCode = request.getApplicationCode();
|
||||
int applicationId = applicationIDService.getOrCreateForApplicationCode(applicationCode);
|
||||
|
||||
if (applicationId != 0) {
|
||||
KeyWithIntegerValue value = KeyWithIntegerValue.newBuilder().setKey(applicationCode).setValue(applicationId).build();
|
||||
builder.addApplications(value);
|
||||
}
|
||||
if (applicationId != 0) {
|
||||
KeyWithIntegerValue value = KeyWithIntegerValue.newBuilder().setKey(applicationCode).setValue(applicationId).build();
|
||||
builder.setApplication(value);
|
||||
}
|
||||
responseObserver.onNext(builder.build());
|
||||
responseObserver.onCompleted();
|
||||
|
|
|
|||
|
|
@ -21,14 +21,16 @@ package org.apache.skywalking.apm.collector.agent.grpc.provider.handler;
|
|||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.AnalysisMetricModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.service.IInstanceHeartBeatService;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.AnalysisRegisterModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.service.IInstanceIDService;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.server.grpc.GRPCHandler;
|
||||
import org.apache.skywalking.apm.network.proto.ApplicationInstance;
|
||||
import org.apache.skywalking.apm.network.proto.ApplicationInstanceHeartbeat;
|
||||
import org.apache.skywalking.apm.network.proto.ApplicationInstanceMapping;
|
||||
import org.apache.skywalking.apm.network.proto.ApplicationInstanceRecover;
|
||||
import org.apache.skywalking.apm.network.proto.Downstream;
|
||||
import org.apache.skywalking.apm.network.proto.InstanceDiscoveryServiceGrpc;
|
||||
import org.apache.skywalking.apm.network.proto.OSInfo;
|
||||
|
|
@ -43,15 +45,18 @@ public class InstanceDiscoveryServiceHandler extends InstanceDiscoveryServiceGrp
|
|||
private final Logger logger = LoggerFactory.getLogger(InstanceDiscoveryServiceHandler.class);
|
||||
|
||||
private final IInstanceIDService instanceIDService;
|
||||
private final IInstanceHeartBeatService instanceHeartBeatService;
|
||||
|
||||
public InstanceDiscoveryServiceHandler(ModuleManager moduleManager) {
|
||||
this.instanceIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IInstanceIDService.class);
|
||||
this.instanceHeartBeatService = moduleManager.find(AnalysisMetricModule.NAME).getService(IInstanceHeartBeatService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(ApplicationInstance request, StreamObserver<ApplicationInstanceMapping> responseObserver) {
|
||||
public void registerInstance(ApplicationInstance request,
|
||||
StreamObserver<ApplicationInstanceMapping> responseObserver) {
|
||||
long timeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(request.getRegisterTime());
|
||||
int instanceId = instanceIDService.getOrCreate(request.getApplicationId(), request.getAgentUUID(), timeBucket, buildOsInfo(request.getOsinfo()));
|
||||
int instanceId = instanceIDService.getOrCreateByAgentUUID(request.getApplicationId(), request.getAgentUUID(), timeBucket, buildOsInfo(request.getOsinfo()));
|
||||
ApplicationInstanceMapping.Builder builder = ApplicationInstanceMapping.newBuilder();
|
||||
builder.setApplicationId(request.getApplicationId());
|
||||
builder.setApplicationInstanceId(instanceId);
|
||||
|
|
@ -59,12 +64,10 @@ public class InstanceDiscoveryServiceHandler extends InstanceDiscoveryServiceGrp
|
|||
responseObserver.onCompleted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecover(ApplicationInstanceRecover request, StreamObserver<Downstream> responseObserver) {
|
||||
long timeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(request.getRegisterTime());
|
||||
instanceIDService.recover(request.getApplicationInstanceId(), request.getApplicationId(), timeBucket, buildOsInfo(request.getOsinfo()));
|
||||
responseObserver.onNext(Downstream.newBuilder().build());
|
||||
responseObserver.onCompleted();
|
||||
@Override public void heartbeat(ApplicationInstanceHeartbeat request, StreamObserver<Downstream> responseObserver) {
|
||||
int instanceId = request.getApplicationInstanceId();
|
||||
long heartBeatTime = request.getHeartbeatTime();
|
||||
this.instanceHeartBeatService.heartBeat(instanceId, heartBeatTime);
|
||||
}
|
||||
|
||||
private String buildOsInfo(OSInfo osinfo) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import java.util.List;
|
|||
import org.apache.skywalking.apm.collector.analysis.jvm.define.AnalysisJVMModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.ICpuMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IGCMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IInstanceHeartBeatService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IMemoryMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IMemoryPoolMetricService;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
|
|
@ -50,14 +49,12 @@ public class JVMMetricsServiceHandler extends JVMMetricsServiceGrpc.JVMMetricsSe
|
|||
private final IGCMetricService gcMetricService;
|
||||
private final IMemoryMetricService memoryMetricService;
|
||||
private final IMemoryPoolMetricService memoryPoolMetricService;
|
||||
private final IInstanceHeartBeatService instanceHeartBeatService;
|
||||
|
||||
public JVMMetricsServiceHandler(ModuleManager moduleManager) {
|
||||
this.cpuMetricService = moduleManager.find(AnalysisJVMModule.NAME).getService(ICpuMetricService.class);
|
||||
this.gcMetricService = moduleManager.find(AnalysisJVMModule.NAME).getService(IGCMetricService.class);
|
||||
this.memoryMetricService = moduleManager.find(AnalysisJVMModule.NAME).getService(IMemoryMetricService.class);
|
||||
this.memoryPoolMetricService = moduleManager.find(AnalysisJVMModule.NAME).getService(IMemoryPoolMetricService.class);
|
||||
this.instanceHeartBeatService = moduleManager.find(AnalysisJVMModule.NAME).getService(IInstanceHeartBeatService.class);
|
||||
}
|
||||
|
||||
@Override public void collect(JVMMetrics request, StreamObserver<Downstream> responseObserver) {
|
||||
|
|
@ -66,7 +63,6 @@ public class JVMMetricsServiceHandler extends JVMMetricsServiceGrpc.JVMMetricsSe
|
|||
|
||||
request.getMetricsList().forEach(metric -> {
|
||||
long time = TimeBucketUtils.INSTANCE.getSecondTimeBucket(metric.getTime());
|
||||
sendToInstanceHeartBeatService(instanceId, metric.getTime());
|
||||
sendToCpuMetricService(instanceId, time, metric.getCpu());
|
||||
sendToMemoryMetricService(instanceId, time, metric.getMemoryList());
|
||||
sendToMemoryPoolMetricService(instanceId, time, metric.getMemoryPoolList());
|
||||
|
|
@ -77,10 +73,6 @@ public class JVMMetricsServiceHandler extends JVMMetricsServiceGrpc.JVMMetricsSe
|
|||
responseObserver.onCompleted();
|
||||
}
|
||||
|
||||
private void sendToInstanceHeartBeatService(int instanceId, long heartBeatTime) {
|
||||
instanceHeartBeatService.send(instanceId, heartBeatTime);
|
||||
}
|
||||
|
||||
private void sendToMemoryMetricService(int instanceId, long timeBucket, List<Memory> memories) {
|
||||
memories.forEach(memory -> memoryMetricService.send(instanceId, timeBucket, memory.getIsHeap(), memory.getInit(), memory.getMax(), memory.getUsed(), memory.getCommitted()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.agent.grpc.provider.handler;
|
||||
|
||||
import com.google.protobuf.ProtocolStringList;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.AnalysisRegisterModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.service.INetworkAddressIDService;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.server.grpc.GRPCHandler;
|
||||
import org.apache.skywalking.apm.network.proto.KeyWithIntegerValue;
|
||||
import org.apache.skywalking.apm.network.proto.NetworkAddressMappings;
|
||||
import org.apache.skywalking.apm.network.proto.NetworkAddressRegisterServiceGrpc;
|
||||
import org.apache.skywalking.apm.network.proto.NetworkAddresses;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class NetworkAddressRegisterServiceHandler extends NetworkAddressRegisterServiceGrpc.NetworkAddressRegisterServiceImplBase implements GRPCHandler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(NetworkAddressRegisterServiceHandler.class);
|
||||
|
||||
private final INetworkAddressIDService networkAddressIDService;
|
||||
|
||||
public NetworkAddressRegisterServiceHandler(ModuleManager moduleManager) {
|
||||
this.networkAddressIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(INetworkAddressIDService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchRegister(NetworkAddresses request, StreamObserver<NetworkAddressMappings> responseObserver) {
|
||||
logger.debug("register application");
|
||||
ProtocolStringList addressesList = request.getAddressesList();
|
||||
|
||||
NetworkAddressMappings.Builder builder = NetworkAddressMappings.newBuilder();
|
||||
for (int i = 0; i < addressesList.size(); i++) {
|
||||
String networkAddress = addressesList.get(i);
|
||||
int addressId = networkAddressIDService.getOrCreate(networkAddress);
|
||||
|
||||
if (addressId != 0) {
|
||||
KeyWithIntegerValue value = KeyWithIntegerValue.newBuilder().setKey(networkAddress).setValue(addressId).build();
|
||||
builder.addAddressIds(value);
|
||||
}
|
||||
}
|
||||
responseObserver.onNext(builder.build());
|
||||
responseObserver.onCompleted();
|
||||
}
|
||||
}
|
||||
|
|
@ -16,14 +16,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.agent.grpc.provider.handler;
|
||||
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
import org.apache.skywalking.apm.network.proto.ApplicationMappings;
|
||||
import org.apache.skywalking.apm.network.proto.Application;
|
||||
import org.apache.skywalking.apm.network.proto.ApplicationMapping;
|
||||
import org.apache.skywalking.apm.network.proto.ApplicationRegisterServiceGrpc;
|
||||
import org.apache.skywalking.apm.network.proto.Applications;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -40,8 +39,8 @@ public class ApplicationRegisterServiceHandlerTestCase {
|
|||
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 11800).usePlaintext(true).build();
|
||||
stub = ApplicationRegisterServiceGrpc.newBlockingStub(channel);
|
||||
|
||||
Applications application = Applications.newBuilder().addApplicationCodes("test141").build();
|
||||
ApplicationMappings mapping = stub.batchRegister(application);
|
||||
logger.debug(mapping.getApplications(0).getKey() + ", " + mapping.getApplications(0).getValue());
|
||||
Application application = Application.newBuilder().setApplicationCode("test141").build();
|
||||
ApplicationMapping mapping = stub.applicationCodeRegister(application);
|
||||
logger.debug(mapping.getApplication().getKey() + ", " + mapping.getApplication().getValue());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.agent.grpc.provider.handler;
|
||||
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
import org.apache.skywalking.apm.network.proto.ApplicationInstanceHeartbeat;
|
||||
import org.apache.skywalking.apm.network.proto.InstanceDiscoveryServiceGrpc;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstHeartBeatServiceTestCase {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 11800).usePlaintext(true).build();
|
||||
InstanceDiscoveryServiceGrpc.InstanceDiscoveryServiceBlockingStub blockingStub = InstanceDiscoveryServiceGrpc.newBlockingStub(channel);
|
||||
|
||||
ApplicationInstanceHeartbeat.Builder builder = ApplicationInstanceHeartbeat.newBuilder();
|
||||
builder.setApplicationInstanceId(2);
|
||||
builder.setHeartbeatTime(System.currentTimeMillis());
|
||||
blockingStub.heartbeat(builder.build());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.agent.grpc.provider.handler;
|
||||
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
import org.apache.skywalking.apm.network.proto.CPU;
|
||||
import org.apache.skywalking.apm.network.proto.GC;
|
||||
import org.apache.skywalking.apm.network.proto.GCPhrase;
|
||||
import org.apache.skywalking.apm.network.proto.JVMMetric;
|
||||
import org.apache.skywalking.apm.network.proto.JVMMetrics;
|
||||
import org.apache.skywalking.apm.network.proto.JVMMetricsServiceGrpc;
|
||||
import org.apache.skywalking.apm.network.proto.Memory;
|
||||
import org.apache.skywalking.apm.network.proto.MemoryPool;
|
||||
import org.apache.skywalking.apm.network.proto.PoolType;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class JVMMetricServiceHandlerTestCase {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 11800).usePlaintext(true).build();
|
||||
JVMMetricsServiceGrpc.JVMMetricsServiceBlockingStub blockingStub = JVMMetricsServiceGrpc.newBlockingStub(channel);
|
||||
|
||||
JVMMetrics.Builder builder = JVMMetrics.newBuilder();
|
||||
builder.setApplicationInstanceId(2);
|
||||
|
||||
JVMMetric.Builder metricBuilder = JVMMetric.newBuilder();
|
||||
metricBuilder.setTime(System.currentTimeMillis());
|
||||
|
||||
buildCPUMetric(metricBuilder);
|
||||
buildGCMetric(metricBuilder);
|
||||
buildMemoryMetric(metricBuilder);
|
||||
buildMemoryPoolMetric(metricBuilder);
|
||||
|
||||
builder.addMetrics(metricBuilder.build());
|
||||
|
||||
blockingStub.collect(builder.build());
|
||||
}
|
||||
|
||||
private static void buildMemoryPoolMetric(JVMMetric.Builder metricBuilder) {
|
||||
MemoryPool.Builder builder = MemoryPool.newBuilder();
|
||||
builder.setInit(20);
|
||||
builder.setMax(50);
|
||||
builder.setCommited(20);
|
||||
builder.setUsed(15);
|
||||
builder.setType(PoolType.NEWGEN_USAGE);
|
||||
|
||||
metricBuilder.addMemoryPool(builder);
|
||||
}
|
||||
|
||||
private static void buildMemoryMetric(JVMMetric.Builder metricBuilder) {
|
||||
Memory.Builder builder = Memory.newBuilder();
|
||||
builder.setInit(20);
|
||||
builder.setMax(50);
|
||||
builder.setCommitted(20);
|
||||
builder.setUsed(15);
|
||||
builder.setIsHeap(true);
|
||||
|
||||
metricBuilder.addMemory(builder);
|
||||
}
|
||||
|
||||
private static void buildGCMetric(JVMMetric.Builder metricBuilder) {
|
||||
GC.Builder builder = GC.newBuilder();
|
||||
builder.setPhrase(GCPhrase.NEW);
|
||||
builder.setCount(2);
|
||||
|
||||
metricBuilder.addGc(builder);
|
||||
}
|
||||
|
||||
private static void buildCPUMetric(JVMMetric.Builder metricBuilder) {
|
||||
CPU.Builder builder = CPU.newBuilder();
|
||||
builder.setUsagePercent(20);
|
||||
|
||||
metricBuilder.setCpu(builder.build());
|
||||
}
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ import java.util.Properties;
|
|||
import org.apache.skywalking.apm.collector.agent.jetty.define.AgentJettyModule;
|
||||
import org.apache.skywalking.apm.collector.agent.jetty.provider.handler.ApplicationRegisterServletHandler;
|
||||
import org.apache.skywalking.apm.collector.agent.jetty.provider.handler.InstanceDiscoveryServletHandler;
|
||||
import org.apache.skywalking.apm.collector.agent.jetty.provider.handler.NetworkAddressRegisterServletHandler;
|
||||
import org.apache.skywalking.apm.collector.agent.jetty.provider.handler.ServiceNameDiscoveryServiceHandler;
|
||||
import org.apache.skywalking.apm.collector.agent.jetty.provider.handler.TraceSegmentServletHandler;
|
||||
import org.apache.skywalking.apm.collector.agent.jetty.provider.handler.naming.AgentJettyNamingHandler;
|
||||
|
|
@ -93,5 +94,6 @@ public class AgentModuleJettyProvider extends ModuleProvider {
|
|||
jettyServer.addHandler(new ApplicationRegisterServletHandler(getManager()));
|
||||
jettyServer.addHandler(new InstanceDiscoveryServletHandler(getManager()));
|
||||
jettyServer.addHandler(new ServiceNameDiscoveryServiceHandler(getManager()));
|
||||
jettyServer.addHandler(new NetworkAddressRegisterServletHandler(getManager()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class ApplicationRegisterServletHandler extends JettyHandler {
|
|||
JsonArray applicationCodes = gson.fromJson(req.getReader(), JsonArray.class);
|
||||
for (int i = 0; i < applicationCodes.size(); i++) {
|
||||
String applicationCode = applicationCodes.get(i).getAsString();
|
||||
int applicationId = applicationIDService.getOrCreate(applicationCode);
|
||||
int applicationId = applicationIDService.getOrCreateForApplicationCode(applicationCode);
|
||||
JsonObject mapping = new JsonObject();
|
||||
mapping.addProperty(APPLICATION_CODE, applicationCode);
|
||||
mapping.addProperty(APPLICATION_ID, applicationId);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class InstanceDiscoveryServletHandler extends JettyHandler {
|
|||
long registerTime = instance.get(REGISTER_TIME).getAsLong();
|
||||
JsonObject osInfo = instance.get(OS_INFO).getAsJsonObject();
|
||||
|
||||
int instanceId = instanceIDService.getOrCreate(applicationId, agentUUID, registerTime, osInfo.toString());
|
||||
int instanceId = instanceIDService.getOrCreateByAgentUUID(applicationId, agentUUID, registerTime, osInfo.toString());
|
||||
responseJson.addProperty(APPLICATION_ID, applicationId);
|
||||
responseJson.addProperty(INSTANCE_ID, instanceId);
|
||||
} catch (IOException e) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.agent.jetty.provider.handler;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.AnalysisRegisterModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.service.INetworkAddressIDService;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException;
|
||||
import org.apache.skywalking.apm.collector.server.jetty.JettyHandler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class NetworkAddressRegisterServletHandler extends JettyHandler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(NetworkAddressRegisterServletHandler.class);
|
||||
|
||||
private final INetworkAddressIDService networkAddressIDService;
|
||||
private Gson gson = new Gson();
|
||||
private static final String NETWORK_ADDRESS = "n";
|
||||
private static final String ADDRESS_ID = "i";
|
||||
|
||||
public NetworkAddressRegisterServletHandler(ModuleManager moduleManager) {
|
||||
this.networkAddressIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(INetworkAddressIDService.class);
|
||||
}
|
||||
|
||||
@Override public String pathSpec() {
|
||||
return "/networkAddress/register";
|
||||
}
|
||||
|
||||
@Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException {
|
||||
JsonArray responseArray = new JsonArray();
|
||||
try {
|
||||
JsonArray networkAddresses = gson.fromJson(req.getReader(), JsonArray.class);
|
||||
for (int i = 0; i < networkAddresses.size(); i++) {
|
||||
String networkAddress = networkAddresses.get(i).getAsString();
|
||||
logger.debug("network address register, network address: {}", networkAddress);
|
||||
int addressId = networkAddressIDService.getOrCreate(networkAddress);
|
||||
JsonObject mapping = new JsonObject();
|
||||
mapping.addProperty(ADDRESS_ID, addressId);
|
||||
mapping.addProperty(NETWORK_ADDRESS, networkAddress);
|
||||
responseArray.add(mapping);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return responseArray;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
24040000
|
||||
],
|
||||
"ai": -1,
|
||||
"ii": 1,
|
||||
"ii": 2,
|
||||
"rs": [],
|
||||
"ss": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
48780000
|
||||
],
|
||||
"ai": 2,
|
||||
"ii": 2,
|
||||
"ii": 3,
|
||||
"ss": [
|
||||
{
|
||||
"si": 0,
|
||||
|
|
@ -37,13 +37,13 @@
|
|||
185809,
|
||||
24040000
|
||||
],
|
||||
"pii": 1,
|
||||
"pii": 2,
|
||||
"psp": 0,
|
||||
"psi": 0,
|
||||
"psn": "/dubbox-case/case/dubbox-rest",
|
||||
"ni": 0,
|
||||
"nn": "172.25.0.4:20880",
|
||||
"eii": 1,
|
||||
"eii": 2,
|
||||
"esi": 0,
|
||||
"esn": "/dubbox-case/case/dubbox-rest",
|
||||
"rn": 0
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.define.graph;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class AlarmGraphIdDefine {
|
||||
public static final int SERVICE_METRIC_ALARM_GRAPH_ID = 500;
|
||||
public static final int INSTANCE_METRIC_ALARM_GRAPH_ID = 501;
|
||||
public static final int APPLICATION_METRIC_ALARM_GRAPH_ID = 502;
|
||||
public static final int SERVICE_REFERENCE_METRIC_ALARM_GRAPH_ID = 503;
|
||||
public static final int INSTANCE_REFERENCE_METRIC_ALARM_GRAPH_ID = 504;
|
||||
public static final int APPLICATION_REFERENCE_METRIC_ALARM_GRAPH_ID = 505;
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.define.graph;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class AlarmWorkerIdDefine {
|
||||
public static final int SERVICE_METRIC_ALARM_ASSERT_WORKER_ID = 500;
|
||||
public static final int SERVICE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 501;
|
||||
public static final int SERVICE_METRIC_ALARM_REMOTE_WORKER_ID = 502;
|
||||
public static final int SERVICE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 503;
|
||||
public static final int SERVICE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 504;
|
||||
public static final int SERVICE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 505;
|
||||
|
||||
public static final int INSTANCE_METRIC_ALARM_ASSERT_WORKER_ID = 510;
|
||||
public static final int INSTANCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 511;
|
||||
public static final int INSTANCE_METRIC_ALARM_REMOTE_WORKER_ID = 512;
|
||||
public static final int INSTANCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 513;
|
||||
public static final int INSTANCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 514;
|
||||
public static final int INSTANCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 515;
|
||||
|
||||
public static final int APPLICATION_METRIC_ALARM_ASSERT_WORKER_ID = 520;
|
||||
public static final int APPLICATION_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 521;
|
||||
public static final int APPLICATION_METRIC_ALARM_REMOTE_WORKER_ID = 522;
|
||||
public static final int APPLICATION_METRIC_ALARM_PERSISTENCE_WORKER_ID = 523;
|
||||
public static final int APPLICATION_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 524;
|
||||
public static final int APPLICATION_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 525;
|
||||
|
||||
public static final int SERVICE_REFERENCE_METRIC_ALARM_ASSERT_WORKER_ID = 530;
|
||||
public static final int SERVICE_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 531;
|
||||
public static final int SERVICE_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID = 532;
|
||||
public static final int SERVICE_REFERENCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 533;
|
||||
public static final int SERVICE_REFERENCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 534;
|
||||
public static final int SERVICE_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 535;
|
||||
|
||||
public static final int INSTANCE_REFERENCE_METRIC_ALARM_ASSERT_WORKER_ID = 540;
|
||||
public static final int INSTANCE_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 541;
|
||||
public static final int INSTANCE_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID = 542;
|
||||
public static final int INSTANCE_REFERENCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 543;
|
||||
public static final int INSTANCE_REFERENCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 544;
|
||||
public static final int INSTANCE_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 545;
|
||||
|
||||
public static final int APPLICATION_REFERENCE_METRIC_ALARM_ASSERT_WORKER_ID = 550;
|
||||
public static final int APPLICATION_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 551;
|
||||
public static final int APPLICATION_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID = 552;
|
||||
public static final int APPLICATION_REFERENCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 553;
|
||||
public static final int APPLICATION_REFERENCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 554;
|
||||
public static final int APPLICATION_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 555;
|
||||
}
|
||||
|
|
@ -36,6 +36,16 @@
|
|||
<artifactId>alarm-define</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>metric-define</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>collector-configuration-define</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>collector-storage-define</artifactId>
|
||||
|
|
|
|||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider;
|
||||
|
||||
import java.util.Properties;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.AnalysisAlarmModule;
|
||||
import org.apache.skywalking.apm.collector.core.module.Module;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ServiceNotProvidedException;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class AlertingModuleProvider extends ModuleProvider {
|
||||
|
||||
@Override public String name() {
|
||||
return "default";
|
||||
}
|
||||
|
||||
@Override public Class<? extends Module> module() {
|
||||
return AnalysisAlarmModule.class;
|
||||
}
|
||||
|
||||
@Override public void prepare(Properties config) throws ServiceNotProvidedException {
|
||||
|
||||
}
|
||||
|
||||
@Override public void start(Properties config) throws ServiceNotProvidedException {
|
||||
|
||||
}
|
||||
|
||||
@Override public void notifyAfterCompleted() throws ServiceNotProvidedException {
|
||||
|
||||
}
|
||||
|
||||
@Override public String[] requiredModules() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider;
|
||||
|
||||
import java.util.Properties;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.AnalysisAlarmModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.application.ApplicationMetricAlarmGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.application.ApplicationReferenceMetricAlarmGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.instance.InstanceMetricAlarmGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.instance.InstanceReferenceMetricAlarmGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.service.ServiceMetricAlarmGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.service.ServiceReferenceMetricAlarmGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.AnalysisMetricModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.timer.PersistenceTimer;
|
||||
import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
|
||||
import org.apache.skywalking.apm.collector.core.module.Module;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ServiceNotProvidedException;
|
||||
import org.apache.skywalking.apm.collector.remote.RemoteModule;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class AnalysisAlarmModuleProvider extends ModuleProvider {
|
||||
|
||||
@Override public String name() {
|
||||
return "default";
|
||||
}
|
||||
|
||||
@Override public Class<? extends Module> module() {
|
||||
return AnalysisAlarmModule.class;
|
||||
}
|
||||
|
||||
@Override public void prepare(Properties config) throws ServiceNotProvidedException {
|
||||
|
||||
}
|
||||
|
||||
@Override public void start(Properties config) throws ServiceNotProvidedException {
|
||||
WorkerCreateListener workerCreateListener = new WorkerCreateListener();
|
||||
|
||||
ServiceMetricAlarmGraph serviceMetricAlarmGraph = new ServiceMetricAlarmGraph(getManager(), workerCreateListener);
|
||||
serviceMetricAlarmGraph.create();
|
||||
|
||||
InstanceMetricAlarmGraph instanceMetricAlarmGraph = new InstanceMetricAlarmGraph(getManager(), workerCreateListener);
|
||||
instanceMetricAlarmGraph.create();
|
||||
|
||||
ApplicationMetricAlarmGraph applicationMetricAlarmGraph = new ApplicationMetricAlarmGraph(getManager(), workerCreateListener);
|
||||
applicationMetricAlarmGraph.create();
|
||||
|
||||
ServiceReferenceMetricAlarmGraph serviceReferenceMetricAlarmGraph = new ServiceReferenceMetricAlarmGraph(getManager(), workerCreateListener);
|
||||
serviceReferenceMetricAlarmGraph.create();
|
||||
|
||||
InstanceReferenceMetricAlarmGraph instanceReferenceMetricAlarmGraph = new InstanceReferenceMetricAlarmGraph(getManager(), workerCreateListener);
|
||||
instanceReferenceMetricAlarmGraph.create();
|
||||
|
||||
ApplicationReferenceMetricAlarmGraph applicationReferenceMetricAlarmGraph = new ApplicationReferenceMetricAlarmGraph(getManager(), workerCreateListener);
|
||||
applicationReferenceMetricAlarmGraph.create();
|
||||
|
||||
PersistenceTimer persistenceTimer = new PersistenceTimer(AnalysisAlarmModule.NAME);
|
||||
persistenceTimer.start(getManager(), workerCreateListener.getPersistenceWorkers());
|
||||
}
|
||||
|
||||
@Override public void notifyAfterCompleted() throws ServiceNotProvidedException {
|
||||
|
||||
}
|
||||
|
||||
@Override public String[] requiredModules() {
|
||||
return new String[] {RemoteModule.NAME, AnalysisMetricModule.NAME, ConfigurationModule.NAME, StorageModule.NAME};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.MetricSource;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException;
|
||||
import org.apache.skywalking.apm.collector.core.data.StreamData;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.NumberFormatUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.Metric;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.Alarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.AlarmType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public abstract class AlarmAssertWorker<INPUT extends StreamData & Metric, OUTPUT extends StreamData & Alarm> extends AbstractLocalAsyncWorker<INPUT, OUTPUT> {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(AlarmAssertWorker.class);
|
||||
|
||||
public AlarmAssertWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override protected final void onWork(INPUT inputMetric) throws WorkerException {
|
||||
errorRateAlarmAssert(inputMetric);
|
||||
averageResponseTimeAlarmAssert(inputMetric);
|
||||
}
|
||||
|
||||
protected abstract OUTPUT newAlarmObject(String id, INPUT inputMetric);
|
||||
|
||||
protected abstract Double calleeErrorRateThreshold();
|
||||
|
||||
protected abstract Double callerErrorRateThreshold();
|
||||
|
||||
private void errorRateAlarmAssert(INPUT inputMetric) {
|
||||
Double errorRate = Double.valueOf(inputMetric.getTransactionErrorCalls()) / Double.valueOf(inputMetric.getTransactionCalls());
|
||||
errorRate = NumberFormatUtils.rateNumberFormat(errorRate);
|
||||
|
||||
if (inputMetric.getSourceValue().equals(MetricSource.Callee.getValue())) {
|
||||
if (errorRate >= calleeErrorRateThreshold()) {
|
||||
String id = String.valueOf(MetricSource.Callee.getValue()) + Const.ID_SPLIT + AlarmType.ERROR_RATE.getValue();
|
||||
OUTPUT alarm = newAlarmObject(id, inputMetric);
|
||||
alarm.setAlarmType(AlarmType.ERROR_RATE.getValue());
|
||||
alarm.setLastTimeBucket(inputMetric.getTimeBucket());
|
||||
alarm.setSourceValue(MetricSource.Callee.getValue());
|
||||
alarm.setAlarmContent("");
|
||||
|
||||
onNext(alarm);
|
||||
}
|
||||
} else if (inputMetric.getSourceValue().equals(MetricSource.Caller.getValue())) {
|
||||
if (errorRate >= callerErrorRateThreshold()) {
|
||||
String id = String.valueOf(MetricSource.Caller.getValue()) + Const.ID_SPLIT + AlarmType.ERROR_RATE.getValue();
|
||||
OUTPUT alarm = newAlarmObject(id, inputMetric);
|
||||
alarm.setAlarmType(AlarmType.ERROR_RATE.getValue());
|
||||
alarm.setLastTimeBucket(inputMetric.getTimeBucket());
|
||||
alarm.setSourceValue(MetricSource.Caller.getValue());
|
||||
alarm.setAlarmContent("");
|
||||
|
||||
onNext(alarm);
|
||||
}
|
||||
} else {
|
||||
logger.error("Please check the metric source, the value must be {} or {}", MetricSource.Caller.getValue(), MetricSource.Callee.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Double calleeAverageResponseTimeThreshold();
|
||||
|
||||
protected abstract Double callerAverageResponseTimeThreshold();
|
||||
|
||||
private void averageResponseTimeAlarmAssert(INPUT inputMetric) {
|
||||
Long transactionSuccessDurationSum = inputMetric.getTransactionDurationSum() - inputMetric.getTransactionErrorDurationSum();
|
||||
Long transactionSuccessCalls = inputMetric.getTransactionCalls() - inputMetric.getTransactionErrorCalls();
|
||||
Double averageResponseTime = Double.valueOf(transactionSuccessDurationSum) / Double.valueOf(transactionSuccessCalls);
|
||||
|
||||
if (inputMetric.getSourceValue().equals(MetricSource.Callee.getValue())) {
|
||||
|
||||
if (averageResponseTime >= calleeAverageResponseTimeThreshold()) {
|
||||
String id = String.valueOf(MetricSource.Callee.getValue()) + Const.ID_SPLIT + AlarmType.SLOW_RTT.getValue();
|
||||
OUTPUT alarm = newAlarmObject(id, inputMetric);
|
||||
alarm.setAlarmType(AlarmType.SLOW_RTT.getValue());
|
||||
alarm.setLastTimeBucket(inputMetric.getTimeBucket());
|
||||
alarm.setSourceValue(MetricSource.Callee.getValue());
|
||||
alarm.setAlarmContent("");
|
||||
|
||||
onNext(alarm);
|
||||
} else if (inputMetric.getSourceValue().equals(MetricSource.Caller.getValue())) {
|
||||
if (averageResponseTime >= callerAverageResponseTimeThreshold()) {
|
||||
String id = String.valueOf(MetricSource.Caller.getValue()) + Const.ID_SPLIT + AlarmType.SLOW_RTT.getValue();
|
||||
OUTPUT alarm = newAlarmObject(id, inputMetric);
|
||||
alarm.setAlarmType(AlarmType.SLOW_RTT.getValue());
|
||||
alarm.setLastTimeBucket(inputMetric.getTimeBucket());
|
||||
alarm.setSourceValue(MetricSource.Caller.getValue());
|
||||
alarm.setAlarmContent("");
|
||||
|
||||
onNext(alarm);
|
||||
}
|
||||
} else {
|
||||
logger.error("Please check the metric source, the value must be {} or {}", MetricSource.Caller.getValue(), MetricSource.Callee.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,25 +18,18 @@
|
|||
|
||||
package org.apache.skywalking.apm.collector.analysis.alarm.provider.worker;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.data.StreamData;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alerting.AlertingList;
|
||||
import org.apache.skywalking.apm.collector.storage.table.Metric;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.Alarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class AlertingListAggregationWorker extends AbstractLocalAsyncWorker<AlertingList, AlertingList> {
|
||||
public abstract class AlarmAssertWorkerProvider<INPUT extends StreamData & Metric, OUTPUT extends StreamData & Alarm, WORKER_TYPE extends AlarmAssertWorker<INPUT, OUTPUT>> extends AbstractLocalAsyncWorkerProvider<INPUT, OUTPUT, WORKER_TYPE> {
|
||||
|
||||
public AlertingListAggregationWorker(ModuleManager moduleManager) {
|
||||
public AlarmAssertWorkerProvider(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override protected void onWork(AlertingList message) throws WorkerException {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.application;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
|
||||
import org.apache.skywalking.apm.collector.configuration.service.IApplicationAlarmRuleConfig;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationMetricAlarmAssertWorker extends AlarmAssertWorker<ApplicationMetric, ApplicationAlarm> {
|
||||
|
||||
private final IApplicationAlarmRuleConfig applicationAlarmRuleConfig;
|
||||
|
||||
public ApplicationMetricAlarmAssertWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
this.applicationAlarmRuleConfig = moduleManager.find(ConfigurationModule.NAME).getService(IApplicationAlarmRuleConfig.class);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_ASSERT_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected ApplicationAlarm newAlarmObject(String id, ApplicationMetric inputMetric) {
|
||||
ApplicationAlarm applicationAlarm = new ApplicationAlarm();
|
||||
applicationAlarm.setId(id + Const.ID_SPLIT + inputMetric.getApplicationId());
|
||||
applicationAlarm.setApplicationId(inputMetric.getApplicationId());
|
||||
return applicationAlarm;
|
||||
}
|
||||
|
||||
@Override protected Double calleeErrorRateThreshold() {
|
||||
return applicationAlarmRuleConfig.calleeErrorRateThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double callerErrorRateThreshold() {
|
||||
return applicationAlarmRuleConfig.callerErrorRateThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double calleeAverageResponseTimeThreshold() {
|
||||
return applicationAlarmRuleConfig.calleeAverageResponseTimeThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double callerAverageResponseTimeThreshold() {
|
||||
return applicationAlarmRuleConfig.callerAverageResponseTimeThreshold();
|
||||
}
|
||||
|
||||
public static class Factory extends AlarmAssertWorkerProvider<ApplicationMetric, ApplicationAlarm, ApplicationMetricAlarmAssertWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public ApplicationMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ApplicationMetricAlarmAssertWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.application;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmGraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Graph;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.remote.RemoteModule;
|
||||
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationMetricAlarmGraph {
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private final WorkerCreateListener workerCreateListener;
|
||||
|
||||
public ApplicationMetricAlarmGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) {
|
||||
this.moduleManager = moduleManager;
|
||||
this.workerCreateListener = workerCreateListener;
|
||||
}
|
||||
|
||||
public void create() {
|
||||
RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class);
|
||||
|
||||
Graph<ApplicationMetric> graph = GraphManager.INSTANCE.createIfAbsent(AlarmGraphIdDefine.APPLICATION_METRIC_ALARM_GRAPH_ID, ApplicationMetric.class);
|
||||
|
||||
graph.addNode(new ApplicationMetricAlarmAssertWorker.Factory(moduleManager).create(workerCreateListener))
|
||||
.addNext(new ApplicationMetricAlarmRemoteWorker.Factory(moduleManager, remoteSenderService, AlarmGraphIdDefine.APPLICATION_METRIC_ALARM_GRAPH_ID).create(workerCreateListener))
|
||||
.addNext(new ApplicationMetricAlarmPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
graph.toFinder().findNode(AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_REMOTE_WORKER_ID, ApplicationAlarm.class)
|
||||
.addNext(new ApplicationMetricAlarmToListNodeProcessor())
|
||||
.addNext(new ApplicationMetricAlarmListPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
link(graph);
|
||||
}
|
||||
|
||||
private void link(Graph<ApplicationMetric> graph) {
|
||||
GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.APPLICATION_METRIC_GRAPH_ID, ApplicationMetric.class)
|
||||
.toFinder().findNode(MetricWorkerIdDefine.APPLICATION_MINUTE_METRIC_PERSISTENCE_WORKER_ID, ApplicationMetric.class)
|
||||
.addNext(new NodeProcessor<ApplicationMetric, ApplicationMetric>() {
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override public void process(ApplicationMetric instanceMetric,
|
||||
Next<ApplicationMetric> next) {
|
||||
graph.start(instanceMetric);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.application;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationMetricAlarmListPersistenceWorker extends PersistenceWorker<ApplicationAlarmList> {
|
||||
|
||||
public ApplicationMetricAlarmListPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, ApplicationAlarmList> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmListPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<ApplicationAlarmList, ApplicationMetricAlarmListPersistenceWorker> {
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public ApplicationMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ApplicationMetricAlarmListPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.application;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationMetricAlarmPersistenceWorker extends PersistenceWorker<ApplicationAlarm> {
|
||||
|
||||
public ApplicationMetricAlarmPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, ApplicationAlarm> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<ApplicationAlarm, ApplicationMetricAlarmPersistenceWorker> {
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public ApplicationMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ApplicationMetricAlarmPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.application;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
|
||||
import org.apache.skywalking.apm.collector.remote.service.Selector;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationMetricAlarmRemoteWorker extends AbstractRemoteWorker<ApplicationAlarm, ApplicationAlarm> {
|
||||
|
||||
public ApplicationMetricAlarmRemoteWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_REMOTE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override public Selector selector() {
|
||||
return Selector.HashCode;
|
||||
}
|
||||
|
||||
@Override protected void onWork(ApplicationAlarm message) throws WorkerException {
|
||||
onNext(message);
|
||||
}
|
||||
|
||||
public static class Factory extends AbstractRemoteWorkerProvider<ApplicationAlarm, ApplicationAlarm, ApplicationMetricAlarmRemoteWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) {
|
||||
super(moduleManager, remoteSenderService, graphId);
|
||||
}
|
||||
|
||||
@Override public ApplicationMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ApplicationMetricAlarmRemoteWorker(moduleManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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.skywalking.apm.collector.analysis.alarm.provider.worker.application;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationMetricAlarmToListNodeProcessor implements NodeProcessor<ApplicationAlarm, ApplicationAlarmList> {
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID;
|
||||
}
|
||||
|
||||
@Override public void process(ApplicationAlarm applicationAlarm, Next<ApplicationAlarmList> next) {
|
||||
String id = applicationAlarm.getLastTimeBucket() + Const.ID_SPLIT + applicationAlarm.getSourceValue()
|
||||
+ Const.ID_SPLIT + applicationAlarm.getAlarmType()
|
||||
+ Const.ID_SPLIT + applicationAlarm.getApplicationId();
|
||||
|
||||
ApplicationAlarmList applicationAlarmList = new ApplicationAlarmList();
|
||||
applicationAlarmList.setId(id);
|
||||
applicationAlarmList.setApplicationId(applicationAlarm.getApplicationId());
|
||||
applicationAlarmList.setSourceValue(applicationAlarm.getSourceValue());
|
||||
applicationAlarmList.setAlarmType(applicationAlarm.getAlarmType());
|
||||
applicationAlarmList.setTimeBucket(applicationAlarm.getLastTimeBucket());
|
||||
applicationAlarmList.setAlarmContent(applicationAlarm.getAlarmContent());
|
||||
next.execute(applicationAlarmList);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.application;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
|
||||
import org.apache.skywalking.apm.collector.configuration.service.IApplicationReferenceAlarmRuleConfig;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationReferenceMetricAlarmAssertWorker extends AlarmAssertWorker<ApplicationReferenceMetric, ApplicationReferenceAlarm> {
|
||||
|
||||
private final IApplicationReferenceAlarmRuleConfig applicationReferenceAlarmRuleConfig;
|
||||
|
||||
public ApplicationReferenceMetricAlarmAssertWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
this.applicationReferenceAlarmRuleConfig = moduleManager.find(ConfigurationModule.NAME).getService(IApplicationReferenceAlarmRuleConfig.class);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.APPLICATION_REFERENCE_METRIC_ALARM_ASSERT_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected ApplicationReferenceAlarm newAlarmObject(String id, ApplicationReferenceMetric inputMetric) {
|
||||
ApplicationReferenceAlarm applicationReferenceAlarm = new ApplicationReferenceAlarm();
|
||||
applicationReferenceAlarm.setId(id + Const.ID_SPLIT + inputMetric.getFrontApplicationId() + Const.ID_SPLIT + inputMetric.getBehindApplicationId());
|
||||
applicationReferenceAlarm.setFrontApplicationId(inputMetric.getFrontApplicationId());
|
||||
applicationReferenceAlarm.setBehindApplicationId(inputMetric.getBehindApplicationId());
|
||||
return applicationReferenceAlarm;
|
||||
}
|
||||
|
||||
@Override protected Double calleeErrorRateThreshold() {
|
||||
return applicationReferenceAlarmRuleConfig.calleeErrorRateThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double callerErrorRateThreshold() {
|
||||
return applicationReferenceAlarmRuleConfig.callerErrorRateThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double calleeAverageResponseTimeThreshold() {
|
||||
return applicationReferenceAlarmRuleConfig.calleeAverageResponseTimeThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double callerAverageResponseTimeThreshold() {
|
||||
return applicationReferenceAlarmRuleConfig.callerAverageResponseTimeThreshold();
|
||||
}
|
||||
|
||||
public static class Factory extends AlarmAssertWorkerProvider<ApplicationReferenceMetric, ApplicationReferenceAlarm, ApplicationReferenceMetricAlarmAssertWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public ApplicationReferenceMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ApplicationReferenceMetricAlarmAssertWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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.skywalking.apm.collector.analysis.alarm.provider.worker.application;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmGraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Graph;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.remote.RemoteModule;
|
||||
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationReferenceMetricAlarmGraph {
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private final WorkerCreateListener workerCreateListener;
|
||||
|
||||
public ApplicationReferenceMetricAlarmGraph(ModuleManager moduleManager,
|
||||
WorkerCreateListener workerCreateListener) {
|
||||
this.moduleManager = moduleManager;
|
||||
this.workerCreateListener = workerCreateListener;
|
||||
}
|
||||
|
||||
public void create() {
|
||||
RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class);
|
||||
|
||||
Graph<ApplicationReferenceMetric> graph = GraphManager.INSTANCE.createIfAbsent(AlarmGraphIdDefine.APPLICATION_REFERENCE_METRIC_ALARM_GRAPH_ID, ApplicationReferenceMetric.class);
|
||||
|
||||
graph.addNode(new ApplicationReferenceMetricAlarmAssertWorker.Factory(moduleManager).create(workerCreateListener))
|
||||
.addNext(new ApplicationReferenceMetricAlarmRemoteWorker.Factory(moduleManager, remoteSenderService, AlarmGraphIdDefine.APPLICATION_REFERENCE_METRIC_ALARM_GRAPH_ID).create(workerCreateListener))
|
||||
.addNext(new ApplicationReferenceMetricAlarmPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
graph.toFinder().findNode(AlarmWorkerIdDefine.APPLICATION_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID, ApplicationReferenceAlarm.class)
|
||||
.addNext(new ApplicationReferenceMetricAlarmToListNodeProcessor())
|
||||
.addNext(new ApplicationReferenceMetricAlarmListPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
link(graph);
|
||||
}
|
||||
|
||||
private void link(Graph<ApplicationReferenceMetric> graph) {
|
||||
GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.APPLICATION_REFERENCE_METRIC_GRAPH_ID, ApplicationReferenceMetric.class)
|
||||
.toFinder().findNode(MetricWorkerIdDefine.APPLICATION_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID, ApplicationReferenceMetric.class)
|
||||
.addNext(new NodeProcessor<ApplicationReferenceMetric, ApplicationReferenceMetric>() {
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.APPLICATION_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override public void process(ApplicationReferenceMetric applicationReferenceMetric,
|
||||
Next<ApplicationReferenceMetric> next) {
|
||||
graph.start(applicationReferenceMetric);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.application;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmListPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarmList;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationReferenceMetricAlarmListPersistenceWorker extends PersistenceWorker<ApplicationReferenceAlarmList> {
|
||||
|
||||
public ApplicationReferenceMetricAlarmListPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.APPLICATION_REFERENCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, ApplicationReferenceAlarmList> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceAlarmListPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<ApplicationReferenceAlarmList, ApplicationReferenceMetricAlarmListPersistenceWorker> {
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationReferenceMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ApplicationReferenceMetricAlarmListPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.application;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationReferenceMetricAlarmPersistenceWorker extends PersistenceWorker<ApplicationReferenceAlarm> {
|
||||
|
||||
public ApplicationReferenceMetricAlarmPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.APPLICATION_REFERENCE_METRIC_ALARM_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, ApplicationReferenceAlarm> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceAlarmPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<ApplicationReferenceAlarm, ApplicationReferenceMetricAlarmPersistenceWorker> {
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public ApplicationReferenceMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ApplicationReferenceMetricAlarmPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.application;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
|
||||
import org.apache.skywalking.apm.collector.remote.service.Selector;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationReferenceMetricAlarmRemoteWorker extends AbstractRemoteWorker<ApplicationReferenceAlarm, ApplicationReferenceAlarm> {
|
||||
|
||||
public ApplicationReferenceMetricAlarmRemoteWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.APPLICATION_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override public Selector selector() {
|
||||
return Selector.HashCode;
|
||||
}
|
||||
|
||||
@Override protected void onWork(ApplicationReferenceAlarm message) throws WorkerException {
|
||||
onNext(message);
|
||||
}
|
||||
|
||||
public static class Factory extends AbstractRemoteWorkerProvider<ApplicationReferenceAlarm, ApplicationReferenceAlarm, ApplicationReferenceMetricAlarmRemoteWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) {
|
||||
super(moduleManager, remoteSenderService, graphId);
|
||||
}
|
||||
|
||||
@Override public ApplicationReferenceMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ApplicationReferenceMetricAlarmRemoteWorker(moduleManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.application;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarmList;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationReferenceMetricAlarmToListNodeProcessor implements NodeProcessor<ApplicationReferenceAlarm, ApplicationReferenceAlarmList> {
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.APPLICATION_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ApplicationReferenceAlarm applicationReferenceAlarm, Next<ApplicationReferenceAlarmList> next) {
|
||||
String id = applicationReferenceAlarm.getLastTimeBucket() + Const.ID_SPLIT + applicationReferenceAlarm.getSourceValue()
|
||||
+ Const.ID_SPLIT + applicationReferenceAlarm.getAlarmType()
|
||||
+ Const.ID_SPLIT + applicationReferenceAlarm.getFrontApplicationId()
|
||||
+ Const.ID_SPLIT + applicationReferenceAlarm.getBehindApplicationId();
|
||||
|
||||
ApplicationReferenceAlarmList applicationReferenceAlarmList = new ApplicationReferenceAlarmList();
|
||||
applicationReferenceAlarmList.setId(id);
|
||||
applicationReferenceAlarmList.setFrontApplicationId(applicationReferenceAlarm.getFrontApplicationId());
|
||||
applicationReferenceAlarmList.setBehindApplicationId(applicationReferenceAlarm.getBehindApplicationId());
|
||||
applicationReferenceAlarmList.setSourceValue(applicationReferenceAlarm.getSourceValue());
|
||||
applicationReferenceAlarmList.setAlarmType(applicationReferenceAlarm.getAlarmType());
|
||||
applicationReferenceAlarmList.setTimeBucket(applicationReferenceAlarm.getLastTimeBucket());
|
||||
applicationReferenceAlarmList.setAlarmContent(applicationReferenceAlarm.getAlarmContent());
|
||||
next.execute(applicationReferenceAlarmList);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.instance;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
|
||||
import org.apache.skywalking.apm.collector.configuration.service.IInstanceAlarmRuleConfig;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceMetricAlarmAssertWorker extends AlarmAssertWorker<InstanceMetric, InstanceAlarm> {
|
||||
|
||||
private final IInstanceAlarmRuleConfig instanceAlarmRuleConfig;
|
||||
|
||||
public InstanceMetricAlarmAssertWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
this.instanceAlarmRuleConfig = moduleManager.find(ConfigurationModule.NAME).getService(IInstanceAlarmRuleConfig.class);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_ASSERT_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected InstanceAlarm newAlarmObject(String id, InstanceMetric inputMetric) {
|
||||
InstanceAlarm instanceAlarm = new InstanceAlarm();
|
||||
instanceAlarm.setId(id + Const.ID_SPLIT + inputMetric.getInstanceId());
|
||||
instanceAlarm.setApplicationId(inputMetric.getApplicationId());
|
||||
instanceAlarm.setInstanceId(inputMetric.getInstanceId());
|
||||
return instanceAlarm;
|
||||
}
|
||||
|
||||
@Override protected Double calleeErrorRateThreshold() {
|
||||
return instanceAlarmRuleConfig.calleeErrorRateThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double callerErrorRateThreshold() {
|
||||
return instanceAlarmRuleConfig.callerErrorRateThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double calleeAverageResponseTimeThreshold() {
|
||||
return instanceAlarmRuleConfig.calleeAverageResponseTimeThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double callerAverageResponseTimeThreshold() {
|
||||
return instanceAlarmRuleConfig.callerAverageResponseTimeThreshold();
|
||||
}
|
||||
|
||||
public static class Factory extends AlarmAssertWorkerProvider<InstanceMetric, InstanceAlarm, InstanceMetricAlarmAssertWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public InstanceMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new InstanceMetricAlarmAssertWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.instance;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmGraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Graph;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.remote.RemoteModule;
|
||||
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceMetricAlarmGraph {
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private final WorkerCreateListener workerCreateListener;
|
||||
|
||||
public InstanceMetricAlarmGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) {
|
||||
this.moduleManager = moduleManager;
|
||||
this.workerCreateListener = workerCreateListener;
|
||||
}
|
||||
|
||||
public void create() {
|
||||
RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class);
|
||||
|
||||
Graph<InstanceMetric> graph = GraphManager.INSTANCE.createIfAbsent(AlarmGraphIdDefine.INSTANCE_METRIC_ALARM_GRAPH_ID, InstanceMetric.class);
|
||||
|
||||
graph.addNode(new InstanceMetricAlarmAssertWorker.Factory(moduleManager).create(workerCreateListener))
|
||||
.addNext(new InstanceMetricAlarmRemoteWorker.Factory(moduleManager, remoteSenderService, AlarmGraphIdDefine.INSTANCE_METRIC_ALARM_GRAPH_ID).create(workerCreateListener))
|
||||
.addNext(new InstanceMetricAlarmPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
graph.toFinder().findNode(AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_REMOTE_WORKER_ID, InstanceAlarm.class)
|
||||
.addNext(new InstanceMetricAlarmToListNodeProcessor())
|
||||
.addNext(new InstanceMetricAlarmListPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
link(graph);
|
||||
}
|
||||
|
||||
private void link(Graph<InstanceMetric> graph) {
|
||||
GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.INSTANCE_METRIC_GRAPH_ID, InstanceMetric.class)
|
||||
.toFinder().findNode(MetricWorkerIdDefine.INSTANCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID, InstanceMetric.class)
|
||||
.addNext(new NodeProcessor<InstanceMetric, InstanceMetric>() {
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override public void process(InstanceMetric instanceMetric,
|
||||
Next<InstanceMetric> next) {
|
||||
graph.start(instanceMetric);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.instance;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceAlarmListPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmList;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceMetricAlarmListPersistenceWorker extends PersistenceWorker<InstanceAlarmList> {
|
||||
|
||||
public InstanceMetricAlarmListPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, InstanceAlarmList> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IInstanceAlarmListPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<InstanceAlarmList, InstanceMetricAlarmListPersistenceWorker> {
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public InstanceMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new InstanceMetricAlarmListPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.instance;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceAlarmPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceMetricAlarmPersistenceWorker extends PersistenceWorker<InstanceAlarm> {
|
||||
|
||||
public InstanceMetricAlarmPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, InstanceAlarm> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IInstanceAlarmPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<InstanceAlarm, InstanceMetricAlarmPersistenceWorker> {
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public InstanceMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new InstanceMetricAlarmPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.instance;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
|
||||
import org.apache.skywalking.apm.collector.remote.service.Selector;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceMetricAlarmRemoteWorker extends AbstractRemoteWorker<InstanceAlarm, InstanceAlarm> {
|
||||
|
||||
public InstanceMetricAlarmRemoteWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_REMOTE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override public Selector selector() {
|
||||
return Selector.HashCode;
|
||||
}
|
||||
|
||||
@Override protected void onWork(InstanceAlarm message) throws WorkerException {
|
||||
onNext(message);
|
||||
}
|
||||
|
||||
public static class Factory extends AbstractRemoteWorkerProvider<InstanceAlarm, InstanceAlarm, InstanceMetricAlarmRemoteWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) {
|
||||
super(moduleManager, remoteSenderService, graphId);
|
||||
}
|
||||
|
||||
@Override public InstanceMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new InstanceMetricAlarmRemoteWorker(moduleManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.instance;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmList;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceMetricAlarmToListNodeProcessor implements NodeProcessor<InstanceAlarm, InstanceAlarmList> {
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID;
|
||||
}
|
||||
|
||||
@Override public void process(InstanceAlarm instanceAlarm, Next<InstanceAlarmList> next) {
|
||||
String id = instanceAlarm.getLastTimeBucket() + Const.ID_SPLIT + instanceAlarm.getSourceValue()
|
||||
+ Const.ID_SPLIT + instanceAlarm.getAlarmType()
|
||||
+ Const.ID_SPLIT + instanceAlarm.getInstanceId();
|
||||
|
||||
InstanceAlarmList instanceAlarmList = new InstanceAlarmList();
|
||||
instanceAlarmList.setId(id);
|
||||
instanceAlarmList.setApplicationId(instanceAlarm.getApplicationId());
|
||||
instanceAlarmList.setInstanceId(instanceAlarm.getInstanceId());
|
||||
instanceAlarmList.setSourceValue(instanceAlarm.getSourceValue());
|
||||
instanceAlarmList.setAlarmType(instanceAlarm.getAlarmType());
|
||||
instanceAlarmList.setTimeBucket(instanceAlarm.getLastTimeBucket());
|
||||
instanceAlarmList.setAlarmContent(instanceAlarm.getAlarmContent());
|
||||
next.execute(instanceAlarmList);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.instance;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
|
||||
import org.apache.skywalking.apm.collector.configuration.service.IInstanceReferenceAlarmRuleConfig;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceReferenceMetricAlarmAssertWorker extends AlarmAssertWorker<InstanceReferenceMetric, InstanceReferenceAlarm> {
|
||||
|
||||
private final IInstanceReferenceAlarmRuleConfig instanceReferenceAlarmRuleConfig;
|
||||
|
||||
public InstanceReferenceMetricAlarmAssertWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
this.instanceReferenceAlarmRuleConfig = moduleManager.find(ConfigurationModule.NAME).getService(IInstanceReferenceAlarmRuleConfig.class);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.INSTANCE_REFERENCE_METRIC_ALARM_ASSERT_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected InstanceReferenceAlarm newAlarmObject(String id, InstanceReferenceMetric inputMetric) {
|
||||
InstanceReferenceAlarm instanceReferenceAlarm = new InstanceReferenceAlarm();
|
||||
instanceReferenceAlarm.setId(id + Const.ID_SPLIT + inputMetric.getFrontInstanceId() + Const.ID_SPLIT + inputMetric.getBehindInstanceId());
|
||||
instanceReferenceAlarm.setFrontApplicationId(inputMetric.getFrontApplicationId());
|
||||
instanceReferenceAlarm.setBehindApplicationId(inputMetric.getBehindApplicationId());
|
||||
instanceReferenceAlarm.setFrontInstanceId(inputMetric.getFrontInstanceId());
|
||||
instanceReferenceAlarm.setBehindInstanceId(inputMetric.getBehindInstanceId());
|
||||
return instanceReferenceAlarm;
|
||||
}
|
||||
|
||||
@Override protected Double calleeErrorRateThreshold() {
|
||||
return instanceReferenceAlarmRuleConfig.calleeErrorRateThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double callerErrorRateThreshold() {
|
||||
return instanceReferenceAlarmRuleConfig.callerErrorRateThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double calleeAverageResponseTimeThreshold() {
|
||||
return instanceReferenceAlarmRuleConfig.calleeAverageResponseTimeThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double callerAverageResponseTimeThreshold() {
|
||||
return instanceReferenceAlarmRuleConfig.callerAverageResponseTimeThreshold();
|
||||
}
|
||||
|
||||
public static class Factory extends AlarmAssertWorkerProvider<InstanceReferenceMetric, InstanceReferenceAlarm, InstanceReferenceMetricAlarmAssertWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public InstanceReferenceMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new InstanceReferenceMetricAlarmAssertWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.instance;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmGraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Graph;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.remote.RemoteModule;
|
||||
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceReferenceMetricAlarmGraph {
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private final WorkerCreateListener workerCreateListener;
|
||||
|
||||
public InstanceReferenceMetricAlarmGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) {
|
||||
this.moduleManager = moduleManager;
|
||||
this.workerCreateListener = workerCreateListener;
|
||||
}
|
||||
|
||||
public void create() {
|
||||
RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class);
|
||||
|
||||
Graph<InstanceReferenceMetric> graph = GraphManager.INSTANCE.createIfAbsent(AlarmGraphIdDefine.INSTANCE_REFERENCE_METRIC_ALARM_GRAPH_ID, InstanceReferenceMetric.class);
|
||||
|
||||
graph.addNode(new InstanceReferenceMetricAlarmAssertWorker.Factory(moduleManager).create(workerCreateListener))
|
||||
.addNext(new InstanceReferenceMetricAlarmRemoteWorker.Factory(moduleManager, remoteSenderService, AlarmGraphIdDefine.INSTANCE_REFERENCE_METRIC_ALARM_GRAPH_ID).create(workerCreateListener))
|
||||
.addNext(new InstanceReferenceMetricAlarmPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
graph.toFinder().findNode(AlarmWorkerIdDefine.INSTANCE_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID, InstanceReferenceAlarm.class)
|
||||
.addNext(new InstanceReferenceMetricAlarmToListNodeProcessor())
|
||||
.addNext(new InstanceReferenceMetricAlarmListPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
link(graph);
|
||||
}
|
||||
|
||||
private void link(Graph<InstanceReferenceMetric> graph) {
|
||||
GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.INSTANCE_REFERENCE_METRIC_GRAPH_ID, InstanceReferenceMetric.class)
|
||||
.toFinder().findNode(MetricWorkerIdDefine.INSTANCE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID, InstanceReferenceMetric.class)
|
||||
.addNext(new NodeProcessor<InstanceReferenceMetric, InstanceReferenceMetric>() {
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.INSTANCE_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override public void process(InstanceReferenceMetric instanceReferenceMetric,
|
||||
Next<InstanceReferenceMetric> next) {
|
||||
graph.start(instanceReferenceMetric);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.instance;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceReferenceAlarmListPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarmList;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceReferenceMetricAlarmListPersistenceWorker extends PersistenceWorker<InstanceReferenceAlarmList> {
|
||||
|
||||
public InstanceReferenceMetricAlarmListPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.INSTANCE_REFERENCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, InstanceReferenceAlarmList> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IInstanceReferenceAlarmListPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<InstanceReferenceAlarmList, InstanceReferenceMetricAlarmListPersistenceWorker> {
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public InstanceReferenceMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new InstanceReferenceMetricAlarmListPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.instance;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceReferenceAlarmPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceReferenceMetricAlarmPersistenceWorker extends PersistenceWorker<InstanceReferenceAlarm> {
|
||||
|
||||
public InstanceReferenceMetricAlarmPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.INSTANCE_REFERENCE_METRIC_ALARM_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, InstanceReferenceAlarm> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IInstanceReferenceAlarmPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<InstanceReferenceAlarm, InstanceReferenceMetricAlarmPersistenceWorker> {
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public InstanceReferenceMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new InstanceReferenceMetricAlarmPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.instance;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
|
||||
import org.apache.skywalking.apm.collector.remote.service.Selector;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceReferenceMetricAlarmRemoteWorker extends AbstractRemoteWorker<InstanceReferenceAlarm, InstanceReferenceAlarm> {
|
||||
|
||||
public InstanceReferenceMetricAlarmRemoteWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.INSTANCE_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override public Selector selector() {
|
||||
return Selector.HashCode;
|
||||
}
|
||||
|
||||
@Override protected void onWork(InstanceReferenceAlarm message) throws WorkerException {
|
||||
onNext(message);
|
||||
}
|
||||
|
||||
public static class Factory extends AbstractRemoteWorkerProvider<InstanceReferenceAlarm, InstanceReferenceAlarm, InstanceReferenceMetricAlarmRemoteWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) {
|
||||
super(moduleManager, remoteSenderService, graphId);
|
||||
}
|
||||
|
||||
@Override public InstanceReferenceMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new InstanceReferenceMetricAlarmRemoteWorker(moduleManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.instance;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarmList;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceReferenceMetricAlarmToListNodeProcessor implements NodeProcessor<InstanceReferenceAlarm, InstanceReferenceAlarmList> {
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.INSTANCE_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(InstanceReferenceAlarm instanceReferenceAlarm, Next<InstanceReferenceAlarmList> next) {
|
||||
String id = instanceReferenceAlarm.getLastTimeBucket() + Const.ID_SPLIT + instanceReferenceAlarm.getSourceValue()
|
||||
+ Const.ID_SPLIT + instanceReferenceAlarm.getAlarmType()
|
||||
+ Const.ID_SPLIT + instanceReferenceAlarm.getFrontInstanceId()
|
||||
+ Const.ID_SPLIT + instanceReferenceAlarm.getBehindInstanceId();
|
||||
|
||||
InstanceReferenceAlarmList instanceReferenceAlarmList = new InstanceReferenceAlarmList();
|
||||
instanceReferenceAlarmList.setId(id);
|
||||
instanceReferenceAlarmList.setFrontApplicationId(instanceReferenceAlarm.getFrontApplicationId());
|
||||
instanceReferenceAlarmList.setBehindApplicationId(instanceReferenceAlarm.getBehindApplicationId());
|
||||
instanceReferenceAlarmList.setFrontInstanceId(instanceReferenceAlarm.getFrontInstanceId());
|
||||
instanceReferenceAlarmList.setBehindInstanceId(instanceReferenceAlarm.getBehindInstanceId());
|
||||
instanceReferenceAlarmList.setSourceValue(instanceReferenceAlarm.getSourceValue());
|
||||
instanceReferenceAlarmList.setAlarmType(instanceReferenceAlarm.getAlarmType());
|
||||
instanceReferenceAlarmList.setTimeBucket(instanceReferenceAlarm.getLastTimeBucket());
|
||||
instanceReferenceAlarmList.setAlarmContent(instanceReferenceAlarm.getAlarmContent());
|
||||
next.execute(instanceReferenceAlarmList);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
|
||||
import org.apache.skywalking.apm.collector.configuration.service.IServiceAlarmRuleConfig;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceMetricAlarmAssertWorker extends AlarmAssertWorker<ServiceMetric, ServiceAlarm> {
|
||||
|
||||
private final IServiceAlarmRuleConfig serviceAlarmRuleConfig;
|
||||
|
||||
public ServiceMetricAlarmAssertWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
this.serviceAlarmRuleConfig = moduleManager.find(ConfigurationModule.NAME).getService(IServiceAlarmRuleConfig.class);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.SERVICE_METRIC_ALARM_ASSERT_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected ServiceAlarm newAlarmObject(String id, ServiceMetric inputMetric) {
|
||||
ServiceAlarm serviceAlarm = new ServiceAlarm();
|
||||
serviceAlarm.setId(id + Const.ID_SPLIT + inputMetric.getServiceId());
|
||||
serviceAlarm.setApplicationId(inputMetric.getApplicationId());
|
||||
serviceAlarm.setInstanceId(inputMetric.getInstanceId());
|
||||
serviceAlarm.setServiceId(inputMetric.getServiceId());
|
||||
return serviceAlarm;
|
||||
}
|
||||
|
||||
@Override protected Double calleeErrorRateThreshold() {
|
||||
return serviceAlarmRuleConfig.calleeErrorRateThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double callerErrorRateThreshold() {
|
||||
return serviceAlarmRuleConfig.callerErrorRateThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double calleeAverageResponseTimeThreshold() {
|
||||
return serviceAlarmRuleConfig.calleeAverageResponseTimeThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double callerAverageResponseTimeThreshold() {
|
||||
return serviceAlarmRuleConfig.callerAverageResponseTimeThreshold();
|
||||
}
|
||||
|
||||
public static class Factory extends AlarmAssertWorkerProvider<ServiceMetric, ServiceAlarm, ServiceMetricAlarmAssertWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public ServiceMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ServiceMetricAlarmAssertWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmGraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Graph;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.remote.RemoteModule;
|
||||
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceMetricAlarmGraph {
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private final WorkerCreateListener workerCreateListener;
|
||||
|
||||
public ServiceMetricAlarmGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) {
|
||||
this.moduleManager = moduleManager;
|
||||
this.workerCreateListener = workerCreateListener;
|
||||
}
|
||||
|
||||
public void create() {
|
||||
RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class);
|
||||
|
||||
Graph<ServiceMetric> graph = GraphManager.INSTANCE.createIfAbsent(AlarmGraphIdDefine.SERVICE_METRIC_ALARM_GRAPH_ID, ServiceMetric.class);
|
||||
|
||||
graph.addNode(new ServiceMetricAlarmAssertWorker.Factory(moduleManager).create(workerCreateListener))
|
||||
.addNext(new ServiceMetricAlarmRemoteWorker.Factory(moduleManager, remoteSenderService, AlarmGraphIdDefine.SERVICE_METRIC_ALARM_GRAPH_ID).create(workerCreateListener))
|
||||
.addNext(new ServiceMetricAlarmPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
graph.toFinder().findNode(AlarmWorkerIdDefine.SERVICE_METRIC_ALARM_REMOTE_WORKER_ID, ServiceAlarm.class)
|
||||
.addNext(new ServiceMetricAlarmToListNodeProcessor())
|
||||
.addNext(new ServiceMetricAlarmListPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
link(graph);
|
||||
}
|
||||
|
||||
private void link(Graph<ServiceMetric> graph) {
|
||||
GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.SERVICE_METRIC_GRAPH_ID, ServiceMetric.class)
|
||||
.toFinder().findNode(MetricWorkerIdDefine.SERVICE_MINUTE_METRIC_PERSISTENCE_WORKER_ID, ServiceMetric.class)
|
||||
.addNext(new NodeProcessor<ServiceMetric, ServiceMetric>() {
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.SERVICE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override public void process(ServiceMetric serviceMetric,
|
||||
Next<ServiceMetric> next) {
|
||||
graph.start(serviceMetric);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceAlarmListPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarmList;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceMetricAlarmListPersistenceWorker extends PersistenceWorker<ServiceAlarmList> {
|
||||
|
||||
public ServiceMetricAlarmListPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.SERVICE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, ServiceAlarmList> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IServiceAlarmListPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<ServiceAlarmList, ServiceMetricAlarmListPersistenceWorker> {
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public ServiceMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ServiceMetricAlarmListPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,45 +16,46 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.analysis.alarm.provider.worker;
|
||||
package org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IAlertingListPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alerting.AlertingList;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceAlarmPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class AlertingListPersistenceWorker extends PersistenceWorker<AlertingList, AlertingList> {
|
||||
public class ServiceMetricAlarmPersistenceWorker extends PersistenceWorker<ServiceAlarm> {
|
||||
|
||||
public AlertingListPersistenceWorker(ModuleManager moduleManager) {
|
||||
public ServiceMetricAlarmPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return 114;
|
||||
return AlarmWorkerIdDefine.SERVICE_METRIC_ALARM_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override protected IPersistenceDAO persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IAlertingListPersistenceDAO.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, ServiceAlarm> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IServiceAlarmPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends AbstractLocalAsyncWorkerProvider<AlertingList, AlertingList, AlertingListPersistenceWorker> {
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<ServiceAlarm, ServiceMetricAlarmPersistenceWorker> {
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public AlertingListPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new AlertingListPersistenceWorker(moduleManager);
|
||||
@Override public ServiceMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ServiceMetricAlarmPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -16,46 +16,46 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service;
|
||||
package org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
|
||||
import org.apache.skywalking.apm.collector.remote.service.Selector;
|
||||
import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceEntryRemoteWorker extends AbstractRemoteWorker<ServiceEntry, ServiceEntry> {
|
||||
public class ServiceMetricAlarmRemoteWorker extends AbstractRemoteWorker<ServiceAlarm, ServiceAlarm> {
|
||||
|
||||
public ServiceEntryRemoteWorker(ModuleManager moduleManager) {
|
||||
public ServiceMetricAlarmRemoteWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.SERVICE_ENTRY_REMOTE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected void onWork(ServiceEntry serviceEntry) throws WorkerException {
|
||||
onNext(serviceEntry);
|
||||
return AlarmWorkerIdDefine.SERVICE_METRIC_ALARM_REMOTE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override public Selector selector() {
|
||||
return Selector.HashCode;
|
||||
}
|
||||
|
||||
public static class Factory extends AbstractRemoteWorkerProvider<ServiceEntry, ServiceEntry, ServiceEntryRemoteWorker> {
|
||||
@Override protected void onWork(ServiceAlarm message) throws WorkerException {
|
||||
onNext(message);
|
||||
}
|
||||
|
||||
public static class Factory extends AbstractRemoteWorkerProvider<ServiceAlarm, ServiceAlarm, ServiceMetricAlarmRemoteWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) {
|
||||
super(moduleManager, remoteSenderService, graphId);
|
||||
}
|
||||
|
||||
@Override public ServiceEntryRemoteWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ServiceEntryRemoteWorker(moduleManager);
|
||||
@Override public ServiceMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ServiceMetricAlarmRemoteWorker(moduleManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarmList;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceMetricAlarmToListNodeProcessor implements NodeProcessor<ServiceAlarm, ServiceAlarmList> {
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.SERVICE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID;
|
||||
}
|
||||
|
||||
@Override public void process(ServiceAlarm serviceAlarm, Next<ServiceAlarmList> next) {
|
||||
String id = serviceAlarm.getLastTimeBucket() + Const.ID_SPLIT + serviceAlarm.getSourceValue()
|
||||
+ Const.ID_SPLIT + serviceAlarm.getAlarmType()
|
||||
+ Const.ID_SPLIT + serviceAlarm.getServiceId();
|
||||
|
||||
ServiceAlarmList serviceAlarmList = new ServiceAlarmList();
|
||||
serviceAlarmList.setId(id);
|
||||
serviceAlarmList.setApplicationId(serviceAlarm.getApplicationId());
|
||||
serviceAlarmList.setInstanceId(serviceAlarm.getInstanceId());
|
||||
serviceAlarmList.setServiceId(serviceAlarm.getServiceId());
|
||||
serviceAlarmList.setSourceValue(serviceAlarm.getSourceValue());
|
||||
serviceAlarmList.setAlarmType(serviceAlarm.getAlarmType());
|
||||
serviceAlarmList.setTimeBucket(serviceAlarm.getLastTimeBucket());
|
||||
serviceAlarmList.setAlarmContent(serviceAlarm.getAlarmContent());
|
||||
next.execute(serviceAlarmList);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
|
||||
import org.apache.skywalking.apm.collector.configuration.service.IServiceReferenceAlarmRuleConfig;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceReferenceMetricAlarmAssertWorker extends AlarmAssertWorker<ServiceReferenceMetric, ServiceReferenceAlarm> {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ServiceReferenceMetricAlarmAssertWorker.class);
|
||||
|
||||
private final IServiceReferenceAlarmRuleConfig serviceReferenceAlarmRuleConfig;
|
||||
|
||||
public ServiceReferenceMetricAlarmAssertWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
this.serviceReferenceAlarmRuleConfig = moduleManager.find(ConfigurationModule.NAME).getService(IServiceReferenceAlarmRuleConfig.class);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.SERVICE_REFERENCE_METRIC_ALARM_ASSERT_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected ServiceReferenceAlarm newAlarmObject(String id, ServiceReferenceMetric inputMetric) {
|
||||
ServiceReferenceAlarm serviceReferenceAlarm = new ServiceReferenceAlarm();
|
||||
serviceReferenceAlarm.setId(id + Const.ID_SPLIT + inputMetric.getFrontServiceId() + Const.ID_SPLIT + inputMetric.getBehindServiceId());
|
||||
serviceReferenceAlarm.setFrontApplicationId(inputMetric.getFrontApplicationId());
|
||||
serviceReferenceAlarm.setBehindApplicationId(inputMetric.getBehindApplicationId());
|
||||
serviceReferenceAlarm.setFrontInstanceId(inputMetric.getFrontInstanceId());
|
||||
serviceReferenceAlarm.setBehindInstanceId(inputMetric.getBehindInstanceId());
|
||||
serviceReferenceAlarm.setFrontServiceId(inputMetric.getFrontServiceId());
|
||||
serviceReferenceAlarm.setBehindServiceId(inputMetric.getBehindServiceId());
|
||||
return serviceReferenceAlarm;
|
||||
}
|
||||
|
||||
@Override protected Double calleeErrorRateThreshold() {
|
||||
return serviceReferenceAlarmRuleConfig.calleeErrorRateThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double callerErrorRateThreshold() {
|
||||
return serviceReferenceAlarmRuleConfig.callerErrorRateThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double calleeAverageResponseTimeThreshold() {
|
||||
return serviceReferenceAlarmRuleConfig.calleeAverageResponseTimeThreshold();
|
||||
}
|
||||
|
||||
@Override protected Double callerAverageResponseTimeThreshold() {
|
||||
return serviceReferenceAlarmRuleConfig.callerAverageResponseTimeThreshold();
|
||||
}
|
||||
|
||||
public static class Factory extends AlarmAssertWorkerProvider<ServiceReferenceMetric, ServiceReferenceAlarm, ServiceReferenceMetricAlarmAssertWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public ServiceReferenceMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ServiceReferenceMetricAlarmAssertWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmGraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Graph;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.remote.RemoteModule;
|
||||
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceReferenceMetricAlarmGraph {
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private final WorkerCreateListener workerCreateListener;
|
||||
|
||||
public ServiceReferenceMetricAlarmGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) {
|
||||
this.moduleManager = moduleManager;
|
||||
this.workerCreateListener = workerCreateListener;
|
||||
}
|
||||
|
||||
public void create() {
|
||||
RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class);
|
||||
|
||||
Graph<ServiceReferenceMetric> graph = GraphManager.INSTANCE.createIfAbsent(AlarmGraphIdDefine.SERVICE_REFERENCE_METRIC_ALARM_GRAPH_ID, ServiceReferenceMetric.class);
|
||||
|
||||
graph.addNode(new ServiceReferenceMetricAlarmAssertWorker.Factory(moduleManager).create(workerCreateListener))
|
||||
.addNext(new ServiceReferenceMetricAlarmRemoteWorker.Factory(moduleManager, remoteSenderService, AlarmGraphIdDefine.SERVICE_REFERENCE_METRIC_ALARM_GRAPH_ID).create(workerCreateListener))
|
||||
.addNext(new ServiceReferenceMetricAlarmPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
graph.toFinder().findNode(AlarmWorkerIdDefine.SERVICE_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID, ServiceReferenceAlarm.class)
|
||||
.addNext(new ServiceReferenceMetricAlarmToListNodeProcessor())
|
||||
.addNext(new ServiceReferenceMetricAlarmListPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
link(graph);
|
||||
}
|
||||
|
||||
private void link(Graph<ServiceReferenceMetric> graph) {
|
||||
GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.SERVICE_REFERENCE_METRIC_GRAPH_ID, ServiceReferenceMetric.class)
|
||||
.toFinder().findNode(MetricWorkerIdDefine.SERVICE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID, ServiceReferenceMetric.class)
|
||||
.addNext(new NodeProcessor<ServiceReferenceMetric, ServiceReferenceMetric>() {
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.SERVICE_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override public void process(ServiceReferenceMetric serviceReferenceMetric,
|
||||
Next<ServiceReferenceMetric> next) {
|
||||
graph.start(serviceReferenceMetric);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceReferenceAlarmListPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarmList;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceReferenceMetricAlarmListPersistenceWorker extends PersistenceWorker<ServiceReferenceAlarmList> {
|
||||
|
||||
public ServiceReferenceMetricAlarmListPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.SERVICE_REFERENCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, ServiceReferenceAlarmList> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IServiceReferenceAlarmListPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<ServiceReferenceAlarmList, ServiceReferenceMetricAlarmListPersistenceWorker> {
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public ServiceReferenceMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ServiceReferenceMetricAlarmListPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceReferenceAlarmPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceReferenceMetricAlarmPersistenceWorker extends PersistenceWorker<ServiceReferenceAlarm> {
|
||||
|
||||
public ServiceReferenceMetricAlarmPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.SERVICE_REFERENCE_METRIC_ALARM_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, ServiceReferenceAlarm> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IServiceReferenceAlarmPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<ServiceReferenceAlarm, ServiceReferenceMetricAlarmPersistenceWorker> {
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public ServiceReferenceMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ServiceReferenceMetricAlarmPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
|
||||
import org.apache.skywalking.apm.collector.remote.service.Selector;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceReferenceMetricAlarmRemoteWorker extends AbstractRemoteWorker<ServiceReferenceAlarm, ServiceReferenceAlarm> {
|
||||
|
||||
public ServiceReferenceMetricAlarmRemoteWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.SERVICE_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override public Selector selector() {
|
||||
return Selector.HashCode;
|
||||
}
|
||||
|
||||
@Override protected void onWork(ServiceReferenceAlarm message) throws WorkerException {
|
||||
onNext(message);
|
||||
}
|
||||
|
||||
public static class Factory extends AbstractRemoteWorkerProvider<ServiceReferenceAlarm, ServiceReferenceAlarm, ServiceReferenceMetricAlarmRemoteWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) {
|
||||
super(moduleManager, remoteSenderService, graphId);
|
||||
}
|
||||
|
||||
@Override public ServiceReferenceMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new ServiceReferenceMetricAlarmRemoteWorker(moduleManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.alarm.provider.worker.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarm;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarmList;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceReferenceMetricAlarmToListNodeProcessor implements NodeProcessor<ServiceReferenceAlarm, ServiceReferenceAlarmList> {
|
||||
|
||||
@Override public int id() {
|
||||
return AlarmWorkerIdDefine.SERVICE_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID;
|
||||
}
|
||||
|
||||
@Override public void process(ServiceReferenceAlarm serviceReferenceAlarm, Next<ServiceReferenceAlarmList> next) {
|
||||
String id = serviceReferenceAlarm.getLastTimeBucket() + Const.ID_SPLIT + serviceReferenceAlarm.getSourceValue()
|
||||
+ Const.ID_SPLIT + serviceReferenceAlarm.getAlarmType()
|
||||
+ Const.ID_SPLIT + serviceReferenceAlarm.getFrontServiceId()
|
||||
+ Const.ID_SPLIT + serviceReferenceAlarm.getBehindServiceId();
|
||||
|
||||
ServiceReferenceAlarmList serviceReferenceAlarmList = new ServiceReferenceAlarmList();
|
||||
serviceReferenceAlarmList.setId(id);
|
||||
serviceReferenceAlarmList.setFrontApplicationId(serviceReferenceAlarm.getFrontApplicationId());
|
||||
serviceReferenceAlarmList.setBehindApplicationId(serviceReferenceAlarm.getBehindApplicationId());
|
||||
serviceReferenceAlarmList.setFrontInstanceId(serviceReferenceAlarm.getFrontInstanceId());
|
||||
serviceReferenceAlarmList.setBehindInstanceId(serviceReferenceAlarm.getBehindInstanceId());
|
||||
serviceReferenceAlarmList.setFrontServiceId(serviceReferenceAlarm.getFrontServiceId());
|
||||
serviceReferenceAlarmList.setBehindServiceId(serviceReferenceAlarm.getBehindServiceId());
|
||||
serviceReferenceAlarmList.setSourceValue(serviceReferenceAlarm.getSourceValue());
|
||||
serviceReferenceAlarmList.setAlarmType(serviceReferenceAlarm.getAlarmType());
|
||||
serviceReferenceAlarmList.setTimeBucket(serviceReferenceAlarm.getLastTimeBucket());
|
||||
serviceReferenceAlarmList.setAlarmContent(serviceReferenceAlarm.getAlarmContent());
|
||||
next.execute(serviceReferenceAlarmList);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,23 +16,4 @@
|
|||
#
|
||||
#
|
||||
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
org.apache.skywalking.apm.collector.analysis.alarm.provider.AlertingModuleProvider
|
||||
org.apache.skywalking.apm.collector.analysis.alarm.provider.AnalysisAlarmModuleProvider
|
||||
|
|
@ -20,7 +20,6 @@ package org.apache.skywalking.apm.collector.analysis.jvm.define;
|
|||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.ICpuMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IGCMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IInstanceHeartBeatService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IMemoryMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IMemoryPoolMetricService;
|
||||
import org.apache.skywalking.apm.collector.core.module.Module;
|
||||
|
|
@ -38,7 +37,7 @@ public class AnalysisJVMModule extends Module {
|
|||
|
||||
@Override public Class[] services() {
|
||||
return new Class[] {
|
||||
ICpuMetricService.class, IGCMetricService.class, IInstanceHeartBeatService.class,
|
||||
ICpuMetricService.class, IGCMetricService.class,
|
||||
IMemoryMetricService.class, IMemoryPoolMetricService.class
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ package org.apache.skywalking.apm.collector.analysis.jvm.define.graph;
|
|||
public class GraphIdDefine {
|
||||
public static final int CPU_METRIC_PERSISTENCE_GRAPH_ID = 300;
|
||||
public static final int GC_METRIC_PERSISTENCE_GRAPH_ID = 301;
|
||||
public static final int INSTANCE_HEART_BEAT_PERSISTENCE_GRAPH_ID = 302;
|
||||
public static final int MEMORY_METRIC_PERSISTENCE_GRAPH_ID = 303;
|
||||
public static final int MEMORY_POOL_METRIC_PERSISTENCE_GRAPH_ID = 304;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,47 @@ package org.apache.skywalking.apm.collector.analysis.jvm.define.graph;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
public class WorkerIdDefine {
|
||||
public static final int CPU_METRIC_PERSISTENCE_WORKER_ID = 300;
|
||||
public static final int GC_METRIC_PERSISTENCE_WORKER_ID = 301;
|
||||
public static final int INST_HEART_BEAT_PERSISTENCE_WORKER_ID = 302;
|
||||
public static final int MEMORY_METRIC_PERSISTENCE_WORKER_ID = 303;
|
||||
public static final int MEMORY_POOL_METRIC_PERSISTENCE_WORKER_ID = 303;
|
||||
public static final int CPU_METRIC_BRIDGE_NODE_ID = 3000;
|
||||
public static final int CPU_SECOND_METRIC_PERSISTENCE_WORKER_ID = 3001;
|
||||
public static final int CPU_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 3002;
|
||||
public static final int CPU_MINUTE_METRIC_TRANSFORM_NODE_ID = 3003;
|
||||
public static final int CPU_HOUR_METRIC_PERSISTENCE_WORKER_ID = 3004;
|
||||
public static final int CPU_HOUR_METRIC_TRANSFORM_NODE_ID = 3005;
|
||||
public static final int CPU_DAY_METRIC_PERSISTENCE_WORKER_ID = 3006;
|
||||
public static final int CPU_DAY_METRIC_TRANSFORM_NODE_ID = 3007;
|
||||
public static final int CPU_MONTH_METRIC_PERSISTENCE_WORKER_ID = 3008;
|
||||
public static final int CPU_MONTH_METRIC_TRANSFORM_NODE_ID = 3009;
|
||||
|
||||
public static final int GC_METRIC_BRIDGE_NODE_ID = 3100;
|
||||
public static final int GC_SECOND_METRIC_PERSISTENCE_WORKER_ID = 3101;
|
||||
public static final int GC_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 3102;
|
||||
public static final int GC_MINUTE_METRIC_TRANSFORM_NODE_ID = 3103;
|
||||
public static final int GC_HOUR_METRIC_PERSISTENCE_WORKER_ID = 3104;
|
||||
public static final int GC_HOUR_METRIC_TRANSFORM_NODE_ID = 3105;
|
||||
public static final int GC_DAY_METRIC_PERSISTENCE_WORKER_ID = 3106;
|
||||
public static final int GC_DAY_METRIC_TRANSFORM_NODE_ID = 3107;
|
||||
public static final int GC_MONTH_METRIC_PERSISTENCE_WORKER_ID = 3108;
|
||||
public static final int GC_MONTH_METRIC_TRANSFORM_NODE_ID = 3109;
|
||||
|
||||
public static final int MEMORY_METRIC_BRIDGE_NODE_ID = 3200;
|
||||
public static final int MEMORY_SECOND_METRIC_PERSISTENCE_WORKER_ID = 3201;
|
||||
public static final int MEMORY_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 3202;
|
||||
public static final int MEMORY_MINUTE_METRIC_TRANSFORM_NODE_ID = 3203;
|
||||
public static final int MEMORY_HOUR_METRIC_PERSISTENCE_WORKER_ID = 3204;
|
||||
public static final int MEMORY_HOUR_METRIC_TRANSFORM_NODE_ID = 3205;
|
||||
public static final int MEMORY_DAY_METRIC_PERSISTENCE_WORKER_ID = 3206;
|
||||
public static final int MEMORY_DAY_METRIC_TRANSFORM_NODE_ID = 3207;
|
||||
public static final int MEMORY_MONTH_METRIC_PERSISTENCE_WORKER_ID = 3208;
|
||||
public static final int MEMORY_MONTH_METRIC_TRANSFORM_NODE_ID = 3209;
|
||||
|
||||
public static final int MEMORY_POOL_METRIC_BRIDGE_NODE_ID = 3300;
|
||||
public static final int MEMORY_POOL_SECOND_METRIC_PERSISTENCE_WORKER_ID = 3301;
|
||||
public static final int MEMORY_POOL_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 3302;
|
||||
public static final int MEMORY_POOL_MINUTE_METRIC_TRANSFORM_NODE_ID = 3303;
|
||||
public static final int MEMORY_POOL_HOUR_METRIC_PERSISTENCE_WORKER_ID = 3304;
|
||||
public static final int MEMORY_POOL_HOUR_METRIC_TRANSFORM_NODE_ID = 3305;
|
||||
public static final int MEMORY_POOL_DAY_METRIC_PERSISTENCE_WORKER_ID = 3306;
|
||||
public static final int MEMORY_POOL_DAY_METRIC_TRANSFORM_NODE_ID = 3307;
|
||||
public static final int MEMORY_POOL_MONTH_METRIC_PERSISTENCE_WORKER_ID = 3308;
|
||||
public static final int MEMORY_POOL_MONTH_METRIC_TRANSFORM_NODE_ID = 3309;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@ import org.apache.skywalking.apm.collector.core.module.Service;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IMemoryMetricService extends Service {
|
||||
void send(int instanceId, long timeBucket, boolean isHeap, long init, long max, long used, long commited);
|
||||
void send(int instanceId, long timeBucket, boolean isHeap, long init, long max, long used, long committed);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@ import org.apache.skywalking.apm.collector.core.module.Service;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IMemoryPoolMetricService extends Service {
|
||||
void send(int instanceId, long timeBucket, int poolType, long init, long max, long used, long commited);
|
||||
void send(int instanceId, long timeBucket, int poolType, long init, long max, long used, long committed);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,19 +22,16 @@ import java.util.Properties;
|
|||
import org.apache.skywalking.apm.collector.analysis.jvm.define.AnalysisJVMModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.ICpuMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IGCMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IInstanceHeartBeatService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IMemoryMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IMemoryPoolMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.service.CpuMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.service.GCMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.service.InstanceHeartBeatService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.service.MemoryMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.service.MemoryPoolMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.CpuMetricPersistenceGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.GCMetricPersistenceGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.InstanceHeartBeatPersistenceGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.MemoryMetricPersistenceGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.MemoryPoolMetricPersistenceGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.cpu.CpuMetricPersistenceGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.gc.GCMetricPersistenceGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.memory.MemoryMetricPersistenceGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.memorypool.MemoryPoolMetricPersistenceGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.timer.PersistenceTimer;
|
||||
import org.apache.skywalking.apm.collector.core.module.Module;
|
||||
|
|
@ -61,7 +58,6 @@ public class AnalysisJVMModuleProvider extends ModuleProvider {
|
|||
@Override public void prepare(Properties config) throws ServiceNotProvidedException {
|
||||
this.registerServiceImplementation(ICpuMetricService.class, new CpuMetricService());
|
||||
this.registerServiceImplementation(IGCMetricService.class, new GCMetricService());
|
||||
this.registerServiceImplementation(IInstanceHeartBeatService.class, new InstanceHeartBeatService());
|
||||
this.registerServiceImplementation(IMemoryMetricService.class, new MemoryMetricService());
|
||||
this.registerServiceImplementation(IMemoryPoolMetricService.class, new MemoryPoolMetricService());
|
||||
}
|
||||
|
|
@ -90,9 +86,6 @@ public class AnalysisJVMModuleProvider extends ModuleProvider {
|
|||
GCMetricPersistenceGraph gcMetricPersistenceGraph = new GCMetricPersistenceGraph(getManager(), workerCreateListener);
|
||||
gcMetricPersistenceGraph.create();
|
||||
|
||||
InstanceHeartBeatPersistenceGraph instanceHeartBeatPersistenceGraph = new InstanceHeartBeatPersistenceGraph(getManager(), workerCreateListener);
|
||||
instanceHeartBeatPersistenceGraph.create();
|
||||
|
||||
MemoryMetricPersistenceGraph memoryMetricPersistenceGraph = new MemoryMetricPersistenceGraph(getManager(), workerCreateListener);
|
||||
memoryMetricPersistenceGraph.create();
|
||||
|
||||
|
|
|
|||
|
|
@ -45,9 +45,15 @@ public class CpuMetricService implements ICpuMetricService {
|
|||
}
|
||||
|
||||
@Override public void send(int instanceId, long timeBucket, double usagePercent) {
|
||||
CpuMetric cpuMetric = new CpuMetric(timeBucket + Const.ID_SPLIT + instanceId);
|
||||
String metricId = String.valueOf(instanceId);
|
||||
String id = timeBucket + Const.ID_SPLIT + metricId;
|
||||
|
||||
CpuMetric cpuMetric = new CpuMetric();
|
||||
cpuMetric.setId(id);
|
||||
cpuMetric.setMetricId(metricId);
|
||||
cpuMetric.setInstanceId(instanceId);
|
||||
cpuMetric.setUsagePercent(usagePercent);
|
||||
cpuMetric.setTimes(1L);
|
||||
cpuMetric.setTimeBucket(timeBucket);
|
||||
|
||||
logger.debug("push to cpu metric graph, id: {}", cpuMetric.getId());
|
||||
|
|
|
|||
|
|
@ -45,11 +45,16 @@ public class GCMetricService implements IGCMetricService {
|
|||
}
|
||||
|
||||
@Override public void send(int instanceId, long timeBucket, int phraseValue, long count, long time) {
|
||||
GCMetric gcMetric = new GCMetric(timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + String.valueOf(phraseValue));
|
||||
String metricId = instanceId + Const.ID_SPLIT + String.valueOf(phraseValue);
|
||||
String id = timeBucket + Const.ID_SPLIT + metricId;
|
||||
|
||||
GCMetric gcMetric = new GCMetric();
|
||||
gcMetric.setId(id);
|
||||
gcMetric.setMetricId(metricId);
|
||||
gcMetric.setInstanceId(instanceId);
|
||||
gcMetric.setPhrase(phraseValue);
|
||||
gcMetric.setCount(count);
|
||||
gcMetric.setTime(time);
|
||||
gcMetric.setTimes(1L);
|
||||
gcMetric.setTimeBucket(timeBucket);
|
||||
|
||||
logger.debug("push to gc metric graph, id: {}", gcMetric.getId());
|
||||
|
|
|
|||
|
|
@ -45,14 +45,20 @@ public class MemoryMetricService implements IMemoryMetricService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void send(int instanceId, long timeBucket, boolean isHeap, long init, long max, long used, long commited) {
|
||||
MemoryMetric memoryMetric = new MemoryMetric(timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + String.valueOf(isHeap));
|
||||
public void send(int instanceId, long timeBucket, boolean isHeap, long init, long max, long used, long committed) {
|
||||
String metricId = instanceId + Const.ID_SPLIT + String.valueOf(isHeap);
|
||||
String id = timeBucket + Const.ID_SPLIT + metricId;
|
||||
|
||||
MemoryMetric memoryMetric = new MemoryMetric();
|
||||
memoryMetric.setId(id);
|
||||
memoryMetric.setMetricId(metricId);
|
||||
memoryMetric.setInstanceId(instanceId);
|
||||
memoryMetric.setIsHeap(isHeap);
|
||||
memoryMetric.setInit(init);
|
||||
memoryMetric.setMax(max);
|
||||
memoryMetric.setUsed(used);
|
||||
memoryMetric.setCommitted(commited);
|
||||
memoryMetric.setCommitted(committed);
|
||||
memoryMetric.setTimes(1L);
|
||||
memoryMetric.setTimeBucket(timeBucket);
|
||||
|
||||
logger.debug("push to memory metric graph, id: {}", memoryMetric.getId());
|
||||
|
|
|
|||
|
|
@ -45,14 +45,20 @@ public class MemoryPoolMetricService implements IMemoryPoolMetricService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void send(int instanceId, long timeBucket, int poolType, long init, long max, long used, long commited) {
|
||||
MemoryPoolMetric memoryPoolMetric = new MemoryPoolMetric(timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + String.valueOf(poolType));
|
||||
public void send(int instanceId, long timeBucket, int poolType, long init, long max, long used, long committed) {
|
||||
String metricId = instanceId + Const.ID_SPLIT + String.valueOf(poolType);
|
||||
String id = timeBucket + Const.ID_SPLIT + metricId;
|
||||
|
||||
MemoryPoolMetric memoryPoolMetric = new MemoryPoolMetric();
|
||||
memoryPoolMetric.setId(id);
|
||||
memoryPoolMetric.setMetricId(metricId);
|
||||
memoryPoolMetric.setInstanceId(instanceId);
|
||||
memoryPoolMetric.setPoolType(poolType);
|
||||
memoryPoolMetric.setInit(init);
|
||||
memoryPoolMetric.setMax(max);
|
||||
memoryPoolMetric.setUsed(used);
|
||||
memoryPoolMetric.setCommitted(commited);
|
||||
memoryPoolMetric.setCommitted(committed);
|
||||
memoryPoolMetric.setTimes(1L);
|
||||
memoryPoolMetric.setTimeBucket(timeBucket);
|
||||
|
||||
logger.debug("push to memory pool metric graph, id: {}", memoryPoolMetric.getId());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.cpu;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuDayMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class CpuDayMetricPersistenceWorker extends PersistenceWorker<CpuMetric> {
|
||||
|
||||
public CpuDayMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.CPU_DAY_METRIC_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, CpuMetric> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(ICpuDayMetricPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<CpuMetric, CpuDayMetricPersistenceWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public CpuDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new CpuDayMetricPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.cpu;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class CpuDayMetricTransformNode implements NodeProcessor<CpuMetric, CpuMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.CPU_DAY_METRIC_TRANSFORM_NODE_ID;
|
||||
}
|
||||
|
||||
@Override public void process(CpuMetric cpuMetric, Next<CpuMetric> next) {
|
||||
long timeBucket = TimeBucketUtils.INSTANCE.secondToDay(cpuMetric.getTimeBucket());
|
||||
|
||||
CpuMetric newCpuMetric = CpuMetricCopy.copy(cpuMetric);
|
||||
newCpuMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + cpuMetric.getMetricId());
|
||||
newCpuMetric.setTimeBucket(timeBucket);
|
||||
next.execute(newCpuMetric);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.cpu;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuHourMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class CpuHourMetricPersistenceWorker extends PersistenceWorker<CpuMetric> {
|
||||
|
||||
public CpuHourMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.CPU_HOUR_METRIC_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, CpuMetric> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(ICpuHourMetricPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<CpuMetric, CpuHourMetricPersistenceWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public CpuHourMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new CpuHourMetricPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.cpu;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class CpuHourMetricTransformNode implements NodeProcessor<CpuMetric, CpuMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.CPU_HOUR_METRIC_TRANSFORM_NODE_ID;
|
||||
}
|
||||
|
||||
@Override public void process(CpuMetric cpuMetric, Next<CpuMetric> next) {
|
||||
long timeBucket = TimeBucketUtils.INSTANCE.secondToHour(cpuMetric.getTimeBucket());
|
||||
|
||||
CpuMetric newCpuMetric = CpuMetricCopy.copy(cpuMetric);
|
||||
newCpuMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + cpuMetric.getMetricId());
|
||||
newCpuMetric.setTimeBucket(timeBucket);
|
||||
next.execute(newCpuMetric);
|
||||
}
|
||||
}
|
||||
|
|
@ -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.skywalking.apm.collector.analysis.jvm.provider.worker.cpu;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class CpuMetricBridgeNode implements NodeProcessor<CpuMetric, CpuMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.CPU_METRIC_BRIDGE_NODE_ID;
|
||||
}
|
||||
|
||||
@Override public void process(CpuMetric metric, Next<CpuMetric> next) {
|
||||
next.execute(metric);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.cpu;
|
||||
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class CpuMetricCopy {
|
||||
|
||||
public static CpuMetric copy(CpuMetric cpuMetric) {
|
||||
CpuMetric newCpuMetric = new CpuMetric();
|
||||
newCpuMetric.setId(cpuMetric.getId());
|
||||
newCpuMetric.setMetricId(cpuMetric.getMetricId());
|
||||
|
||||
newCpuMetric.setInstanceId(cpuMetric.getInstanceId());
|
||||
newCpuMetric.setUsagePercent(cpuMetric.getUsagePercent());
|
||||
newCpuMetric.setTimes(cpuMetric.getTimes());
|
||||
|
||||
newCpuMetric.setTimeBucket(cpuMetric.getTimeBucket());
|
||||
return newCpuMetric;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,11 +16,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker;
|
||||
package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.cpu;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.GraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Node;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric;
|
||||
|
||||
|
|
@ -38,7 +39,21 @@ public class CpuMetricPersistenceGraph {
|
|||
}
|
||||
|
||||
public void create() {
|
||||
GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.CPU_METRIC_PERSISTENCE_GRAPH_ID, CpuMetric.class)
|
||||
.addNode(new CpuMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
Node<CpuMetric, CpuMetric> bridgeNode = GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.CPU_METRIC_PERSISTENCE_GRAPH_ID, CpuMetric.class)
|
||||
.addNode(new CpuMetricBridgeNode());
|
||||
|
||||
bridgeNode.addNext(new CpuSecondMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
bridgeNode.addNext(new CpuMinuteMetricTransformNode())
|
||||
.addNext(new CpuMinuteMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
bridgeNode.addNext(new CpuHourMetricTransformNode())
|
||||
.addNext(new CpuHourMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
bridgeNode.addNext(new CpuDayMetricTransformNode())
|
||||
.addNext(new CpuDayMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
bridgeNode.addNext(new CpuMonthMetricTransformNode())
|
||||
.addNext(new CpuMonthMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.cpu;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuMinuteMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class CpuMinuteMetricPersistenceWorker extends PersistenceWorker<CpuMetric> {
|
||||
|
||||
public CpuMinuteMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.CPU_MINUTE_METRIC_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, CpuMetric> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(ICpuMinuteMetricPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<CpuMetric, CpuMinuteMetricPersistenceWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public CpuMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new CpuMinuteMetricPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.cpu;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class CpuMinuteMetricTransformNode implements NodeProcessor<CpuMetric, CpuMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.CPU_MINUTE_METRIC_TRANSFORM_NODE_ID;
|
||||
}
|
||||
|
||||
@Override public void process(CpuMetric cpuMetric, Next<CpuMetric> next) {
|
||||
long timeBucket = TimeBucketUtils.INSTANCE.secondToMinute(cpuMetric.getTimeBucket());
|
||||
|
||||
CpuMetric newCpuMetric = CpuMetricCopy.copy(cpuMetric);
|
||||
newCpuMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + cpuMetric.getMetricId());
|
||||
newCpuMetric.setTimeBucket(timeBucket);
|
||||
next.execute(newCpuMetric);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.cpu;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuMonthMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class CpuMonthMetricPersistenceWorker extends PersistenceWorker<CpuMetric> {
|
||||
|
||||
public CpuMonthMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.CPU_MONTH_METRIC_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, CpuMetric> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(ICpuMonthMetricPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<CpuMetric, CpuMonthMetricPersistenceWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public CpuMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new CpuMonthMetricPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.cpu;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class CpuMonthMetricTransformNode implements NodeProcessor<CpuMetric, CpuMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.CPU_MONTH_METRIC_TRANSFORM_NODE_ID;
|
||||
}
|
||||
|
||||
@Override public void process(CpuMetric cpuMetric, Next<CpuMetric> next) {
|
||||
long timeBucket = TimeBucketUtils.INSTANCE.secondToMonth(cpuMetric.getTimeBucket());
|
||||
|
||||
CpuMetric newCpuMetric = CpuMetricCopy.copy(cpuMetric);
|
||||
newCpuMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + cpuMetric.getMetricId());
|
||||
newCpuMetric.setTimeBucket(timeBucket);
|
||||
next.execute(newCpuMetric);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,46 +16,47 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker;
|
||||
package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.cpu;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class CpuMetricPersistenceWorker extends PersistenceWorker<CpuMetric, CpuMetric> {
|
||||
public class CpuSecondMetricPersistenceWorker extends PersistenceWorker<CpuMetric> {
|
||||
|
||||
public CpuMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
public CpuSecondMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.CPU_METRIC_PERSISTENCE_WORKER_ID;
|
||||
return WorkerIdDefine.CPU_SECOND_METRIC_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override protected IPersistenceDAO persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(ICpuMetricPersistenceDAO.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, CpuMetric> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(ICpuSecondMetricPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends AbstractLocalAsyncWorkerProvider<CpuMetric, CpuMetric, CpuMetricPersistenceWorker> {
|
||||
public static class Factory extends PersistenceWorkerProvider<CpuMetric, CpuSecondMetricPersistenceWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public CpuMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new CpuMetricPersistenceWorker(moduleManager);
|
||||
@Override public CpuSecondMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new CpuSecondMetricPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.gc;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCDayMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class GCDayMetricPersistenceWorker extends PersistenceWorker<GCMetric> {
|
||||
|
||||
public GCDayMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.GC_DAY_METRIC_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, GCMetric> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IGCDayMetricPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<GCMetric, GCDayMetricPersistenceWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public GCDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new GCDayMetricPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.gc;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class GCDayMetricTransformNode implements NodeProcessor<GCMetric, GCMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.GC_DAY_METRIC_TRANSFORM_NODE_ID;
|
||||
}
|
||||
|
||||
@Override public void process(GCMetric gcMetric, Next<GCMetric> next) {
|
||||
long timeBucket = TimeBucketUtils.INSTANCE.secondToDay(gcMetric.getTimeBucket());
|
||||
|
||||
GCMetric newGCMetric = GCMetricCopy.copy(gcMetric);
|
||||
newGCMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + gcMetric.getMetricId());
|
||||
newGCMetric.setTimeBucket(timeBucket);
|
||||
next.execute(newGCMetric);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,46 +16,47 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker;
|
||||
package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.gc;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCHourMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class MemoryMetricPersistenceWorker extends PersistenceWorker<MemoryMetric, MemoryMetric> {
|
||||
public class GCHourMetricPersistenceWorker extends PersistenceWorker<GCMetric> {
|
||||
|
||||
public MemoryMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
public GCHourMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.MEMORY_METRIC_PERSISTENCE_WORKER_ID;
|
||||
return WorkerIdDefine.GC_HOUR_METRIC_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override protected IPersistenceDAO persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IMemoryMetricPersistenceDAO.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, GCMetric> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IGCHourMetricPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends AbstractLocalAsyncWorkerProvider<MemoryMetric, MemoryMetric, MemoryMetricPersistenceWorker> {
|
||||
public static class Factory extends PersistenceWorkerProvider<GCMetric, GCHourMetricPersistenceWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public MemoryMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new MemoryMetricPersistenceWorker(moduleManager);
|
||||
@Override public GCHourMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new GCHourMetricPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.gc;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class GCHourMetricTransformNode implements NodeProcessor<GCMetric, GCMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.GC_HOUR_METRIC_TRANSFORM_NODE_ID;
|
||||
}
|
||||
|
||||
@Override public void process(GCMetric gcMetric, Next<GCMetric> next) {
|
||||
long timeBucket = TimeBucketUtils.INSTANCE.secondToHour(gcMetric.getTimeBucket());
|
||||
|
||||
GCMetric newGCMetric = GCMetricCopy.copy(gcMetric);
|
||||
newGCMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + gcMetric.getMetricId());
|
||||
newGCMetric.setTimeBucket(timeBucket);
|
||||
next.execute(newGCMetric);
|
||||
}
|
||||
}
|
||||
|
|
@ -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.skywalking.apm.collector.analysis.jvm.provider.worker.gc;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class GCMetricBridgeNode implements NodeProcessor<GCMetric, GCMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.GC_METRIC_BRIDGE_NODE_ID;
|
||||
}
|
||||
|
||||
@Override public void process(GCMetric metric, Next<GCMetric> next) {
|
||||
next.execute(metric);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.gc;
|
||||
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class GCMetricCopy {
|
||||
|
||||
public static GCMetric copy(GCMetric gcMetric) {
|
||||
GCMetric newGCMetric = new GCMetric();
|
||||
newGCMetric.setId(gcMetric.getId());
|
||||
newGCMetric.setMetricId(gcMetric.getMetricId());
|
||||
|
||||
newGCMetric.setInstanceId(gcMetric.getInstanceId());
|
||||
newGCMetric.setPhrase(gcMetric.getPhrase());
|
||||
|
||||
newGCMetric.setCount(gcMetric.getCount());
|
||||
newGCMetric.setTimes(gcMetric.getTimes());
|
||||
|
||||
newGCMetric.setTimeBucket(gcMetric.getTimeBucket());
|
||||
return newGCMetric;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,11 +16,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker;
|
||||
package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.gc;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.GraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Node;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric;
|
||||
|
||||
|
|
@ -38,7 +39,21 @@ public class GCMetricPersistenceGraph {
|
|||
}
|
||||
|
||||
public void create() {
|
||||
GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.GC_METRIC_PERSISTENCE_GRAPH_ID, GCMetric.class)
|
||||
.addNode(new GCMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
Node<GCMetric, GCMetric> bridgeNode = GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.GC_METRIC_PERSISTENCE_GRAPH_ID, GCMetric.class)
|
||||
.addNode(new GCMetricBridgeNode());
|
||||
|
||||
bridgeNode.addNext(new GCSecondMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
bridgeNode.addNext(new GCMinuteMetricTransformNode())
|
||||
.addNext(new GCMinuteMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
bridgeNode.addNext(new GCHourMetricTransformNode())
|
||||
.addNext(new GCHourMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
bridgeNode.addNext(new GCDayMetricTransformNode())
|
||||
.addNext(new GCDayMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
|
||||
bridgeNode.addNext(new GCMonthMetricTransformNode())
|
||||
.addNext(new GCMonthMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.gc;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCMinuteMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class GCMinuteMetricPersistenceWorker extends PersistenceWorker<GCMetric> {
|
||||
|
||||
public GCMinuteMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.GC_MINUTE_METRIC_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, GCMetric> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IGCMinuteMetricPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<GCMetric, GCMinuteMetricPersistenceWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public GCMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new GCMinuteMetricPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.gc;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class GCMinuteMetricTransformNode implements NodeProcessor<GCMetric, GCMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.GC_MINUTE_METRIC_TRANSFORM_NODE_ID;
|
||||
}
|
||||
|
||||
@Override public void process(GCMetric gcMetric, Next<GCMetric> next) {
|
||||
long timeBucket = TimeBucketUtils.INSTANCE.secondToMinute(gcMetric.getTimeBucket());
|
||||
|
||||
GCMetric newGCMetric = GCMetricCopy.copy(gcMetric);
|
||||
newGCMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + gcMetric.getMetricId());
|
||||
newGCMetric.setTimeBucket(timeBucket);
|
||||
next.execute(newGCMetric);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.gc;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCMonthMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class GCMonthMetricPersistenceWorker extends PersistenceWorker<GCMetric> {
|
||||
|
||||
public GCMonthMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.GC_MONTH_METRIC_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, GCMetric> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IGCMonthMetricPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<GCMetric, GCMonthMetricPersistenceWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public GCMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new GCMonthMetricPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.gc;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class GCMonthMetricTransformNode implements NodeProcessor<GCMetric, GCMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.GC_MONTH_METRIC_TRANSFORM_NODE_ID;
|
||||
}
|
||||
|
||||
@Override public void process(GCMetric gcMetric, Next<GCMetric> next) {
|
||||
long timeBucket = TimeBucketUtils.INSTANCE.secondToMonth(gcMetric.getTimeBucket());
|
||||
|
||||
GCMetric newGCMetric = GCMetricCopy.copy(gcMetric);
|
||||
newGCMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + gcMetric.getMetricId());
|
||||
newGCMetric.setTimeBucket(timeBucket);
|
||||
next.execute(newGCMetric);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,46 +16,47 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker;
|
||||
package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.gc;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCSecondMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class GCMetricPersistenceWorker extends PersistenceWorker<GCMetric, GCMetric> {
|
||||
public class GCSecondMetricPersistenceWorker extends PersistenceWorker<GCMetric> {
|
||||
|
||||
public GCMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
public GCSecondMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.GC_METRIC_PERSISTENCE_WORKER_ID;
|
||||
return WorkerIdDefine.GC_SECOND_METRIC_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override protected IPersistenceDAO persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IGCMetricPersistenceDAO.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, GCMetric> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IGCSecondMetricPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends AbstractLocalAsyncWorkerProvider<GCMetric, GCMetric, GCMetricPersistenceWorker> {
|
||||
public static class Factory extends PersistenceWorkerProvider<GCMetric, GCSecondMetricPersistenceWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public GCMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new GCMetricPersistenceWorker(moduleManager);
|
||||
@Override public GCSecondMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new GCSecondMetricPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.memory;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryDayMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class MemoryDayMetricPersistenceWorker extends PersistenceWorker<MemoryMetric> {
|
||||
|
||||
public MemoryDayMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.MEMORY_DAY_METRIC_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, MemoryMetric> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IMemoryDayMetricPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<MemoryMetric, MemoryDayMetricPersistenceWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public MemoryDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new MemoryDayMetricPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queueSize() {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.memory;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class MemoryDayMetricTransformNode implements NodeProcessor<MemoryMetric, MemoryMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.MEMORY_DAY_METRIC_TRANSFORM_NODE_ID;
|
||||
}
|
||||
|
||||
@Override public void process(MemoryMetric memoryMetric, Next<MemoryMetric> next) {
|
||||
long timeBucket = TimeBucketUtils.INSTANCE.secondToDay(memoryMetric.getTimeBucket());
|
||||
|
||||
MemoryMetric newMemoryMetric = MemoryMetricCopy.copy(memoryMetric);
|
||||
newMemoryMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + memoryMetric.getMetricId());
|
||||
newMemoryMetric.setTimeBucket(timeBucket);
|
||||
next.execute(newMemoryMetric);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,46 +16,47 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker;
|
||||
package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.memory;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
|
||||
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryHourMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class MemoryPoolMetricPersistenceWorker extends PersistenceWorker<MemoryPoolMetric, MemoryPoolMetric> {
|
||||
public class MemoryHourMetricPersistenceWorker extends PersistenceWorker<MemoryMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.MEMORY_POOL_METRIC_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
public MemoryPoolMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
public MemoryHourMetricPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.MEMORY_HOUR_METRIC_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override protected IPersistenceDAO persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IMemoryPoolMetricPersistenceDAO.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, MemoryMetric> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(IMemoryHourMetricPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends AbstractLocalAsyncWorkerProvider<MemoryPoolMetric, MemoryPoolMetric, MemoryPoolMetricPersistenceWorker> {
|
||||
public static class Factory extends PersistenceWorkerProvider<MemoryMetric, MemoryHourMetricPersistenceWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public MemoryPoolMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new MemoryPoolMetricPersistenceWorker(moduleManager);
|
||||
@Override public MemoryHourMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new MemoryHourMetricPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.skywalking.apm.collector.analysis.jvm.provider.worker.memory;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class MemoryHourMetricTransformNode implements NodeProcessor<MemoryMetric, MemoryMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.MEMORY_HOUR_METRIC_TRANSFORM_NODE_ID;
|
||||
}
|
||||
|
||||
@Override public void process(MemoryMetric memoryMetric, Next<MemoryMetric> next) {
|
||||
long timeBucket = TimeBucketUtils.INSTANCE.secondToHour(memoryMetric.getTimeBucket());
|
||||
|
||||
MemoryMetric newMemoryMetric = MemoryMetricCopy.copy(memoryMetric);
|
||||
newMemoryMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + memoryMetric.getMetricId());
|
||||
newMemoryMetric.setTimeBucket(timeBucket);
|
||||
next.execute(newMemoryMetric);
|
||||
}
|
||||
}
|
||||
|
|
@ -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.skywalking.apm.collector.analysis.jvm.provider.worker.memory;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Next;
|
||||
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
|
||||
import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class MemoryMetricBridgeNode implements NodeProcessor<MemoryMetric, MemoryMetric> {
|
||||
|
||||
@Override public int id() {
|
||||
return WorkerIdDefine.MEMORY_METRIC_BRIDGE_NODE_ID;
|
||||
}
|
||||
|
||||
@Override public void process(MemoryMetric metric, Next<MemoryMetric> next) {
|
||||
next.execute(metric);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue