diff --git a/README.md b/README.md index cdb892f3f..0ac610447 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ microservices, cloud native and container-based (Docker, K8s, Mesos) architectur Underlying technology is a distributed tracing system. [![Build Status](https://travis-ci.org/apache/incubator-skywalking.svg?branch=master)](https://travis-ci.org/apache/incubator-skywalking) -[![Coverage Status](https://coveralls.io/repos/github/apache/incubator-skywalking/badge.svg?branch=master&u=1)](https://coveralls.io/github/apache/incubator-skywalking?branch=master) +[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/AsfSkyWalking) [![Join the chat at https://gitter.im/sky-walking/Lobby](https://badges.gitter.im/openskywalking/Lobby.svg)](https://gitter.im/openskywalking/Lobby) [![OpenTracing-1.x Badge](https://img.shields.io/badge/OpenTracing--1.x-enabled-blue.svg)](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 - - # Document -[![EN doc](https://img.shields.io/badge/document-English-blue.svg)](docs/README.md) [![cn doc](https://img.shields.io/badge/document-中文-blue.svg)](docs/README_ZH.md) +[![EN doc](https://img.shields.io/badge/document-English-blue.svg)](docs/README.md) [![cn doc](https://img.shields.io/badge/文档-中文版-blue.svg)](docs/README_ZH.md) +# 5.x Architecture + + +# 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 diff --git a/README_ZH.md b/README_ZH.md index 5e60fb898..6a274fc04 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -7,7 +7,7 @@ Apache SkyWalking | [English](README.md) 其核心是个分布式追踪系统。 [![Build Status](https://travis-ci.org/apache/incubator-skywalking.svg?branch=master)](https://travis-ci.org/apache/incubator-skywalking) -[![Coverage Status](https://coveralls.io/repos/github/apache/incubator-skywalking/badge.svg?branch=master&u=1)](https://coveralls.io/github/apache/incubator-skywalking?branch=master) +[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/AsfSkyWalking) [![Join the chat at https://gitter.im/openskywalking/Lobby](https://badges.gitter.im/openskywalking/Lobby.svg)](https://gitter.im/openskywalking/Lobby) [![OpenTracing-1.x Badge](https://img.shields.io/badge/OpenTracing--1.x-enabled-blue.svg)](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 - - # Document -[![EN doc](https://img.shields.io/badge/document-English-blue.svg)](docs/README.md) [![cn doc](https://img.shields.io/badge/document-中文-blue.svg)](docs/README_ZH.md) +[![EN doc](https://img.shields.io/badge/document-English-blue.svg)](docs/README.md) [![cn doc](https://img.shields.io/badge/文档-中文版-blue.svg)](docs/README_ZH.md) + +# 5.x Architecture + + +# 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 diff --git a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/pom.xml b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/pom.xml index 2d9a3f83d..0c5c6a316 100644 --- a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/pom.xml +++ b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/pom.xml @@ -60,6 +60,11 @@ jvm-define ${project.version} + + org.apache.skywalking + metric-define + ${project.version} + org.apache.skywalking register-define diff --git a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/AgentModuleGRPCProvider.java b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/AgentModuleGRPCProvider.java index e76c9d610..f3dcdeb29 100644 --- a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/AgentModuleGRPCProvider.java +++ b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/AgentModuleGRPCProvider.java @@ -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())); } } diff --git a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/ApplicationRegisterServiceHandler.java b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/ApplicationRegisterServiceHandler.java index b8072fbd7..2a063b297 100644 --- a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/ApplicationRegisterServiceHandler.java +++ b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/ApplicationRegisterServiceHandler.java @@ -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 responseObserver) { + @Override + public void applicationCodeRegister(Application request, StreamObserver 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(); diff --git a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/InstanceDiscoveryServiceHandler.java b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/InstanceDiscoveryServiceHandler.java index 38f174ef3..682b6c410 100644 --- a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/InstanceDiscoveryServiceHandler.java +++ b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/InstanceDiscoveryServiceHandler.java @@ -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 responseObserver) { + public void registerInstance(ApplicationInstance request, + StreamObserver 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 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 responseObserver) { + int instanceId = request.getApplicationInstanceId(); + long heartBeatTime = request.getHeartbeatTime(); + this.instanceHeartBeatService.heartBeat(instanceId, heartBeatTime); } private String buildOsInfo(OSInfo osinfo) { diff --git a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/JVMMetricsServiceHandler.java b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/JVMMetricsServiceHandler.java index b192a6c0b..1ff4a7f94 100644 --- a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/JVMMetricsServiceHandler.java +++ b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/JVMMetricsServiceHandler.java @@ -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 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 memories) { memories.forEach(memory -> memoryMetricService.send(instanceId, timeBucket, memory.getIsHeap(), memory.getInit(), memory.getMax(), memory.getUsed(), memory.getCommitted())); } diff --git a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/NetworkAddressRegisterServiceHandler.java b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/NetworkAddressRegisterServiceHandler.java new file mode 100644 index 000000000..a00de671c --- /dev/null +++ b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/NetworkAddressRegisterServiceHandler.java @@ -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 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(); + } +} diff --git a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/ApplicationRegisterServiceHandlerTestCase.java b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/ApplicationRegisterServiceHandlerTestCase.java similarity index 82% rename from apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/ApplicationRegisterServiceHandlerTestCase.java rename to apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/ApplicationRegisterServiceHandlerTestCase.java index ca2814508..50d9e82dc 100644 --- a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/ApplicationRegisterServiceHandlerTestCase.java +++ b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/ApplicationRegisterServiceHandlerTestCase.java @@ -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()); } } diff --git a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/InstHeartBeatServiceTestCase.java b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/InstHeartBeatServiceTestCase.java new file mode 100644 index 000000000..56c74c568 --- /dev/null +++ b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/InstHeartBeatServiceTestCase.java @@ -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()); + } +} diff --git a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/JVMMetricServiceHandlerTestCase.java b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/JVMMetricServiceHandlerTestCase.java new file mode 100644 index 000000000..7862fcaaf --- /dev/null +++ b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/JVMMetricServiceHandlerTestCase.java @@ -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()); + } +} diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/AgentModuleJettyProvider.java b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/AgentModuleJettyProvider.java index 8ca30e585..0deed7837 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/AgentModuleJettyProvider.java +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/AgentModuleJettyProvider.java @@ -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())); } } diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/ApplicationRegisterServletHandler.java b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/ApplicationRegisterServletHandler.java index 77296190e..7cb6fbd2f 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/ApplicationRegisterServletHandler.java +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/ApplicationRegisterServletHandler.java @@ -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); diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/InstanceDiscoveryServletHandler.java b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/InstanceDiscoveryServletHandler.java index feac02102..0fd473b65 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/InstanceDiscoveryServletHandler.java +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/InstanceDiscoveryServletHandler.java @@ -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) { diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/NetworkAddressRegisterServletHandler.java b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/NetworkAddressRegisterServletHandler.java new file mode 100644 index 000000000..c5768e767 --- /dev/null +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/NetworkAddressRegisterServletHandler.java @@ -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; + } +} diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-consumer.json b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-consumer.json index 453dce3eb..4c80222bd 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-consumer.json +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-consumer.json @@ -14,7 +14,7 @@ 24040000 ], "ai": -1, - "ii": 1, + "ii": 2, "rs": [], "ss": [ { diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json index a566c2850..e446706f2 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json @@ -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 diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/define/graph/AlarmGraphIdDefine.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/define/graph/AlarmGraphIdDefine.java new file mode 100644 index 000000000..91cafc79a --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/define/graph/AlarmGraphIdDefine.java @@ -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; +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/define/graph/AlarmWorkerIdDefine.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/define/graph/AlarmWorkerIdDefine.java new file mode 100644 index 000000000..0241473f6 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/define/graph/AlarmWorkerIdDefine.java @@ -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; +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/pom.xml b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/pom.xml index 6ba73c217..5afb68de9 100644 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/pom.xml +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/pom.xml @@ -36,6 +36,16 @@ alarm-define ${project.version} + + org.apache.skywalking + metric-define + ${project.version} + + + org.apache.skywalking + collector-configuration-define + ${project.version} + org.apache.skywalking collector-storage-define diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/AlertingModuleProvider.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/AlertingModuleProvider.java deleted file mode 100644 index 802f5f55a..000000000 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/AlertingModuleProvider.java +++ /dev/null @@ -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 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]; - } -} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/AnalysisAlarmModuleProvider.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/AnalysisAlarmModuleProvider.java new file mode 100644 index 000000000..9c560ff4a --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/AnalysisAlarmModuleProvider.java @@ -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 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}; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlarmAssertWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlarmAssertWorker.java new file mode 100644 index 000000000..c00db5644 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlarmAssertWorker.java @@ -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 extends AbstractLocalAsyncWorker { + + 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()); + } + } + } +} \ No newline at end of file diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlertingListAggregationWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlarmAssertWorkerProvider.java similarity index 66% rename from apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlertingListAggregationWorker.java rename to apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlarmAssertWorkerProvider.java index 6e0f4e602..d95418146 100644 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlertingListAggregationWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlarmAssertWorkerProvider.java @@ -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 { +public abstract class AlarmAssertWorkerProvider> extends AbstractLocalAsyncWorkerProvider { - public AlertingListAggregationWorker(ModuleManager moduleManager) { + public AlarmAssertWorkerProvider(ModuleManager moduleManager) { super(moduleManager); } - - @Override public int id() { - return 0; - } - - @Override protected void onWork(AlertingList message) throws WorkerException { - - } } diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmAssertWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmAssertWorker.java new file mode 100644 index 000000000..0a2e6d352 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmAssertWorker.java @@ -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 { + + 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 { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMetricAlarmAssertWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmGraph.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmGraph.java new file mode 100644 index 000000000..0733dbab0 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmGraph.java @@ -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 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 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() { + @Override public int id() { + return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID; + } + + @Override public void process(ApplicationMetric instanceMetric, + Next next) { + graph.start(instanceMetric); + } + }); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListPersistenceWorker.java new file mode 100644 index 000000000..88963870f --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmListPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMetricAlarmListPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmPersistenceWorker.java new file mode 100644 index 000000000..43be3e21f --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMetricAlarmPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmRemoteWorker.java new file mode 100644 index 000000000..8bf49284b --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmRemoteWorker.java @@ -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 { + + 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 { + + public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { + super(moduleManager, remoteSenderService, graphId); + } + + @Override public ApplicationMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMetricAlarmRemoteWorker(moduleManager); + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmToListNodeProcessor.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmToListNodeProcessor.java new file mode 100644 index 000000000..fbebedf06 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmToListNodeProcessor.java @@ -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 { + + @Override public int id() { + return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID; + } + + @Override public void process(ApplicationAlarm applicationAlarm, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmAssertWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmAssertWorker.java new file mode 100644 index 000000000..a68912e1f --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmAssertWorker.java @@ -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 { + + 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 { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationReferenceMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceMetricAlarmAssertWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmGraph.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmGraph.java new file mode 100644 index 000000000..121aed10a --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmGraph.java @@ -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 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 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() { + @Override public int id() { + return AlarmWorkerIdDefine.APPLICATION_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID; + } + + @Override public void process(ApplicationReferenceMetric applicationReferenceMetric, + Next next) { + graph.start(applicationReferenceMetric); + } + }); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmListPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmListPersistenceWorker.java new file mode 100644 index 000000000..fc7f38761 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmListPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceAlarmListPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override + public ApplicationReferenceMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceMetricAlarmListPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmPersistenceWorker.java new file mode 100644 index 000000000..c8f760111 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceAlarmPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationReferenceMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceMetricAlarmPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmRemoteWorker.java new file mode 100644 index 000000000..f52cfc74a --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmRemoteWorker.java @@ -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 { + + 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 { + + public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { + super(moduleManager, remoteSenderService, graphId); + } + + @Override public ApplicationReferenceMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceMetricAlarmRemoteWorker(moduleManager); + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmToListNodeProcessor.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmToListNodeProcessor.java new file mode 100644 index 000000000..de4874adb --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmToListNodeProcessor.java @@ -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 { + + @Override public int id() { + return AlarmWorkerIdDefine.APPLICATION_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID; + } + + @Override + public void process(ApplicationReferenceAlarm applicationReferenceAlarm, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmAssertWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmAssertWorker.java new file mode 100644 index 000000000..2b02dd7df --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmAssertWorker.java @@ -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 { + + 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 { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMetricAlarmAssertWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmGraph.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmGraph.java new file mode 100644 index 000000000..5954314bb --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmGraph.java @@ -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 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 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() { + @Override public int id() { + return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID; + } + + @Override public void process(InstanceMetric instanceMetric, + Next next) { + graph.start(instanceMetric); + } + }); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmListPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmListPersistenceWorker.java new file mode 100644 index 000000000..120d943df --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmListPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceAlarmListPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMetricAlarmListPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmPersistenceWorker.java new file mode 100644 index 000000000..6fce174ae --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceAlarmPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMetricAlarmPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmRemoteWorker.java new file mode 100644 index 000000000..0edad65d6 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmRemoteWorker.java @@ -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 { + + 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 { + + public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { + super(moduleManager, remoteSenderService, graphId); + } + + @Override public InstanceMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMetricAlarmRemoteWorker(moduleManager); + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmToListNodeProcessor.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmToListNodeProcessor.java new file mode 100644 index 000000000..463a64e7d --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmToListNodeProcessor.java @@ -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 { + + @Override public int id() { + return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID; + } + + @Override public void process(InstanceAlarm instanceAlarm, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmAssertWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmAssertWorker.java new file mode 100644 index 000000000..f8e2bf5af --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmAssertWorker.java @@ -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 { + + 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 { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceReferenceMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) { + return new InstanceReferenceMetricAlarmAssertWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmGraph.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmGraph.java new file mode 100644 index 000000000..7ef12e1a6 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmGraph.java @@ -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 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 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() { + @Override public int id() { + return AlarmWorkerIdDefine.INSTANCE_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID; + } + + @Override public void process(InstanceReferenceMetric instanceReferenceMetric, + Next next) { + graph.start(instanceReferenceMetric); + } + }); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmListPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmListPersistenceWorker.java new file mode 100644 index 000000000..d0d9ffd45 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmListPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceReferenceAlarmListPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceReferenceMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceReferenceMetricAlarmListPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmPersistenceWorker.java new file mode 100644 index 000000000..97f271d2b --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceReferenceAlarmPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceReferenceMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceReferenceMetricAlarmPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmRemoteWorker.java new file mode 100644 index 000000000..24840ec79 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmRemoteWorker.java @@ -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 { + + 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 { + + public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { + super(moduleManager, remoteSenderService, graphId); + } + + @Override public InstanceReferenceMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) { + return new InstanceReferenceMetricAlarmRemoteWorker(moduleManager); + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmToListNodeProcessor.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmToListNodeProcessor.java new file mode 100644 index 000000000..553ddebe2 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceReferenceMetricAlarmToListNodeProcessor.java @@ -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 { + + @Override public int id() { + return AlarmWorkerIdDefine.INSTANCE_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID; + } + + @Override + public void process(InstanceReferenceAlarm instanceReferenceAlarm, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmAssertWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmAssertWorker.java new file mode 100644 index 000000000..e7a8242cc --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmAssertWorker.java @@ -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 { + + 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 { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ServiceMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) { + return new ServiceMetricAlarmAssertWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmGraph.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmGraph.java new file mode 100644 index 000000000..18d87ad6d --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmGraph.java @@ -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 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 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() { + @Override public int id() { + return AlarmWorkerIdDefine.SERVICE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID; + } + + @Override public void process(ServiceMetric serviceMetric, + Next next) { + graph.start(serviceMetric); + } + }); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmListPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmListPersistenceWorker.java new file mode 100644 index 000000000..e72568e6d --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmListPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IServiceAlarmListPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ServiceMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ServiceMetricAlarmListPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlertingListPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmPersistenceWorker.java similarity index 62% rename from apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlertingListPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmPersistenceWorker.java index 0546a497d..50c75841a 100644 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlertingListPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmPersistenceWorker.java @@ -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 { +public class ServiceMetricAlarmPersistenceWorker extends PersistenceWorker { - 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IServiceAlarmPersistenceDAO.class); } - public static class Factory extends AbstractLocalAsyncWorkerProvider { - + public static class Factory extends PersistenceWorkerProvider { 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 diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntryRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmRemoteWorker.java similarity index 67% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntryRemoteWorker.java rename to apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmRemoteWorker.java index e16f4a7bd..538dd7553 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntryRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmRemoteWorker.java @@ -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 { +public class ServiceMetricAlarmRemoteWorker extends AbstractRemoteWorker { - 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 { + @Override protected void onWork(ServiceAlarm message) throws WorkerException { + onNext(message); + } + + public static class Factory extends AbstractRemoteWorkerProvider { 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); } } } diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmToListNodeProcessor.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmToListNodeProcessor.java new file mode 100644 index 000000000..ab0d6a802 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceMetricAlarmToListNodeProcessor.java @@ -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 { + + @Override public int id() { + return AlarmWorkerIdDefine.SERVICE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID; + } + + @Override public void process(ServiceAlarm serviceAlarm, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmAssertWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmAssertWorker.java new file mode 100644 index 000000000..a644c01a3 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmAssertWorker.java @@ -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 { + + 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 { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ServiceReferenceMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) { + return new ServiceReferenceMetricAlarmAssertWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmGraph.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmGraph.java new file mode 100644 index 000000000..eda88d430 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmGraph.java @@ -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 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 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() { + @Override public int id() { + return AlarmWorkerIdDefine.SERVICE_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID; + } + + @Override public void process(ServiceReferenceMetric serviceReferenceMetric, + Next next) { + graph.start(serviceReferenceMetric); + } + }); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmListPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmListPersistenceWorker.java new file mode 100644 index 000000000..968231321 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmListPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IServiceReferenceAlarmListPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ServiceReferenceMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ServiceReferenceMetricAlarmListPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmPersistenceWorker.java new file mode 100644 index 000000000..ddfdaaa56 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IServiceReferenceAlarmPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ServiceReferenceMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ServiceReferenceMetricAlarmPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmRemoteWorker.java new file mode 100644 index 000000000..7914d8b12 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmRemoteWorker.java @@ -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 { + + 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 { + + public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { + super(moduleManager, remoteSenderService, graphId); + } + + @Override public ServiceReferenceMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) { + return new ServiceReferenceMetricAlarmRemoteWorker(moduleManager); + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmToListNodeProcessor.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmToListNodeProcessor.java new file mode 100644 index 000000000..2d1fb048a --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/service/ServiceReferenceMetricAlarmToListNodeProcessor.java @@ -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 { + + @Override public int id() { + return AlarmWorkerIdDefine.SERVICE_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID; + } + + @Override public void process(ServiceReferenceAlarm serviceReferenceAlarm, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/resources/META-INF/services/org.apache.skywalking.apm.collector.core.module.ModuleProvider b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/resources/META-INF/services/org.apache.skywalking.apm.collector.core.module.ModuleProvider index 2adafe72c..ec63fccad 100644 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/resources/META-INF/services/org.apache.skywalking.apm.collector.core.module.ModuleProvider +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/resources/META-INF/services/org.apache.skywalking.apm.collector.core.module.ModuleProvider @@ -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 \ No newline at end of file diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/AnalysisJVMModule.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/AnalysisJVMModule.java index b91b96f88..f2cf358ed 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/AnalysisJVMModule.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/AnalysisJVMModule.java @@ -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 }; } diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/graph/GraphIdDefine.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/graph/GraphIdDefine.java index ba80f21e2..28f469594 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/graph/GraphIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/graph/GraphIdDefine.java @@ -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; } diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/graph/WorkerIdDefine.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/graph/WorkerIdDefine.java index 1606225cb..e7270c8b0 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/graph/WorkerIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/graph/WorkerIdDefine.java @@ -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; } diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/service/IMemoryMetricService.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/service/IMemoryMetricService.java index e793ecc04..522d45ec3 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/service/IMemoryMetricService.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/service/IMemoryMetricService.java @@ -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); } diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/service/IMemoryPoolMetricService.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/service/IMemoryPoolMetricService.java index 10be43820..81215ddec 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/service/IMemoryPoolMetricService.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/service/IMemoryPoolMetricService.java @@ -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); } diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/AnalysisJVMModuleProvider.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/AnalysisJVMModuleProvider.java index 2b5904e56..a8d50e2e6 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/AnalysisJVMModuleProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/AnalysisJVMModuleProvider.java @@ -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(); diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/CpuMetricService.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/CpuMetricService.java index 1d93d1415..49b68e926 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/CpuMetricService.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/CpuMetricService.java @@ -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()); diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/GCMetricService.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/GCMetricService.java index 325300804..0729bca9b 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/GCMetricService.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/GCMetricService.java @@ -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()); diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/MemoryMetricService.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/MemoryMetricService.java index 4195db4a0..c9ed19bed 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/MemoryMetricService.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/MemoryMetricService.java @@ -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()); diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/MemoryPoolMetricService.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/MemoryPoolMetricService.java index bec38080b..e99a02759 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/MemoryPoolMetricService.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/MemoryPoolMetricService.java @@ -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()); diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricPersistenceWorker.java new file mode 100644 index 000000000..7b42a800e --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(ICpuDayMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public CpuDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new CpuDayMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricTransformNode.java new file mode 100644 index 000000000..444e9c758 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricTransformNode.java @@ -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 { + + @Override public int id() { + return WorkerIdDefine.CPU_DAY_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(CpuMetric cpuMetric, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricPersistenceWorker.java new file mode 100644 index 000000000..be163fa89 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(ICpuHourMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public CpuHourMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new CpuHourMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricTransformNode.java new file mode 100644 index 000000000..cbc98da8a --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricTransformNode.java @@ -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 { + + @Override public int id() { + return WorkerIdDefine.CPU_HOUR_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(CpuMetric cpuMetric, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricBridgeNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricBridgeNode.java new file mode 100644 index 000000000..745b73b6f --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricBridgeNode.java @@ -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 { + + @Override public int id() { + return WorkerIdDefine.CPU_METRIC_BRIDGE_NODE_ID; + } + + @Override public void process(CpuMetric metric, Next next) { + next.execute(metric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricCopy.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricCopy.java new file mode 100644 index 000000000..067b07344 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricCopy.java @@ -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; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/CpuMetricPersistenceGraph.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricPersistenceGraph.java similarity index 61% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/CpuMetricPersistenceGraph.java rename to apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricPersistenceGraph.java index 9384c85c7..0196ea3b3 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/CpuMetricPersistenceGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricPersistenceGraph.java @@ -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 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)); } } diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricPersistenceWorker.java new file mode 100644 index 000000000..30b6685c2 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(ICpuMinuteMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public CpuMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new CpuMinuteMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricTransformNode.java new file mode 100644 index 000000000..e2d9f22f1 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricTransformNode.java @@ -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 { + + @Override public int id() { + return WorkerIdDefine.CPU_MINUTE_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(CpuMetric cpuMetric, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricPersistenceWorker.java new file mode 100644 index 000000000..8bf3cfe69 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(ICpuMonthMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public CpuMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new CpuMonthMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricTransformNode.java new file mode 100644 index 000000000..6c59f4756 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricTransformNode.java @@ -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 { + + @Override public int id() { + return WorkerIdDefine.CPU_MONTH_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(CpuMetric cpuMetric, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/CpuMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuSecondMetricPersistenceWorker.java similarity index 69% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/CpuMetricPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuSecondMetricPersistenceWorker.java index 1ec5ae9f8..ea2dfeba4 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/CpuMetricPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuSecondMetricPersistenceWorker.java @@ -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 { +public class CpuSecondMetricPersistenceWorker extends PersistenceWorker { - 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(ICpuSecondMetricPersistenceDAO.class); } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { 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 diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCDayMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCDayMetricPersistenceWorker.java new file mode 100644 index 000000000..433a6146c --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCDayMetricPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IGCDayMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public GCDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new GCDayMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCDayMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCDayMetricTransformNode.java new file mode 100644 index 000000000..edc349e1c --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCDayMetricTransformNode.java @@ -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 { + + @Override public int id() { + return WorkerIdDefine.GC_DAY_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(GCMetric gcMetric, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/MemoryMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCHourMetricPersistenceWorker.java similarity index 68% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/MemoryMetricPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCHourMetricPersistenceWorker.java index 3f2cac647..08b9addcb 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/MemoryMetricPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCHourMetricPersistenceWorker.java @@ -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 { +public class GCHourMetricPersistenceWorker extends PersistenceWorker { - 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IGCHourMetricPersistenceDAO.class); } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { 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 diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCHourMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCHourMetricTransformNode.java new file mode 100644 index 000000000..33d870a0f --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCHourMetricTransformNode.java @@ -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 { + + @Override public int id() { + return WorkerIdDefine.GC_HOUR_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(GCMetric gcMetric, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMetricBridgeNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMetricBridgeNode.java new file mode 100644 index 000000000..97e23e772 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMetricBridgeNode.java @@ -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 { + + @Override public int id() { + return WorkerIdDefine.GC_METRIC_BRIDGE_NODE_ID; + } + + @Override public void process(GCMetric metric, Next next) { + next.execute(metric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMetricCopy.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMetricCopy.java new file mode 100644 index 000000000..b914a294b --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMetricCopy.java @@ -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; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/GCMetricPersistenceGraph.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMetricPersistenceGraph.java similarity index 61% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/GCMetricPersistenceGraph.java rename to apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMetricPersistenceGraph.java index 24329f04d..9034ccbb0 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/GCMetricPersistenceGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMetricPersistenceGraph.java @@ -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 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)); } } diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMinuteMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMinuteMetricPersistenceWorker.java new file mode 100644 index 000000000..f65752c95 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMinuteMetricPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IGCMinuteMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public GCMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new GCMinuteMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMinuteMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMinuteMetricTransformNode.java new file mode 100644 index 000000000..8f04d3150 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMinuteMetricTransformNode.java @@ -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 { + + @Override public int id() { + return WorkerIdDefine.GC_MINUTE_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(GCMetric gcMetric, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMonthMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMonthMetricPersistenceWorker.java new file mode 100644 index 000000000..1d5268090 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMonthMetricPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IGCMonthMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public GCMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new GCMonthMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMonthMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMonthMetricTransformNode.java new file mode 100644 index 000000000..05fd93927 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCMonthMetricTransformNode.java @@ -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 { + + @Override public int id() { + return WorkerIdDefine.GC_MONTH_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(GCMetric gcMetric, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/GCMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCSecondMetricPersistenceWorker.java similarity index 69% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/GCMetricPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCSecondMetricPersistenceWorker.java index 2e08e6677..df47a8db1 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/GCMetricPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/gc/GCSecondMetricPersistenceWorker.java @@ -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 { +public class GCSecondMetricPersistenceWorker extends PersistenceWorker { - 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IGCSecondMetricPersistenceDAO.class); } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { 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 diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryDayMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryDayMetricPersistenceWorker.java new file mode 100644 index 000000000..9edaad091 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryDayMetricPersistenceWorker.java @@ -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 { + + 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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IMemoryDayMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public MemoryDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new MemoryDayMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryDayMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryDayMetricTransformNode.java new file mode 100644 index 000000000..99568a410 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryDayMetricTransformNode.java @@ -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 { + + @Override public int id() { + return WorkerIdDefine.MEMORY_DAY_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(MemoryMetric memoryMetric, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/MemoryPoolMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryHourMetricPersistenceWorker.java similarity index 70% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/MemoryPoolMetricPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryHourMetricPersistenceWorker.java index 83e5766c5..af0a90513 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/MemoryPoolMetricPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryHourMetricPersistenceWorker.java @@ -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 { +public class MemoryHourMetricPersistenceWorker extends PersistenceWorker { - @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 persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IMemoryHourMetricPersistenceDAO.class); } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { 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 diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryHourMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryHourMetricTransformNode.java new file mode 100644 index 000000000..dafed4b60 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryHourMetricTransformNode.java @@ -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 { + + @Override public int id() { + return WorkerIdDefine.MEMORY_HOUR_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(MemoryMetric memoryMetric, Next 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); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMetricBridgeNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMetricBridgeNode.java new file mode 100644 index 000000000..2137690f4 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMetricBridgeNode.java @@ -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 { + + @Override public int id() { + return WorkerIdDefine.MEMORY_METRIC_BRIDGE_NODE_ID; + } + + @Override public void process(MemoryMetric metric, Next next) { + next.execute(metric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMetricCopy.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMetricCopy.java new file mode 100644 index 000000000..55b9b134e --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMetricCopy.java @@ -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.storage.table.jvm.MemoryMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryMetricCopy { + + public static MemoryMetric copy(MemoryMetric memoryMetric) { + MemoryMetric newMemoryMetric = new MemoryMetric(); + newMemoryMetric.setId(memoryMetric.getId()); + newMemoryMetric.setMetricId(memoryMetric.getMetricId()); + + newMemoryMetric.setInstanceId(memoryMetric.getInstanceId()); + newMemoryMetric.setIsHeap(memoryMetric.getIsHeap()); + + newMemoryMetric.setInit(memoryMetric.getInit()); + newMemoryMetric.setMax(memoryMetric.getMax()); + newMemoryMetric.setUsed(memoryMetric.getUsed()); + newMemoryMetric.setCommitted(memoryMetric.getCommitted()); + newMemoryMetric.setTimes(memoryMetric.getTimes()); + + newMemoryMetric.setTimeBucket(memoryMetric.getTimeBucket()); + return newMemoryMetric; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/MemoryMetricPersistenceGraph.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMetricPersistenceGraph.java similarity index 60% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/MemoryMetricPersistenceGraph.java rename to apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMetricPersistenceGraph.java index f773581fa..b3e0a09ff 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/MemoryMetricPersistenceGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMetricPersistenceGraph.java @@ -16,11 +16,12 @@ * */ -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.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.MemoryMetric; @@ -38,7 +39,21 @@ public class MemoryMetricPersistenceGraph { } public void create() { - GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.MEMORY_METRIC_PERSISTENCE_GRAPH_ID, MemoryMetric.class) - .addNode(new MemoryMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + Node bridgeNode = GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.MEMORY_METRIC_PERSISTENCE_GRAPH_ID, MemoryMetric.class) + .addNode(new MemoryMetricBridgeNode()); + + bridgeNode.addNext(new MemorySecondMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + bridgeNode.addNext(new MemoryMinuteMetricTransformNode()) + .addNext(new MemoryMinuteMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + bridgeNode.addNext(new MemoryHourMetricTransformNode()) + .addNext(new MemoryHourMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + bridgeNode.addNext(new MemoryDayMetricTransformNode()) + .addNext(new MemoryDayMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + bridgeNode.addNext(new MemoryMonthMetricTransformNode()) + .addNext(new MemoryMonthMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); } } diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMinuteMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMinuteMetricPersistenceWorker.java new file mode 100644 index 000000000..6a64384aa --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMinuteMetricPersistenceWorker.java @@ -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.IMemoryMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryMinuteMetricPersistenceWorker extends PersistenceWorker { + + public MemoryMinuteMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return WorkerIdDefine.MEMORY_MINUTE_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IMemoryMinuteMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public MemoryMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new MemoryMinuteMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMinuteMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMinuteMetricTransformNode.java new file mode 100644 index 000000000..2e5de1be5 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMinuteMetricTransformNode.java @@ -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 MemoryMinuteMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return WorkerIdDefine.MEMORY_MINUTE_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(MemoryMetric memoryMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.secondToMinute(memoryMetric.getTimeBucket()); + + MemoryMetric newMemoryMetric = MemoryMetricCopy.copy(memoryMetric); + newMemoryMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + memoryMetric.getMetricId()); + newMemoryMetric.setTimeBucket(timeBucket); + next.execute(newMemoryMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMonthMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMonthMetricPersistenceWorker.java new file mode 100644 index 000000000..9e22cef9c --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMonthMetricPersistenceWorker.java @@ -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.IMemoryMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryMonthMetricPersistenceWorker extends PersistenceWorker { + + public MemoryMonthMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return WorkerIdDefine.MEMORY_MONTH_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IMemoryMonthMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public MemoryMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new MemoryMonthMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMonthMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMonthMetricTransformNode.java new file mode 100644 index 000000000..e15d17559 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemoryMonthMetricTransformNode.java @@ -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 MemoryMonthMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return WorkerIdDefine.MEMORY_MONTH_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(MemoryMetric memoryMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.secondToMonth(memoryMetric.getTimeBucket()); + + MemoryMetric newMemoryMetric = MemoryMetricCopy.copy(memoryMetric); + newMemoryMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + memoryMetric.getMetricId()); + newMemoryMetric.setTimeBucket(timeBucket); + next.execute(newMemoryMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemorySecondMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemorySecondMetricPersistenceWorker.java new file mode 100644 index 000000000..d1105e5b3 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memory/MemorySecondMetricPersistenceWorker.java @@ -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.IMemorySecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; + +/** + * @author peng-yongsheng + */ +public class MemorySecondMetricPersistenceWorker extends PersistenceWorker { + + public MemorySecondMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return WorkerIdDefine.MEMORY_SECOND_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return false; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IMemorySecondMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public MemorySecondMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new MemorySecondMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolDayMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolDayMetricPersistenceWorker.java new file mode 100644 index 000000000..7336c0087 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolDayMetricPersistenceWorker.java @@ -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.memorypool; + +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.mpoolmp.IMemoryPoolDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolDayMetricPersistenceWorker extends PersistenceWorker { + + @Override public int id() { + return WorkerIdDefine.MEMORY_POOL_DAY_METRIC_PERSISTENCE_WORKER_ID; + } + + public MemoryPoolDayMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IMemoryPoolDayMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public MemoryPoolDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new MemoryPoolDayMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolDayMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolDayMetricTransformNode.java new file mode 100644 index 000000000..41fa06d31 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolDayMetricTransformNode.java @@ -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.memorypool; + +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.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolDayMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return WorkerIdDefine.MEMORY_POOL_DAY_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(MemoryPoolMetric memoryPoolMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.secondToDay(memoryPoolMetric.getTimeBucket()); + + MemoryPoolMetric newMemoryPoolMetric = MemoryPoolMetricCopy.copy(memoryPoolMetric); + newMemoryPoolMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + memoryPoolMetric.getMetricId()); + newMemoryPoolMetric.setTimeBucket(timeBucket); + next.execute(newMemoryPoolMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolHourMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolHourMetricPersistenceWorker.java new file mode 100644 index 000000000..eed97c867 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolHourMetricPersistenceWorker.java @@ -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.memorypool; + +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.mpoolmp.IMemoryPoolHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolHourMetricPersistenceWorker extends PersistenceWorker { + + @Override public int id() { + return WorkerIdDefine.MEMORY_POOL_HOUR_METRIC_PERSISTENCE_WORKER_ID; + } + + public MemoryPoolHourMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IMemoryPoolHourMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public MemoryPoolHourMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new MemoryPoolHourMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolHourMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolHourMetricTransformNode.java new file mode 100644 index 000000000..d073d1888 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolHourMetricTransformNode.java @@ -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.memorypool; + +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.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolHourMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return WorkerIdDefine.MEMORY_POOL_HOUR_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(MemoryPoolMetric memoryPoolMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.secondToHour(memoryPoolMetric.getTimeBucket()); + + MemoryPoolMetric newMemoryPoolMetric = MemoryPoolMetricCopy.copy(memoryPoolMetric); + newMemoryPoolMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + memoryPoolMetric.getMetricId()); + newMemoryPoolMetric.setTimeBucket(timeBucket); + next.execute(newMemoryPoolMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMetricBridgeNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMetricBridgeNode.java new file mode 100644 index 000000000..3220ea876 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMetricBridgeNode.java @@ -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.memorypool; + +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.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolMetricBridgeNode implements NodeProcessor { + + @Override public int id() { + return WorkerIdDefine.MEMORY_POOL_METRIC_BRIDGE_NODE_ID; + } + + @Override public void process(MemoryPoolMetric metric, Next next) { + next.execute(metric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMetricCopy.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMetricCopy.java new file mode 100644 index 000000000..4b805f52f --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMetricCopy.java @@ -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.memorypool; + +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolMetricCopy { + + public static MemoryPoolMetric copy(MemoryPoolMetric memoryPoolMetric) { + MemoryPoolMetric newMemoryPoolMetric = new MemoryPoolMetric(); + newMemoryPoolMetric.setId(memoryPoolMetric.getId()); + newMemoryPoolMetric.setMetricId(memoryPoolMetric.getMetricId()); + + newMemoryPoolMetric.setInstanceId(memoryPoolMetric.getInstanceId()); + + newMemoryPoolMetric.setInit(memoryPoolMetric.getInit()); + newMemoryPoolMetric.setMax(memoryPoolMetric.getMax()); + newMemoryPoolMetric.setUsed(memoryPoolMetric.getUsed()); + newMemoryPoolMetric.setCommitted(memoryPoolMetric.getCommitted()); + newMemoryPoolMetric.setPoolType(memoryPoolMetric.getPoolType()); + newMemoryPoolMetric.setTimes(memoryPoolMetric.getTimes()); + + newMemoryPoolMetric.setTimeBucket(memoryPoolMetric.getTimeBucket()); + return newMemoryPoolMetric; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/MemoryPoolMetricPersistenceGraph.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMetricPersistenceGraph.java similarity index 59% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/MemoryPoolMetricPersistenceGraph.java rename to apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMetricPersistenceGraph.java index 5a45b362f..3d79c9637 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/MemoryPoolMetricPersistenceGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMetricPersistenceGraph.java @@ -16,11 +16,12 @@ * */ -package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker; +package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.memorypool; 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.MemoryPoolMetric; @@ -38,7 +39,21 @@ public class MemoryPoolMetricPersistenceGraph { } public void create() { - GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.MEMORY_POOL_METRIC_PERSISTENCE_GRAPH_ID, MemoryPoolMetric.class) - .addNode(new MemoryPoolMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + Node bridgeNode = GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.MEMORY_POOL_METRIC_PERSISTENCE_GRAPH_ID, MemoryPoolMetric.class) + .addNode(new MemoryPoolMetricBridgeNode()); + + bridgeNode.addNext(new MemoryPoolSecondMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + bridgeNode.addNext(new MemoryPoolMinuteMetricTransformNode()) + .addNext(new MemoryPoolMinuteMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + bridgeNode.addNext(new MemoryPoolHourMetricTransformNode()) + .addNext(new MemoryPoolHourMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + bridgeNode.addNext(new MemoryPoolDayMetricTransformNode()) + .addNext(new MemoryPoolDayMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + bridgeNode.addNext(new MemoryPoolMonthMetricTransformNode()) + .addNext(new MemoryPoolMonthMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); } } diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMinuteMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMinuteMetricPersistenceWorker.java new file mode 100644 index 000000000..81358e165 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMinuteMetricPersistenceWorker.java @@ -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.memorypool; + +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.mpoolmp.IMemoryPoolMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolMinuteMetricPersistenceWorker extends PersistenceWorker { + + @Override public int id() { + return WorkerIdDefine.MEMORY_POOL_MINUTE_METRIC_PERSISTENCE_WORKER_ID; + } + + public MemoryPoolMinuteMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IMemoryPoolMinuteMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public MemoryPoolMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new MemoryPoolMinuteMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMinuteMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMinuteMetricTransformNode.java new file mode 100644 index 000000000..9a94c9853 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMinuteMetricTransformNode.java @@ -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.memorypool; + +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.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolMinuteMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return WorkerIdDefine.MEMORY_POOL_MINUTE_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(MemoryPoolMetric memoryPoolMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.secondToMinute(memoryPoolMetric.getTimeBucket()); + + MemoryPoolMetric newMemoryPoolMetric = MemoryPoolMetricCopy.copy(memoryPoolMetric); + newMemoryPoolMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + memoryPoolMetric.getMetricId()); + newMemoryPoolMetric.setTimeBucket(timeBucket); + next.execute(newMemoryPoolMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMonthMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMonthMetricPersistenceWorker.java new file mode 100644 index 000000000..7bcc3fec9 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMonthMetricPersistenceWorker.java @@ -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.memorypool; + +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.mpoolmp.IMemoryPoolMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolMonthMetricPersistenceWorker extends PersistenceWorker { + + @Override public int id() { + return WorkerIdDefine.MEMORY_POOL_MONTH_METRIC_PERSISTENCE_WORKER_ID; + } + + public MemoryPoolMonthMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IMemoryPoolMonthMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public MemoryPoolMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new MemoryPoolMonthMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMonthMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMonthMetricTransformNode.java new file mode 100644 index 000000000..dec13a7d6 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolMonthMetricTransformNode.java @@ -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.memorypool; + +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.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolMonthMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return WorkerIdDefine.MEMORY_POOL_MONTH_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(MemoryPoolMetric memoryPoolMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.secondToMonth(memoryPoolMetric.getTimeBucket()); + + MemoryPoolMetric newMemoryPoolMetric = MemoryPoolMetricCopy.copy(memoryPoolMetric); + newMemoryPoolMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + memoryPoolMetric.getMetricId()); + newMemoryPoolMetric.setTimeBucket(timeBucket); + next.execute(newMemoryPoolMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolSecondMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolSecondMetricPersistenceWorker.java new file mode 100644 index 000000000..e75153ba9 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/memorypool/MemoryPoolSecondMetricPersistenceWorker.java @@ -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.memorypool; + +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.mpoolmp.IMemoryPoolSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolSecondMetricPersistenceWorker extends PersistenceWorker { + + @Override public int id() { + return WorkerIdDefine.MEMORY_POOL_SECOND_METRIC_PERSISTENCE_WORKER_ID; + } + + public MemoryPoolSecondMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override protected boolean needMergeDBData() { + return false; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IMemoryPoolSecondMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public MemoryPoolSecondMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new MemoryPoolSecondMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/AnalysisMetricModule.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/AnalysisMetricModule.java index 9cf788088..27e917553 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/AnalysisMetricModule.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/AnalysisMetricModule.java @@ -18,6 +18,7 @@ package org.apache.skywalking.apm.collector.analysis.metric.define; +import org.apache.skywalking.apm.collector.analysis.metric.define.service.IInstanceHeartBeatService; import org.apache.skywalking.apm.collector.core.module.Module; /** @@ -32,6 +33,6 @@ public class AnalysisMetricModule extends Module { } @Override public Class[] services() { - return new Class[] {}; + return new Class[] {IInstanceHeartBeatService.class}; } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/MetricSource.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/MetricSource.java similarity index 77% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/MetricSource.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/MetricSource.java index f65969627..7757e13ec 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/MetricSource.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/MetricSource.java @@ -16,12 +16,21 @@ * */ - -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker; +package org.apache.skywalking.apm.collector.analysis.metric.define; /** * @author peng-yongsheng */ public enum MetricSource { - Exit, Entry + Caller(0), Callee(1); + + private final int value; + + private MetricSource(int value) { + this.value = value; + } + + public int getValue() { + return value; + } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/GraphIdDefine.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java similarity index 90% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/GraphIdDefine.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java index 356742db4..d4b69bed7 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/GraphIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java @@ -21,7 +21,7 @@ package org.apache.skywalking.apm.collector.analysis.metric.define.graph; /** * @author peng-yongsheng */ -public class GraphIdDefine { +public class MetricGraphIdDefine { public static final int SERVICE_REFERENCE_METRIC_GRAPH_ID = 400; public static final int INSTANCE_REFERENCE_METRIC_GRAPH_ID = 401; public static final int APPLICATION_REFERENCE_METRIC_GRAPH_ID = 402; @@ -32,7 +32,9 @@ public class GraphIdDefine { public static final int APPLICATION_COMPONENT_GRAPH_ID = 406; public static final int APPLICATION_MAPPING_GRAPH_ID = 407; - public static final int SERVICE_ENTRY_GRAPH_ID = 408; public static final int GLOBAL_TRACE_GRAPH_ID = 409; public static final int SEGMENT_COST_GRAPH_ID = 410; + public static final int INSTANCE_MAPPING_GRAPH_ID = 411; + + public static final int INSTANCE_HEART_BEAT_PERSISTENCE_GRAPH_ID = 412; } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java new file mode 100644 index 000000000..a275a4417 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java @@ -0,0 +1,125 @@ +/* + * 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.metric.define.graph; + +/** + * @author peng-yongsheng + */ +public class MetricWorkerIdDefine { + public static final int SERVICE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4100; + public static final int SERVICE_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID = 4101; + public static final int SERVICE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4102; + public static final int SERVICE_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID = 4103; + public static final int SERVICE_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID = 4104; + public static final int SERVICE_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID = 4105; + public static final int SERVICE_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID = 4106; + public static final int SERVICE_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4107; + public static final int SERVICE_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID = 4108; + + public static final int INSTANCE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4200; + public static final int INSTANCE_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID = 4201; + public static final int INSTANCE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4202; + public static final int INSTANCE_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID = 4203; + public static final int INSTANCE_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID = 4204; + public static final int INSTANCE_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID = 4205; + public static final int INSTANCE_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID = 4206; + public static final int INSTANCE_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4207; + public static final int INSTANCE_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID = 4208; + + public static final int APPLICATION_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4300; + public static final int APPLICATION_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID = 4301; + public static final int APPLICATION_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4302; + public static final int APPLICATION_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID = 4303; + public static final int APPLICATION_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID = 4304; + public static final int APPLICATION_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID = 4305; + public static final int APPLICATION_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID = 4306; + public static final int APPLICATION_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4307; + public static final int APPLICATION_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID = 4308; + + public static final int SERVICE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4400; + public static final int SERVICE_MINUTE_METRIC_REMOTE_WORKER_ID = 4401; + public static final int SERVICE_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4402; + public static final int SERVICE_HOUR_METRIC_PERSISTENCE_WORKER_ID = 4403; + public static final int SERVICE_HOUR_METRIC_TRANSFORM_NODE_ID = 4404; + public static final int SERVICE_DAY_METRIC_PERSISTENCE_WORKER_ID = 4405; + public static final int SERVICE_DAY_METRIC_TRANSFORM_NODE_ID = 4406; + public static final int SERVICE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4407; + public static final int SERVICE_MONTH_METRIC_TRANSFORM_NODE_ID = 4408; + + public static final int INSTANCE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4500; + public static final int INSTANCE_MINUTE_METRIC_REMOTE_WORKER_ID = 4501; + public static final int INSTANCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4502; + public static final int INSTANCE_HOUR_METRIC_PERSISTENCE_WORKER_ID = 4503; + public static final int INSTANCE_HOUR_METRIC_TRANSFORM_NODE_ID = 4504; + public static final int INSTANCE_DAY_METRIC_PERSISTENCE_WORKER_ID = 4505; + public static final int INSTANCE_DAY_METRIC_TRANSFORM_NODE_ID = 4506; + public static final int INSTANCE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4507; + public static final int INSTANCE_MONTH_METRIC_TRANSFORM_NODE_ID = 4508; + + public static final int APPLICATION_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4600; + public static final int APPLICATION_MINUTE_METRIC_REMOTE_WORKER_ID = 4601; + public static final int APPLICATION_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4602; + public static final int APPLICATION_HOUR_METRIC_PERSISTENCE_WORKER_ID = 4603; + public static final int APPLICATION_HOUR_METRIC_TRANSFORM_NODE_ID = 4604; + public static final int APPLICATION_DAY_METRIC_PERSISTENCE_WORKER_ID = 4605; + public static final int APPLICATION_DAY_METRIC_TRANSFORM_NODE_ID = 4606; + public static final int APPLICATION_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4607; + public static final int APPLICATION_MONTH_METRIC_TRANSFORM_NODE_ID = 4608; + + public static final int INSTANCE_MAPPING_MINUTE_AGGREGATION_WORKER_ID = 4700; + public static final int INSTANCE_MAPPING_MINUTE_REMOTE_WORKER_ID = 4701; + public static final int INSTANCE_MAPPING_MINUTE_PERSISTENCE_WORKER_ID = 4702; + public static final int INSTANCE_MAPPING_HOUR_PERSISTENCE_WORKER_ID = 4703; + public static final int INSTANCE_MAPPING_HOUR_TRANSFORM_NODE_ID = 4704; + public static final int INSTANCE_MAPPING_DAY_PERSISTENCE_WORKER_ID = 4705; + public static final int INSTANCE_MAPPING_DAY_TRANSFORM_NODE_ID = 4706; + public static final int INSTANCE_MAPPING_MONTH_PERSISTENCE_WORKER_ID = 4707; + public static final int INSTANCE_MAPPING_MONTH_TRANSFORM_NODE_ID = 4708; + + public static final int APPLICATION_MAPPING_MINUTE_AGGREGATION_WORKER_ID = 4800; + public static final int APPLICATION_MAPPING_MINUTE_REMOTE_WORKER_ID = 4801; + public static final int APPLICATION_MAPPING_MINUTE_PERSISTENCE_WORKER_ID = 4802; + public static final int APPLICATION_MAPPING_HOUR_PERSISTENCE_WORKER_ID = 4803; + public static final int APPLICATION_MAPPING_HOUR_TRANSFORM_NODE_ID = 4804; + public static final int APPLICATION_MAPPING_DAY_PERSISTENCE_WORKER_ID = 4805; + public static final int APPLICATION_MAPPING_DAY_TRANSFORM_NODE_ID = 4806; + public static final int APPLICATION_MAPPING_MONTH_PERSISTENCE_WORKER_ID = 4807; + public static final int APPLICATION_MAPPING_MONTH_TRANSFORM_NODE_ID = 4808; + + public static final int APPLICATION_COMPONENT_MINUTE_AGGREGATION_WORKER_ID = 4900; + public static final int APPLICATION_COMPONENT_MINUTE_REMOTE_WORKER_ID = 4901; + public static final int APPLICATION_COMPONENT_MINUTE_PERSISTENCE_WORKER_ID = 4902; + public static final int APPLICATION_COMPONENT_HOUR_PERSISTENCE_WORKER_ID = 4903; + public static final int APPLICATION_COMPONENT_HOUR_TRANSFORM_NODE_ID = 4904; + public static final int APPLICATION_COMPONENT_DAY_PERSISTENCE_WORKER_ID = 4905; + public static final int APPLICATION_COMPONENT_DAY_TRANSFORM_NODE_ID = 4906; + public static final int APPLICATION_COMPONENT_MONTH_PERSISTENCE_WORKER_ID = 4907; + public static final int APPLICATION_COMPONENT_MONTH_TRANSFORM_NODE_ID = 4908; + + public static final int GLOBAL_TRACE_PERSISTENCE_WORKER_ID = 427; + public static final int SEGMENT_COST_PERSISTENCE_WORKER_ID = 428; + + public static final int INSTANCE_REFERENCE_GRAPH_BRIDGE_WORKER_ID = 429; + public static final int APPLICATION_REFERENCE_GRAPH_BRIDGE_WORKER_ID = 430; + public static final int SERVICE_METRIC_GRAPH_BRIDGE_WORKER_ID = 431; + public static final int INSTANCE_METRIC_GRAPH_BRIDGE_WORKER_ID = 432; + public static final int APPLICATION_METRIC_GRAPH_BRIDGE_WORKER_ID = 433; + + public static final int INST_HEART_BEAT_PERSISTENCE_WORKER_ID = 400; +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/WorkerIdDefine.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/WorkerIdDefine.java deleted file mode 100644 index e2877d83a..000000000 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/WorkerIdDefine.java +++ /dev/null @@ -1,68 +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.metric.define.graph; - -/** - * @author peng-yongsheng - */ -public class WorkerIdDefine { - public static final int SERVICE_REFERENCE_METRIC_AGGREGATION_WORKER_ID = 400; - public static final int SERVICE_REFERENCE_METRIC_REMOTE_WORKER_ID = 401; - public static final int SERVICE_REFERENCE_METRIC_PERSISTENCE_WORKER_ID = 402; - - public static final int INSTANCE_REFERENCE_METRIC_AGGREGATION_WORKER_ID = 403; - public static final int INSTANCE_REFERENCE_METRIC_REMOTE_WORKER_ID = 404; - public static final int INSTANCE_REFERENCE_METRIC_PERSISTENCE_WORKER_ID = 405; - - public static final int APPLICATION_REFERENCE_METRIC_AGGREGATION_WORKER_ID = 406; - public static final int APPLICATION_REFERENCE_METRIC_REMOTE_WORKER_ID = 407; - public static final int APPLICATION_REFERENCE_METRIC_PERSISTENCE_WORKER_ID = 408; - - public static final int SERVICE_METRIC_AGGREGATION_WORKER_ID = 409; - public static final int SERVICE_METRIC_REMOTE_WORKER_ID = 410; - public static final int SERVICE_METRIC_PERSISTENCE_WORKER_ID = 411; - - public static final int INSTANCE_METRIC_AGGREGATION_WORKER_ID = 412; - public static final int INSTANCE_METRIC_REMOTE_WORKER_ID = 413; - public static final int INSTANCE_METRIC_PERSISTENCE_WORKER_ID = 414; - - public static final int APPLICATION_METRIC_AGGREGATION_WORKER_ID = 415; - public static final int APPLICATION_METRIC_REMOTE_WORKER_ID = 416; - public static final int APPLICATION_METRIC_PERSISTENCE_WORKER_ID = 417; - - public static final int APPLICATION_COMPONENT_AGGREGATION_WORKER_ID = 418; - public static final int APPLICATION_COMPONENT_REMOTE_WORKER_ID = 419; - public static final int APPLICATION_COMPONENT_PERSISTENCE_WORKER_ID = 420; - - public static final int APPLICATION_MAPPING_AGGREGATION_WORKER_ID = 421; - public static final int APPLICATION_MAPPING_REMOTE_WORKER_ID = 422; - public static final int APPLICATION_MAPPING_PERSISTENCE_WORKER_ID = 423; - - public static final int SERVICE_ENTRY_AGGREGATION_WORKER_ID = 424; - public static final int SERVICE_ENTRY_REMOTE_WORKER_ID = 425; - public static final int SERVICE_ENTRY_PERSISTENCE_WORKER_ID = 426; - - public static final int GLOBAL_TRACE_PERSISTENCE_WORKER_ID = 427; - public static final int SEGMENT_COST_PERSISTENCE_WORKER_ID = 428; - - public static final int INSTANCE_REFERENCE_GRAPH_BRIDGE_WORKER_ID = 429; - public static final int APPLICATION_REFERENCE_GRAPH_BRIDGE_WORKER_ID = 430; - public static final int SERVICE_METRIC_GRAPH_BRIDGE_WORKER_ID = 431; - public static final int INSTANCE_METRIC_GRAPH_BRIDGE_WORKER_ID = 432; -} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/service/IInstanceHeartBeatService.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/service/IInstanceHeartBeatService.java similarity index 88% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/service/IInstanceHeartBeatService.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/service/IInstanceHeartBeatService.java index 17abda2a0..bcce416ea 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/service/IInstanceHeartBeatService.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/service/IInstanceHeartBeatService.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.apm.collector.analysis.jvm.define.service; +package org.apache.skywalking.apm.collector.analysis.metric.define.service; import org.apache.skywalking.apm.collector.core.module.Service; @@ -24,5 +24,5 @@ import org.apache.skywalking.apm.collector.core.module.Service; * @author peng-yongsheng */ public interface IInstanceHeartBeatService extends Service { - void send(int instanceId, long heartBeatTime); + void heartBeat(int instanceId, long heartBeatTime); } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java index 2ef9ace1a..be6c3d3ee 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java @@ -20,23 +20,26 @@ package org.apache.skywalking.apm.collector.analysis.metric.provider; import java.util.Properties; import org.apache.skywalking.apm.collector.analysis.metric.define.AnalysisMetricModule; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.ApplicationComponentGraph; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.ApplicationComponentSpanListener; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.ApplicationMappingGraph; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.ApplicationMappingSpanListener; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.ApplicationMetricGraph; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.ApplicationReferenceMetricGraph; +import org.apache.skywalking.apm.collector.analysis.metric.define.service.IInstanceHeartBeatService; +import org.apache.skywalking.apm.collector.analysis.metric.provider.service.InstanceHeartBeatService; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.component.ApplicationComponentGraph; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.component.ApplicationComponentSpanListener; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.mapping.ApplicationMappingGraph; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.mapping.ApplicationMappingSpanListener; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.metric.ApplicationMetricGraph; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric.ApplicationReferenceMetricGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global.GlobalTraceGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global.GlobalTraceSpanListener; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.InstanceMetricGraph; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.InstanceReferenceMetricGraph; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.heartbeat.InstanceHeartBeatPersistenceGraph; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping.InstanceMappingGraph; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping.InstanceMappingSpanListener; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.metric.InstanceMetricGraph; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.refmetric.InstanceReferenceMetricGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment.SegmentCostGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment.SegmentCostSpanListener; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.ServiceEntryGraph; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.ServiceEntrySpanListener; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.ServiceMetricGraph; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.ServiceReferenceMetricGraph; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.ServiceReferenceMetricSpanListener; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.metric.ServiceMetricGraph; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.refmetric.ServiceReferenceMetricGraph; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.refmetric.ServiceReferenceMetricSpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.AnalysisSegmentParserModule; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.service.ISegmentParserListenerRegister; import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener; @@ -61,6 +64,7 @@ public class AnalysisMetricModuleProvider extends ModuleProvider { } @Override public void prepare(Properties config) throws ServiceNotProvidedException { + this.registerServiceImplementation(IInstanceHeartBeatService.class, new InstanceHeartBeatService()); } @Override public void start(Properties config) throws ServiceNotProvidedException { @@ -87,7 +91,7 @@ public class AnalysisMetricModuleProvider extends ModuleProvider { segmentParserListenerRegister.register(new ServiceReferenceMetricSpanListener.Factory()); segmentParserListenerRegister.register(new ApplicationComponentSpanListener.Factory()); segmentParserListenerRegister.register(new ApplicationMappingSpanListener.Factory()); - segmentParserListenerRegister.register(new ServiceEntrySpanListener.Factory()); + segmentParserListenerRegister.register(new InstanceMappingSpanListener.Factory()); segmentParserListenerRegister.register(new GlobalTraceSpanListener.Factory()); segmentParserListenerRegister.register(new SegmentCostSpanListener.Factory()); } @@ -117,13 +121,16 @@ public class AnalysisMetricModuleProvider extends ModuleProvider { ApplicationMappingGraph applicationMappingGraph = new ApplicationMappingGraph(getManager(), workerCreateListener); applicationMappingGraph.create(); - ServiceEntryGraph serviceEntryGraph = new ServiceEntryGraph(getManager(), workerCreateListener); - serviceEntryGraph.create(); + InstanceMappingGraph instanceMappingGraph = new InstanceMappingGraph(getManager(), workerCreateListener); + instanceMappingGraph.create(); GlobalTraceGraph globalTraceGraph = new GlobalTraceGraph(getManager(), workerCreateListener); globalTraceGraph.create(); SegmentCostGraph segmentCostGraph = new SegmentCostGraph(getManager(), workerCreateListener); segmentCostGraph.create(); + + InstanceHeartBeatPersistenceGraph instanceHeartBeatPersistenceGraph = new InstanceHeartBeatPersistenceGraph(getManager(), workerCreateListener); + instanceHeartBeatPersistenceGraph.create(); } } diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/InstanceHeartBeatService.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/service/InstanceHeartBeatService.java similarity index 78% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/InstanceHeartBeatService.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/service/InstanceHeartBeatService.java index 8d95234b1..31db2f8bb 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/InstanceHeartBeatService.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/service/InstanceHeartBeatService.java @@ -16,10 +16,10 @@ * */ -package org.apache.skywalking.apm.collector.analysis.jvm.provider.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.service; -import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.GraphIdDefine; -import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IInstanceHeartBeatService; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.service.IInstanceHeartBeatService; 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.util.ObjectUtils; @@ -39,13 +39,14 @@ public class InstanceHeartBeatService implements IInstanceHeartBeatService { private Graph getHeartBeatGraph() { if (ObjectUtils.isEmpty(heartBeatGraph)) { - this.heartBeatGraph = GraphManager.INSTANCE.findGraph(GraphIdDefine.INSTANCE_HEART_BEAT_PERSISTENCE_GRAPH_ID, Instance.class); + this.heartBeatGraph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.INSTANCE_HEART_BEAT_PERSISTENCE_GRAPH_ID, Instance.class); } return heartBeatGraph; } - @Override public void send(int instanceId, long heartBeatTime) { - Instance instance = new Instance(String.valueOf(instanceId)); + @Override public void heartBeat(int instanceId, long heartBeatTime) { + Instance instance = new Instance(); + instance.setId(String.valueOf(instanceId)); instance.setHeartBeatTime(TimeBucketUtils.INSTANCE.getSecondTimeBucket(heartBeatTime)); instance.setInstanceId(instanceId); diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentCopy.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentCopy.java new file mode 100644 index 000000000..27cf97272 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentCopy.java @@ -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.metric.provider.worker.application.component; + +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentCopy { + + public static ApplicationComponent copy(ApplicationComponent applicationComponent) { + ApplicationComponent newApplicationComponent = new ApplicationComponent(); + newApplicationComponent.setId(applicationComponent.getId()); + newApplicationComponent.setMetricId(applicationComponent.getMetricId()); + + newApplicationComponent.setComponentId(applicationComponent.getComponentId()); + newApplicationComponent.setPeerId(applicationComponent.getPeerId()); + newApplicationComponent.setTimeBucket(newApplicationComponent.getTimeBucket()); + return newApplicationComponent; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentDayPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentDayPersistenceWorker.java new file mode 100644 index 000000000..4da338c07 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentDayPersistenceWorker.java @@ -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.metric.provider.worker.application.component; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.acp.IApplicationComponentDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentDayPersistenceWorker extends PersistenceWorker { + + public ApplicationComponentDayPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_COMPONENT_DAY_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationComponentDayPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationComponentDayPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationComponentDayPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentDayTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentDayTransformNode.java new file mode 100644 index 000000000..ff72a0f1f --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentDayTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.application.component; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.application.ApplicationComponent; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentDayTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_COMPONENT_DAY_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationComponent applicationComponent, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToDay(applicationComponent.getTimeBucket()); + + ApplicationComponent newApplicationComponent = ApplicationComponentCopy.copy(applicationComponent); + newApplicationComponent.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationComponent.getMetricId()); + newApplicationComponent.setTimeBucket(timeBucket); + next.execute(newApplicationComponent); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentGraph.java similarity index 59% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentGraph.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentGraph.java index d274a8a0d..07370b779 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentGraph.java @@ -16,11 +16,12 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.component; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; 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.remote.RemoteModule; import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; @@ -42,9 +43,19 @@ public class ApplicationComponentGraph { public void create() { RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); - GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.APPLICATION_COMPONENT_GRAPH_ID, ApplicationComponent.class) - .addNode(new ApplicationComponentAggregationWorker.Factory(moduleManager).create(workerCreateListener)) - .addNext(new ApplicationComponentRemoteWorker.Factory(moduleManager, remoteSenderService, GraphIdDefine.APPLICATION_COMPONENT_GRAPH_ID).create(workerCreateListener)) - .addNext(new ApplicationComponentPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + Node remoteNode = GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.APPLICATION_COMPONENT_GRAPH_ID, ApplicationComponent.class) + .addNode(new ApplicationComponentMinuteAggregationWorker.Factory(moduleManager).create(workerCreateListener)) + .addNext(new ApplicationComponentMinuteRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.APPLICATION_COMPONENT_GRAPH_ID).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationComponentMinutePersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationComponentHourTransformNode()) + .addNext(new ApplicationComponentHourPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationComponentDayTransformNode()) + .addNext(new ApplicationComponentDayPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationComponentMonthTransformNode()) + .addNext(new ApplicationComponentMonthPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentHourPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentHourPersistenceWorker.java new file mode 100644 index 000000000..fc18f82d7 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentHourPersistenceWorker.java @@ -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.metric.provider.worker.application.component; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.acp.IApplicationComponentHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentHourPersistenceWorker extends PersistenceWorker { + + public ApplicationComponentHourPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_COMPONENT_HOUR_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationComponentHourPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationComponentHourPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationComponentHourPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentHourTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentHourTransformNode.java new file mode 100644 index 000000000..6c90cb65e --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentHourTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.application.component; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.application.ApplicationComponent; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentHourTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_COMPONENT_HOUR_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationComponent applicationComponent, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToHour(applicationComponent.getTimeBucket()); + + ApplicationComponent newApplicationComponent = ApplicationComponentCopy.copy(applicationComponent); + newApplicationComponent.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationComponent.getMetricId()); + newApplicationComponent.setTimeBucket(timeBucket); + next.execute(newApplicationComponent); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentAggregationWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMinuteAggregationWorker.java similarity index 74% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentAggregationWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMinuteAggregationWorker.java index 6dfac7a4e..bfadf6bd8 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentAggregationWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMinuteAggregationWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.component; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; import org.apache.skywalking.apm.collector.analysis.worker.model.impl.AggregationWorker; import org.apache.skywalking.apm.collector.core.module.ModuleManager; @@ -27,24 +27,24 @@ import org.apache.skywalking.apm.collector.storage.table.application.Application /** * @author peng-yongsheng */ -public class ApplicationComponentAggregationWorker extends AggregationWorker { +public class ApplicationComponentMinuteAggregationWorker extends AggregationWorker { - public ApplicationComponentAggregationWorker(ModuleManager moduleManager) { + public ApplicationComponentMinuteAggregationWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.APPLICATION_COMPONENT_AGGREGATION_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_COMPONENT_MINUTE_AGGREGATION_WORKER_ID; } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends AbstractLocalAsyncWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ApplicationComponentAggregationWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationComponentAggregationWorker(moduleManager); + @Override public ApplicationComponentMinuteAggregationWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationComponentMinuteAggregationWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMinutePersistenceWorker.java similarity index 67% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMinutePersistenceWorker.java index faa6127b2..78ca9cd23 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMinutePersistenceWorker.java @@ -16,46 +16,47 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.component; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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.IApplicationReferenceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; /** * @author peng-yongsheng */ -public class ApplicationReferenceMetricPersistenceWorker extends PersistenceWorker { +public class ApplicationComponentMinutePersistenceWorker extends PersistenceWorker { - public ApplicationReferenceMetricPersistenceWorker(ModuleManager moduleManager) { + public ApplicationComponentMinutePersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.APPLICATION_REFERENCE_METRIC_PERSISTENCE_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_COMPONENT_MINUTE_PERSISTENCE_WORKER_ID; } @Override protected boolean needMergeDBData() { return true; } - @Override protected IPersistenceDAO persistenceDAO() { - return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceMetricPersistenceDAO.class); + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationComponentMinutePersistenceDAO.class); } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ApplicationReferenceMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationReferenceMetricPersistenceWorker(moduleManager); + @Override public ApplicationComponentMinutePersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationComponentMinutePersistenceWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMinuteRemoteWorker.java similarity index 79% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentRemoteWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMinuteRemoteWorker.java index 2190876dd..d262b71c7 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMinuteRemoteWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.component; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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; @@ -30,14 +30,14 @@ import org.apache.skywalking.apm.collector.storage.table.application.Application /** * @author peng-yongsheng */ -public class ApplicationComponentRemoteWorker extends AbstractRemoteWorker { +public class ApplicationComponentMinuteRemoteWorker extends AbstractRemoteWorker { - ApplicationComponentRemoteWorker(ModuleManager moduleManager) { + ApplicationComponentMinuteRemoteWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.APPLICATION_COMPONENT_REMOTE_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_COMPONENT_MINUTE_REMOTE_WORKER_ID; } @Override protected void onWork(ApplicationComponent applicationComponent) throws WorkerException { @@ -48,14 +48,14 @@ public class ApplicationComponentRemoteWorker extends AbstractRemoteWorker { + public static class Factory extends AbstractRemoteWorkerProvider { public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { super(moduleManager, remoteSenderService, graphId); } - @Override public ApplicationComponentRemoteWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationComponentRemoteWorker(moduleManager); + @Override public ApplicationComponentMinuteRemoteWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationComponentMinuteRemoteWorker(moduleManager); } } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMonthPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMonthPersistenceWorker.java new file mode 100644 index 000000000..bd5d2f07c --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMonthPersistenceWorker.java @@ -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.metric.provider.worker.application.component; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.acp.IApplicationComponentMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentMonthPersistenceWorker extends PersistenceWorker { + + public ApplicationComponentMonthPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_COMPONENT_MONTH_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationComponentMonthPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationComponentMonthPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationComponentMonthPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMonthTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMonthTransformNode.java new file mode 100644 index 000000000..35ee9fe63 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentMonthTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.application.component; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.application.ApplicationComponent; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentMonthTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_COMPONENT_MONTH_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationComponent applicationComponent, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToMonth(applicationComponent.getTimeBucket()); + + ApplicationComponent newApplicationComponent = ApplicationComponentCopy.copy(applicationComponent); + newApplicationComponent.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationComponent.getMetricId()); + newApplicationComponent.setTimeBucket(timeBucket); + next.execute(newApplicationComponent); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentSpanListener.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentSpanListener.java similarity index 86% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentSpanListener.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentSpanListener.java index 2f59e5ba2..80e4c7ece 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentSpanListener.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentSpanListener.java @@ -16,11 +16,11 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.component; import java.util.ArrayList; import java.util.List; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.EntrySpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.ExitSpanListener; @@ -33,24 +33,21 @@ 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.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ public class ApplicationComponentSpanListener implements EntrySpanListener, ExitSpanListener, FirstSpanListener { - private final Logger logger = LoggerFactory.getLogger(ApplicationComponentSpanListener.class); - private List applicationComponents = new ArrayList<>(); private long timeBucket; @Override public void parseExit(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) { - String id = spanDecorator.getPeerId() + Const.ID_SPLIT + String.valueOf(spanDecorator.getComponentId()); + String metricId = spanDecorator.getPeerId() + Const.ID_SPLIT + String.valueOf(spanDecorator.getComponentId()); - ApplicationComponent applicationComponent = new ApplicationComponent(id); + ApplicationComponent applicationComponent = new ApplicationComponent(); + applicationComponent.setMetricId(metricId); applicationComponent.setComponentId(spanDecorator.getComponentId()); applicationComponent.setPeerId(spanDecorator.getPeerId()); applicationComponents.add(applicationComponent); @@ -58,9 +55,10 @@ public class ApplicationComponentSpanListener implements EntrySpanListener, Exit @Override public void parseEntry(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) { - String id = String.valueOf(applicationId) + Const.ID_SPLIT + String.valueOf(spanDecorator.getComponentId()); + String metricId = String.valueOf(applicationId) + Const.ID_SPLIT + String.valueOf(spanDecorator.getComponentId()); - ApplicationComponent applicationComponent = new ApplicationComponent(id); + ApplicationComponent applicationComponent = new ApplicationComponent(); + applicationComponent.setMetricId(metricId); applicationComponent.setComponentId(spanDecorator.getComponentId()); applicationComponent.setPeerId(applicationId); applicationComponents.add(applicationComponent); @@ -73,10 +71,10 @@ public class ApplicationComponentSpanListener implements EntrySpanListener, Exit } @Override public void build() { - Graph graph = GraphManager.INSTANCE.findGraph(GraphIdDefine.APPLICATION_COMPONENT_GRAPH_ID, ApplicationComponent.class); + Graph graph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.APPLICATION_COMPONENT_GRAPH_ID, ApplicationComponent.class); applicationComponents.forEach(applicationComponent -> { - applicationComponent.setId(timeBucket + Const.ID_SPLIT + applicationComponent.getId()); + applicationComponent.setId(timeBucket + Const.ID_SPLIT + applicationComponent.getMetricId()); applicationComponent.setTimeBucket(timeBucket); graph.start(applicationComponent); }); diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingCopy.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingCopy.java new file mode 100644 index 000000000..aa5aad45f --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingCopy.java @@ -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.metric.provider.worker.application.mapping; + +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingCopy { + + public static ApplicationMapping copy(ApplicationMapping applicationMapping) { + ApplicationMapping newApplicationMapping = new ApplicationMapping(); + newApplicationMapping.setId(applicationMapping.getId()); + newApplicationMapping.setMetricId(applicationMapping.getMetricId()); + newApplicationMapping.setTimeBucket(applicationMapping.getTimeBucket()); + + newApplicationMapping.setApplicationId(applicationMapping.getApplicationId()); + newApplicationMapping.setAddressId(applicationMapping.getAddressId()); + return newApplicationMapping; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingDayPersistenceWorker.java similarity index 66% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingDayPersistenceWorker.java index 8e2d2ced2..71600093e 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingDayPersistenceWorker.java @@ -16,46 +16,47 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.mapping; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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.IApplicationMappingPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingDayPersistenceDAO; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; /** * @author peng-yongsheng */ -public class ApplicationMappingPersistenceWorker extends PersistenceWorker { +public class ApplicationMappingDayPersistenceWorker extends PersistenceWorker { - ApplicationMappingPersistenceWorker(ModuleManager moduleManager) { + ApplicationMappingDayPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.APPLICATION_MAPPING_PERSISTENCE_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_MAPPING_DAY_PERSISTENCE_WORKER_ID; } @Override protected boolean needMergeDBData() { return true; } - @Override protected IPersistenceDAO persistenceDAO() { - return getModuleManager().find(StorageModule.NAME).getService(IApplicationMappingPersistenceDAO.class); + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationMappingDayPersistenceDAO.class); } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ApplicationMappingPersistenceWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationMappingPersistenceWorker(moduleManager); + @Override public ApplicationMappingDayPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMappingDayPersistenceWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingDayTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingDayTransformNode.java new file mode 100644 index 000000000..a4b84b1c3 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingDayTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.application.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.application.ApplicationMapping; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingDayTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_MAPPING_DAY_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationMapping applicationMapping, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToDay(applicationMapping.getTimeBucket()); + + ApplicationMapping newApplicationMapping = ApplicationMappingCopy.copy(applicationMapping); + newApplicationMapping.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationMapping.getMetricId()); + newApplicationMapping.setTimeBucket(timeBucket); + next.execute(newApplicationMapping); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingGraph.java similarity index 61% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingGraph.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingGraph.java index f87d9cd02..4ed6857c8 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingGraph.java @@ -16,11 +16,12 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.mapping; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; 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.remote.RemoteModule; import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; @@ -42,9 +43,19 @@ public class ApplicationMappingGraph { public void create() { RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); - GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.APPLICATION_MAPPING_GRAPH_ID, ApplicationMapping.class) - .addNode(new ApplicationMappingAggregationWorker.Factory(moduleManager).create(workerCreateListener)) - .addNext(new ApplicationMappingRemoteWorker.Factory(moduleManager, remoteSenderService, GraphIdDefine.APPLICATION_MAPPING_GRAPH_ID).create(workerCreateListener)) - .addNext(new ApplicationMappingPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + Node remoteNode = GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.APPLICATION_MAPPING_GRAPH_ID, ApplicationMapping.class) + .addNode(new ApplicationMappingMinuteAggregationWorker.Factory(moduleManager).create(workerCreateListener)) + .addNext(new ApplicationMappingMinuteRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.APPLICATION_MAPPING_GRAPH_ID).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationMappingMinutePersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationMappingHourTransformNode()) + .addNext(new ApplicationMappingHourPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationMappingDayTransformNode()) + .addNext(new ApplicationMappingDayPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationMappingMonthTransformNode()) + .addNext(new ApplicationMappingMonthPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingHourPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingHourPersistenceWorker.java new file mode 100644 index 000000000..953876e3f --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingHourPersistenceWorker.java @@ -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.metric.provider.worker.application.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.ampp.IApplicationMappingHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingHourPersistenceWorker extends PersistenceWorker { + + ApplicationMappingHourPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_MAPPING_HOUR_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationMappingHourPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationMappingHourPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMappingHourPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingHourTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingHourTransformNode.java new file mode 100644 index 000000000..2fb129265 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingHourTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.application.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.application.ApplicationMapping; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingHourTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_MAPPING_HOUR_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationMapping applicationMapping, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToHour(applicationMapping.getTimeBucket()); + + ApplicationMapping newApplicationMapping = ApplicationMappingCopy.copy(applicationMapping); + newApplicationMapping.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationMapping.getMetricId()); + newApplicationMapping.setTimeBucket(timeBucket); + next.execute(newApplicationMapping); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingAggregationWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMinuteAggregationWorker.java similarity index 75% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingAggregationWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMinuteAggregationWorker.java index b56c99d04..60aa45d4c 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingAggregationWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMinuteAggregationWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.mapping; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; import org.apache.skywalking.apm.collector.analysis.worker.model.impl.AggregationWorker; import org.apache.skywalking.apm.collector.core.module.ModuleManager; @@ -27,24 +27,24 @@ import org.apache.skywalking.apm.collector.storage.table.application.Application /** * @author peng-yongsheng */ -public class ApplicationMappingAggregationWorker extends AggregationWorker { +public class ApplicationMappingMinuteAggregationWorker extends AggregationWorker { - ApplicationMappingAggregationWorker(ModuleManager moduleManager) { + ApplicationMappingMinuteAggregationWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.APPLICATION_MAPPING_AGGREGATION_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_MAPPING_MINUTE_AGGREGATION_WORKER_ID; } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends AbstractLocalAsyncWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ApplicationMappingAggregationWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationMappingAggregationWorker(moduleManager); + @Override public ApplicationMappingMinuteAggregationWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMappingMinuteAggregationWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMinutePersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMinutePersistenceWorker.java new file mode 100644 index 000000000..71ebf4db7 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMinutePersistenceWorker.java @@ -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.metric.provider.worker.application.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.ampp.IApplicationMappingMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingMinutePersistenceWorker extends PersistenceWorker { + + ApplicationMappingMinutePersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_MAPPING_MINUTE_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationMappingMinutePersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationMappingMinutePersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMappingMinutePersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMinuteRemoteWorker.java similarity index 77% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingRemoteWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMinuteRemoteWorker.java index 9ac4faeec..585af25bd 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMinuteRemoteWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.mapping; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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; @@ -30,14 +30,14 @@ import org.apache.skywalking.apm.collector.storage.table.application.Application /** * @author peng-yongsheng */ -public class ApplicationMappingRemoteWorker extends AbstractRemoteWorker { +public class ApplicationMappingMinuteRemoteWorker extends AbstractRemoteWorker { - ApplicationMappingRemoteWorker(ModuleManager moduleManager) { + ApplicationMappingMinuteRemoteWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.APPLICATION_MAPPING_REMOTE_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_MAPPING_MINUTE_REMOTE_WORKER_ID; } @Override protected void onWork(ApplicationMapping applicationMapping) throws WorkerException { @@ -48,13 +48,13 @@ public class ApplicationMappingRemoteWorker extends AbstractRemoteWorker { + public static class Factory extends AbstractRemoteWorkerProvider { public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { super(moduleManager, remoteSenderService, graphId); } - @Override public ApplicationMappingRemoteWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationMappingRemoteWorker(moduleManager); + @Override public ApplicationMappingMinuteRemoteWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMappingMinuteRemoteWorker(moduleManager); } } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMonthPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMonthPersistenceWorker.java new file mode 100644 index 000000000..51aaf319b --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMonthPersistenceWorker.java @@ -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.metric.provider.worker.application.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.ampp.IApplicationMappingMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingMonthPersistenceWorker extends PersistenceWorker { + + ApplicationMappingMonthPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_MAPPING_MONTH_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationMappingMonthPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationMappingMonthPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMappingMonthPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMonthTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMonthTransformNode.java new file mode 100644 index 000000000..1ea1ce068 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingMonthTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.application.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.application.ApplicationMapping; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingMonthTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_MAPPING_MONTH_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationMapping applicationMapping, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToMonth(applicationMapping.getTimeBucket()); + + ApplicationMapping newApplicationMapping = ApplicationMappingCopy.copy(applicationMapping); + newApplicationMapping.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationMapping.getMetricId()); + newApplicationMapping.setTimeBucket(timeBucket); + next.execute(newApplicationMapping); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingSpanListener.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingSpanListener.java similarity index 76% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingSpanListener.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingSpanListener.java index cc3cddbad..9433f2d5e 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMappingSpanListener.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingSpanListener.java @@ -16,11 +16,11 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.mapping; import java.util.LinkedList; import java.util.List; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.EntrySpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.FirstSpanListener; @@ -46,14 +46,17 @@ public class ApplicationMappingSpanListener implements FirstSpanListener, EntryS private long timeBucket; @Override public void parseEntry(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) { - logger.debug("node mapping listener parse reference"); + logger.debug("application mapping listener parse reference"); if (spanDecorator.getRefsCount() > 0) { - ApplicationMapping applicationMapping = new ApplicationMapping(Const.EMPTY_STRING); - applicationMapping.setApplicationId(applicationId); - applicationMapping.setAddressId(spanDecorator.getRefs(0).getNetworkAddressId()); - String id = String.valueOf(applicationId) + Const.ID_SPLIT + String.valueOf(applicationMapping.getAddressId()); - applicationMapping.setId(id); - applicationMappings.add(applicationMapping); + for (int i = 0; i < spanDecorator.getRefsCount(); i++) { + ApplicationMapping applicationMapping = new ApplicationMapping(); + applicationMapping.setApplicationId(applicationId); + applicationMapping.setAddressId(spanDecorator.getRefs(i).getNetworkAddressId()); + + String metricId = String.valueOf(applicationId) + Const.ID_SPLIT + String.valueOf(applicationMapping.getAddressId()); + applicationMapping.setMetricId(metricId); + applicationMappings.add(applicationMapping); + } } } @@ -64,12 +67,12 @@ public class ApplicationMappingSpanListener implements FirstSpanListener, EntryS } @Override public void build() { - logger.debug("node mapping listener build"); - Graph graph = GraphManager.INSTANCE.findGraph(GraphIdDefine.APPLICATION_MAPPING_GRAPH_ID, ApplicationMapping.class); + logger.debug("application mapping listener build"); + Graph graph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.APPLICATION_MAPPING_GRAPH_ID, ApplicationMapping.class); applicationMappings.forEach(applicationMapping -> { - applicationMapping.setId(timeBucket + Const.ID_SPLIT + applicationMapping.getId()); + applicationMapping.setId(timeBucket + Const.ID_SPLIT + applicationMapping.getMetricId()); applicationMapping.setTimeBucket(timeBucket); - logger.debug("push to node mapping aggregation worker, id: {}", applicationMapping.getId()); + logger.debug("push to application mapping aggregation worker, id: {}", applicationMapping.getId()); graph.start(applicationMapping); }); } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationDayMetricPersistenceWorker.java similarity index 68% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationDayMetricPersistenceWorker.java index a1e23a0c7..4a64714d9 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationComponentPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationDayMetricPersistenceWorker.java @@ -16,46 +16,47 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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.IApplicationComponentPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; /** * @author peng-yongsheng */ -public class ApplicationComponentPersistenceWorker extends PersistenceWorker { +public class ApplicationDayMetricPersistenceWorker extends PersistenceWorker { - public ApplicationComponentPersistenceWorker(ModuleManager moduleManager) { + public ApplicationDayMetricPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.APPLICATION_COMPONENT_PERSISTENCE_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_DAY_METRIC_PERSISTENCE_WORKER_ID; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationDayMetricPersistenceDAO.class); } @Override protected boolean needMergeDBData() { return true; } - @Override protected IPersistenceDAO persistenceDAO() { - return getModuleManager().find(StorageModule.NAME).getService(IApplicationComponentPersistenceDAO.class); - } - - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ApplicationComponentPersistenceWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationComponentPersistenceWorker(moduleManager); + @Override public ApplicationDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationDayMetricPersistenceWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationDayMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationDayMetricTransformNode.java new file mode 100644 index 000000000..d88c194e1 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationDayMetricTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.application.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.application.ApplicationMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationDayMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_DAY_METRIC_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationMetric applicationMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToDay(applicationMetric.getTimeBucket()); + + ApplicationMetric newApplicationMetric = ApplicationMetricCopy.copy(applicationMetric); + newApplicationMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationMetric.getMetricId()); + newApplicationMetric.setTimeBucket(timeBucket); + next.execute(newApplicationMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationHourMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationHourMetricPersistenceWorker.java new file mode 100644 index 000000000..4f7d4e7b2 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationHourMetricPersistenceWorker.java @@ -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.metric.provider.worker.application.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.amp.IApplicationHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationHourMetricPersistenceWorker extends PersistenceWorker { + + public ApplicationHourMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_HOUR_METRIC_PERSISTENCE_WORKER_ID; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationHourMetricPersistenceDAO.class); + } + + @Override protected boolean needMergeDBData() { + return true; + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationHourMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationHourMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationHourMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationHourMetricTransformNode.java new file mode 100644 index 000000000..9c7800473 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationHourMetricTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.application.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.application.ApplicationMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationHourMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_HOUR_METRIC_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationMetric applicationMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToHour(applicationMetric.getTimeBucket()); + + ApplicationMetric newApplicationMetric = ApplicationMetricCopy.copy(applicationMetric); + newApplicationMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationMetric.getMetricId()); + newApplicationMetric.setTimeBucket(timeBucket); + next.execute(newApplicationMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMetricCopy.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMetricCopy.java new file mode 100644 index 000000000..266399d2c --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMetricCopy.java @@ -0,0 +1,59 @@ +/* + * 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.metric.provider.worker.application.metric; + +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationMetricCopy { + + public static ApplicationMetric copy(ApplicationMetric applicationMetric) { + ApplicationMetric newApplicationMetric = new ApplicationMetric(); + newApplicationMetric.setId(applicationMetric.getId()); + newApplicationMetric.setMetricId(applicationMetric.getMetricId()); + newApplicationMetric.setSourceValue(applicationMetric.getSourceValue()); + + newApplicationMetric.setApplicationId(applicationMetric.getApplicationId()); + + newApplicationMetric.setTransactionCalls(applicationMetric.getTransactionCalls()); + newApplicationMetric.setTransactionDurationSum(applicationMetric.getTransactionDurationSum()); + newApplicationMetric.setTransactionErrorCalls(applicationMetric.getTransactionErrorCalls()); + newApplicationMetric.setTransactionErrorDurationSum(applicationMetric.getTransactionErrorDurationSum()); + + newApplicationMetric.setBusinessTransactionCalls(applicationMetric.getBusinessTransactionCalls()); + newApplicationMetric.setBusinessTransactionDurationSum(applicationMetric.getBusinessTransactionDurationSum()); + newApplicationMetric.setBusinessTransactionErrorCalls(applicationMetric.getBusinessTransactionErrorCalls()); + newApplicationMetric.setBusinessTransactionErrorDurationSum(applicationMetric.getBusinessTransactionErrorDurationSum()); + + newApplicationMetric.setMqTransactionCalls(applicationMetric.getMqTransactionCalls()); + newApplicationMetric.setMqTransactionDurationSum(applicationMetric.getMqTransactionDurationSum()); + newApplicationMetric.setMqTransactionErrorCalls(applicationMetric.getMqTransactionErrorCalls()); + newApplicationMetric.setMqTransactionErrorDurationSum(applicationMetric.getMqTransactionErrorDurationSum()); + + newApplicationMetric.setSatisfiedCount(applicationMetric.getSatisfiedCount()); + newApplicationMetric.setToleratingCount(applicationMetric.getToleratingCount()); + newApplicationMetric.setFrustratedCount(applicationMetric.getFrustratedCount()); + + newApplicationMetric.setTimeBucket(applicationMetric.getTimeBucket()); + + return newApplicationMetric; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMetricGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMetricGraph.java new file mode 100644 index 000000000..16771f1a8 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMetricGraph.java @@ -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.metric.provider.worker.application.metric; + +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.Node; +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.application.ApplicationMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationMetricGraph { + + private final ModuleManager moduleManager; + private final WorkerCreateListener workerCreateListener; + + public ApplicationMetricGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) { + this.moduleManager = moduleManager; + this.workerCreateListener = workerCreateListener; + } + + public void create() { + RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); + + Graph graph = GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.APPLICATION_METRIC_GRAPH_ID, ApplicationReferenceMetric.class); + + Node remoteNode = graph.addNode(new ApplicationMinuteMetricAggregationWorker.Factory(moduleManager).create(workerCreateListener)) + .addNext(new ApplicationMinuteMetricRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.APPLICATION_METRIC_GRAPH_ID).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationMinuteMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationHourMetricTransformNode()) + .addNext(new ApplicationHourMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationDayMetricTransformNode()) + .addNext(new ApplicationDayMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationMonthMetricTransformNode()) + .addNext(new ApplicationMonthMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + link(graph); + } + + private void link(Graph graph) { + GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.APPLICATION_REFERENCE_METRIC_GRAPH_ID, ApplicationReferenceMetric.class) + .toFinder().findNode(MetricWorkerIdDefine.APPLICATION_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID, ApplicationReferenceMetric.class) + .addNext(new NodeProcessor() { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_METRIC_GRAPH_BRIDGE_WORKER_ID; + } + + @Override + public void process(ApplicationReferenceMetric applicationReferenceMetric, + Next next) { + graph.start(applicationReferenceMetric); + } + }); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMetricAggregationWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMinuteMetricAggregationWorker.java similarity index 80% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMetricAggregationWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMinuteMetricAggregationWorker.java index 98364e00b..4c21b9559 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMetricAggregationWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMinuteMetricAggregationWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; import org.apache.skywalking.apm.collector.analysis.worker.model.impl.AggregationWorker; import org.apache.skywalking.apm.collector.core.module.ModuleManager; @@ -29,21 +29,32 @@ import org.apache.skywalking.apm.collector.storage.table.application.Application /** * @author peng-yongsheng */ -public class ApplicationMetricAggregationWorker extends AggregationWorker { +public class ApplicationMinuteMetricAggregationWorker extends AggregationWorker { - public ApplicationMetricAggregationWorker(ModuleManager moduleManager) { + public ApplicationMinuteMetricAggregationWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.APPLICATION_METRIC_AGGREGATION_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_MINUTE_METRIC_AGGREGATION_WORKER_ID; } @Override protected ApplicationMetric transform(ApplicationReferenceMetric applicationReferenceMetric) { Integer applicationId = applicationReferenceMetric.getBehindApplicationId(); Long timeBucket = applicationReferenceMetric.getTimeBucket(); - ApplicationMetric applicationMetric = new ApplicationMetric(String.valueOf(timeBucket) + Const.ID_SPLIT + String.valueOf(applicationId)); + + String metricId = String.valueOf(applicationId) + + Const.ID_SPLIT + applicationReferenceMetric.getSourceValue(); + + String id = String.valueOf(timeBucket) + + Const.ID_SPLIT + metricId; + + ApplicationMetric applicationMetric = new ApplicationMetric(); + applicationMetric.setId(id); + applicationMetric.setMetricId(metricId); + applicationMetric.setApplicationId(applicationId); + applicationMetric.setSourceValue(applicationReferenceMetric.getSourceValue()); applicationMetric.setTransactionCalls(applicationReferenceMetric.getTransactionCalls()); applicationMetric.setTransactionDurationSum(applicationReferenceMetric.getTransactionDurationSum()); @@ -69,14 +80,14 @@ public class ApplicationMetricAggregationWorker extends AggregationWorker { + public static class Factory extends AbstractLocalAsyncWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ApplicationMetricAggregationWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationMetricAggregationWorker(moduleManager); + @Override public ApplicationMinuteMetricAggregationWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMinuteMetricAggregationWorker(moduleManager); } @Override public int queueSize() { diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMinuteMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMinuteMetricPersistenceWorker.java new file mode 100644 index 000000000..89c97a0ac --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMinuteMetricPersistenceWorker.java @@ -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.metric.provider.worker.application.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.amp.IApplicationMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationMinuteMetricPersistenceWorker extends PersistenceWorker { + + public ApplicationMinuteMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_MINUTE_METRIC_PERSISTENCE_WORKER_ID; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationMinuteMetricPersistenceDAO.class); + } + + @Override protected boolean needMergeDBData() { + return true; + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMinuteMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMetricRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMinuteMetricRemoteWorker.java similarity index 77% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMetricRemoteWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMinuteMetricRemoteWorker.java index 9748626ae..6aea53626 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMetricRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMinuteMetricRemoteWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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; @@ -30,14 +30,14 @@ import org.apache.skywalking.apm.collector.storage.table.application.Application /** * @author peng-yongsheng */ -public class ApplicationMetricRemoteWorker extends AbstractRemoteWorker { +public class ApplicationMinuteMetricRemoteWorker extends AbstractRemoteWorker { - public ApplicationMetricRemoteWorker(ModuleManager moduleManager) { + public ApplicationMinuteMetricRemoteWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.APPLICATION_METRIC_REMOTE_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_MINUTE_METRIC_REMOTE_WORKER_ID; } @Override protected void onWork(ApplicationMetric applicationMetric) throws WorkerException { @@ -48,13 +48,13 @@ public class ApplicationMetricRemoteWorker extends AbstractRemoteWorker { + public static class Factory extends AbstractRemoteWorkerProvider { public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { super(moduleManager, remoteSenderService, graphId); } - @Override public ApplicationMetricRemoteWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationMetricRemoteWorker(moduleManager); + @Override public ApplicationMinuteMetricRemoteWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMinuteMetricRemoteWorker(moduleManager); } } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMonthMetricPersistenceWorker.java similarity index 65% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMonthMetricPersistenceWorker.java index 167afe11f..8419cdb9c 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMonthMetricPersistenceWorker.java @@ -16,46 +16,47 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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.IServiceReferenceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; /** * @author peng-yongsheng */ -public class ServiceReferenceMetricPersistenceWorker extends PersistenceWorker { +public class ApplicationMonthMetricPersistenceWorker extends PersistenceWorker { - public ServiceReferenceMetricPersistenceWorker(ModuleManager moduleManager) { + public ApplicationMonthMetricPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.SERVICE_REFERENCE_METRIC_PERSISTENCE_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_MONTH_METRIC_PERSISTENCE_WORKER_ID; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationMonthMetricPersistenceDAO.class); } @Override protected boolean needMergeDBData() { return true; } - @Override protected IPersistenceDAO persistenceDAO() { - return getModuleManager().find(StorageModule.NAME).getService(IServiceReferenceMetricPersistenceDAO.class); - } - - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ServiceReferenceMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { - return new ServiceReferenceMetricPersistenceWorker(moduleManager); + @Override public ApplicationMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMonthMetricPersistenceWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMonthMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMonthMetricTransformNode.java new file mode 100644 index 000000000..6becd28ba --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/metric/ApplicationMonthMetricTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.application.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.application.ApplicationMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationMonthMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_MONTH_METRIC_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationMetric applicationMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToMonth(applicationMetric.getTimeBucket()); + + ApplicationMetric newApplicationMetric = ApplicationMetricCopy.copy(applicationMetric); + newApplicationMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationMetric.getMetricId()); + newApplicationMetric.setTimeBucket(timeBucket); + next.execute(newApplicationMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceDayMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceDayMetricPersistenceWorker.java new file mode 100644 index 000000000..2741c3cb1 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceDayMetricPersistenceWorker.java @@ -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.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.armp.IApplicationReferenceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceDayMetricPersistenceWorker extends PersistenceWorker { + + public ApplicationReferenceDayMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceDayMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationReferenceDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceDayMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceDayMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceDayMetricTransformNode.java new file mode 100644 index 000000000..75af43d88 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceDayMetricTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceDayMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationReferenceMetric applicationReferenceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToDay(applicationReferenceMetric.getTimeBucket()); + + ApplicationReferenceMetric newApplicationReferenceMetric = ApplicationReferenceMetricCopy.copy(applicationReferenceMetric); + newApplicationReferenceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationReferenceMetric.getMetricId()); + newApplicationReferenceMetric.setTimeBucket(timeBucket); + next.execute(newApplicationReferenceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricPersistenceWorker.java new file mode 100644 index 000000000..7a74d2e25 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricPersistenceWorker.java @@ -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.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.armp.IApplicationReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceHourMetricPersistenceWorker extends PersistenceWorker { + + public ApplicationReferenceHourMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceHourMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationReferenceHourMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceHourMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricTransformNode.java new file mode 100644 index 000000000..eb768da22 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceHourMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationReferenceMetric applicationReferenceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToHour(applicationReferenceMetric.getTimeBucket()); + + ApplicationReferenceMetric newApplicationReferenceMetric = ApplicationReferenceMetricCopy.copy(applicationReferenceMetric); + newApplicationReferenceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationReferenceMetric.getMetricId()); + newApplicationReferenceMetric.setTimeBucket(timeBucket); + next.execute(newApplicationReferenceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricCopy.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricCopy.java new file mode 100644 index 000000000..4cf5b4ef3 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricCopy.java @@ -0,0 +1,60 @@ +/* + * 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.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMetricCopy { + + public static ApplicationReferenceMetric copy(ApplicationReferenceMetric applicationReferenceMetric) { + ApplicationReferenceMetric newApplicationReferenceMetric = new ApplicationReferenceMetric(); + newApplicationReferenceMetric.setId(applicationReferenceMetric.getId()); + newApplicationReferenceMetric.setMetricId(applicationReferenceMetric.getMetricId()); + newApplicationReferenceMetric.setSourceValue(applicationReferenceMetric.getSourceValue()); + + newApplicationReferenceMetric.setFrontApplicationId(applicationReferenceMetric.getFrontApplicationId()); + newApplicationReferenceMetric.setBehindApplicationId(applicationReferenceMetric.getBehindApplicationId()); + + newApplicationReferenceMetric.setTransactionCalls(applicationReferenceMetric.getTransactionCalls()); + newApplicationReferenceMetric.setTransactionDurationSum(applicationReferenceMetric.getTransactionDurationSum()); + newApplicationReferenceMetric.setTransactionErrorCalls(applicationReferenceMetric.getTransactionErrorCalls()); + newApplicationReferenceMetric.setTransactionErrorDurationSum(applicationReferenceMetric.getTransactionErrorDurationSum()); + + newApplicationReferenceMetric.setBusinessTransactionCalls(applicationReferenceMetric.getBusinessTransactionCalls()); + newApplicationReferenceMetric.setBusinessTransactionDurationSum(applicationReferenceMetric.getBusinessTransactionDurationSum()); + newApplicationReferenceMetric.setBusinessTransactionErrorCalls(applicationReferenceMetric.getBusinessTransactionErrorCalls()); + newApplicationReferenceMetric.setBusinessTransactionErrorDurationSum(applicationReferenceMetric.getBusinessTransactionErrorDurationSum()); + + newApplicationReferenceMetric.setMqTransactionCalls(applicationReferenceMetric.getMqTransactionCalls()); + newApplicationReferenceMetric.setMqTransactionDurationSum(applicationReferenceMetric.getMqTransactionDurationSum()); + newApplicationReferenceMetric.setMqTransactionErrorCalls(applicationReferenceMetric.getMqTransactionErrorCalls()); + newApplicationReferenceMetric.setMqTransactionErrorDurationSum(applicationReferenceMetric.getMqTransactionErrorDurationSum()); + + newApplicationReferenceMetric.setSatisfiedCount(applicationReferenceMetric.getSatisfiedCount()); + newApplicationReferenceMetric.setToleratingCount(applicationReferenceMetric.getToleratingCount()); + newApplicationReferenceMetric.setFrustratedCount(applicationReferenceMetric.getFrustratedCount()); + + newApplicationReferenceMetric.setTimeBucket(applicationReferenceMetric.getTimeBucket()); + + return newApplicationReferenceMetric; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricGraph.java similarity index 59% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricGraph.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricGraph.java index 3af27d37b..f6bcf8b17 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricGraph.java @@ -16,18 +16,20 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +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.Node; 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.application.ApplicationReferenceMetric; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; /** @@ -46,21 +48,31 @@ public class ApplicationReferenceMetricGraph { public void create() { RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); - Graph graph = GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.APPLICATION_REFERENCE_METRIC_GRAPH_ID, InstanceReferenceMetric.class); + Graph graph = GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.APPLICATION_REFERENCE_METRIC_GRAPH_ID, InstanceReferenceMetric.class); - graph.addNode(new ApplicationReferenceMetricAggregationWorker.Factory(moduleManager).create(workerCreateListener)) - .addNext(new ApplicationReferenceMetricRemoteWorker.Factory(moduleManager, remoteSenderService, GraphIdDefine.APPLICATION_REFERENCE_METRIC_GRAPH_ID).create(workerCreateListener)) - .addNext(new ApplicationReferenceMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + Node remoteNode = graph.addNode(new ApplicationReferenceMinuteMetricAggregationWorker.Factory(moduleManager).create(workerCreateListener)) + .addNext(new ApplicationReferenceMinuteMetricRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.APPLICATION_REFERENCE_METRIC_GRAPH_ID).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationReferenceMinuteMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationReferenceHourMetricTransformNode()) + .addNext(new ApplicationReferenceHourMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationReferenceDayMetricTransformNode()) + .addNext(new ApplicationReferenceDayMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationReferenceMonthMetricTransformNode()) + .addNext(new ApplicationReferenceMonthMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); link(graph); } private void link(Graph graph) { - GraphManager.INSTANCE.findGraph(GraphIdDefine.INSTANCE_REFERENCE_METRIC_GRAPH_ID, InstanceReferenceMetric.class) - .toFinder().findNode(WorkerIdDefine.INSTANCE_REFERENCE_METRIC_AGGREGATION_WORKER_ID, InstanceReferenceMetric.class) + GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.INSTANCE_REFERENCE_METRIC_GRAPH_ID, InstanceReferenceMetric.class) + .toFinder().findNode(MetricWorkerIdDefine.INSTANCE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID, InstanceReferenceMetric.class) .addNext(new NodeProcessor() { @Override public int id() { - return WorkerIdDefine.APPLICATION_REFERENCE_GRAPH_BRIDGE_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_REFERENCE_GRAPH_BRIDGE_WORKER_ID; } @Override public void process(InstanceReferenceMetric instanceReferenceMetric, diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricAggregationWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMinuteMetricAggregationWorker.java similarity index 78% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricAggregationWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMinuteMetricAggregationWorker.java index 5b3914c95..3910de510 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricAggregationWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMinuteMetricAggregationWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; import org.apache.skywalking.apm.collector.analysis.worker.model.impl.AggregationWorker; import org.apache.skywalking.apm.collector.cache.CacheModule; @@ -34,30 +34,38 @@ import org.apache.skywalking.apm.collector.storage.table.instance.InstanceRefere /** * @author peng-yongsheng */ -public class ApplicationReferenceMetricAggregationWorker extends AggregationWorker { +public class ApplicationReferenceMinuteMetricAggregationWorker extends AggregationWorker { private final InstanceCacheService instanceCacheService; private final IApdexThresholdService apdexThresholdService; - public ApplicationReferenceMetricAggregationWorker(ModuleManager moduleManager) { + public ApplicationReferenceMinuteMetricAggregationWorker(ModuleManager moduleManager) { super(moduleManager); this.instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class); this.apdexThresholdService = moduleManager.find(ConfigurationModule.NAME).getService(IApdexThresholdService.class); } @Override public int id() { - return WorkerIdDefine.APPLICATION_REFERENCE_METRIC_AGGREGATION_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID; } @Override protected ApplicationReferenceMetric transform(InstanceReferenceMetric instanceReferenceMetric) { - Integer frontApplicationId = instanceCacheService.get(instanceReferenceMetric.getFrontInstanceId()); - Integer behindApplicationId = instanceCacheService.get(instanceReferenceMetric.getBehindInstanceId()); + Integer frontApplicationId = instanceCacheService.getApplicationId(instanceReferenceMetric.getFrontInstanceId()); + Integer behindApplicationId = instanceCacheService.getApplicationId(instanceReferenceMetric.getBehindInstanceId()); - String id = instanceReferenceMetric.getTimeBucket() + Const.ID_SPLIT + frontApplicationId + Const.ID_SPLIT + behindApplicationId; + String metricId = frontApplicationId + + Const.ID_SPLIT + behindApplicationId + + Const.ID_SPLIT + instanceReferenceMetric.getSourceValue(); - ApplicationReferenceMetric applicationReferenceMetric = new ApplicationReferenceMetric(id); + String id = instanceReferenceMetric.getTimeBucket() + + Const.ID_SPLIT + metricId; + + ApplicationReferenceMetric applicationReferenceMetric = new ApplicationReferenceMetric(); + applicationReferenceMetric.setId(id); + applicationReferenceMetric.setMetricId(metricId); applicationReferenceMetric.setFrontApplicationId(frontApplicationId); applicationReferenceMetric.setBehindApplicationId(behindApplicationId); + applicationReferenceMetric.setSourceValue(instanceReferenceMetric.getSourceValue()); applicationReferenceMetric.setTransactionCalls(instanceReferenceMetric.getTransactionCalls()); applicationReferenceMetric.setTransactionErrorCalls(instanceReferenceMetric.getTransactionErrorCalls()); @@ -88,14 +96,14 @@ public class ApplicationReferenceMetricAggregationWorker extends AggregationWork return applicationReferenceMetric; } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends AbstractLocalAsyncWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ApplicationReferenceMetricAggregationWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationReferenceMetricAggregationWorker(moduleManager); + @Override public ApplicationReferenceMinuteMetricAggregationWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceMinuteMetricAggregationWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMinuteMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMinuteMetricPersistenceWorker.java new file mode 100644 index 000000000..72b542911 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMinuteMetricPersistenceWorker.java @@ -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.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.armp.IApplicationReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMinuteMetricPersistenceWorker extends PersistenceWorker { + + public ApplicationReferenceMinuteMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceMinuteMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationReferenceMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceMinuteMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMinuteMetricRemoteWorker.java similarity index 78% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricRemoteWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMinuteMetricRemoteWorker.java index 51994a1ed..a39bd7ad0 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMinuteMetricRemoteWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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; @@ -30,14 +30,14 @@ import org.apache.skywalking.apm.collector.storage.table.application.Application /** * @author peng-yongsheng */ -public class ApplicationReferenceMetricRemoteWorker extends AbstractRemoteWorker { +public class ApplicationReferenceMinuteMetricRemoteWorker extends AbstractRemoteWorker { - ApplicationReferenceMetricRemoteWorker(ModuleManager moduleManager) { + ApplicationReferenceMinuteMetricRemoteWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.APPLICATION_REFERENCE_METRIC_REMOTE_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID; } @Override protected void onWork(ApplicationReferenceMetric applicationReferenceMetric) throws WorkerException { @@ -48,13 +48,13 @@ public class ApplicationReferenceMetricRemoteWorker extends AbstractRemoteWorker return Selector.HashCode; } - public static class Factory extends AbstractRemoteWorkerProvider { + public static class Factory extends AbstractRemoteWorkerProvider { public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { super(moduleManager, remoteSenderService, graphId); } - @Override public ApplicationReferenceMetricRemoteWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationReferenceMetricRemoteWorker(moduleManager); + @Override public ApplicationReferenceMinuteMetricRemoteWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceMinuteMetricRemoteWorker(moduleManager); } } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricPersistenceWorker.java new file mode 100644 index 000000000..ac6f3b52a --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricPersistenceWorker.java @@ -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.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.armp.IApplicationReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMonthMetricPersistenceWorker extends PersistenceWorker { + + public ApplicationReferenceMonthMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceMonthMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationReferenceMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceMonthMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricTransformNode.java new file mode 100644 index 000000000..426aee5c4 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMonthMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationReferenceMetric applicationReferenceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToMonth(applicationReferenceMetric.getTimeBucket()); + + ApplicationReferenceMetric newApplicationReferenceMetric = ApplicationReferenceMetricCopy.copy(applicationReferenceMetric); + newApplicationReferenceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationReferenceMetric.getMetricId()); + newApplicationReferenceMetric.setTimeBucket(timeBucket); + next.execute(newApplicationReferenceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/GlobalTraceGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/GlobalTraceGraph.java index 2188b1655..d2579ab27 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/GlobalTraceGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/GlobalTraceGraph.java @@ -18,7 +18,7 @@ package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; 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.module.ModuleManager; @@ -38,7 +38,7 @@ public class GlobalTraceGraph { } public void create() { - GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.GLOBAL_TRACE_GRAPH_ID, GlobalTrace.class) + GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.GLOBAL_TRACE_GRAPH_ID, GlobalTrace.class) .addNode(new GlobalTracePersistenceWorker.Factory(moduleManager).create(workerCreateListener)); } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/GlobalTracePersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/GlobalTracePersistenceWorker.java index ad4fdff7d..bb4bd6472 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/GlobalTracePersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/GlobalTracePersistenceWorker.java @@ -18,9 +18,9 @@ package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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; @@ -30,25 +30,26 @@ import org.apache.skywalking.apm.collector.storage.table.global.GlobalTrace; /** * @author peng-yongsheng */ -public class GlobalTracePersistenceWorker extends PersistenceWorker { +public class GlobalTracePersistenceWorker extends PersistenceWorker { public GlobalTracePersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.GLOBAL_TRACE_PERSISTENCE_WORKER_ID; + return MetricWorkerIdDefine.GLOBAL_TRACE_PERSISTENCE_WORKER_ID; } @Override protected boolean needMergeDBData() { return false; } - @Override protected IPersistenceDAO persistenceDAO() { + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { return getModuleManager().find(StorageModule.NAME).getService(IGlobalTracePersistenceDAO.class); } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/GlobalTraceSpanListener.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/GlobalTraceSpanListener.java index 1a794e0ca..23b293986 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/GlobalTraceSpanListener.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/GlobalTraceSpanListener.java @@ -20,7 +20,7 @@ package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.glob import java.util.ArrayList; import java.util.List; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.FirstSpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.GlobalTraceIdsListener; @@ -69,9 +69,10 @@ public class GlobalTraceSpanListener implements FirstSpanListener, GlobalTraceId @Override public void build() { logger.debug("global trace listener build"); - Graph graph = GraphManager.INSTANCE.findGraph(GraphIdDefine.GLOBAL_TRACE_GRAPH_ID, GlobalTrace.class); + Graph graph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.GLOBAL_TRACE_GRAPH_ID, GlobalTrace.class); for (String globalTraceId : globalTraceIds) { - GlobalTrace globalTrace = new GlobalTrace(segmentId + Const.ID_SPLIT + globalTraceId); + GlobalTrace globalTrace = new GlobalTrace(); + globalTrace.setId(segmentId + Const.ID_SPLIT + globalTraceId); globalTrace.setGlobalTraceId(globalTraceId); globalTrace.setSegmentId(segmentId); globalTrace.setTimeBucket(timeBucket); diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/InstHeartBeatPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/heartbeat/InstHeartBeatPersistenceWorker.java similarity index 80% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/InstHeartBeatPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/heartbeat/InstHeartBeatPersistenceWorker.java index 28491e81f..d157d0a9a 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/InstHeartBeatPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/heartbeat/InstHeartBeatPersistenceWorker.java @@ -16,11 +16,11 @@ * */ -package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.heartbeat; -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.metric.define.graph.MetricWorkerIdDefine; 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; @@ -30,25 +30,26 @@ import org.apache.skywalking.apm.collector.storage.table.register.Instance; /** * @author peng-yongsheng */ -public class InstHeartBeatPersistenceWorker extends PersistenceWorker { +public class InstHeartBeatPersistenceWorker extends PersistenceWorker { public InstHeartBeatPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.INST_HEART_BEAT_PERSISTENCE_WORKER_ID; + return MetricWorkerIdDefine.INST_HEART_BEAT_PERSISTENCE_WORKER_ID; } @Override protected boolean needMergeDBData() { return true; } - @Override protected IPersistenceDAO persistenceDAO() { + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { return getModuleManager().find(StorageModule.NAME).getService(IInstanceHeartBeatPersistenceDAO.class); } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/InstanceHeartBeatPersistenceGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/heartbeat/InstanceHeartBeatPersistenceGraph.java similarity index 84% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/InstanceHeartBeatPersistenceGraph.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/heartbeat/InstanceHeartBeatPersistenceGraph.java index 8caf4f4fb..7eab8f080 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/InstanceHeartBeatPersistenceGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/heartbeat/InstanceHeartBeatPersistenceGraph.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.heartbeat; -import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; 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.module.ModuleManager; @@ -38,7 +38,7 @@ public class InstanceHeartBeatPersistenceGraph { } public void create() { - GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.INSTANCE_HEART_BEAT_PERSISTENCE_GRAPH_ID, Instance.class) + GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.INSTANCE_HEART_BEAT_PERSISTENCE_GRAPH_ID, Instance.class) .addNode(new InstHeartBeatPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingCopy.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingCopy.java new file mode 100644 index 000000000..684d7a418 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingCopy.java @@ -0,0 +1,39 @@ +/* + * 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.metric.provider.worker.instance.mapping; + +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingCopy { + + public static InstanceMapping copy(InstanceMapping instanceMapping) { + InstanceMapping newInstanceMapping = new InstanceMapping(); + newInstanceMapping.setId(instanceMapping.getId()); + newInstanceMapping.setMetricId(instanceMapping.getMetricId()); + + newInstanceMapping.setApplicationId(instanceMapping.getApplicationId()); + newInstanceMapping.setInstanceId(instanceMapping.getInstanceId()); + newInstanceMapping.setAddressId(instanceMapping.getAddressId()); + newInstanceMapping.setTimeBucket(instanceMapping.getTimeBucket()); + return newInstanceMapping; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingDayPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingDayPersistenceWorker.java new file mode 100644 index 000000000..d0f31f981 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingDayPersistenceWorker.java @@ -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.metric.provider.worker.instance.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.impp.IInstanceMappingDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingDayPersistenceWorker extends PersistenceWorker { + + InstanceMappingDayPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_MAPPING_DAY_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceMappingDayPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceMappingDayPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMappingDayPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingDayTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingDayTransformNode.java new file mode 100644 index 000000000..ce0c49c05 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingDayTransformNode.java @@ -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.metric.provider.worker.instance.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.instance.InstanceMapping; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingDayTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_MAPPING_DAY_TRANSFORM_NODE_ID; + } + + @Override public void process(InstanceMapping instanceMapping, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToDay(instanceMapping.getTimeBucket()); + + InstanceMapping newInstanceMapping = InstanceMappingCopy.copy(instanceMapping); + newInstanceMapping.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + instanceMapping.getMetricId()); + newInstanceMapping.setTimeBucket(timeBucket); + next.execute(newInstanceMapping); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntryGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingGraph.java similarity index 53% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntryGraph.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingGraph.java index 86c57a065..0d2cd1bda 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntryGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingGraph.java @@ -16,25 +16,26 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; 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.remote.RemoteModule; import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; /** * @author peng-yongsheng */ -public class ServiceEntryGraph { +public class InstanceMappingGraph { private final ModuleManager moduleManager; private final WorkerCreateListener workerCreateListener; - public ServiceEntryGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) { + public InstanceMappingGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) { this.moduleManager = moduleManager; this.workerCreateListener = workerCreateListener; } @@ -42,9 +43,19 @@ public class ServiceEntryGraph { public void create() { RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); - GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.SERVICE_ENTRY_GRAPH_ID, ServiceEntry.class) - .addNode(new ServiceEntryAggregationWorker.Factory(moduleManager).create(workerCreateListener)) - .addNext(new ServiceEntryRemoteWorker.Factory(moduleManager, remoteSenderService, GraphIdDefine.SERVICE_ENTRY_GRAPH_ID).create(workerCreateListener)) - .addNext(new ServiceEntryPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + Node remoteNode = GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.INSTANCE_MAPPING_GRAPH_ID, InstanceMapping.class) + .addNode(new InstanceMappingMinuteAggregationWorker.Factory(moduleManager).create(workerCreateListener)) + .addNext(new InstanceMappingMinuteRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.INSTANCE_MAPPING_GRAPH_ID).create(workerCreateListener)); + + remoteNode.addNext(new InstanceMappingMinutePersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new InstanceMappingHourTransformNode()) + .addNext(new InstanceMappingHourPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new InstanceMappingDayTransformNode()) + .addNext(new InstanceMappingDayPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new InstanceMappingMonthTransformNode()) + .addNext(new InstanceMappingMonthPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingHourPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingHourPersistenceWorker.java new file mode 100644 index 000000000..9c9307dac --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingHourPersistenceWorker.java @@ -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.metric.provider.worker.instance.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.impp.IInstanceMappingHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingHourPersistenceWorker extends PersistenceWorker { + + InstanceMappingHourPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_MAPPING_HOUR_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceMappingHourPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceMappingHourPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMappingHourPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingHourTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingHourTransformNode.java new file mode 100644 index 000000000..5acc7c389 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingHourTransformNode.java @@ -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.metric.provider.worker.instance.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.instance.InstanceMapping; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingHourTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_MAPPING_HOUR_TRANSFORM_NODE_ID; + } + + @Override public void process(InstanceMapping instanceMapping, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToHour(instanceMapping.getTimeBucket()); + + InstanceMapping newInstanceMapping = InstanceMappingCopy.copy(instanceMapping); + newInstanceMapping.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + instanceMapping.getMetricId()); + newInstanceMapping.setTimeBucket(timeBucket); + next.execute(newInstanceMapping); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntryAggregationWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMinuteAggregationWorker.java similarity index 69% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntryAggregationWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMinuteAggregationWorker.java index 3296dad7c..1154641aa 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntryAggregationWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMinuteAggregationWorker.java @@ -16,35 +16,35 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; import org.apache.skywalking.apm.collector.analysis.worker.model.impl.AggregationWorker; import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; /** * @author peng-yongsheng */ -public class ServiceEntryAggregationWorker extends AggregationWorker { +public class InstanceMappingMinuteAggregationWorker extends AggregationWorker { - public ServiceEntryAggregationWorker(ModuleManager moduleManager) { + InstanceMappingMinuteAggregationWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.SERVICE_ENTRY_AGGREGATION_WORKER_ID; + return MetricWorkerIdDefine.INSTANCE_MAPPING_MINUTE_AGGREGATION_WORKER_ID; } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends AbstractLocalAsyncWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ServiceEntryAggregationWorker workerInstance(ModuleManager moduleManager) { - return new ServiceEntryAggregationWorker(moduleManager); + @Override public InstanceMappingMinuteAggregationWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMappingMinuteAggregationWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMinutePersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMinutePersistenceWorker.java new file mode 100644 index 000000000..3a95ce025 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMinutePersistenceWorker.java @@ -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.metric.provider.worker.instance.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.impp.IInstanceMappingMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingMinutePersistenceWorker extends PersistenceWorker { + + InstanceMappingMinutePersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_MAPPING_MINUTE_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceMappingMinutePersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceMappingMinutePersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMappingMinutePersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMinuteRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMinuteRemoteWorker.java new file mode 100644 index 000000000..ced825b21 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMinuteRemoteWorker.java @@ -0,0 +1,60 @@ +/* + * 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.metric.provider.worker.instance.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.instance.InstanceMapping; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingMinuteRemoteWorker extends AbstractRemoteWorker { + + InstanceMappingMinuteRemoteWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_MAPPING_MINUTE_REMOTE_WORKER_ID; + } + + @Override protected void onWork(InstanceMapping instanceMapping) throws WorkerException { + onNext(instanceMapping); + } + + @Override public Selector selector() { + return Selector.HashCode; + } + + public static class Factory extends AbstractRemoteWorkerProvider { + public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { + super(moduleManager, remoteSenderService, graphId); + } + + @Override public InstanceMappingMinuteRemoteWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMappingMinuteRemoteWorker(moduleManager); + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMonthPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMonthPersistenceWorker.java new file mode 100644 index 000000000..0752040c4 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMonthPersistenceWorker.java @@ -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.metric.provider.worker.instance.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.impp.IInstanceMappingMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingMonthPersistenceWorker extends PersistenceWorker { + + InstanceMappingMonthPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_MAPPING_MONTH_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceMappingMonthPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceMappingMonthPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMappingMonthPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMonthTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMonthTransformNode.java new file mode 100644 index 000000000..46cd30631 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingMonthTransformNode.java @@ -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.metric.provider.worker.instance.mapping; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.instance.InstanceMapping; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingMonthTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_MAPPING_MONTH_TRANSFORM_NODE_ID; + } + + @Override public void process(InstanceMapping instanceMapping, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToMonth(instanceMapping.getTimeBucket()); + + InstanceMapping newInstanceMapping = InstanceMappingCopy.copy(instanceMapping); + newInstanceMapping.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + instanceMapping.getMetricId()); + newInstanceMapping.setTimeBucket(timeBucket); + next.execute(newInstanceMapping); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntrySpanListener.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingSpanListener.java similarity index 52% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntrySpanListener.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingSpanListener.java index 6bf47b33d..39034b332 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntrySpanListener.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/mapping/InstanceMappingSpanListener.java @@ -16,53 +16,47 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.EntrySpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.FirstSpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListenerFactory; -import org.apache.skywalking.apm.collector.cache.CacheModule; -import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; 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.module.ModuleManager; 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.service.ServiceEntry; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ -public class ServiceEntrySpanListener implements FirstSpanListener, EntrySpanListener { +public class InstanceMappingSpanListener implements FirstSpanListener, EntrySpanListener { - private final Logger logger = LoggerFactory.getLogger(ServiceEntrySpanListener.class); + private final Logger logger = LoggerFactory.getLogger(InstanceMappingSpanListener.class); + private List instanceMappings = new LinkedList<>(); private long timeBucket; - private boolean hasReference = false; - private int applicationId; - private int entryServiceId; - private String entryServiceName; - private boolean hasEntry = false; - private final ServiceNameCacheService serviceNameCacheService; - public ServiceEntrySpanListener(ModuleManager moduleManager) { - this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class); - } - - @Override - public void parseEntry(SpanDecorator spanDecorator, int applicationId, int instanceId, - String segmentId) { - this.applicationId = applicationId; - this.entryServiceId = spanDecorator.getOperationNameId(); - this.entryServiceName = serviceNameCacheService.getSplitServiceName(serviceNameCacheService.get(entryServiceId)); - this.hasEntry = true; + @Override public void parseEntry(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) { + logger.debug("instance mapping listener parse reference"); if (spanDecorator.getRefsCount() > 0) { - this.hasReference = true; + for (int i = 0; i < spanDecorator.getRefsCount(); i++) { + InstanceMapping instanceMapping = new InstanceMapping(); + instanceMapping.setApplicationId(applicationId); + instanceMapping.setInstanceId(instanceId); + instanceMapping.setAddressId(spanDecorator.getRefs(i).getNetworkAddressId()); + String metricId = String.valueOf(instanceId) + Const.ID_SPLIT + String.valueOf(instanceMapping.getAddressId()); + instanceMapping.setMetricId(metricId); + instanceMappings.add(instanceMapping); + } } } @@ -73,24 +67,19 @@ public class ServiceEntrySpanListener implements FirstSpanListener, EntrySpanLis } @Override public void build() { - logger.debug("entry service listener build"); - if (!hasReference && hasEntry) { - ServiceEntry serviceEntry = new ServiceEntry(applicationId + Const.ID_SPLIT + entryServiceId); - serviceEntry.setApplicationId(applicationId); - serviceEntry.setEntryServiceId(entryServiceId); - serviceEntry.setEntryServiceName(entryServiceName); - serviceEntry.setRegisterTime(timeBucket); - serviceEntry.setNewestTime(timeBucket); - - logger.debug("push to service entry aggregation worker, id: {}", serviceEntry.getId()); - Graph graph = GraphManager.INSTANCE.findGraph(GraphIdDefine.SERVICE_ENTRY_GRAPH_ID, ServiceEntry.class); - graph.start(serviceEntry); - } + logger.debug("instance mapping listener build"); + Graph graph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.INSTANCE_MAPPING_GRAPH_ID, InstanceMapping.class); + instanceMappings.forEach(instanceMapping -> { + instanceMapping.setId(timeBucket + Const.ID_SPLIT + instanceMapping.getMetricId()); + instanceMapping.setTimeBucket(timeBucket); + logger.debug("push to instance mapping aggregation worker, id: {}", instanceMapping.getId()); + graph.start(instanceMapping); + }); } public static class Factory implements SpanListenerFactory { @Override public SpanListener create(ModuleManager moduleManager) { - return new ServiceEntrySpanListener(moduleManager); + return new InstanceMappingSpanListener(); } } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceReferencePersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceDayMetricPersistenceWorker.java similarity index 68% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceReferencePersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceDayMetricPersistenceWorker.java index a88c0e798..e65280be1 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceReferencePersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceDayMetricPersistenceWorker.java @@ -16,46 +16,47 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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.IInstanceReferenceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; /** * @author peng-yongsheng */ -public class InstanceReferencePersistenceWorker extends PersistenceWorker { +public class InstanceDayMetricPersistenceWorker extends PersistenceWorker { - public InstanceReferencePersistenceWorker(ModuleManager moduleManager) { + public InstanceDayMetricPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.INSTANCE_REFERENCE_METRIC_PERSISTENCE_WORKER_ID; - } - - @Override protected IPersistenceDAO persistenceDAO() { - return getModuleManager().find(StorageModule.NAME).getService(IInstanceReferenceMetricPersistenceDAO.class); + return MetricWorkerIdDefine.INSTANCE_DAY_METRIC_PERSISTENCE_WORKER_ID; } @Override protected boolean needMergeDBData() { return true; } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceDayMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public InstanceReferencePersistenceWorker workerInstance(ModuleManager moduleManager) { - return new InstanceReferencePersistenceWorker(moduleManager); + @Override public InstanceDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceDayMetricPersistenceWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceDayMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceDayMetricTransformNode.java new file mode 100644 index 000000000..5d4859ebb --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceDayMetricTransformNode.java @@ -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.metric.provider.worker.instance.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.instance.InstanceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceDayMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_DAY_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(InstanceMetric instanceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToDay(instanceMetric.getTimeBucket()); + + InstanceMetric newInstanceMetric = InstanceMetricCopy.copy(instanceMetric); + newInstanceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + instanceMetric.getMetricId()); + newInstanceMetric.setTimeBucket(timeBucket); + next.execute(newInstanceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceHourMetricPersistenceWorker.java similarity index 67% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceMetricPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceHourMetricPersistenceWorker.java index 7f154df42..0250bf130 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceMetricPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceHourMetricPersistenceWorker.java @@ -16,46 +16,47 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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.IInstanceMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceHourMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; /** * @author peng-yongsheng */ -public class InstanceMetricPersistenceWorker extends PersistenceWorker { +public class InstanceHourMetricPersistenceWorker extends PersistenceWorker { - public InstanceMetricPersistenceWorker(ModuleManager moduleManager) { + public InstanceHourMetricPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.INSTANCE_METRIC_PERSISTENCE_WORKER_ID; + return MetricWorkerIdDefine.INSTANCE_HOUR_METRIC_PERSISTENCE_WORKER_ID; } @Override protected boolean needMergeDBData() { return true; } - @Override protected IPersistenceDAO persistenceDAO() { - return getModuleManager().find(StorageModule.NAME).getService(IInstanceMetricPersistenceDAO.class); + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceHourMetricPersistenceDAO.class); } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public InstanceMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { - return new InstanceMetricPersistenceWorker(moduleManager); + @Override public InstanceHourMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceHourMetricPersistenceWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceHourMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceHourMetricTransformNode.java new file mode 100644 index 000000000..ac947cc34 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceHourMetricTransformNode.java @@ -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.metric.provider.worker.instance.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.instance.InstanceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceHourMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_HOUR_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(InstanceMetric instanceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToHour(instanceMetric.getTimeBucket()); + + InstanceMetric newInstanceMetric = InstanceMetricCopy.copy(instanceMetric); + newInstanceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + instanceMetric.getMetricId()); + newInstanceMetric.setTimeBucket(timeBucket); + next.execute(newInstanceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMetricCopy.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMetricCopy.java new file mode 100644 index 000000000..0c4c5142c --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMetricCopy.java @@ -0,0 +1,55 @@ +/* + * 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.metric.provider.worker.instance.metric; + +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceMetricCopy { + + public static InstanceMetric copy(InstanceMetric instanceMetric) { + InstanceMetric newInstanceMetric = new InstanceMetric(); + newInstanceMetric.setId(instanceMetric.getId()); + newInstanceMetric.setMetricId(instanceMetric.getMetricId()); + newInstanceMetric.setSourceValue(instanceMetric.getSourceValue()); + + newInstanceMetric.setApplicationId(instanceMetric.getApplicationId()); + newInstanceMetric.setInstanceId(instanceMetric.getInstanceId()); + + newInstanceMetric.setTransactionCalls(instanceMetric.getTransactionCalls()); + newInstanceMetric.setTransactionDurationSum(instanceMetric.getTransactionDurationSum()); + newInstanceMetric.setTransactionErrorCalls(instanceMetric.getTransactionErrorCalls()); + newInstanceMetric.setTransactionErrorDurationSum(instanceMetric.getTransactionErrorDurationSum()); + + newInstanceMetric.setBusinessTransactionCalls(instanceMetric.getBusinessTransactionCalls()); + newInstanceMetric.setBusinessTransactionDurationSum(instanceMetric.getBusinessTransactionDurationSum()); + newInstanceMetric.setBusinessTransactionErrorCalls(instanceMetric.getBusinessTransactionErrorCalls()); + newInstanceMetric.setBusinessTransactionErrorDurationSum(instanceMetric.getBusinessTransactionErrorDurationSum()); + + newInstanceMetric.setMqTransactionCalls(instanceMetric.getMqTransactionCalls()); + newInstanceMetric.setMqTransactionDurationSum(instanceMetric.getMqTransactionDurationSum()); + newInstanceMetric.setMqTransactionErrorCalls(instanceMetric.getMqTransactionErrorCalls()); + newInstanceMetric.setMqTransactionErrorDurationSum(instanceMetric.getMqTransactionErrorDurationSum()); + + newInstanceMetric.setTimeBucket(instanceMetric.getTimeBucket()); + return newInstanceMetric; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceMetricGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMetricGraph.java similarity index 62% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceMetricGraph.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMetricGraph.java index c5d93b0fd..68ff79a9d 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceMetricGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMetricGraph.java @@ -16,18 +16,20 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +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.Node; 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.instance.InstanceMetric; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; /** @@ -46,22 +48,32 @@ public class InstanceMetricGraph { public void create() { RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); - Graph graph = GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.INSTANCE_METRIC_GRAPH_ID, InstanceReferenceMetric.class); + Graph graph = GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.INSTANCE_METRIC_GRAPH_ID, InstanceReferenceMetric.class); - graph.addNode(new InstanceMetricAggregationWorker.Factory(moduleManager).create(workerCreateListener)) - .addNext(new InstanceMetricRemoteWorker.Factory(moduleManager, remoteSenderService, GraphIdDefine.INSTANCE_METRIC_GRAPH_ID).create(workerCreateListener)) - .addNext(new InstanceMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + Node remoteNode = graph.addNode(new InstanceMinuteMetricAggregationWorker.Factory(moduleManager).create(workerCreateListener)) + .addNext(new InstanceMinuteMetricRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.INSTANCE_METRIC_GRAPH_ID).create(workerCreateListener)); + + remoteNode.addNext(new InstanceMinuteMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new InstanceHourMetricTransformNode()) + .addNext(new InstanceHourMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new InstanceDayMetricTransformNode()) + .addNext(new InstanceDayMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new InstanceMonthMetricTransformNode()) + .addNext(new InstanceMonthMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); link(graph); } private void link(Graph graph) { - GraphManager.INSTANCE.findGraph(GraphIdDefine.INSTANCE_REFERENCE_METRIC_GRAPH_ID, InstanceReferenceMetric.class) - .toFinder().findNode(WorkerIdDefine.INSTANCE_REFERENCE_METRIC_AGGREGATION_WORKER_ID, InstanceReferenceMetric.class) + GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.INSTANCE_REFERENCE_METRIC_GRAPH_ID, InstanceReferenceMetric.class) + .toFinder().findNode(MetricWorkerIdDefine.INSTANCE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID, InstanceReferenceMetric.class) .addNext(new NodeProcessor() { @Override public int id() { - return WorkerIdDefine.INSTANCE_METRIC_GRAPH_BRIDGE_WORKER_ID; + return MetricWorkerIdDefine.INSTANCE_METRIC_GRAPH_BRIDGE_WORKER_ID; } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceMetricAggregationWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMinuteMetricAggregationWorker.java similarity index 76% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceMetricAggregationWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMinuteMetricAggregationWorker.java index d9c295177..ff0f92a50 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceMetricAggregationWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMinuteMetricAggregationWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; import org.apache.skywalking.apm.collector.analysis.worker.model.impl.AggregationWorker; import org.apache.skywalking.apm.collector.core.module.ModuleManager; @@ -29,21 +29,27 @@ import org.apache.skywalking.apm.collector.storage.table.instance.InstanceRefere /** * @author peng-yongsheng */ -public class InstanceMetricAggregationWorker extends AggregationWorker { +public class InstanceMinuteMetricAggregationWorker extends AggregationWorker { - public InstanceMetricAggregationWorker(ModuleManager moduleManager) { + public InstanceMinuteMetricAggregationWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.INSTANCE_METRIC_AGGREGATION_WORKER_ID; + return MetricWorkerIdDefine.INSTANCE_MINUTE_METRIC_AGGREGATION_WORKER_ID; } @Override protected InstanceMetric transform(InstanceReferenceMetric instanceReferenceMetric) { - String id = instanceReferenceMetric.getTimeBucket() + Const.ID_SPLIT + instanceReferenceMetric.getBehindInstanceId(); + String metricId = instanceReferenceMetric.getBehindInstanceId() + Const.ID_SPLIT + instanceReferenceMetric.getSourceValue(); + String id = instanceReferenceMetric.getTimeBucket() + Const.ID_SPLIT + metricId; - InstanceMetric instanceMetric = new InstanceMetric(id); + InstanceMetric instanceMetric = new InstanceMetric(); + instanceMetric.setId(id); + instanceMetric.setMetricId(metricId); + + instanceMetric.setApplicationId(instanceReferenceMetric.getBehindApplicationId()); instanceMetric.setInstanceId(instanceReferenceMetric.getBehindInstanceId()); + instanceMetric.setSourceValue(instanceReferenceMetric.getSourceValue()); instanceMetric.setTransactionCalls(instanceReferenceMetric.getTransactionCalls()); instanceMetric.setTransactionErrorCalls(instanceReferenceMetric.getTransactionErrorCalls()); @@ -64,14 +70,14 @@ public class InstanceMetricAggregationWorker extends AggregationWorker { + public static class Factory extends AbstractLocalAsyncWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public InstanceMetricAggregationWorker workerInstance(ModuleManager moduleManager) { - return new InstanceMetricAggregationWorker(moduleManager); + @Override public InstanceMinuteMetricAggregationWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMinuteMetricAggregationWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMinuteMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMinuteMetricPersistenceWorker.java new file mode 100644 index 000000000..7b92c606f --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMinuteMetricPersistenceWorker.java @@ -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.metric.provider.worker.instance.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.imp.IInstanceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceMinuteMetricPersistenceWorker extends PersistenceWorker { + + public InstanceMinuteMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceMinuteMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMinuteMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceMetricRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMinuteMetricRemoteWorker.java similarity index 78% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceMetricRemoteWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMinuteMetricRemoteWorker.java index bd500340f..1d3255436 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceMetricRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMinuteMetricRemoteWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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; @@ -30,14 +30,14 @@ import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric /** * @author peng-yongsheng */ -public class InstanceMetricRemoteWorker extends AbstractRemoteWorker { +public class InstanceMinuteMetricRemoteWorker extends AbstractRemoteWorker { - public InstanceMetricRemoteWorker(ModuleManager moduleManager) { + public InstanceMinuteMetricRemoteWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.INSTANCE_METRIC_REMOTE_WORKER_ID; + return MetricWorkerIdDefine.INSTANCE_MINUTE_METRIC_REMOTE_WORKER_ID; } @Override public Selector selector() { @@ -48,14 +48,14 @@ public class InstanceMetricRemoteWorker extends AbstractRemoteWorker { + public static class Factory extends AbstractRemoteWorkerProvider { public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { super(moduleManager, remoteSenderService, graphId); } - @Override public InstanceMetricRemoteWorker workerInstance(ModuleManager moduleManager) { - return new InstanceMetricRemoteWorker(moduleManager); + @Override public InstanceMinuteMetricRemoteWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMinuteMetricRemoteWorker(moduleManager); } } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMonthMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMonthMetricPersistenceWorker.java new file mode 100644 index 000000000..d11f82776 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMonthMetricPersistenceWorker.java @@ -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.metric.provider.worker.instance.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.imp.IInstanceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceMonthMetricPersistenceWorker extends PersistenceWorker { + + public InstanceMonthMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_MONTH_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceMonthMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMonthMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMonthMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMonthMetricTransformNode.java new file mode 100644 index 000000000..6bf9a83a6 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/metric/InstanceMonthMetricTransformNode.java @@ -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.metric.provider.worker.instance.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.instance.InstanceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceMonthMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_MONTH_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(InstanceMetric instanceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToMonth(instanceMetric.getTimeBucket()); + + InstanceMetric newInstanceMetric = InstanceMetricCopy.copy(instanceMetric); + newInstanceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + instanceMetric.getMetricId()); + newInstanceMetric.setTimeBucket(timeBucket); + next.execute(newInstanceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceDayMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceDayMetricPersistenceWorker.java new file mode 100644 index 000000000..2cbd7c101 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceDayMetricPersistenceWorker.java @@ -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.metric.provider.worker.instance.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.irmp.IInstanceReferenceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceDayMetricPersistenceWorker extends PersistenceWorker { + + public InstanceReferenceDayMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceReferenceDayMetricPersistenceDAO.class); + } + + @Override protected boolean needMergeDBData() { + return true; + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceReferenceDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceReferenceDayMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceDayMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceDayMetricTransformNode.java new file mode 100644 index 000000000..0fa8e9d26 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceDayMetricTransformNode.java @@ -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.metric.provider.worker.instance.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.instance.InstanceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceDayMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(InstanceReferenceMetric instanceReferenceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToDay(instanceReferenceMetric.getTimeBucket()); + + InstanceReferenceMetric newInstanceReferenceMetric = InstanceReferenceMetricCopy.copy(instanceReferenceMetric); + newInstanceReferenceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + instanceReferenceMetric.getMetricId()); + newInstanceReferenceMetric.setTimeBucket(timeBucket); + next.execute(newInstanceReferenceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceHourMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceHourMetricPersistenceWorker.java new file mode 100644 index 000000000..f5b26726a --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceHourMetricPersistenceWorker.java @@ -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.metric.provider.worker.instance.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.irmp.IInstanceReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceHourMetricPersistenceWorker extends PersistenceWorker { + + public InstanceReferenceHourMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceReferenceHourMetricPersistenceDAO.class); + } + + @Override protected boolean needMergeDBData() { + return true; + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceReferenceHourMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceReferenceHourMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceHourMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceHourMetricTransformNode.java new file mode 100644 index 000000000..363506200 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceHourMetricTransformNode.java @@ -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.metric.provider.worker.instance.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.instance.InstanceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceHourMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(InstanceReferenceMetric instanceReferenceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToHour(instanceReferenceMetric.getTimeBucket()); + + InstanceReferenceMetric newInstanceReferenceMetric = InstanceReferenceMetricCopy.copy(instanceReferenceMetric); + newInstanceReferenceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + instanceReferenceMetric.getMetricId()); + newInstanceReferenceMetric.setTimeBucket(timeBucket); + next.execute(newInstanceReferenceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMetricCopy.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMetricCopy.java new file mode 100644 index 000000000..5a3457003 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMetricCopy.java @@ -0,0 +1,58 @@ +/* + * 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.metric.provider.worker.instance.refmetric; + +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceMetricCopy { + + public static InstanceReferenceMetric copy(InstanceReferenceMetric instanceReferenceMetric) { + InstanceReferenceMetric newInstanceReferenceMetric = new InstanceReferenceMetric(); + newInstanceReferenceMetric.setId(instanceReferenceMetric.getId()); + newInstanceReferenceMetric.setMetricId(instanceReferenceMetric.getMetricId()); + newInstanceReferenceMetric.setSourceValue(instanceReferenceMetric.getSourceValue()); + + newInstanceReferenceMetric.setFrontApplicationId(instanceReferenceMetric.getFrontApplicationId()); + newInstanceReferenceMetric.setFrontInstanceId(instanceReferenceMetric.getFrontInstanceId()); + newInstanceReferenceMetric.setBehindApplicationId(instanceReferenceMetric.getBehindApplicationId()); + newInstanceReferenceMetric.setBehindInstanceId(instanceReferenceMetric.getBehindInstanceId()); + + newInstanceReferenceMetric.setTransactionCalls(instanceReferenceMetric.getTransactionCalls()); + newInstanceReferenceMetric.setTransactionDurationSum(instanceReferenceMetric.getTransactionDurationSum()); + newInstanceReferenceMetric.setTransactionErrorCalls(instanceReferenceMetric.getTransactionErrorCalls()); + newInstanceReferenceMetric.setTransactionErrorDurationSum(instanceReferenceMetric.getTransactionErrorDurationSum()); + + newInstanceReferenceMetric.setBusinessTransactionCalls(instanceReferenceMetric.getBusinessTransactionCalls()); + newInstanceReferenceMetric.setBusinessTransactionDurationSum(instanceReferenceMetric.getBusinessTransactionDurationSum()); + newInstanceReferenceMetric.setBusinessTransactionErrorCalls(instanceReferenceMetric.getBusinessTransactionErrorCalls()); + newInstanceReferenceMetric.setBusinessTransactionErrorDurationSum(instanceReferenceMetric.getBusinessTransactionErrorDurationSum()); + + newInstanceReferenceMetric.setMqTransactionCalls(instanceReferenceMetric.getMqTransactionCalls()); + newInstanceReferenceMetric.setMqTransactionDurationSum(instanceReferenceMetric.getMqTransactionDurationSum()); + newInstanceReferenceMetric.setMqTransactionErrorCalls(instanceReferenceMetric.getMqTransactionErrorCalls()); + newInstanceReferenceMetric.setMqTransactionErrorDurationSum(instanceReferenceMetric.getMqTransactionErrorDurationSum()); + + newInstanceReferenceMetric.setTimeBucket(instanceReferenceMetric.getTimeBucket()); + + return newInstanceReferenceMetric; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceReferenceMetricGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMetricGraph.java similarity index 60% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceReferenceMetricGraph.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMetricGraph.java index d75e8e4da..8a9fa79ae 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceReferenceMetricGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMetricGraph.java @@ -16,18 +16,20 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.refmetric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +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.Node; 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.instance.InstanceReferenceMetric; import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; /** @@ -46,21 +48,31 @@ public class InstanceReferenceMetricGraph { public void create() { RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); - Graph graph = GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.INSTANCE_REFERENCE_METRIC_GRAPH_ID, ServiceReferenceMetric.class); + Graph graph = GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.INSTANCE_REFERENCE_METRIC_GRAPH_ID, ServiceReferenceMetric.class); - graph.addNode(new InstanceReferenceMetricAggregationWorker.Factory(moduleManager).create(workerCreateListener)) - .addNext(new InstanceReferenceMetricRemoteWorker.Factory(moduleManager, remoteSenderService, GraphIdDefine.INSTANCE_REFERENCE_METRIC_GRAPH_ID).create(workerCreateListener)) - .addNext(new InstanceReferencePersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + Node remoteNode = graph.addNode(new InstanceReferenceMinuteMetricAggregationWorker.Factory(moduleManager).create(workerCreateListener)) + .addNext(new InstanceReferenceMinuteMetricRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.INSTANCE_REFERENCE_METRIC_GRAPH_ID).create(workerCreateListener)); + + remoteNode.addNext(new InstanceReferenceMinuteMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new InstanceReferenceHourMetricTransformNode()) + .addNext(new InstanceReferenceHourMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new InstanceReferenceDayMetricTransformNode()) + .addNext(new InstanceReferenceDayMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new InstanceReferenceMonthMetricTransformNode()) + .addNext(new InstanceReferenceMonthMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); link(graph); } private void link(Graph graph) { - GraphManager.INSTANCE.findGraph(GraphIdDefine.SERVICE_REFERENCE_METRIC_GRAPH_ID, ServiceReferenceMetric.class) - .toFinder().findNode(WorkerIdDefine.SERVICE_REFERENCE_METRIC_AGGREGATION_WORKER_ID, ServiceReferenceMetric.class) + GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.SERVICE_REFERENCE_METRIC_GRAPH_ID, ServiceReferenceMetric.class) + .toFinder().findNode(MetricWorkerIdDefine.SERVICE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID, ServiceReferenceMetric.class) .addNext(new NodeProcessor() { @Override public int id() { - return WorkerIdDefine.INSTANCE_REFERENCE_GRAPH_BRIDGE_WORKER_ID; + return MetricWorkerIdDefine.INSTANCE_REFERENCE_GRAPH_BRIDGE_WORKER_ID; } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceReferenceMetricAggregationWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMinuteMetricAggregationWorker.java similarity index 75% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceReferenceMetricAggregationWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMinuteMetricAggregationWorker.java index 4d7a67a37..04b6238f3 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceReferenceMetricAggregationWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMinuteMetricAggregationWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.refmetric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; import org.apache.skywalking.apm.collector.analysis.worker.model.impl.AggregationWorker; import org.apache.skywalking.apm.collector.core.module.ModuleManager; @@ -29,22 +29,32 @@ import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenc /** * @author peng-yongsheng */ -public class InstanceReferenceMetricAggregationWorker extends AggregationWorker { +public class InstanceReferenceMinuteMetricAggregationWorker extends AggregationWorker { - public InstanceReferenceMetricAggregationWorker(ModuleManager moduleManager) { + public InstanceReferenceMinuteMetricAggregationWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.INSTANCE_REFERENCE_METRIC_AGGREGATION_WORKER_ID; + return MetricWorkerIdDefine.INSTANCE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID; } @Override protected InstanceReferenceMetric transform(ServiceReferenceMetric serviceReferenceMetric) { - String id = serviceReferenceMetric.getTimeBucket() + Const.ID_SPLIT + serviceReferenceMetric.getFrontInstanceId() + Const.ID_SPLIT + serviceReferenceMetric.getBehindInstanceId(); + String metricId = serviceReferenceMetric.getFrontInstanceId() + + Const.ID_SPLIT + serviceReferenceMetric.getBehindInstanceId() + + Const.ID_SPLIT + serviceReferenceMetric.getSourceValue(); - InstanceReferenceMetric instanceReferenceMetric = new InstanceReferenceMetric(id); + String id = serviceReferenceMetric.getTimeBucket() + + Const.ID_SPLIT + metricId; + + InstanceReferenceMetric instanceReferenceMetric = new InstanceReferenceMetric(); + instanceReferenceMetric.setId(id); + instanceReferenceMetric.setMetricId(metricId); + instanceReferenceMetric.setFrontApplicationId(serviceReferenceMetric.getFrontApplicationId()); instanceReferenceMetric.setFrontInstanceId(serviceReferenceMetric.getFrontInstanceId()); + instanceReferenceMetric.setBehindApplicationId(serviceReferenceMetric.getBehindApplicationId()); instanceReferenceMetric.setBehindInstanceId(serviceReferenceMetric.getBehindInstanceId()); + instanceReferenceMetric.setSourceValue(serviceReferenceMetric.getSourceValue()); instanceReferenceMetric.setTransactionCalls(serviceReferenceMetric.getTransactionCalls()); instanceReferenceMetric.setTransactionErrorCalls(serviceReferenceMetric.getTransactionErrorCalls()); @@ -61,19 +71,18 @@ public class InstanceReferenceMetricAggregationWorker extends AggregationWorker< instanceReferenceMetric.setMqTransactionDurationSum(instanceReferenceMetric.getMqTransactionDurationSum()); instanceReferenceMetric.setMqTransactionErrorDurationSum(instanceReferenceMetric.getMqTransactionErrorDurationSum()); - instanceReferenceMetric.setSourceValue(serviceReferenceMetric.getSourceValue()); instanceReferenceMetric.setTimeBucket(serviceReferenceMetric.getTimeBucket()); return instanceReferenceMetric; } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends AbstractLocalAsyncWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public InstanceReferenceMetricAggregationWorker workerInstance(ModuleManager moduleManager) { - return new InstanceReferenceMetricAggregationWorker(moduleManager); + @Override public InstanceReferenceMinuteMetricAggregationWorker workerInstance(ModuleManager moduleManager) { + return new InstanceReferenceMinuteMetricAggregationWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMinuteMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMinuteMetricPersistenceWorker.java new file mode 100644 index 000000000..c38aa3d27 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMinuteMetricPersistenceWorker.java @@ -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.metric.provider.worker.instance.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.irmp.IInstanceReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceMinuteMetricPersistenceWorker extends PersistenceWorker { + + public InstanceReferenceMinuteMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceReferenceMinuteMetricPersistenceDAO.class); + } + + @Override protected boolean needMergeDBData() { + return true; + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceReferenceMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceReferenceMinuteMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceReferenceMetricRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMinuteMetricRemoteWorker.java similarity index 78% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceReferenceMetricRemoteWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMinuteMetricRemoteWorker.java index d21f44b6b..0ee660948 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/InstanceReferenceMetricRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMinuteMetricRemoteWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.refmetric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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; @@ -30,14 +30,14 @@ import org.apache.skywalking.apm.collector.storage.table.instance.InstanceRefere /** * @author peng-yongsheng */ -public class InstanceReferenceMetricRemoteWorker extends AbstractRemoteWorker { +public class InstanceReferenceMinuteMetricRemoteWorker extends AbstractRemoteWorker { - public InstanceReferenceMetricRemoteWorker(ModuleManager moduleManager) { + public InstanceReferenceMinuteMetricRemoteWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.INSTANCE_REFERENCE_METRIC_REMOTE_WORKER_ID; + return MetricWorkerIdDefine.INSTANCE_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID; } @Override public Selector selector() { @@ -48,14 +48,14 @@ public class InstanceReferenceMetricRemoteWorker extends AbstractRemoteWorker { + public static class Factory extends AbstractRemoteWorkerProvider { public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { super(moduleManager, remoteSenderService, graphId); } - @Override public InstanceReferenceMetricRemoteWorker workerInstance(ModuleManager moduleManager) { - return new InstanceReferenceMetricRemoteWorker(moduleManager); + @Override public InstanceReferenceMinuteMetricRemoteWorker workerInstance(ModuleManager moduleManager) { + return new InstanceReferenceMinuteMetricRemoteWorker(moduleManager); } } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMonthMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMonthMetricPersistenceWorker.java new file mode 100644 index 000000000..03972af00 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMonthMetricPersistenceWorker.java @@ -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.metric.provider.worker.instance.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.irmp.IInstanceReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceMonthMetricPersistenceWorker extends PersistenceWorker { + + public InstanceReferenceMonthMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceReferenceMonthMetricPersistenceDAO.class); + } + + @Override protected boolean needMergeDBData() { + return true; + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceReferenceMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceReferenceMonthMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMonthMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMonthMetricTransformNode.java new file mode 100644 index 000000000..dfad097cc --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/instance/refmetric/InstanceReferenceMonthMetricTransformNode.java @@ -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.metric.provider.worker.instance.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.instance.InstanceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceMonthMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.INSTANCE_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(InstanceReferenceMetric instanceReferenceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToMonth(instanceReferenceMetric.getTimeBucket()); + + InstanceReferenceMetric newInstanceReferenceMetric = InstanceReferenceMetricCopy.copy(instanceReferenceMetric); + newInstanceReferenceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + instanceReferenceMetric.getMetricId()); + newInstanceReferenceMetric.setTimeBucket(timeBucket); + next.execute(newInstanceReferenceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostGraph.java index f40c80234..badd115a0 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostGraph.java @@ -18,7 +18,7 @@ package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; 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.module.ModuleManager; @@ -38,7 +38,7 @@ public class SegmentCostGraph { } public void create() { - GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.SEGMENT_COST_GRAPH_ID, SegmentCost.class) + GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.SEGMENT_COST_GRAPH_ID, SegmentCost.class) .addNode(new SegmentCostPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostPersistenceWorker.java index a58565462..aa6093627 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostPersistenceWorker.java @@ -18,9 +18,9 @@ package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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; @@ -30,25 +30,26 @@ import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost; /** * @author peng-yongsheng */ -public class SegmentCostPersistenceWorker extends PersistenceWorker { +public class SegmentCostPersistenceWorker extends PersistenceWorker { public SegmentCostPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.SEGMENT_COST_PERSISTENCE_WORKER_ID; + return MetricWorkerIdDefine.SEGMENT_COST_PERSISTENCE_WORKER_ID; } @Override protected boolean needMergeDBData() { return false; } - @Override protected IPersistenceDAO persistenceDAO() { + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { return getModuleManager().find(StorageModule.NAME).getService(ISegmentCostPersistenceDAO.class); } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostSpanListener.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostSpanListener.java index 03b5aa94b..9c16671e8 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostSpanListener.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostSpanListener.java @@ -20,7 +20,7 @@ package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segm import java.util.ArrayList; import java.util.List; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.EntrySpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.ExitSpanListener; @@ -33,7 +33,6 @@ import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService 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.module.ModuleManager; -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.segment.SegmentCost; import org.slf4j.Logger; @@ -61,13 +60,13 @@ public class SegmentCostSpanListener implements EntrySpanListener, ExitSpanListe String segmentId) { timeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(spanDecorator.getStartTime()); - SegmentCost segmentCost = new SegmentCost(Const.EMPTY_STRING); + SegmentCost segmentCost = new SegmentCost(); + segmentCost.setId(segmentId); segmentCost.setSegmentId(segmentId); segmentCost.setApplicationId(applicationId); segmentCost.setCost(spanDecorator.getEndTime() - spanDecorator.getStartTime()); segmentCost.setStartTime(spanDecorator.getStartTime()); segmentCost.setEndTime(spanDecorator.getEndTime()); - segmentCost.setId(segmentId); if (spanDecorator.getOperationNameId() == 0) { segmentCost.setServiceName(spanDecorator.getOperationName()); } else { @@ -96,7 +95,7 @@ public class SegmentCostSpanListener implements EntrySpanListener, ExitSpanListe } @Override public void build() { - Graph graph = GraphManager.INSTANCE.findGraph(GraphIdDefine.SEGMENT_COST_GRAPH_ID, SegmentCost.class); + Graph graph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.SEGMENT_COST_GRAPH_ID, SegmentCost.class); logger.debug("segment cost listener build"); for (SegmentCost segmentCost : segmentCosts) { segmentCost.setIsError(isError); diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceDayMetricPersistenceWorker.java similarity index 67% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceMetricPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceDayMetricPersistenceWorker.java index d6038a03a..fb2e112d3 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceMetricPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceDayMetricPersistenceWorker.java @@ -16,46 +16,47 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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.IServiceMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceDayMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; /** * @author peng-yongsheng */ -public class ServiceMetricPersistenceWorker extends PersistenceWorker { +public class ServiceDayMetricPersistenceWorker extends PersistenceWorker { - public ServiceMetricPersistenceWorker(ModuleManager moduleManager) { + public ServiceDayMetricPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.SERVICE_METRIC_PERSISTENCE_WORKER_ID; + return MetricWorkerIdDefine.SERVICE_DAY_METRIC_PERSISTENCE_WORKER_ID; } - @Override protected IPersistenceDAO persistenceDAO() { - return getModuleManager().find(StorageModule.NAME).getService(IServiceMetricPersistenceDAO.class); + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IServiceDayMetricPersistenceDAO.class); } @Override protected boolean needMergeDBData() { return true; } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ServiceMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { - return new ServiceMetricPersistenceWorker(moduleManager); + @Override public ServiceDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ServiceDayMetricPersistenceWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceDayMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceDayMetricTransformNode.java new file mode 100644 index 000000000..fcffa5ec7 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceDayMetricTransformNode.java @@ -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.metric.provider.worker.service.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.service.ServiceMetric; + +/** + * @author peng-yongsheng + */ +public class ServiceDayMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.SERVICE_DAY_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(ServiceMetric serviceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToDay(serviceMetric.getTimeBucket()); + + ServiceMetric newServiceMetric = ServiceMetricCopy.copy(serviceMetric); + newServiceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + serviceMetric.getMetricId()); + newServiceMetric.setTimeBucket(timeBucket); + next.execute(newServiceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceHourMetricPersistenceWorker.java similarity index 66% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMetricPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceHourMetricPersistenceWorker.java index bb17cc9ec..712735f49 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMetricPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceHourMetricPersistenceWorker.java @@ -16,46 +16,47 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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.IApplicationMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; /** * @author peng-yongsheng */ -public class ApplicationMetricPersistenceWorker extends PersistenceWorker { +public class ServiceHourMetricPersistenceWorker extends PersistenceWorker { - public ApplicationMetricPersistenceWorker(ModuleManager moduleManager) { + public ServiceHourMetricPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.APPLICATION_METRIC_PERSISTENCE_WORKER_ID; + return MetricWorkerIdDefine.SERVICE_HOUR_METRIC_PERSISTENCE_WORKER_ID; } - @Override protected IPersistenceDAO persistenceDAO() { - return getModuleManager().find(StorageModule.NAME).getService(IApplicationMetricPersistenceDAO.class); + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IServiceHourMetricPersistenceDAO.class); } @Override protected boolean needMergeDBData() { return true; } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ApplicationMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationMetricPersistenceWorker(moduleManager); + @Override public ServiceHourMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ServiceHourMetricPersistenceWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceHourMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceHourMetricTransformNode.java new file mode 100644 index 000000000..6495f4340 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceHourMetricTransformNode.java @@ -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.metric.provider.worker.service.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.service.ServiceMetric; + +/** + * @author peng-yongsheng + */ +public class ServiceHourMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.SERVICE_HOUR_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(ServiceMetric serviceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToHour(serviceMetric.getTimeBucket()); + + ServiceMetric newServiceMetric = ServiceMetricCopy.copy(serviceMetric); + newServiceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + serviceMetric.getMetricId()); + newServiceMetric.setTimeBucket(timeBucket); + next.execute(newServiceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMetricCopy.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMetricCopy.java new file mode 100644 index 000000000..cda3db58d --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMetricCopy.java @@ -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.metric.provider.worker.service.metric; + +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; + +/** + * @author peng-yongsheng + */ +public class ServiceMetricCopy { + + public static ServiceMetric copy(ServiceMetric serviceMetric) { + ServiceMetric newServiceMetric = new ServiceMetric(); + newServiceMetric.setId(serviceMetric.getId()); + newServiceMetric.setMetricId(serviceMetric.getMetricId()); + newServiceMetric.setSourceValue(serviceMetric.getSourceValue()); + + newServiceMetric.setApplicationId(serviceMetric.getApplicationId()); + newServiceMetric.setInstanceId(serviceMetric.getInstanceId()); + newServiceMetric.setServiceId(serviceMetric.getServiceId()); + + newServiceMetric.setTransactionCalls(serviceMetric.getTransactionCalls()); + newServiceMetric.setTransactionDurationSum(serviceMetric.getTransactionDurationSum()); + newServiceMetric.setTransactionErrorCalls(serviceMetric.getTransactionErrorCalls()); + newServiceMetric.setTransactionErrorDurationSum(serviceMetric.getTransactionErrorDurationSum()); + + newServiceMetric.setBusinessTransactionCalls(serviceMetric.getBusinessTransactionCalls()); + newServiceMetric.setBusinessTransactionDurationSum(serviceMetric.getBusinessTransactionDurationSum()); + newServiceMetric.setBusinessTransactionErrorCalls(serviceMetric.getBusinessTransactionErrorCalls()); + newServiceMetric.setBusinessTransactionErrorDurationSum(serviceMetric.getBusinessTransactionErrorDurationSum()); + + newServiceMetric.setMqTransactionCalls(serviceMetric.getMqTransactionCalls()); + newServiceMetric.setMqTransactionDurationSum(serviceMetric.getMqTransactionDurationSum()); + newServiceMetric.setMqTransactionErrorCalls(serviceMetric.getMqTransactionErrorCalls()); + newServiceMetric.setMqTransactionErrorDurationSum(serviceMetric.getMqTransactionErrorDurationSum()); + + newServiceMetric.setTimeBucket(serviceMetric.getTimeBucket()); + + return newServiceMetric; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceMetricGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMetricGraph.java similarity index 62% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceMetricGraph.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMetricGraph.java index 82f35db70..84f62691a 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceMetricGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMetricGraph.java @@ -16,18 +16,20 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +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.Node; 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.service.ServiceMetric; import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; /** @@ -46,21 +48,31 @@ public class ServiceMetricGraph { public void create() { RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); - Graph graph = GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.SERVICE_METRIC_GRAPH_ID, ServiceReferenceMetric.class); + Graph graph = GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.SERVICE_METRIC_GRAPH_ID, ServiceReferenceMetric.class); - graph.addNode(new ServiceMetricAggregationWorker.Factory(moduleManager).create(workerCreateListener)) - .addNext(new ServiceMetricRemoteWorker.Factory(moduleManager, remoteSenderService, GraphIdDefine.SERVICE_METRIC_GRAPH_ID).create(workerCreateListener)) - .addNext(new ServiceMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + Node remoteNode = graph.addNode(new ServiceMetricMinuteAggregationWorker.Factory(moduleManager).create(workerCreateListener)) + .addNext(new ServiceMinuteMetricRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.SERVICE_METRIC_GRAPH_ID).create(workerCreateListener)); + + remoteNode.addNext(new ServiceMinuteMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ServiceHourMetricTransformNode()) + .addNext(new ServiceHourMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ServiceDayMetricTransformNode()) + .addNext(new ServiceDayMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ServiceMonthMetricTransformNode()) + .addNext(new ServiceMonthMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); link(graph); } private void link(Graph graph) { - GraphManager.INSTANCE.findGraph(GraphIdDefine.SERVICE_REFERENCE_METRIC_GRAPH_ID, ServiceReferenceMetric.class) - .toFinder().findNode(WorkerIdDefine.SERVICE_REFERENCE_METRIC_AGGREGATION_WORKER_ID, ServiceReferenceMetric.class) + GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.SERVICE_REFERENCE_METRIC_GRAPH_ID, ServiceReferenceMetric.class) + .toFinder().findNode(MetricWorkerIdDefine.SERVICE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID, ServiceReferenceMetric.class) .addNext(new NodeProcessor() { @Override public int id() { - return WorkerIdDefine.SERVICE_METRIC_GRAPH_BRIDGE_WORKER_ID; + return MetricWorkerIdDefine.SERVICE_METRIC_GRAPH_BRIDGE_WORKER_ID; } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceMetricAggregationWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMetricMinuteAggregationWorker.java similarity index 73% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceMetricAggregationWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMetricMinuteAggregationWorker.java index a6a090af3..59c49c06c 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceMetricAggregationWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMetricMinuteAggregationWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; import org.apache.skywalking.apm.collector.analysis.worker.model.impl.AggregationWorker; import org.apache.skywalking.apm.collector.core.module.ModuleManager; @@ -29,21 +29,32 @@ import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenc /** * @author peng-yongsheng */ -public class ServiceMetricAggregationWorker extends AggregationWorker { +public class ServiceMetricMinuteAggregationWorker extends AggregationWorker { - public ServiceMetricAggregationWorker(ModuleManager moduleManager) { + public ServiceMetricMinuteAggregationWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.SERVICE_METRIC_AGGREGATION_WORKER_ID; + return MetricWorkerIdDefine.SERVICE_MINUTE_METRIC_AGGREGATION_WORKER_ID; } @Override protected ServiceMetric transform(ServiceReferenceMetric serviceReferenceMetric) { Integer serviceId = serviceReferenceMetric.getBehindServiceId(); Long timeBucket = serviceReferenceMetric.getTimeBucket(); - ServiceMetric serviceMetric = new ServiceMetric(String.valueOf(timeBucket) + Const.ID_SPLIT + String.valueOf(serviceId)); + Integer sourceValue = serviceReferenceMetric.getSourceValue(); + + String metricId = String.valueOf(serviceId) + Const.ID_SPLIT + String.valueOf(sourceValue); + String id = String.valueOf(timeBucket) + Const.ID_SPLIT + metricId; + + ServiceMetric serviceMetric = new ServiceMetric(); + serviceMetric.setId(id); + serviceMetric.setMetricId(metricId); + + serviceMetric.setApplicationId(serviceReferenceMetric.getBehindApplicationId()); + serviceMetric.setInstanceId(serviceReferenceMetric.getBehindInstanceId()); serviceMetric.setServiceId(serviceId); + serviceMetric.setSourceValue(sourceValue); serviceMetric.setTransactionCalls(serviceReferenceMetric.getTransactionCalls()); serviceMetric.setTransactionDurationSum(serviceReferenceMetric.getTransactionDurationSum()); @@ -65,14 +76,14 @@ public class ServiceMetricAggregationWorker extends AggregationWorker { + public static class Factory extends AbstractLocalAsyncWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ServiceMetricAggregationWorker workerInstance(ModuleManager moduleManager) { - return new ServiceMetricAggregationWorker(moduleManager); + @Override public ServiceMetricMinuteAggregationWorker workerInstance(ModuleManager moduleManager) { + return new ServiceMetricMinuteAggregationWorker(moduleManager); } @Override public int queueSize() { diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMinuteMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMinuteMetricPersistenceWorker.java new file mode 100644 index 000000000..e8748518c --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMinuteMetricPersistenceWorker.java @@ -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.metric.provider.worker.service.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.smp.IServiceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; + +/** + * @author peng-yongsheng + */ +public class ServiceMinuteMetricPersistenceWorker extends PersistenceWorker { + + public ServiceMinuteMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.SERVICE_MINUTE_METRIC_PERSISTENCE_WORKER_ID; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IServiceMinuteMetricPersistenceDAO.class); + } + + @Override protected boolean needMergeDBData() { + return true; + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ServiceMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ServiceMinuteMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceMetricRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMinuteMetricRemoteWorker.java similarity index 79% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceMetricRemoteWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMinuteMetricRemoteWorker.java index 4552213c9..e9375aa94 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceMetricRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMinuteMetricRemoteWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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; @@ -30,14 +30,14 @@ import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; /** * @author peng-yongsheng */ -public class ServiceMetricRemoteWorker extends AbstractRemoteWorker { +public class ServiceMinuteMetricRemoteWorker extends AbstractRemoteWorker { - public ServiceMetricRemoteWorker(ModuleManager moduleManager) { + public ServiceMinuteMetricRemoteWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.SERVICE_METRIC_REMOTE_WORKER_ID; + return MetricWorkerIdDefine.SERVICE_MINUTE_METRIC_REMOTE_WORKER_ID; } @Override protected void onWork(ServiceMetric serviceMetric) throws WorkerException { @@ -48,13 +48,13 @@ public class ServiceMetricRemoteWorker extends AbstractRemoteWorker { + public static class Factory extends AbstractRemoteWorkerProvider { public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { super(moduleManager, remoteSenderService, graphId); } - @Override public ServiceMetricRemoteWorker workerInstance(ModuleManager moduleManager) { - return new ServiceMetricRemoteWorker(moduleManager); + @Override public ServiceMinuteMetricRemoteWorker workerInstance(ModuleManager moduleManager) { + return new ServiceMinuteMetricRemoteWorker(moduleManager); } } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntryPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMonthMetricPersistenceWorker.java similarity index 66% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntryPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMonthMetricPersistenceWorker.java index 419befdc7..cce30ab9c 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceEntryPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMonthMetricPersistenceWorker.java @@ -16,45 +16,47 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.metric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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.IServiceEntryPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; /** * @author peng-yongsheng */ -public class ServiceEntryPersistenceWorker extends PersistenceWorker { +public class ServiceMonthMetricPersistenceWorker extends PersistenceWorker { - public ServiceEntryPersistenceWorker(ModuleManager moduleManager) { + public ServiceMonthMetricPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.SERVICE_ENTRY_PERSISTENCE_WORKER_ID; + return MetricWorkerIdDefine.SERVICE_MONTH_METRIC_PERSISTENCE_WORKER_ID; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IServiceMonthMetricPersistenceDAO.class); } @Override protected boolean needMergeDBData() { return true; } - @Override protected IPersistenceDAO persistenceDAO() { - return getModuleManager().find(StorageModule.NAME).getService(IServiceEntryPersistenceDAO.class); - } + public static class Factory extends PersistenceWorkerProvider { - public static class Factory extends AbstractLocalAsyncWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ServiceEntryPersistenceWorker workerInstance(ModuleManager moduleManager) { - return new ServiceEntryPersistenceWorker(moduleManager); + @Override public ServiceMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ServiceMonthMetricPersistenceWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMonthMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMonthMetricTransformNode.java new file mode 100644 index 000000000..1d3928787 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/metric/ServiceMonthMetricTransformNode.java @@ -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.metric.provider.worker.service.metric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.service.ServiceMetric; + +/** + * @author peng-yongsheng + */ +public class ServiceMonthMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.SERVICE_MONTH_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(ServiceMetric serviceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToMonth(serviceMetric.getTimeBucket()); + + ServiceMetric newServiceMetric = ServiceMetricCopy.copy(serviceMetric); + newServiceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + serviceMetric.getMetricId()); + newServiceMetric.setTimeBucket(timeBucket); + next.execute(newServiceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceDayMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceDayMetricPersistenceWorker.java new file mode 100644 index 000000000..4fa92ecfc --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceDayMetricPersistenceWorker.java @@ -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.metric.provider.worker.service.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.srmp.IServiceReferenceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceDayMetricPersistenceWorker extends PersistenceWorker { + + public ServiceReferenceDayMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.SERVICE_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IServiceReferenceDayMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ServiceReferenceDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ServiceReferenceDayMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceDayMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceDayMetricTransformNode.java new file mode 100644 index 000000000..8707b9b50 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceDayMetricTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.service.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.service.ServiceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceDayMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.SERVICE_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(ServiceReferenceMetric serviceReferenceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToDay(serviceReferenceMetric.getTimeBucket()); + + ServiceReferenceMetric newServiceReferenceMetric = ServiceReferenceMetricCopy.copy(serviceReferenceMetric); + newServiceReferenceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + serviceReferenceMetric.getMetricId()); + newServiceReferenceMetric.setTimeBucket(timeBucket); + + next.execute(newServiceReferenceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceHourMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceHourMetricPersistenceWorker.java new file mode 100644 index 000000000..53b8263d1 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceHourMetricPersistenceWorker.java @@ -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.metric.provider.worker.service.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.srmp.IServiceReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceHourMetricPersistenceWorker extends PersistenceWorker { + + public ServiceReferenceHourMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.SERVICE_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IServiceReferenceHourMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ServiceReferenceHourMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ServiceReferenceHourMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceHourMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceHourMetricTransformNode.java new file mode 100644 index 000000000..d4265cde2 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceHourMetricTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.service.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.service.ServiceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceHourMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.SERVICE_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(ServiceReferenceMetric serviceReferenceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToHour(serviceReferenceMetric.getTimeBucket()); + + ServiceReferenceMetric newServiceReferenceMetric = ServiceReferenceMetricCopy.copy(serviceReferenceMetric); + newServiceReferenceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + serviceReferenceMetric.getMetricId()); + newServiceReferenceMetric.setTimeBucket(timeBucket); + + next.execute(newServiceReferenceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricCopy.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricCopy.java new file mode 100644 index 000000000..825ebd1a0 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricCopy.java @@ -0,0 +1,59 @@ +/* + * 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.metric.provider.worker.service.refmetric; + +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceMetricCopy { + + public static ServiceReferenceMetric copy(ServiceReferenceMetric serviceReferenceMetric) { + ServiceReferenceMetric newServiceReferenceMetric = new ServiceReferenceMetric(); + newServiceReferenceMetric.setId(serviceReferenceMetric.getId()); + newServiceReferenceMetric.setMetricId(serviceReferenceMetric.getMetricId()); + newServiceReferenceMetric.setSourceValue(serviceReferenceMetric.getSourceValue()); + + newServiceReferenceMetric.setFrontApplicationId(serviceReferenceMetric.getFrontApplicationId()); + newServiceReferenceMetric.setFrontInstanceId(serviceReferenceMetric.getFrontInstanceId()); + newServiceReferenceMetric.setFrontServiceId(serviceReferenceMetric.getFrontServiceId()); + newServiceReferenceMetric.setBehindApplicationId(serviceReferenceMetric.getBehindApplicationId()); + newServiceReferenceMetric.setBehindInstanceId(serviceReferenceMetric.getBehindInstanceId()); + newServiceReferenceMetric.setBehindServiceId(serviceReferenceMetric.getBehindServiceId()); + + newServiceReferenceMetric.setTransactionCalls(serviceReferenceMetric.getTransactionCalls()); + newServiceReferenceMetric.setTransactionDurationSum(serviceReferenceMetric.getTransactionDurationSum()); + newServiceReferenceMetric.setTransactionErrorCalls(serviceReferenceMetric.getTransactionErrorCalls()); + newServiceReferenceMetric.setTransactionErrorDurationSum(serviceReferenceMetric.getTransactionErrorDurationSum()); + + newServiceReferenceMetric.setBusinessTransactionCalls(serviceReferenceMetric.getBusinessTransactionCalls()); + newServiceReferenceMetric.setBusinessTransactionDurationSum(serviceReferenceMetric.getBusinessTransactionDurationSum()); + newServiceReferenceMetric.setBusinessTransactionErrorCalls(serviceReferenceMetric.getBusinessTransactionErrorCalls()); + newServiceReferenceMetric.setBusinessTransactionErrorDurationSum(serviceReferenceMetric.getBusinessTransactionErrorDurationSum()); + + newServiceReferenceMetric.setMqTransactionCalls(serviceReferenceMetric.getMqTransactionCalls()); + newServiceReferenceMetric.setMqTransactionDurationSum(serviceReferenceMetric.getMqTransactionDurationSum()); + newServiceReferenceMetric.setMqTransactionErrorCalls(serviceReferenceMetric.getMqTransactionErrorCalls()); + newServiceReferenceMetric.setMqTransactionErrorDurationSum(serviceReferenceMetric.getMqTransactionErrorDurationSum()); + + newServiceReferenceMetric.setTimeBucket(serviceReferenceMetric.getTimeBucket()); + return newServiceReferenceMetric; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricGraph.java similarity index 59% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricGraph.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricGraph.java index f01e88605..4a0f0c657 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricGraph.java @@ -16,11 +16,12 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.refmetric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; 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.remote.RemoteModule; import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; @@ -42,9 +43,19 @@ public class ServiceReferenceMetricGraph { public void create() { RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); - GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.SERVICE_REFERENCE_METRIC_GRAPH_ID, ServiceReferenceMetric.class) - .addNode(new ServiceReferenceMetricAggregationWorker.Factory(moduleManager).create(workerCreateListener)) - .addNext(new ServiceReferenceMetricRemoteWorker.Factory(moduleManager, remoteSenderService, GraphIdDefine.SERVICE_REFERENCE_METRIC_GRAPH_ID).create(workerCreateListener)) - .addNext(new ServiceReferenceMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + Node remoteNode = GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.SERVICE_REFERENCE_METRIC_GRAPH_ID, ServiceReferenceMetric.class) + .addNode(new ServiceReferenceMinuteMetricAggregationWorker.Factory(moduleManager).create(workerCreateListener)) + .addNext(new ServiceReferenceMinuteMetricRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.SERVICE_REFERENCE_METRIC_GRAPH_ID).create(workerCreateListener)); + + remoteNode.addNext(new ServiceReferenceMinuteMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ServiceReferenceHourMetricTransformNode()) + .addNext(new ServiceReferenceHourMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ServiceReferenceDayMetricTransformNode()) + .addNext(new ServiceReferenceDayMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ServiceReferenceMonthMetricTransformNode()) + .addNext(new ServiceReferenceMonthMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricSpanListener.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricSpanListener.java similarity index 62% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricSpanListener.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricSpanListener.java index 41a309d6d..c2b933d72 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricSpanListener.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricSpanListener.java @@ -16,12 +16,12 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.refmetric; import java.util.LinkedList; import java.util.List; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.GraphIdDefine; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.MetricSource; +import org.apache.skywalking.apm.collector.analysis.metric.define.MetricSource; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.ReferenceDecorator; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.EntrySpanListener; @@ -29,6 +29,9 @@ import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listen import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.FirstSpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListenerFactory; +import org.apache.skywalking.apm.collector.cache.CacheModule; +import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; +import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService; 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.module.ModuleManager; @@ -47,15 +50,24 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En private final Logger logger = LoggerFactory.getLogger(ServiceReferenceMetricSpanListener.class); - private List entryReferenceMetric = new LinkedList<>(); - private List exitReferenceMetric = new LinkedList<>(); + private final InstanceCacheService instanceCacheService; + private final ApplicationCacheService applicationCacheService; + private final List entryReferenceMetric; + private List exitReferenceMetric; private SpanDecorator entrySpanDecorator; private long timeBucket; + ServiceReferenceMetricSpanListener(ModuleManager moduleManager) { + this.entryReferenceMetric = new LinkedList<>(); + this.exitReferenceMetric = new LinkedList<>(); + this.instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class); + this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); + } + @Override public void parseFirst(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) { - timeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(spanDecorator.getStartTime()); + this.timeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(spanDecorator.getStartTime()); } @Override @@ -64,83 +76,87 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En if (spanDecorator.getRefsCount() > 0) { for (int i = 0; i < spanDecorator.getRefsCount(); i++) { ReferenceDecorator reference = spanDecorator.getRefs(i); - ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(Const.EMPTY_STRING); - serviceReferenceMetric.setEntryServiceId(reference.getEntryServiceId()); - serviceReferenceMetric.setEntryInstanceId(reference.getEntryApplicationInstanceId()); + ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(); serviceReferenceMetric.setFrontServiceId(reference.getParentServiceId()); serviceReferenceMetric.setFrontInstanceId(reference.getParentApplicationInstanceId()); + serviceReferenceMetric.setFrontApplicationId(instanceCacheService.getApplicationId(reference.getParentApplicationInstanceId())); serviceReferenceMetric.setBehindServiceId(spanDecorator.getOperationNameId()); serviceReferenceMetric.setBehindInstanceId(instanceId); - serviceReferenceMetric.setSourceValue(MetricSource.Entry.ordinal()); - calculateCost(serviceReferenceMetric, spanDecorator, true); + serviceReferenceMetric.setBehindApplicationId(applicationId); + serviceReferenceMetric.setSourceValue(MetricSource.Callee.getValue()); + calculateDuration(serviceReferenceMetric, spanDecorator); entryReferenceMetric.add(serviceReferenceMetric); } } else { - ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(Const.EMPTY_STRING); - serviceReferenceMetric.setEntryServiceId(spanDecorator.getOperationNameId()); - serviceReferenceMetric.setEntryInstanceId(instanceId); + ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(); serviceReferenceMetric.setFrontServiceId(Const.NONE_SERVICE_ID); - serviceReferenceMetric.setFrontInstanceId(instanceId); + serviceReferenceMetric.setFrontInstanceId(Const.NONE_INSTANCE_ID); + serviceReferenceMetric.setFrontApplicationId(Const.NONE_APPLICATION_ID); serviceReferenceMetric.setBehindServiceId(spanDecorator.getOperationNameId()); serviceReferenceMetric.setBehindInstanceId(instanceId); - serviceReferenceMetric.setSourceValue(MetricSource.Entry.ordinal()); + serviceReferenceMetric.setBehindApplicationId(applicationId); + serviceReferenceMetric.setSourceValue(MetricSource.Callee.getValue()); - calculateCost(serviceReferenceMetric, spanDecorator, false); + calculateDuration(serviceReferenceMetric, spanDecorator); entryReferenceMetric.add(serviceReferenceMetric); } this.entrySpanDecorator = spanDecorator; } @Override public void parseExit(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) { - ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(Const.EMPTY_STRING); + ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(); + int peerId = spanDecorator.getPeerId(); + int behindApplicationId = applicationCacheService.getApplicationIdByAddressId(peerId); + int behindInstanceId = instanceCacheService.getInstanceIdByAddressId(behindApplicationId, peerId); + + serviceReferenceMetric.setFrontServiceId(Const.NONE_SERVICE_ID); serviceReferenceMetric.setFrontInstanceId(instanceId); + serviceReferenceMetric.setFrontApplicationId(applicationId); serviceReferenceMetric.setBehindServiceId(spanDecorator.getOperationNameId()); - serviceReferenceMetric.setSourceValue(MetricSource.Exit.ordinal()); - calculateCost(serviceReferenceMetric, spanDecorator, true); + serviceReferenceMetric.setBehindInstanceId(behindInstanceId); + serviceReferenceMetric.setBehindApplicationId(behindApplicationId); + serviceReferenceMetric.setSourceValue(MetricSource.Caller.getValue()); + calculateDuration(serviceReferenceMetric, spanDecorator); exitReferenceMetric.add(serviceReferenceMetric); } - private void calculateCost(ServiceReferenceMetric serviceReferenceMetric, SpanDecorator spanDecorator, - boolean hasReference) { + private void calculateDuration(ServiceReferenceMetric serviceReferenceMetric, SpanDecorator spanDecorator) { long duration = spanDecorator.getEndTime() - spanDecorator.getStartTime(); if (spanDecorator.getIsError()) { serviceReferenceMetric.setTransactionErrorCalls(1L); serviceReferenceMetric.setTransactionErrorDurationSum(duration); - } else { - serviceReferenceMetric.setTransactionCalls(1L); - serviceReferenceMetric.setTransactionDurationSum(duration); - } - - if (hasReference) { - if (spanDecorator.getIsError()) { - serviceReferenceMetric.setBusinessTransactionErrorCalls(1L); - serviceReferenceMetric.setBusinessTransactionErrorDurationSum(duration); - } else { - serviceReferenceMetric.setBusinessTransactionCalls(1L); - serviceReferenceMetric.setBusinessTransactionDurationSum(duration); - } } + serviceReferenceMetric.setTransactionCalls(1L); + serviceReferenceMetric.setTransactionDurationSum(duration); if (SpanLayer.MQ.equals(spanDecorator.getSpanLayer())) { if (spanDecorator.getIsError()) { serviceReferenceMetric.setMqTransactionErrorCalls(1L); serviceReferenceMetric.setMqTransactionErrorDurationSum(duration); - } else { - serviceReferenceMetric.setMqTransactionCalls(1L); - serviceReferenceMetric.setMqTransactionDurationSum(duration); } + serviceReferenceMetric.setMqTransactionCalls(1L); + serviceReferenceMetric.setMqTransactionDurationSum(duration); + } else { + if (spanDecorator.getIsError()) { + serviceReferenceMetric.setBusinessTransactionErrorCalls(1L); + serviceReferenceMetric.setBusinessTransactionErrorDurationSum(duration); + } + serviceReferenceMetric.setBusinessTransactionCalls(1L); + serviceReferenceMetric.setBusinessTransactionDurationSum(duration); } } @Override public void build() { logger.debug("service reference listener build"); - Graph graph = GraphManager.INSTANCE.findGraph(GraphIdDefine.SERVICE_REFERENCE_METRIC_GRAPH_ID, ServiceReferenceMetric.class); + Graph graph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.SERVICE_REFERENCE_METRIC_GRAPH_ID, ServiceReferenceMetric.class); entryReferenceMetric.forEach(serviceReferenceMetric -> { - String id = timeBucket + Const.ID_SPLIT + serviceReferenceMetric.getEntryServiceId() + Const.ID_SPLIT + serviceReferenceMetric.getFrontServiceId() + Const.ID_SPLIT + serviceReferenceMetric.getBehindServiceId(); + String metricId = serviceReferenceMetric.getFrontServiceId() + Const.ID_SPLIT + serviceReferenceMetric.getBehindServiceId() + Const.ID_SPLIT + serviceReferenceMetric.getSourceValue(); + String id = timeBucket + Const.ID_SPLIT + metricId; serviceReferenceMetric.setId(id); + serviceReferenceMetric.setMetricId(metricId); serviceReferenceMetric.setTimeBucket(timeBucket); logger.debug("push to service reference aggregation worker, id: {}", serviceReferenceMetric.getId()); @@ -148,17 +164,16 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En }); exitReferenceMetric.forEach(serviceReferenceMetric -> { - serviceReferenceMetric.setEntryInstanceId(Const.NONE_INSTANCE_ID); if (ObjectUtils.isNotEmpty(entrySpanDecorator)) { - serviceReferenceMetric.setEntryServiceId(entrySpanDecorator.getOperationNameId()); serviceReferenceMetric.setFrontServiceId(entrySpanDecorator.getOperationNameId()); } else { - serviceReferenceMetric.setEntryServiceId(Const.NONE_SERVICE_ID); serviceReferenceMetric.setFrontServiceId(Const.NONE_SERVICE_ID); } - String id = timeBucket + Const.ID_SPLIT + serviceReferenceMetric.getEntryServiceId() + Const.ID_SPLIT + serviceReferenceMetric.getFrontServiceId() + Const.ID_SPLIT + serviceReferenceMetric.getBehindServiceId(); + String metricId = serviceReferenceMetric.getFrontServiceId() + Const.ID_SPLIT + serviceReferenceMetric.getBehindServiceId() + Const.ID_SPLIT + serviceReferenceMetric.getSourceValue(); + String id = timeBucket + Const.ID_SPLIT + metricId; serviceReferenceMetric.setId(id); + serviceReferenceMetric.setMetricId(metricId); serviceReferenceMetric.setTimeBucket(timeBucket); graph.start(serviceReferenceMetric); @@ -167,7 +182,7 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En public static class Factory implements SpanListenerFactory { @Override public SpanListener create(ModuleManager moduleManager) { - return new ServiceReferenceMetricSpanListener(); + return new ServiceReferenceMetricSpanListener(moduleManager); } } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricAggregationWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMinuteMetricAggregationWorker.java similarity index 73% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricAggregationWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMinuteMetricAggregationWorker.java index e594bd268..4ac0d982f 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricAggregationWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMinuteMetricAggregationWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.refmetric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; import org.apache.skywalking.apm.collector.analysis.worker.model.impl.AggregationWorker; import org.apache.skywalking.apm.collector.core.module.ModuleManager; @@ -27,24 +27,24 @@ import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenc /** * @author peng-yongsheng */ -public class ServiceReferenceMetricAggregationWorker extends AggregationWorker { +public class ServiceReferenceMinuteMetricAggregationWorker extends AggregationWorker { - public ServiceReferenceMetricAggregationWorker(ModuleManager moduleManager) { + public ServiceReferenceMinuteMetricAggregationWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.SERVICE_REFERENCE_METRIC_AGGREGATION_WORKER_ID; + return MetricWorkerIdDefine.SERVICE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID; } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends AbstractLocalAsyncWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ServiceReferenceMetricAggregationWorker workerInstance(ModuleManager moduleManager) { - return new ServiceReferenceMetricAggregationWorker(moduleManager); + @Override public ServiceReferenceMinuteMetricAggregationWorker workerInstance(ModuleManager moduleManager) { + return new ServiceReferenceMinuteMetricAggregationWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMinuteMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMinuteMetricPersistenceWorker.java new file mode 100644 index 000000000..1eeef7293 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMinuteMetricPersistenceWorker.java @@ -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.metric.provider.worker.service.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.srmp.IServiceReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceMinuteMetricPersistenceWorker extends PersistenceWorker { + + public ServiceReferenceMinuteMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.SERVICE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IServiceReferenceMinuteMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ServiceReferenceMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ServiceReferenceMinuteMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMinuteMetricRemoteWorker.java similarity index 78% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricRemoteWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMinuteMetricRemoteWorker.java index c582c8894..500d00630 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/ServiceReferenceMetricRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMinuteMetricRemoteWorker.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.refmetric; -import org.apache.skywalking.apm.collector.analysis.metric.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; 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; @@ -30,14 +30,14 @@ import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenc /** * @author peng-yongsheng */ -public class ServiceReferenceMetricRemoteWorker extends AbstractRemoteWorker { +public class ServiceReferenceMinuteMetricRemoteWorker extends AbstractRemoteWorker { - public ServiceReferenceMetricRemoteWorker(ModuleManager moduleManager) { + public ServiceReferenceMinuteMetricRemoteWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.SERVICE_REFERENCE_METRIC_REMOTE_WORKER_ID; + return MetricWorkerIdDefine.SERVICE_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID; } @Override protected void onWork(ServiceReferenceMetric serviceReferenceMetric) throws WorkerException { @@ -48,14 +48,14 @@ public class ServiceReferenceMetricRemoteWorker extends AbstractRemoteWorker { + public static class Factory extends AbstractRemoteWorkerProvider { public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { super(moduleManager, remoteSenderService, graphId); } - @Override public ServiceReferenceMetricRemoteWorker workerInstance(ModuleManager moduleManager) { - return new ServiceReferenceMetricRemoteWorker(moduleManager); + @Override public ServiceReferenceMinuteMetricRemoteWorker workerInstance(ModuleManager moduleManager) { + return new ServiceReferenceMinuteMetricRemoteWorker(moduleManager); } } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMonthMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMonthMetricPersistenceWorker.java new file mode 100644 index 000000000..7135166b6 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMonthMetricPersistenceWorker.java @@ -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.metric.provider.worker.service.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.srmp.IServiceReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceMonthMetricPersistenceWorker extends PersistenceWorker { + + public ServiceReferenceMonthMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.SERVICE_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IServiceReferenceMonthMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ServiceReferenceMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ServiceReferenceMonthMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMonthMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMonthMetricTransformNode.java new file mode 100644 index 000000000..eda5515cf --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMonthMetricTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.metric.provider.worker.service.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +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.service.ServiceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceMonthMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.SERVICE_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(ServiceReferenceMetric serviceReferenceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToMonth(serviceReferenceMetric.getTimeBucket()); + + ServiceReferenceMetric newServiceReferenceMetric = ServiceReferenceMetricCopy.copy(serviceReferenceMetric); + newServiceReferenceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + serviceReferenceMetric.getMetricId()); + newServiceReferenceMetric.setTimeBucket(timeBucket); + + next.execute(newServiceReferenceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/AnalysisRegisterModule.java b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/AnalysisRegisterModule.java index 95347495e..48f5228ea 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/AnalysisRegisterModule.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/AnalysisRegisterModule.java @@ -20,6 +20,7 @@ package org.apache.skywalking.apm.collector.analysis.register.define; import org.apache.skywalking.apm.collector.analysis.register.define.service.IApplicationIDService; import org.apache.skywalking.apm.collector.analysis.register.define.service.IInstanceIDService; +import org.apache.skywalking.apm.collector.analysis.register.define.service.INetworkAddressIDService; import org.apache.skywalking.apm.collector.analysis.register.define.service.IServiceNameService; import org.apache.skywalking.apm.collector.core.module.Module; @@ -35,6 +36,6 @@ public class AnalysisRegisterModule extends Module { } @Override public Class[] services() { - return new Class[] {IApplicationIDService.class, IInstanceIDService.class, IServiceNameService.class}; + return new Class[] {IApplicationIDService.class, IInstanceIDService.class, IServiceNameService.class, INetworkAddressIDService.class}; } } diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/GraphIdDefine.java b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/GraphIdDefine.java index 787c18931..1b99bcfe7 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/GraphIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/GraphIdDefine.java @@ -25,4 +25,5 @@ public class GraphIdDefine { public static final int APPLICATION_REGISTER_GRAPH_ID = 200; public static final int INSTANCE_REGISTER_GRAPH_ID = 201; public static final int SERVICE_NAME_REGISTER_GRAPH_ID = 202; + public static final int NETWORK_ADDRESS_NAME_REGISTER_GRAPH_ID = 203; } diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/WorkerIdDefine.java b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/WorkerIdDefine.java index b16dfc0ae..c8e13bf20 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/WorkerIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/WorkerIdDefine.java @@ -28,4 +28,6 @@ public class WorkerIdDefine { public static final int INSTANCE_REGISTER_SERIAL_WORKER = 203; public static final int SERVICE_NAME_REGISTER_REMOTE_WORKER = 204; public static final int SERVICE_NAME_REGISTER_SERIAL_WORKER = 205; + public static final int NETWORK_ADDRESS_REGISTER_REMOTE_WORKER = 206; + public static final int NETWORK_ADDRESS_REGISTER_SERIAL_WORKER = 207; } diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/IApplicationIDService.java b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/IApplicationIDService.java index 27734ebff..3e05aa3ff 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/IApplicationIDService.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/IApplicationIDService.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.analysis.register.define.service; import org.apache.skywalking.apm.collector.core.module.Service; @@ -25,5 +24,7 @@ import org.apache.skywalking.apm.collector.core.module.Service; * @author peng-yongsheng */ public interface IApplicationIDService extends Service { - int getOrCreate(String applicationCode); + int getOrCreateForApplicationCode(String applicationCode); + + int getOrCreateForAddressId(int addressId, String networkAddress); } diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/IInstanceIDService.java b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/IInstanceIDService.java index 56c44e6c9..a8f72f85e 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/IInstanceIDService.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/IInstanceIDService.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.analysis.register.define.service; import org.apache.skywalking.apm.collector.core.module.Service; @@ -25,7 +24,9 @@ import org.apache.skywalking.apm.collector.core.module.Service; * @author peng-yongsheng */ public interface IInstanceIDService extends Service { - int getOrCreate(int applicationId, String agentUUID, long registerTime, String osInfo); + int getOrCreateByAgentUUID(int applicationId, String agentUUID, long registerTime, String osInfo); void recover(int instanceId, int applicationId, long registerTime, String osInfo); + + int getOrCreateByAddressId(int applicationId, int addressId, long registerTime); } diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/INetworkAddressIDService.java b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/INetworkAddressIDService.java new file mode 100644 index 000000000..427f605bc --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/INetworkAddressIDService.java @@ -0,0 +1,28 @@ +/* + * 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.register.define.service; + +import org.apache.skywalking.apm.collector.core.module.Service; + +/** + * @author peng-yongsheng + */ +public interface INetworkAddressIDService extends Service { + int getOrCreate(String networkAddress); +} diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/AnalysisRegisterModuleProvider.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/AnalysisRegisterModuleProvider.java index 89eca44b2..ac4eb5a1a 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/AnalysisRegisterModuleProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/AnalysisRegisterModuleProvider.java @@ -22,12 +22,15 @@ import java.util.Properties; 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.analysis.register.define.service.IInstanceIDService; +import org.apache.skywalking.apm.collector.analysis.register.define.service.INetworkAddressIDService; import org.apache.skywalking.apm.collector.analysis.register.define.service.IServiceNameService; import org.apache.skywalking.apm.collector.analysis.register.provider.register.ApplicationRegisterGraph; import org.apache.skywalking.apm.collector.analysis.register.provider.register.InstanceRegisterGraph; +import org.apache.skywalking.apm.collector.analysis.register.provider.register.NetworkAddressRegisterGraph; import org.apache.skywalking.apm.collector.analysis.register.provider.register.ServiceNameRegisterGraph; import org.apache.skywalking.apm.collector.analysis.register.provider.service.ApplicationIDService; import org.apache.skywalking.apm.collector.analysis.register.provider.service.InstanceIDService; +import org.apache.skywalking.apm.collector.analysis.register.provider.service.NetworkAddressIDService; import org.apache.skywalking.apm.collector.analysis.register.provider.service.ServiceNameService; import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener; import org.apache.skywalking.apm.collector.analysis.worker.timer.PersistenceTimer; @@ -57,6 +60,7 @@ public class AnalysisRegisterModuleProvider extends ModuleProvider { this.registerServiceImplementation(IApplicationIDService.class, new ApplicationIDService(getManager())); this.registerServiceImplementation(IInstanceIDService.class, new InstanceIDService(getManager())); this.registerServiceImplementation(IServiceNameService.class, new ServiceNameService(getManager())); + this.registerServiceImplementation(INetworkAddressIDService.class, new NetworkAddressIDService(getManager())); } @Override public void start(Properties config) throws ServiceNotProvidedException { @@ -85,5 +89,8 @@ public class AnalysisRegisterModuleProvider extends ModuleProvider { ServiceNameRegisterGraph serviceNameRegisterGraph = new ServiceNameRegisterGraph(getManager(), workerCreateListener); serviceNameRegisterGraph.create(); + + NetworkAddressRegisterGraph networkAddressRegisterGraph = new NetworkAddressRegisterGraph(getManager(), workerCreateListener); + networkAddressRegisterGraph.create(); } } diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ApplicationRegisterSerialWorker.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ApplicationRegisterSerialWorker.java index 5024cc61c..0562c9485 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ApplicationRegisterSerialWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ApplicationRegisterSerialWorker.java @@ -27,7 +27,7 @@ import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService 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.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegisterDAO; import org.apache.skywalking.apm.collector.storage.table.register.Application; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,27 +54,36 @@ public class ApplicationRegisterSerialWorker extends AbstractLocalAsyncWorker { + + private final Logger logger = LoggerFactory.getLogger(NetworkAddressRegisterRemoteWorker.class); + + public NetworkAddressRegisterRemoteWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return WorkerIdDefine.NETWORK_ADDRESS_REGISTER_REMOTE_WORKER; + } + + @Override protected void onWork(NetworkAddress message) throws WorkerException { + logger.debug("network address: {}", message.getNetworkAddress()); + onNext(message); + } + + @Override public Selector selector() { + return Selector.ForeverFirst; + } + + public static class Factory extends AbstractRemoteWorkerProvider { + + public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { + super(moduleManager, remoteSenderService, graphId); + } + + @Override public NetworkAddressRegisterRemoteWorker workerInstance(ModuleManager moduleManager) { + return new NetworkAddressRegisterRemoteWorker(moduleManager); + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/NetworkAddressRegisterSerialWorker.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/NetworkAddressRegisterSerialWorker.java new file mode 100644 index 000000000..9ec551498 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/NetworkAddressRegisterSerialWorker.java @@ -0,0 +1,93 @@ +/* + * 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.register.provider.register; + +import org.apache.skywalking.apm.collector.analysis.register.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorker; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException; +import org.apache.skywalking.apm.collector.cache.CacheModule; +import org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheService; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.register.INetworkAddressRegisterDAO; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddress; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class NetworkAddressRegisterSerialWorker extends AbstractLocalAsyncWorker { + + private final Logger logger = LoggerFactory.getLogger(NetworkAddressRegisterSerialWorker.class); + + private final INetworkAddressRegisterDAO networkAddressRegisterDAO; + private final NetworkAddressCacheService networkAddressCacheService; + + public NetworkAddressRegisterSerialWorker(ModuleManager moduleManager) { + super(moduleManager); + this.networkAddressRegisterDAO = getModuleManager().find(StorageModule.NAME).getService(INetworkAddressRegisterDAO.class); + this.networkAddressCacheService = getModuleManager().find(CacheModule.NAME).getService(NetworkAddressCacheService.class); + } + + @Override public int id() { + return WorkerIdDefine.NETWORK_ADDRESS_REGISTER_SERIAL_WORKER; + } + + @Override protected void onWork(NetworkAddress networkAddress) throws WorkerException { + logger.debug("register network address, address: {}", networkAddress.getNetworkAddress()); + int addressId = networkAddressCacheService.getAddressId(networkAddress.getNetworkAddress()); + + if (addressId == 0) { + NetworkAddress newNetworkAddress; + int min = networkAddressRegisterDAO.getMinNetworkAddressId(); + if (min == 0) { + newNetworkAddress = new NetworkAddress(); + newNetworkAddress.setId("-1"); + newNetworkAddress.setAddressId(-1); + newNetworkAddress.setNetworkAddress(networkAddress.getNetworkAddress()); + } else { + int max = networkAddressRegisterDAO.getMaxNetworkAddressId(); + addressId = IdAutoIncrement.INSTANCE.increment(min, max); + + newNetworkAddress = new NetworkAddress(); + newNetworkAddress.setId(String.valueOf(addressId)); + newNetworkAddress.setAddressId(addressId); + newNetworkAddress.setNetworkAddress(networkAddress.getNetworkAddress()); + } + networkAddressRegisterDAO.save(newNetworkAddress); + } + } + + public static class Factory extends AbstractLocalAsyncWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public NetworkAddressRegisterSerialWorker workerInstance(ModuleManager moduleManager) { + return new NetworkAddressRegisterSerialWorker(moduleManager); + } + + @Override public int queueSize() { + return 256; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ServiceNameRegisterSerialWorker.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ServiceNameRegisterSerialWorker.java index f404ef8e8..26869fa6b 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ServiceNameRegisterSerialWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ServiceNameRegisterSerialWorker.java @@ -27,7 +27,7 @@ import org.apache.skywalking.apm.collector.cache.service.ServiceIdCacheService; 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.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.IServiceNameRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IServiceNameRegisterDAO; import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,13 +60,15 @@ public class ServiceNameRegisterSerialWorker extends AbstractLocalAsyncWorker applicationRegisterGraph; public ApplicationIDService(ModuleManager moduleManager) { @@ -59,13 +62,39 @@ public class ApplicationIDService implements IApplicationIDService { return applicationCacheService; } - public int getOrCreate(String applicationCode) { - int applicationId = getApplicationCacheService().get(applicationCode); + private NetworkAddressCacheService getNetworkAddressCacheService() { + if (ObjectUtils.isEmpty(networkAddressCacheService)) { + this.networkAddressCacheService = moduleManager.find(CacheModule.NAME).getService(NetworkAddressCacheService.class); + } + return networkAddressCacheService; + } + + @Override public int getOrCreateForApplicationCode(String applicationCode) { + int applicationId = getApplicationCacheService().getApplicationIdByCode(applicationCode); if (applicationId == 0) { - Application application = new Application(applicationCode); + Application application = new Application(); + application.setId(applicationCode); application.setApplicationCode(applicationCode); application.setApplicationId(0); + application.setAddressId(Const.NONE); + application.setIsAddress(false); + + getApplicationRegisterGraph().start(application); + } + return applicationId; + } + + @Override public int getOrCreateForAddressId(int addressId, String networkAddress) { + int applicationId = getApplicationCacheService().getApplicationIdByAddressId(addressId); + + if (applicationId == 0) { + Application application = new Application(); + application.setId(networkAddress); + application.setApplicationCode(networkAddress); + application.setApplicationId(0); + application.setAddressId(addressId); + application.setIsAddress(true); getApplicationRegisterGraph().start(application); } diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/InstanceIDService.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/InstanceIDService.java index 38a83e782..b3ebb66bd 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/InstanceIDService.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/InstanceIDService.java @@ -25,9 +25,10 @@ import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService; 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.module.ModuleManager; +import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO; import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,27 +70,52 @@ public class InstanceIDService implements IInstanceIDService { return instanceRegisterDAO; } - public int getOrCreate(int applicationId, String agentUUID, long registerTime, String osInfo) { - logger.debug("get or create instance id, application id: {}, agentUUID: {}, registerTime: {}, osInfo: {}", applicationId, agentUUID, registerTime, osInfo); - int instanceId = getInstanceCacheService().getInstanceId(applicationId, agentUUID); + @Override public int getOrCreateByAgentUUID(int applicationId, String agentUUID, long registerTime, String osInfo) { + logger.debug("get or create instance id by agent UUID, application id: {}, agentUUID: {}, registerTime: {}, osInfo: {}", applicationId, agentUUID, registerTime, osInfo); + int instanceId = getInstanceCacheService().getInstanceIdByAgentUUID(applicationId, agentUUID); if (instanceId == 0) { - Instance instance = new Instance("0"); + Instance instance = new Instance(); + instance.setId("0"); instance.setApplicationId(applicationId); instance.setAgentUUID(agentUUID); instance.setRegisterTime(registerTime); instance.setHeartBeatTime(registerTime); instance.setInstanceId(0); instance.setOsInfo(osInfo); + instance.setIsAddress(false); + instance.setAddressId(Const.NONE); getInstanceRegisterGraph().start(instance); } return instanceId; } - public void recover(int instanceId, int applicationId, long registerTime, String osInfo) { + @Override public int getOrCreateByAddressId(int applicationId, int addressId, long registerTime) { + logger.debug("get or create instance id by address id, application id: {}, address id: {}, registerTime: {}", applicationId, addressId, registerTime); + int instanceId = getInstanceCacheService().getInstanceIdByAddressId(applicationId, addressId); + + if (instanceId == 0) { + Instance instance = new Instance(); + instance.setId("0"); + instance.setApplicationId(applicationId); + instance.setAgentUUID(Const.EMPTY_STRING); + instance.setRegisterTime(registerTime); + instance.setHeartBeatTime(registerTime); + instance.setInstanceId(0); + instance.setOsInfo(Const.EMPTY_STRING); + instance.setIsAddress(true); + instance.setAddressId(addressId); + + getInstanceRegisterGraph().start(instance); + } + return instanceId; + } + + @Override public void recover(int instanceId, int applicationId, long registerTime, String osInfo) { logger.debug("instance recover, instance id: {}, application id: {}, register time: {}", instanceId, applicationId, registerTime); - Instance instance = new Instance(String.valueOf(instanceId)); + Instance instance = new Instance(); + instance.setId(String.valueOf(instanceId)); instance.setApplicationId(applicationId); instance.setAgentUUID(""); instance.setRegisterTime(registerTime); diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/NetworkAddressIDService.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/NetworkAddressIDService.java new file mode 100644 index 000000000..ad5fc4c8b --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/NetworkAddressIDService.java @@ -0,0 +1,105 @@ +/* + * 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.register.provider.service; + +import org.apache.skywalking.apm.collector.analysis.register.define.AnalysisRegisterModule; +import org.apache.skywalking.apm.collector.analysis.register.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.register.define.service.IApplicationIDService; +import org.apache.skywalking.apm.collector.analysis.register.define.service.IInstanceIDService; +import org.apache.skywalking.apm.collector.analysis.register.define.service.INetworkAddressIDService; +import org.apache.skywalking.apm.collector.cache.CacheModule; +import org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheService; +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.module.ModuleManager; +import org.apache.skywalking.apm.collector.core.util.ObjectUtils; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddress; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class NetworkAddressIDService implements INetworkAddressIDService { + + private final Logger logger = LoggerFactory.getLogger(NetworkAddressIDService.class); + + private final ModuleManager moduleManager; + private NetworkAddressCacheService networkAddressCacheService; + private IApplicationIDService applicationIDService; + private IInstanceIDService instanceIDService; + private Graph networkAddressGraph; + + public NetworkAddressIDService(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + } + + private NetworkAddressCacheService getNetworkAddressCacheService() { + if (ObjectUtils.isEmpty(networkAddressCacheService)) { + this.networkAddressCacheService = moduleManager.find(CacheModule.NAME).getService(NetworkAddressCacheService.class); + } + return this.networkAddressCacheService; + } + + private IApplicationIDService getApplicationIDService() { + if (ObjectUtils.isEmpty(applicationIDService)) { + this.applicationIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IApplicationIDService.class); + } + return this.applicationIDService; + } + + private IInstanceIDService getInstanceIDService() { + if (ObjectUtils.isEmpty(instanceIDService)) { + this.instanceIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IInstanceIDService.class); + } + return this.instanceIDService; + } + + private Graph getNetworkAddressGraph() { + if (ObjectUtils.isEmpty(networkAddressGraph)) { + this.networkAddressGraph = GraphManager.INSTANCE.findGraph(GraphIdDefine.NETWORK_ADDRESS_NAME_REGISTER_GRAPH_ID, NetworkAddress.class); + } + return this.networkAddressGraph; + } + + @Override public int getOrCreate(String networkAddress) { + int addressId = getNetworkAddressCacheService().getAddressId(networkAddress); + + if (addressId != 0) { + int applicationId = getApplicationIDService().getOrCreateForAddressId(addressId, networkAddress); + + if (applicationId != 0) { + int instanceId = getInstanceIDService().getOrCreateByAddressId(applicationId, addressId, System.currentTimeMillis()); + + if (instanceId != 0) { + return addressId; + } + } + } else { + NetworkAddress newNetworkAddress = new NetworkAddress(); + newNetworkAddress.setId("0"); + newNetworkAddress.setNetworkAddress(networkAddress); + newNetworkAddress.setAddressId(0); + + getNetworkAddressGraph().start(newNetworkAddress); + } + + return 0; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/ServiceNameService.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/ServiceNameService.java index 7e85e77ad..34f8d1f75 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/ServiceNameService.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/ServiceNameService.java @@ -63,7 +63,8 @@ public class ServiceNameService implements IServiceNameService { int serviceId = getServiceIdCacheService().get(applicationId, serviceName); if (serviceId == 0) { - ServiceName service = new ServiceName("0"); + ServiceName service = new ServiceName(); + service.setId("0"); service.setApplicationId(applicationId); service.setServiceName(serviceName); service.setServiceId(0); diff --git a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentParse.java b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentParse.java index 1c8ab9fa0..060bb88a4 100644 --- a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentParse.java +++ b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentParse.java @@ -162,7 +162,8 @@ public class SegmentParse { } private void buildSegment(String id, byte[] dataBinary) { - Segment segment = new Segment(id); + Segment segment = new Segment(); + segment.setId(id); segment.setDataBinary(dataBinary); segment.setTimeBucket(timeBucket); Graph graph = GraphManager.INSTANCE.findGraph(GraphIdDefine.SEGMENT_PERSISTENCE_GRAPH_ID, Segment.class); diff --git a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentPersistenceWorker.java index 18949ac9e..3ecd508fb 100644 --- a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentPersistenceWorker.java @@ -19,8 +19,8 @@ package org.apache.skywalking.apm.collector.analysis.segment.parser.provider.parser; import org.apache.skywalking.apm.collector.analysis.segment.parser.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; @@ -30,7 +30,7 @@ import org.apache.skywalking.apm.collector.storage.table.segment.Segment; /** * @author peng-yongsheng */ -public class SegmentPersistenceWorker extends PersistenceWorker { +public class SegmentPersistenceWorker extends PersistenceWorker { public SegmentPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); @@ -44,11 +44,12 @@ public class SegmentPersistenceWorker extends PersistenceWorker persistenceDAO() { return getModuleManager().find(StorageModule.NAME).getService(ISegmentPersistenceDAO.class); } - public static class Factory extends AbstractLocalAsyncWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } diff --git a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/IdExchanger.java b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/IdExchanger.java index 6bf7148c7..07e50d423 100644 --- a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/IdExchanger.java +++ b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/IdExchanger.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.analysis.segment.parser.provider.parser.standardization; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.StandardBuilder; diff --git a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java index 1dd97b4e9..ccef9af41 100644 --- a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java +++ b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java @@ -20,6 +20,7 @@ package org.apache.skywalking.apm.collector.analysis.segment.parser.provider.par 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.analysis.register.define.service.INetworkAddressIDService; import org.apache.skywalking.apm.collector.analysis.register.define.service.IServiceNameService; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.ReferenceDecorator; import org.apache.skywalking.apm.collector.cache.CacheModule; @@ -41,6 +42,7 @@ public class ReferenceIdExchanger implements IdExchanger { private final IApplicationIDService applicationIDService; private final IServiceNameService serviceNameService; private final InstanceCacheService instanceCacheService; + private final INetworkAddressIDService networkAddressIDService; public static ReferenceIdExchanger getInstance(ModuleManager moduleManager) { if (EXCHANGER == null) { @@ -50,18 +52,19 @@ public class ReferenceIdExchanger implements IdExchanger { } private ReferenceIdExchanger(ModuleManager moduleManager) { - applicationIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IApplicationIDService.class); - serviceNameService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IServiceNameService.class); - instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class); + this.applicationIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IApplicationIDService.class); + this.serviceNameService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IServiceNameService.class); + this.networkAddressIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(INetworkAddressIDService.class); + this.instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class); } @Override public boolean exchange(ReferenceDecorator standardBuilder, int applicationId) { if (standardBuilder.getEntryServiceId() == 0 && StringUtils.isNotEmpty(standardBuilder.getEntryServiceName())) { - int entryServiceId = serviceNameService.getOrCreate(instanceCacheService.get(standardBuilder.getEntryApplicationInstanceId()), standardBuilder.getEntryServiceName()); + int entryServiceId = serviceNameService.getOrCreate(instanceCacheService.getApplicationId(standardBuilder.getEntryApplicationInstanceId()), standardBuilder.getEntryServiceName()); if (entryServiceId == 0) { if (logger.isDebugEnabled()) { - int entryApplicationId = instanceCacheService.get(standardBuilder.getEntryApplicationInstanceId()); + int entryApplicationId = instanceCacheService.getApplicationId(standardBuilder.getEntryApplicationInstanceId()); logger.debug("entry service name: {} from application id: {} exchange failed", standardBuilder.getEntryServiceName(), entryApplicationId); } return false; @@ -73,11 +76,11 @@ public class ReferenceIdExchanger implements IdExchanger { } if (standardBuilder.getParentServiceId() == 0 && StringUtils.isNotEmpty(standardBuilder.getParentServiceName())) { - int parentServiceId = serviceNameService.getOrCreate(instanceCacheService.get(standardBuilder.getParentApplicationInstanceId()), standardBuilder.getParentServiceName()); + int parentServiceId = serviceNameService.getOrCreate(instanceCacheService.getApplicationId(standardBuilder.getParentApplicationInstanceId()), standardBuilder.getParentServiceName()); if (parentServiceId == 0) { if (logger.isDebugEnabled()) { - int parentApplicationId = instanceCacheService.get(standardBuilder.getParentApplicationInstanceId()); + int parentApplicationId = instanceCacheService.getApplicationId(standardBuilder.getParentApplicationInstanceId()); logger.debug("parent service name: {} from application id: {} exchange failed", standardBuilder.getParentServiceName(), parentApplicationId); } return false; @@ -89,7 +92,7 @@ public class ReferenceIdExchanger implements IdExchanger { } if (standardBuilder.getNetworkAddressId() == 0 && StringUtils.isNotEmpty(standardBuilder.getNetworkAddress())) { - int networkAddressId = applicationIDService.getOrCreate(standardBuilder.getNetworkAddress()); + int networkAddressId = networkAddressIDService.getOrCreate(standardBuilder.getNetworkAddress()); if (networkAddressId == 0) { if (logger.isDebugEnabled()) { logger.debug("network address: {} from application id: {} exchange failed", standardBuilder.getNetworkAddress(), applicationId); diff --git a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/SegmentStandardization.java b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/SegmentStandardization.java index 08717ce40..bb247fa0b 100644 --- a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/SegmentStandardization.java +++ b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/SegmentStandardization.java @@ -16,19 +16,35 @@ * */ - package org.apache.skywalking.apm.collector.analysis.segment.parser.provider.parser.standardization; -import org.apache.skywalking.apm.collector.core.data.EndOfBatchQueueMessage; +import org.apache.skywalking.apm.collector.core.data.QueueData; +import org.apache.skywalking.apm.collector.core.queue.EndOfBatchContext; import org.apache.skywalking.apm.network.proto.UpstreamSegment; /** * @author peng-yongsheng */ -public class SegmentStandardization extends EndOfBatchQueueMessage { +public class SegmentStandardization implements QueueData { - public SegmentStandardization(String key) { - super(key); + private final String id; + + public SegmentStandardization(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + private EndOfBatchContext context; + + @Override public EndOfBatchContext getEndOfBatchContext() { + return this.context; + } + + @Override public void setEndOfBatchContext(EndOfBatchContext context) { + this.context = context; } private UpstreamSegment upstreamSegment; diff --git a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/SpanIdExchanger.java b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/SpanIdExchanger.java index 44a7ebe20..13f8d6a6d 100644 --- a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/SpanIdExchanger.java +++ b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/SpanIdExchanger.java @@ -19,7 +19,7 @@ package org.apache.skywalking.apm.collector.analysis.segment.parser.provider.parser.standardization; 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.analysis.register.define.service.INetworkAddressIDService; import org.apache.skywalking.apm.collector.analysis.register.define.service.IServiceNameService; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator; import org.apache.skywalking.apm.collector.core.module.ModuleManager; @@ -36,8 +36,8 @@ public class SpanIdExchanger implements IdExchanger { private final Logger logger = LoggerFactory.getLogger(SpanIdExchanger.class); private static SpanIdExchanger EXCHANGER; - private final IApplicationIDService applicationIDService; private final IServiceNameService serviceNameService; + private final INetworkAddressIDService networkAddressIDService; public static SpanIdExchanger getInstance(ModuleManager moduleManager) { if (EXCHANGER == null) { @@ -47,13 +47,14 @@ public class SpanIdExchanger implements IdExchanger { } private SpanIdExchanger(ModuleManager moduleManager) { - applicationIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IApplicationIDService.class); - serviceNameService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IServiceNameService.class); + this.serviceNameService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IServiceNameService.class); + this.networkAddressIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(INetworkAddressIDService.class); } @Override public boolean exchange(SpanDecorator standardBuilder, int applicationId) { if (standardBuilder.getPeerId() == 0 && StringUtils.isNotEmpty(standardBuilder.getPeer())) { - int peerId = applicationIDService.getOrCreate(standardBuilder.getPeer()); + int peerId = networkAddressIDService.getOrCreate(standardBuilder.getPeer()); + if (peerId == 0) { logger.debug("peer: {} in application: {} exchange failed", standardBuilder.getPeer(), applicationId); return false; diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractLocalAsyncWorker.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractLocalAsyncWorker.java index 73a48df6c..d85ac9f5d 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractLocalAsyncWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractLocalAsyncWorker.java @@ -18,7 +18,7 @@ package org.apache.skywalking.apm.collector.analysis.worker.model.base; -import org.apache.skywalking.apm.collector.core.data.EndOfBatchQueueMessage; +import org.apache.skywalking.apm.collector.core.data.QueueData; import org.apache.skywalking.apm.collector.core.module.ModuleManager; /** @@ -28,7 +28,7 @@ import org.apache.skywalking.apm.collector.core.module.ModuleManager; * @author peng-yongsheng * @since v3.0-2017 */ -public abstract class AbstractLocalAsyncWorker extends AbstractWorker { +public abstract class AbstractLocalAsyncWorker extends AbstractWorker { public AbstractLocalAsyncWorker(ModuleManager moduleManager) { super(moduleManager); diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractLocalAsyncWorkerProvider.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractLocalAsyncWorkerProvider.java index 54d92ef92..472f4d173 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractLocalAsyncWorkerProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractLocalAsyncWorkerProvider.java @@ -18,14 +18,14 @@ package org.apache.skywalking.apm.collector.analysis.worker.model.base; -import org.apache.skywalking.apm.collector.core.data.EndOfBatchQueueMessage; +import org.apache.skywalking.apm.collector.core.data.QueueData; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.commons.datacarrier.DataCarrier; /** * @author peng-yongsheng */ -public abstract class AbstractLocalAsyncWorkerProvider> extends AbstractWorkerProvider { +public abstract class AbstractLocalAsyncWorkerProvider> extends AbstractWorkerProvider { public abstract int queueSize(); diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractRemoteWorker.java index 2445a6bd8..42769c464 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractRemoteWorker.java @@ -18,7 +18,7 @@ package org.apache.skywalking.apm.collector.analysis.worker.model.base; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.RemoteData; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.remote.service.Selector; @@ -31,7 +31,7 @@ import org.apache.skywalking.apm.collector.remote.service.Selector; * @author peng-yongsheng * @since v3.0-2017 */ -public abstract class AbstractRemoteWorker extends AbstractWorker { +public abstract class AbstractRemoteWorker extends AbstractWorker { public AbstractRemoteWorker(ModuleManager moduleManager) { super(moduleManager); diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractRemoteWorkerProvider.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractRemoteWorkerProvider.java index 0742bbf6e..e007524d9 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractRemoteWorkerProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractRemoteWorkerProvider.java @@ -18,7 +18,7 @@ package org.apache.skywalking.apm.collector.analysis.worker.model.base; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.RemoteData; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; @@ -30,7 +30,7 @@ import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; * @author peng-yongsheng * @since v3.0-2017 */ -public abstract class AbstractRemoteWorkerProvider> extends AbstractWorkerProvider { +public abstract class AbstractRemoteWorkerProvider> extends AbstractWorkerProvider { private final RemoteSenderService remoteSenderService; private final int graphId; diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractWorker.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractWorker.java index da4efdbbc..e3b697ba2 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractWorker.java @@ -18,7 +18,6 @@ package org.apache.skywalking.apm.collector.analysis.worker.model.base; -import org.apache.skywalking.apm.collector.core.data.EndOfBatchQueueMessage; 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; @@ -28,13 +27,13 @@ import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ -public abstract class AbstractWorker implements NodeProcessor { +public abstract class AbstractWorker implements NodeProcessor { private final Logger logger = LoggerFactory.getLogger(AbstractWorker.class); private final ModuleManager moduleManager; - public AbstractWorker(ModuleManager moduleManager) { + AbstractWorker(ModuleManager moduleManager) { this.moduleManager = moduleManager; } diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractWorkerProvider.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractWorkerProvider.java index 8ebc62d70..b312af532 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractWorkerProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractWorkerProvider.java @@ -18,17 +18,16 @@ package org.apache.skywalking.apm.collector.analysis.worker.model.base; -import org.apache.skywalking.apm.collector.core.data.EndOfBatchQueueMessage; import org.apache.skywalking.apm.collector.core.module.ModuleManager; /** * @author peng-yongsheng */ -public abstract class AbstractWorkerProvider> implements Provider { +public abstract class AbstractWorkerProvider> implements Provider { private final ModuleManager moduleManager; - public AbstractWorkerProvider(ModuleManager moduleManager) { + AbstractWorkerProvider(ModuleManager moduleManager) { this.moduleManager = moduleManager; } diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/LocalAsyncWorkerRef.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/LocalAsyncWorkerRef.java index 58d831a20..da2e8107b 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/LocalAsyncWorkerRef.java +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/LocalAsyncWorkerRef.java @@ -20,8 +20,9 @@ package org.apache.skywalking.apm.collector.analysis.worker.model.base; import java.util.Iterator; import java.util.List; -import org.apache.skywalking.apm.collector.core.data.EndOfBatchQueueMessage; +import org.apache.skywalking.apm.collector.core.data.QueueData; import org.apache.skywalking.apm.collector.core.graph.NodeProcessor; +import org.apache.skywalking.apm.collector.core.queue.EndOfBatchContext; import org.apache.skywalking.apm.commons.datacarrier.DataCarrier; import org.apache.skywalking.apm.commons.datacarrier.consumer.IConsumer; import org.slf4j.Logger; @@ -30,7 +31,7 @@ import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ -public class LocalAsyncWorkerRef extends WorkerRef implements IConsumer { +public class LocalAsyncWorkerRef extends WorkerRef implements IConsumer { private final Logger logger = LoggerFactory.getLogger(LocalAsyncWorkerRef.class); @@ -40,7 +41,7 @@ public class LocalAsyncWorkerRef dataCarrier) { + void setQueueEventHandler(DataCarrier dataCarrier) { this.dataCarrier = dataCarrier; } @@ -52,7 +53,7 @@ public class LocalAsyncWorkerRef extends WorkerRef { +public class RemoteWorkerRef extends WorkerRef { private final Logger logger = LoggerFactory.getLogger(RemoteWorkerRef.class); diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/WorkerCreateListener.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/WorkerCreateListener.java index 23e602d28..fe1a48f72 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/WorkerCreateListener.java +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/WorkerCreateListener.java @@ -33,7 +33,7 @@ public class WorkerCreateListener { this.persistenceWorkers = new ArrayList<>(); } - public void addWorker(AbstractWorker worker) { + void addWorker(AbstractWorker worker) { if (worker instanceof PersistenceWorker) { persistenceWorkers.add((PersistenceWorker)worker); } diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/WorkerRef.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/WorkerRef.java index b1fa00b5d..3dbb71d27 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/WorkerRef.java +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/WorkerRef.java @@ -24,7 +24,7 @@ import org.apache.skywalking.apm.collector.core.graph.WayToNode; /** * @author peng-yongsheng */ -public abstract class WorkerRef extends WayToNode { +abstract class WorkerRef extends WayToNode { WorkerRef(NodeProcessor destinationHandler) { super(destinationHandler); } diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/AggregationWorker.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/AggregationWorker.java index 1c8207da8..0b6f3240d 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/AggregationWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/AggregationWorker.java @@ -21,7 +21,7 @@ package org.apache.skywalking.apm.collector.analysis.worker.model.impl; 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.impl.data.DataCache; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ -public abstract class AggregationWorker extends AbstractLocalAsyncWorker { +public abstract class AggregationWorker extends AbstractLocalAsyncWorker { private final Logger logger = LoggerFactory.getLogger(AggregationWorker.class); @@ -47,9 +47,7 @@ public abstract class AggregationWorker } @Override protected final void onWork(INPUT message) throws WorkerException { - boolean isEndOfBatch = message.isEndOfBatch(); OUTPUT output = transform(message); - output.setEndOfBatch(isEndOfBatch); messageNum++; aggregate(output); @@ -58,8 +56,7 @@ public abstract class AggregationWorker sendToNext(); messageNum = 0; } - if (output.isEndOfBatch()) { - output.setEndOfBatch(false); + if (message.getEndOfBatchContext().isEndOfBatch()) { sendToNext(); } } diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/PersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/PersistenceWorker.java index 82da9d17f..6dfb39b49 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/PersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/PersistenceWorker.java @@ -24,7 +24,7 @@ import java.util.Map; 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.impl.data.DataCache; -import org.apache.skywalking.apm.collector.core.data.Data; +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.ObjectUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; @@ -36,11 +36,11 @@ import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ -public abstract class PersistenceWorker extends AbstractLocalAsyncWorker { +public abstract class PersistenceWorker extends AbstractLocalAsyncWorker { private final Logger logger = LoggerFactory.getLogger(PersistenceWorker.class); - private final DataCache dataCache; + private final DataCache dataCache; private final IBatchDAO batchDAO; public PersistenceWorker(ModuleManager moduleManager) { @@ -59,7 +59,7 @@ public abstract class PersistenceWorker } } - @Override protected final void onWork(INPUT message) throws WorkerException { + @Override protected final void onWork(INPUT_AND_OUTPUT input) throws WorkerException { if (dataCache.currentCollectionSize() >= 5000) { try { if (dataCache.trySwitchPointer()) { @@ -72,7 +72,7 @@ public abstract class PersistenceWorker dataCache.trySwitchPointerFinally(); } } - aggregate(message); + aggregate(input); } public final List buildBatchCollection() throws WorkerException { @@ -95,22 +95,24 @@ public abstract class PersistenceWorker return batchCollection; } - protected final List prepareBatch(Map dataMap) { + private List prepareBatch(Map dataMap) { List insertBatchCollection = new LinkedList<>(); List updateBatchCollection = new LinkedList<>(); dataMap.forEach((id, data) -> { if (needMergeDBData()) { - Data dbData = persistenceDAO().get(id); + INPUT_AND_OUTPUT dbData = persistenceDAO().get(id); if (ObjectUtils.isNotEmpty(dbData)) { dbData.mergeData(data); try { updateBatchCollection.add(persistenceDAO().prepareBatchUpdate(dbData)); + onNext(dbData); } catch (Throwable t) { logger.error(t.getMessage(), t); } } else { try { insertBatchCollection.add(persistenceDAO().prepareBatchInsert(data)); + onNext(data); } catch (Throwable t) { logger.error(t.getMessage(), t); } @@ -118,6 +120,7 @@ public abstract class PersistenceWorker } else { try { insertBatchCollection.add(persistenceDAO().prepareBatchInsert(data)); + onNext(data); } catch (Throwable t) { logger.error(t.getMessage(), t); } @@ -128,20 +131,18 @@ public abstract class PersistenceWorker return insertBatchCollection; } - private void aggregate(Object message) { + private void aggregate(INPUT_AND_OUTPUT input) { dataCache.writing(); - OUTPUT newData = (OUTPUT)message; - - if (dataCache.containsKey(newData.getId())) { - dataCache.get(newData.getId()).mergeData(newData); + if (dataCache.containsKey(input.getId())) { + dataCache.get(input.getId()).mergeData(input); } else { - dataCache.put(newData.getId(), newData); + dataCache.put(input.getId(), input); } dataCache.finishWriting(); } - protected abstract IPersistenceDAO persistenceDAO(); + protected abstract IPersistenceDAO persistenceDAO(); protected abstract boolean needMergeDBData(); } diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/PersistenceWorkerProvider.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/PersistenceWorkerProvider.java new file mode 100644 index 000000000..b9769a871 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/PersistenceWorkerProvider.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.analysis.worker.model.impl; + +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; + +/** + * @author peng-yongsheng + */ +public abstract class PersistenceWorkerProvider> extends AbstractLocalAsyncWorkerProvider { + + public PersistenceWorkerProvider(ModuleManager moduleManager) { + super(moduleManager); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/data/DataCache.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/data/DataCache.java index 7e2891a11..7cfa06637 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/data/DataCache.java +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/data/DataCache.java @@ -16,20 +16,19 @@ * */ - package org.apache.skywalking.apm.collector.analysis.worker.model.impl.data; import org.apache.skywalking.apm.collector.core.cache.Window; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; /** * @author peng-yongsheng */ -public class DataCache extends Window> { +public class DataCache extends Window> { - private DataCollection lockedDataCollection; + private DataCollection lockedDataCollection; - @Override public DataCollection collectionInstance() { + @Override public DataCollection collectionInstance() { return new DataCollection<>(); } @@ -37,11 +36,11 @@ public class DataCache extends Window implements Collection> { - private Map data; +public class DataCollection implements Collection> { + private Map data; private volatile boolean writing; private volatile boolean reading; @@ -66,11 +65,11 @@ public class DataCollection implements Collection implements Collection collection() { + public Map collection() { return data; } } diff --git a/apm-collector/apm-collector-boot/src/main/resources/application.yml b/apm-collector/apm-collector-boot/src/main/resources/application.yml index 7c77423bb..dfbc142e7 100644 --- a/apm-collector/apm-collector-boot/src/main/resources/application.yml +++ b/apm-collector/apm-collector-boot/src/main/resources/application.yml @@ -41,4 +41,13 @@ storage: cluster_nodes: localhost:9300 index_shards_number: 2 index_replicas_number: 0 - ttl: 7 \ No newline at end of file + ttl: 7 +configuration: + default: + application_apdex_threshold: 2000 + service_error_rate_threshold: 10.00 + service_average_response_time_threshold: 2000 + instance_error_rate_threshold: 10.00 + instance_average_response_time_threshold: 2000 + application_error_rate_threshold: 10.00 + application_average_response_time_threshold: 2000 \ No newline at end of file diff --git a/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/CacheModule.java b/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/CacheModule.java index 3cda871d9..b73f30956 100644 --- a/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/CacheModule.java +++ b/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/CacheModule.java @@ -16,11 +16,11 @@ * */ - package org.apache.skywalking.apm.collector.cache; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService; +import org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheService; import org.apache.skywalking.apm.collector.cache.service.ServiceIdCacheService; import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; import org.apache.skywalking.apm.collector.core.module.Module; @@ -37,6 +37,6 @@ public class CacheModule extends Module { } @Override public Class[] services() { - return new Class[] {ApplicationCacheService.class, InstanceCacheService.class, ServiceIdCacheService.class, ServiceNameCacheService.class}; + return new Class[] {ApplicationCacheService.class, InstanceCacheService.class, ServiceIdCacheService.class, ServiceNameCacheService.class, NetworkAddressCacheService.class}; } } diff --git a/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ApplicationCacheService.java b/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ApplicationCacheService.java index 76a9497fa..57d0c39e3 100644 --- a/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ApplicationCacheService.java +++ b/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ApplicationCacheService.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.cache.service; import org.apache.skywalking.apm.collector.core.module.Service; @@ -25,7 +24,9 @@ import org.apache.skywalking.apm.collector.core.module.Service; * @author peng-yongsheng */ public interface ApplicationCacheService extends Service { - int get(String applicationCode); + int getApplicationIdByCode(String applicationCode); - String get(int applicationId); + String getApplicationCodeById(int applicationId); + + int getApplicationIdByAddressId(int addressId); } diff --git a/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/InstanceCacheService.java b/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/InstanceCacheService.java index b44d70601..646ea3175 100644 --- a/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/InstanceCacheService.java +++ b/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/InstanceCacheService.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.cache.service; import org.apache.skywalking.apm.collector.core.module.Service; @@ -25,7 +24,9 @@ import org.apache.skywalking.apm.collector.core.module.Service; * @author peng-yongsheng */ public interface InstanceCacheService extends Service { - int get(int applicationInstanceId); + int getApplicationId(int instanceId); - int getInstanceId(int applicationId, String agentUUID); + int getInstanceIdByAgentUUID(int applicationId, String agentUUID); + + int getInstanceIdByAddressId(int applicationId, int addressId); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricPersistenceDAO.java b/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/NetworkAddressCacheService.java similarity index 72% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricPersistenceDAO.java rename to apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/NetworkAddressCacheService.java index db5ec8a3f..f0483af11 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricPersistenceDAO.java +++ b/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/NetworkAddressCacheService.java @@ -16,14 +16,15 @@ * */ +package org.apache.skywalking.apm.collector.cache.service; -package org.apache.skywalking.apm.collector.storage.dao; - -import org.apache.skywalking.apm.collector.core.data.Data; -import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.core.module.Service; /** * @author peng-yongsheng */ -public interface IGCMetricPersistenceDAO extends IPersistenceDAO { +public interface NetworkAddressCacheService extends Service { + int getAddressId(String networkAddress); + + String getAddress(int addressId); } diff --git a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/CacheModuleGuavaProvider.java b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/CacheModuleGuavaProvider.java index b4a9c6ae4..af2d54cb1 100644 --- a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/CacheModuleGuavaProvider.java +++ b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/CacheModuleGuavaProvider.java @@ -16,22 +16,23 @@ * */ - package org.apache.skywalking.apm.collector.cache.guava; import java.util.Properties; import org.apache.skywalking.apm.collector.cache.CacheModule; import org.apache.skywalking.apm.collector.cache.guava.service.ApplicationCacheGuavaService; import org.apache.skywalking.apm.collector.cache.guava.service.InstanceCacheGuavaService; +import org.apache.skywalking.apm.collector.cache.guava.service.NetworAddressCacheGuavaService; import org.apache.skywalking.apm.collector.cache.guava.service.ServiceIdCacheGuavaService; import org.apache.skywalking.apm.collector.cache.guava.service.ServiceNameCacheGuavaService; -import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService; -import org.apache.skywalking.apm.collector.cache.service.ServiceIdCacheService; -import org.apache.skywalking.apm.collector.core.module.ModuleProvider; -import org.apache.skywalking.apm.collector.core.module.ServiceNotProvidedException; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; +import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService; +import org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheService; +import org.apache.skywalking.apm.collector.cache.service.ServiceIdCacheService; import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; 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.storage.StorageModule; /** @@ -52,6 +53,7 @@ public class CacheModuleGuavaProvider extends ModuleProvider { this.registerServiceImplementation(InstanceCacheService.class, new InstanceCacheGuavaService(getManager())); this.registerServiceImplementation(ServiceIdCacheService.class, new ServiceIdCacheGuavaService(getManager())); this.registerServiceImplementation(ServiceNameCacheService.class, new ServiceNameCacheGuavaService(getManager())); + this.registerServiceImplementation(NetworkAddressCacheService.class, new NetworAddressCacheGuavaService(getManager())); } @Override public void start(Properties config) throws ServiceNotProvidedException { diff --git a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ApplicationCacheGuavaService.java b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ApplicationCacheGuavaService.java index bc50f245b..530378740 100644 --- a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ApplicationCacheGuavaService.java +++ b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ApplicationCacheGuavaService.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.cache.guava.service; import com.google.common.cache.Cache; @@ -27,7 +26,7 @@ import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,16 +53,16 @@ public class ApplicationCacheGuavaService implements ApplicationCacheService { return this.applicationCacheDAO; } - public int get(String applicationCode) { + @Override public int getApplicationIdByCode(String applicationCode) { int applicationId = 0; try { - applicationId = codeCache.get(applicationCode, () -> getApplicationCacheDAO().getApplicationId(applicationCode)); + applicationId = codeCache.get(applicationCode, () -> getApplicationCacheDAO().getApplicationIdByCode(applicationCode)); } catch (Throwable e) { logger.error(e.getMessage(), e); } if (applicationId == 0) { - applicationId = getApplicationCacheDAO().getApplicationId(applicationCode); + applicationId = getApplicationCacheDAO().getApplicationIdByCode(applicationCode); if (applicationId != 0) { codeCache.put(applicationCode, applicationId); } @@ -73,7 +72,7 @@ public class ApplicationCacheGuavaService implements ApplicationCacheService { private final Cache idCache = CacheBuilder.newBuilder().maximumSize(1000).build(); - public String get(int applicationId) { + @Override public String getApplicationCodeById(int applicationId) { String applicationCode = Const.EMPTY_STRING; try { applicationCode = idCache.get(applicationId, () -> getApplicationCacheDAO().getApplicationCode(applicationId)); @@ -89,4 +88,23 @@ public class ApplicationCacheGuavaService implements ApplicationCacheService { } return applicationCode; } + + private final Cache addressIdCache = CacheBuilder.newBuilder().maximumSize(1000).build(); + + @Override public int getApplicationIdByAddressId(int addressId) { + int applicationId = 0; + try { + applicationId = addressIdCache.get(addressId, () -> getApplicationCacheDAO().getApplicationIdByAddressId(addressId)); + } catch (Throwable e) { + logger.error(e.getMessage(), e); + } + + if (applicationId == 0) { + applicationId = getApplicationCacheDAO().getApplicationIdByAddressId(addressId); + if (applicationId != 0) { + addressIdCache.put(addressId, applicationId); + } + } + return applicationId; + } } diff --git a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/InstanceCacheGuavaService.java b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/InstanceCacheGuavaService.java index 15886a311..7f5f265b6 100644 --- a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/InstanceCacheGuavaService.java +++ b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/InstanceCacheGuavaService.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.cache.guava.service; import com.google.common.cache.Cache; @@ -25,8 +24,8 @@ import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService; 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.ObjectUtils; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceCacheDAO; import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.cache.IInstanceCacheDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,9 +36,11 @@ public class InstanceCacheGuavaService implements InstanceCacheService { private final Logger logger = LoggerFactory.getLogger(InstanceCacheGuavaService.class); - private final Cache integerCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build(); + private final Cache applicationIdCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build(); - private final Cache stringCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build(); + private final Cache agentUUIDCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build(); + + private final Cache addressIdCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build(); private final ModuleManager moduleManager; private IInstanceCacheDAO instanceCacheDAO; @@ -55,38 +56,56 @@ public class InstanceCacheGuavaService implements InstanceCacheService { return this.instanceCacheDAO; } - public int get(int applicationInstanceId) { - + @Override public int getApplicationId(int instanceId) { int applicationId = 0; try { - applicationId = integerCache.get(applicationInstanceId, () -> getInstanceCacheDAO().getApplicationId(applicationInstanceId)); + applicationId = applicationIdCache.get(instanceId, () -> getInstanceCacheDAO().getApplicationId(instanceId)); } catch (Throwable e) { logger.error(e.getMessage(), e); } if (applicationId == 0) { - applicationId = getInstanceCacheDAO().getApplicationId(applicationInstanceId); + applicationId = getInstanceCacheDAO().getApplicationId(instanceId); if (applicationId != 0) { - integerCache.put(applicationInstanceId, applicationId); + applicationIdCache.put(instanceId, applicationId); } } return applicationId; } - @Override public int getInstanceId(int applicationId, String agentUUID) { + @Override public int getInstanceIdByAgentUUID(int applicationId, String agentUUID) { String key = applicationId + Const.ID_SPLIT + agentUUID; int instanceId = 0; try { - instanceId = stringCache.get(key, () -> getInstanceCacheDAO().getInstanceId(applicationId, agentUUID)); + instanceId = agentUUIDCache.get(key, () -> getInstanceCacheDAO().getInstanceIdByAgentUUID(applicationId, agentUUID)); } catch (Throwable e) { logger.error(e.getMessage(), e); } if (instanceId == 0) { - instanceId = getInstanceCacheDAO().getInstanceId(applicationId, agentUUID); + instanceId = getInstanceCacheDAO().getInstanceIdByAgentUUID(applicationId, agentUUID); if (applicationId != 0) { - stringCache.put(key, instanceId); + agentUUIDCache.put(key, instanceId); + } + } + return instanceId; + } + + @Override public int getInstanceIdByAddressId(int applicationId, int addressId) { + String key = applicationId + Const.ID_SPLIT + addressId; + + int instanceId = 0; + try { + instanceId = addressIdCache.get(key, () -> getInstanceCacheDAO().getInstanceIdByAddressId(applicationId, addressId)); + } catch (Throwable e) { + logger.error(e.getMessage(), e); + } + + if (instanceId == 0) { + instanceId = getInstanceCacheDAO().getInstanceIdByAddressId(applicationId, addressId); + if (applicationId != 0) { + addressIdCache.put(key, instanceId); } } return instanceId; diff --git a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/NetworAddressCacheGuavaService.java b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/NetworAddressCacheGuavaService.java new file mode 100644 index 000000000..6bf6c8469 --- /dev/null +++ b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/NetworAddressCacheGuavaService.java @@ -0,0 +1,91 @@ +/* + * 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.cache.guava.service; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheService; +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.ObjectUtils; +import org.apache.skywalking.apm.collector.core.util.StringUtils; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.cache.INetworkAddressCacheDAO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class NetworAddressCacheGuavaService implements NetworkAddressCacheService { + + private final Logger logger = LoggerFactory.getLogger(NetworAddressCacheGuavaService.class); + + private final Cache addressCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build(); + + private final ModuleManager moduleManager; + private INetworkAddressCacheDAO networkAddressCacheDAO; + + public NetworAddressCacheGuavaService(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + } + + private INetworkAddressCacheDAO getNetworkAddressCacheDAO() { + if (ObjectUtils.isEmpty(networkAddressCacheDAO)) { + this.networkAddressCacheDAO = moduleManager.find(StorageModule.NAME).getService(INetworkAddressCacheDAO.class); + } + return this.networkAddressCacheDAO; + } + + public int getAddressId(String networkAddress) { + int addressId = 0; + try { + addressId = addressCache.get(networkAddress, () -> getNetworkAddressCacheDAO().getAddressId(networkAddress)); + } catch (Throwable e) { + logger.error(e.getMessage(), e); + } + + if (addressId == 0) { + addressId = getNetworkAddressCacheDAO().getAddressId(networkAddress); + if (addressId != 0) { + addressCache.put(networkAddress, addressId); + } + } + return addressId; + } + + private final Cache idCache = CacheBuilder.newBuilder().maximumSize(5000).build(); + + public String getAddress(int addressId) { + String networkAddress = Const.EMPTY_STRING; + try { + networkAddress = idCache.get(addressId, () -> getNetworkAddressCacheDAO().getAddress(addressId)); + } catch (Throwable e) { + logger.error(e.getMessage(), e); + } + + if (StringUtils.isEmpty(networkAddress)) { + networkAddress = getNetworkAddressCacheDAO().getAddress(addressId); + if (StringUtils.isNotEmpty(networkAddress)) { + addressCache.put(networkAddress, addressId); + } + } + return networkAddress; + } +} diff --git a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceIdCacheGuavaService.java b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceIdCacheGuavaService.java index 4dcefba9a..5c5a618b9 100644 --- a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceIdCacheGuavaService.java +++ b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceIdCacheGuavaService.java @@ -26,7 +26,7 @@ import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.cache.service.ServiceIdCacheService; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceNameCacheGuavaService.java b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceNameCacheGuavaService.java index aef733248..5aa3fd80e 100644 --- a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceNameCacheGuavaService.java +++ b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceNameCacheGuavaService.java @@ -27,7 +27,7 @@ import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModule.java b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModule.java index f22a9df14..2b9e50ccf 100644 --- a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModule.java +++ b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModule.java @@ -16,10 +16,15 @@ * */ - package org.apache.skywalking.apm.collector.configuration; import org.apache.skywalking.apm.collector.configuration.service.IApdexThresholdService; +import org.apache.skywalking.apm.collector.configuration.service.IApplicationAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.IApplicationReferenceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.IInstanceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.IInstanceReferenceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.IServiceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.IServiceReferenceAlarmRuleConfig; import org.apache.skywalking.apm.collector.core.module.Module; /** @@ -34,6 +39,9 @@ public class ConfigurationModule extends Module { } @Override public Class[] services() { - return new Class[] {IApdexThresholdService.class}; + return new Class[] { + IApdexThresholdService.class, + IServiceAlarmRuleConfig.class, IInstanceAlarmRuleConfig.class, IApplicationAlarmRuleConfig.class, + IServiceReferenceAlarmRuleConfig.class, IInstanceReferenceAlarmRuleConfig.class, IApplicationReferenceAlarmRuleConfig.class}; } } diff --git a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IApplicationAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IApplicationAlarmRuleConfig.java new file mode 100644 index 000000000..08a19fb7b --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IApplicationAlarmRuleConfig.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.configuration.service; + +import org.apache.skywalking.apm.collector.core.module.Service; + +/** + * @author peng-yongsheng + */ +public interface IApplicationAlarmRuleConfig extends Service { + double calleeErrorRateThreshold(); + + double calleeAverageResponseTimeThreshold(); + + double callerErrorRateThreshold(); + + double callerAverageResponseTimeThreshold(); +} diff --git a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IApplicationReferenceAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IApplicationReferenceAlarmRuleConfig.java new file mode 100644 index 000000000..39596e4f1 --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IApplicationReferenceAlarmRuleConfig.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.configuration.service; + +import org.apache.skywalking.apm.collector.core.module.Service; + +/** + * @author peng-yongsheng + */ +public interface IApplicationReferenceAlarmRuleConfig extends Service { + double calleeErrorRateThreshold(); + + double calleeAverageResponseTimeThreshold(); + + double callerErrorRateThreshold(); + + double callerAverageResponseTimeThreshold(); +} diff --git a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IInstanceAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IInstanceAlarmRuleConfig.java new file mode 100644 index 000000000..b53ccaeac --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IInstanceAlarmRuleConfig.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.configuration.service; + +import org.apache.skywalking.apm.collector.core.module.Service; + +/** + * @author peng-yongsheng + */ +public interface IInstanceAlarmRuleConfig extends Service { + double calleeErrorRateThreshold(); + + double calleeAverageResponseTimeThreshold(); + + double callerErrorRateThreshold(); + + double callerAverageResponseTimeThreshold(); +} diff --git a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IInstanceReferenceAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IInstanceReferenceAlarmRuleConfig.java new file mode 100644 index 000000000..e59c7aed8 --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IInstanceReferenceAlarmRuleConfig.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.configuration.service; + +import org.apache.skywalking.apm.collector.core.module.Service; + +/** + * @author peng-yongsheng + */ +public interface IInstanceReferenceAlarmRuleConfig extends Service { + double calleeErrorRateThreshold(); + + double calleeAverageResponseTimeThreshold(); + + double callerErrorRateThreshold(); + + double callerAverageResponseTimeThreshold(); +} diff --git a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IServiceAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IServiceAlarmRuleConfig.java new file mode 100644 index 000000000..778c0cdb4 --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IServiceAlarmRuleConfig.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.configuration.service; + +import org.apache.skywalking.apm.collector.core.module.Service; + +/** + * @author peng-yongsheng + */ +public interface IServiceAlarmRuleConfig extends Service { + double calleeErrorRateThreshold(); + + double calleeAverageResponseTimeThreshold(); + + double callerErrorRateThreshold(); + + double callerAverageResponseTimeThreshold(); +} diff --git a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IServiceReferenceAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IServiceReferenceAlarmRuleConfig.java new file mode 100644 index 000000000..97eee2144 --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IServiceReferenceAlarmRuleConfig.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.configuration.service; + +import org.apache.skywalking.apm.collector.core.module.Service; + +/** + * @author peng-yongsheng + */ +public interface IServiceReferenceAlarmRuleConfig extends Service { + double calleeErrorRateThreshold(); + + double calleeAverageResponseTimeThreshold(); + + double callerErrorRateThreshold(); + + double callerAverageResponseTimeThreshold(); +} diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModuleProvider.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModuleProvider.java index ee79e4e49..eb0c95e45 100644 --- a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModuleProvider.java +++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModuleProvider.java @@ -16,21 +16,40 @@ * */ - package org.apache.skywalking.apm.collector.configuration; import java.util.Properties; import org.apache.skywalking.apm.collector.configuration.service.ApdexThresholdService; +import org.apache.skywalking.apm.collector.configuration.service.ApplicationAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.ApplicationReferenceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.IApdexThresholdService; +import org.apache.skywalking.apm.collector.configuration.service.IApplicationAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.IApplicationReferenceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.IInstanceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.IInstanceReferenceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.IServiceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.IServiceReferenceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.InstanceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.InstanceReferenceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.ServiceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.ServiceReferenceAlarmRuleConfig; +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.configuration.service.IApdexThresholdService; -import org.apache.skywalking.apm.collector.core.module.Module; /** * @author peng-yongsheng */ public class ConfigurationModuleProvider extends ModuleProvider { + private static final String APPLICATION_APDEX_THRESHOLD = "application_apdex_threshold"; + private static final String SERVICE_ERROR_RATE_THRESHOLD = "service_error_rate_threshold"; + private static final String SERVICE_AVERAGE_RESPONSE_TIME_THRESHOLD = "service_average_response_time_threshold"; + private static final String INSTANCE_ERROR_RATE_THRESHOLD = "instance_error_rate_threshold"; + private static final String INSTANCE_AVERAGE_RESPONSE_TIME_THRESHOLD = "instance_average_response_time_threshold"; + private static final String APPLICATION_ERROR_RATE_THRESHOLD = "application_error_rate_threshold"; + private static final String APPLICATION_AVERAGE_RESPONSE_TIME_THRESHOLD = "application_average_response_time_threshold"; + @Override public String name() { return "default"; } @@ -40,7 +59,21 @@ public class ConfigurationModuleProvider extends ModuleProvider { } @Override public void prepare(Properties config) throws ServiceNotProvidedException { - this.registerServiceImplementation(IApdexThresholdService.class, new ApdexThresholdService()); + Integer applicationApdexThreshold = (Integer)config.getOrDefault(APPLICATION_APDEX_THRESHOLD, 2000); + Double serviceErrorRateThreshold = (Double)config.getOrDefault(SERVICE_ERROR_RATE_THRESHOLD, 10.00); + Integer serviceAverageResponseTimeThreshold = (Integer)config.getOrDefault(SERVICE_AVERAGE_RESPONSE_TIME_THRESHOLD, 2000); + Double instanceErrorRateThreshold = (Double)config.getOrDefault(INSTANCE_ERROR_RATE_THRESHOLD, 10.00); + Integer instanceAverageResponseTimeThreshold = (Integer)config.getOrDefault(INSTANCE_AVERAGE_RESPONSE_TIME_THRESHOLD, 2000); + Double applicationErrorRateThreshold = (Double)config.getOrDefault(APPLICATION_ERROR_RATE_THRESHOLD, 10.00); + Integer applicationAverageResponseTimeThreshold = (Integer)config.getOrDefault(APPLICATION_AVERAGE_RESPONSE_TIME_THRESHOLD, 2000); + + this.registerServiceImplementation(IApdexThresholdService.class, new ApdexThresholdService(applicationApdexThreshold)); + this.registerServiceImplementation(IServiceAlarmRuleConfig.class, new ServiceAlarmRuleConfig(serviceErrorRateThreshold, serviceAverageResponseTimeThreshold)); + this.registerServiceImplementation(IInstanceAlarmRuleConfig.class, new InstanceAlarmRuleConfig(instanceErrorRateThreshold, instanceAverageResponseTimeThreshold)); + this.registerServiceImplementation(IApplicationAlarmRuleConfig.class, new ApplicationAlarmRuleConfig(applicationErrorRateThreshold, applicationAverageResponseTimeThreshold)); + this.registerServiceImplementation(IServiceReferenceAlarmRuleConfig.class, new ServiceReferenceAlarmRuleConfig(serviceErrorRateThreshold, serviceAverageResponseTimeThreshold)); + this.registerServiceImplementation(IInstanceReferenceAlarmRuleConfig.class, new InstanceReferenceAlarmRuleConfig(instanceErrorRateThreshold, instanceAverageResponseTimeThreshold)); + this.registerServiceImplementation(IApplicationReferenceAlarmRuleConfig.class, new ApplicationReferenceAlarmRuleConfig(applicationErrorRateThreshold, applicationAverageResponseTimeThreshold)); } @Override public void start(Properties config) throws ServiceNotProvidedException { diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ApdexThresholdService.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ApdexThresholdService.java index 1d9225b7c..5b841096e 100644 --- a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ApdexThresholdService.java +++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ApdexThresholdService.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.configuration.service; /** @@ -24,6 +23,12 @@ package org.apache.skywalking.apm.collector.configuration.service; */ public class ApdexThresholdService implements IApdexThresholdService { + private int apdexThreshold; + + public ApdexThresholdService(int apdexThreshold) { + this.apdexThreshold = apdexThreshold; + } + /** * Apdex T applies to web transactions only * @@ -31,6 +36,6 @@ public class ApdexThresholdService implements IApdexThresholdService { * @return This value is in milli-seconds. */ @Override public Integer getApplicationApdexThreshold(int applicationId) { - return 1000; + return apdexThreshold; } } diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ApplicationAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ApplicationAlarmRuleConfig.java new file mode 100644 index 000000000..53ec71936 --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ApplicationAlarmRuleConfig.java @@ -0,0 +1,49 @@ +/* + * 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.configuration.service; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmRuleConfig implements IApplicationAlarmRuleConfig { + + private double errorRateThreshold; + private int averageResponseTimeThreshold; + + public ApplicationAlarmRuleConfig(double errorRateThreshold, int averageResponseTimeThreshold) { + this.errorRateThreshold = errorRateThreshold; + this.averageResponseTimeThreshold = averageResponseTimeThreshold; + } + + @Override public double calleeErrorRateThreshold() { + return errorRateThreshold; + } + + @Override public double calleeAverageResponseTimeThreshold() { + return averageResponseTimeThreshold; + } + + @Override public double callerErrorRateThreshold() { + return errorRateThreshold; + } + + @Override public double callerAverageResponseTimeThreshold() { + return averageResponseTimeThreshold; + } +} diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ApplicationReferenceAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ApplicationReferenceAlarmRuleConfig.java new file mode 100644 index 000000000..0e9ef86cb --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ApplicationReferenceAlarmRuleConfig.java @@ -0,0 +1,49 @@ +/* + * 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.configuration.service; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceAlarmRuleConfig implements IApplicationReferenceAlarmRuleConfig { + + private double errorRateThreshold; + private int averageResponseTimeThreshold; + + public ApplicationReferenceAlarmRuleConfig(double errorRateThreshold, int averageResponseTimeThreshold) { + this.errorRateThreshold = errorRateThreshold; + this.averageResponseTimeThreshold = averageResponseTimeThreshold; + } + + @Override public double calleeErrorRateThreshold() { + return errorRateThreshold; + } + + @Override public double calleeAverageResponseTimeThreshold() { + return averageResponseTimeThreshold; + } + + @Override public double callerErrorRateThreshold() { + return errorRateThreshold; + } + + @Override public double callerAverageResponseTimeThreshold() { + return averageResponseTimeThreshold; + } +} diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/InstanceAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/InstanceAlarmRuleConfig.java new file mode 100644 index 000000000..3f3122346 --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/InstanceAlarmRuleConfig.java @@ -0,0 +1,49 @@ +/* + * 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.configuration.service; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmRuleConfig implements IInstanceAlarmRuleConfig { + + private double errorRateThreshold; + private int averageResponseTimeThreshold; + + public InstanceAlarmRuleConfig(double errorRateThreshold, int averageResponseTimeThreshold) { + this.errorRateThreshold = errorRateThreshold; + this.averageResponseTimeThreshold = averageResponseTimeThreshold; + } + + @Override public double calleeErrorRateThreshold() { + return errorRateThreshold; + } + + @Override public double calleeAverageResponseTimeThreshold() { + return averageResponseTimeThreshold; + } + + @Override public double callerErrorRateThreshold() { + return errorRateThreshold; + } + + @Override public double callerAverageResponseTimeThreshold() { + return averageResponseTimeThreshold; + } +} diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/InstanceReferenceAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/InstanceReferenceAlarmRuleConfig.java new file mode 100644 index 000000000..6076ee725 --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/InstanceReferenceAlarmRuleConfig.java @@ -0,0 +1,49 @@ +/* + * 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.configuration.service; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceAlarmRuleConfig implements IInstanceReferenceAlarmRuleConfig { + + private double errorRateThreshold; + private int averageResponseTimeThreshold; + + public InstanceReferenceAlarmRuleConfig(double errorRateThreshold, int averageResponseTimeThreshold) { + this.errorRateThreshold = errorRateThreshold; + this.averageResponseTimeThreshold = averageResponseTimeThreshold; + } + + @Override public double calleeErrorRateThreshold() { + return errorRateThreshold; + } + + @Override public double calleeAverageResponseTimeThreshold() { + return averageResponseTimeThreshold; + } + + @Override public double callerErrorRateThreshold() { + return errorRateThreshold; + } + + @Override public double callerAverageResponseTimeThreshold() { + return averageResponseTimeThreshold; + } +} diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ServiceAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ServiceAlarmRuleConfig.java new file mode 100644 index 000000000..ae4e04f47 --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ServiceAlarmRuleConfig.java @@ -0,0 +1,49 @@ +/* + * 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.configuration.service; + +/** + * @author peng-yongsheng + */ +public class ServiceAlarmRuleConfig implements IServiceAlarmRuleConfig { + + private double errorRateThreshold; + private int averageResponseTimeThreshold; + + public ServiceAlarmRuleConfig(double errorRateThreshold, int averageResponseTimeThreshold) { + this.errorRateThreshold = errorRateThreshold; + this.averageResponseTimeThreshold = averageResponseTimeThreshold; + } + + @Override public double calleeErrorRateThreshold() { + return errorRateThreshold; + } + + @Override public double calleeAverageResponseTimeThreshold() { + return averageResponseTimeThreshold; + } + + @Override public double callerErrorRateThreshold() { + return errorRateThreshold; + } + + @Override public double callerAverageResponseTimeThreshold() { + return averageResponseTimeThreshold; + } +} diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ServiceReferenceAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ServiceReferenceAlarmRuleConfig.java new file mode 100644 index 000000000..0fba6fa4e --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ServiceReferenceAlarmRuleConfig.java @@ -0,0 +1,49 @@ +/* + * 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.configuration.service; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceAlarmRuleConfig implements IServiceReferenceAlarmRuleConfig { + + private double errorRateThreshold; + private int averageResponseTimeThreshold; + + public ServiceReferenceAlarmRuleConfig(double errorRateThreshold, int averageResponseTimeThreshold) { + this.errorRateThreshold = errorRateThreshold; + this.averageResponseTimeThreshold = averageResponseTimeThreshold; + } + + @Override public double calleeErrorRateThreshold() { + return errorRateThreshold; + } + + @Override public double calleeAverageResponseTimeThreshold() { + return averageResponseTimeThreshold; + } + + @Override public double callerErrorRateThreshold() { + return errorRateThreshold; + } + + @Override public double callerAverageResponseTimeThreshold() { + return averageResponseTimeThreshold; + } +} diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/cache/Window.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/cache/Window.java index 0dcba24cf..ae007d440 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/cache/Window.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/cache/Window.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.core.cache; import java.util.concurrent.atomic.AtomicInteger; diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/AbstractData.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/AbstractData.java new file mode 100644 index 000000000..51f2a3f08 --- /dev/null +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/AbstractData.java @@ -0,0 +1,196 @@ +/* + * 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.core.data; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractData { + private String[] dataStrings; + private Long[] dataLongs; + private Double[] dataDoubles; + private Integer[] dataIntegers; + private Boolean[] dataBooleans; + private byte[][] dataBytes; + private final Column[] stringColumns; + private final Column[] longColumns; + private final Column[] doubleColumns; + private final Column[] integerColumns; + private final Column[] booleanColumns; + private final Column[] byteColumns; + + public AbstractData(Column[] stringColumns, Column[] longColumns, Column[] doubleColumns, + Column[] integerColumns, Column[] booleanColumns, Column[] byteColumns) { + this.dataStrings = new String[stringColumns.length]; + this.dataLongs = new Long[longColumns.length]; + this.dataDoubles = new Double[doubleColumns.length]; + this.dataIntegers = new Integer[integerColumns.length]; + this.dataBooleans = new Boolean[booleanColumns.length]; + this.dataBytes = new byte[byteColumns.length][]; + this.stringColumns = stringColumns; + this.longColumns = longColumns; + this.doubleColumns = doubleColumns; + this.integerColumns = integerColumns; + this.booleanColumns = booleanColumns; + this.byteColumns = byteColumns; + } + + public final int getDataStringsCount() { + return dataStrings.length; + } + + public final int getDataLongsCount() { + return dataLongs.length; + } + + public final int getDataDoublesCount() { + return dataDoubles.length; + } + + public final int getDataIntegersCount() { + return dataIntegers.length; + } + + public final int getDataBooleansCount() { + return dataBooleans.length; + } + + public final int getDataBytesCount() { + return dataBytes.length; + } + + public final void setDataString(int position, String value) { + dataStrings[position] = value; + } + + public final void setDataLong(int position, Long value) { + dataLongs[position] = value; + } + + public final void setDataDouble(int position, Double value) { + dataDoubles[position] = value; + } + + public final void setDataInteger(int position, Integer value) { + dataIntegers[position] = value; + } + + public final void setDataBoolean(int position, Boolean value) { + dataBooleans[position] = value; + } + + public final void setDataBytes(int position, byte[] dataBytes) { + this.dataBytes[position] = dataBytes; + } + + public final String getDataString(int position) { + return dataStrings[position]; + } + + public final Long getDataLong(int position) { + if (position + 1 > dataLongs.length) { + throw new IndexOutOfBoundsException(); + } else if (dataLongs[position] == null) { + return 0L; + } else { + return dataLongs[position]; + } + } + + public final Double getDataDouble(int position) { + if (position + 1 > dataDoubles.length) { + throw new IndexOutOfBoundsException(); + } else if (dataDoubles[position] == null) { + return 0D; + } else { + return dataDoubles[position]; + } + } + + public final Integer getDataInteger(int position) { + if (position + 1 > dataIntegers.length) { + throw new IndexOutOfBoundsException(); + } else if (dataIntegers[position] == null) { + return 0; + } else { + return dataIntegers[position]; + } + } + + public final Boolean getDataBoolean(int position) { + return dataBooleans[position]; + } + + public final byte[] getDataBytes(int position) { + return dataBytes[position]; + } + + public final void mergeData(AbstractData newData) { + for (int i = 0; i < stringColumns.length; i++) { + String stringData = stringColumns[i].getOperation().operate(newData.getDataString(i), this.getDataString(i)); + this.dataStrings[i] = stringData; + } + for (int i = 0; i < longColumns.length; i++) { + Long longData = longColumns[i].getOperation().operate(newData.getDataLong(i), this.getDataLong(i)); + this.dataLongs[i] = longData; + } + for (int i = 0; i < doubleColumns.length; i++) { + Double doubleData = doubleColumns[i].getOperation().operate(newData.getDataDouble(i), this.getDataDouble(i)); + this.dataDoubles[i] = doubleData; + } + for (int i = 0; i < integerColumns.length; i++) { + Integer integerData = integerColumns[i].getOperation().operate(newData.getDataInteger(i), this.getDataInteger(i)); + this.dataIntegers[i] = integerData; + } + for (int i = 0; i < booleanColumns.length; i++) { + Boolean booleanData = booleanColumns[i].getOperation().operate(newData.getDataBoolean(i), this.getDataBoolean(i)); + this.dataBooleans[i] = booleanData; + } + for (int i = 0; i < byteColumns.length; i++) { + byte[] byteData = byteColumns[i].getOperation().operate(newData.getDataBytes(i), this.getDataBytes(i)); + this.dataBytes[i] = byteData; + } + } + + @Override public final String toString() { + StringBuilder dataStr = new StringBuilder(); + dataStr.append("string: ["); + for (String dataString : dataStrings) { + dataStr.append(dataString).append(","); + } + dataStr.append("], longs: ["); + for (Long dataLong : dataLongs) { + dataStr.append(dataLong).append(","); + } + dataStr.append("], double: ["); + for (Double dataDouble : dataDoubles) { + dataStr.append(dataDouble).append(","); + } + dataStr.append("], integer: ["); + for (Integer dataInteger : dataIntegers) { + dataStr.append(dataInteger).append(","); + } + dataStr.append("], boolean: ["); + for (Boolean dataBoolean : dataBooleans) { + dataStr.append(dataBoolean).append(","); + } + dataStr.append("]"); + return dataStr.toString(); + } +} diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/CommonTable.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/CommonTable.java index 5110571af..8d8e7e420 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/CommonTable.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/CommonTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.core.data; /** @@ -25,5 +24,6 @@ package org.apache.skywalking.apm.collector.core.data; public abstract class CommonTable { public static final String TABLE_TYPE = "type"; public static final String COLUMN_ID = "id"; + public static final String COLUMN_METRIC_ID = "metric_id"; public static final String COLUMN_TIME_BUCKET = "time_bucket"; } diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/Data.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/Data.java index 9e190797c..f93b68f07 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/Data.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/Data.java @@ -16,193 +16,45 @@ * */ - package org.apache.skywalking.apm.collector.core.data; /** * @author peng-yongsheng */ -public abstract class Data extends EndOfBatchQueueMessage { - private String[] dataStrings; - private Long[] dataLongs; - private Double[] dataDoubles; - private Integer[] dataIntegers; - private Boolean[] dataBooleans; - private byte[][] dataBytes; - private final Column[] stringColumns; - private final Column[] longColumns; - private final Column[] doubleColumns; - private final Column[] integerColumns; - private final Column[] booleanColumns; - private final Column[] byteColumns; +public interface Data { + int getDataStringsCount(); - public Data(String id, Column[] stringColumns, Column[] longColumns, Column[] doubleColumns, - Column[] integerColumns, Column[] booleanColumns, Column[] byteColumns) { - super(id); - this.dataStrings = new String[stringColumns.length]; - this.dataStrings[0] = id; - this.dataLongs = new Long[longColumns.length]; - this.dataDoubles = new Double[doubleColumns.length]; - this.dataIntegers = new Integer[integerColumns.length]; - this.dataBooleans = new Boolean[booleanColumns.length]; - this.dataBytes = new byte[byteColumns.length][]; - this.stringColumns = stringColumns; - this.longColumns = longColumns; - this.doubleColumns = doubleColumns; - this.integerColumns = integerColumns; - this.booleanColumns = booleanColumns; - this.byteColumns = byteColumns; - } + int getDataLongsCount(); - public int getDataStringsCount() { - return dataStrings.length; - } + int getDataDoublesCount(); - public int getDataLongsCount() { - return dataLongs.length; - } + int getDataIntegersCount(); - public int getDataDoublesCount() { - return dataDoubles.length; - } + int getDataBooleansCount(); - public int getDataIntegersCount() { - return dataIntegers.length; - } + int getDataBytesCount(); - public int getDataBooleansCount() { - return dataBooleans.length; - } + void setDataString(int position, String value); - public int getDataBytesCount() { - return dataBytes.length; - } + void setDataLong(int position, Long value); - public void setDataString(int position, String value) { - dataStrings[position] = value; - } + void setDataDouble(int position, Double value); - public void setDataLong(int position, Long value) { - dataLongs[position] = value; - } + void setDataInteger(int position, Integer value); - public void setDataDouble(int position, Double value) { - dataDoubles[position] = value; - } + void setDataBoolean(int position, Boolean value); - public void setDataInteger(int position, Integer value) { - dataIntegers[position] = value; - } + void setDataBytes(int position, byte[] dataBytes); - public void setDataBoolean(int position, Boolean value) { - dataBooleans[position] = value; - } + String getDataString(int position); - public void setDataBytes(int position, byte[] dataBytes) { - this.dataBytes[position] = dataBytes; - } + Long getDataLong(int position); - public String getDataString(int position) { - return dataStrings[position]; - } + Double getDataDouble(int position); - public Long getDataLong(int position) { - if (position + 1 > dataLongs.length) { - throw new IndexOutOfBoundsException(); - } else if (dataLongs[position] == null) { - return 0L; - } else { - return dataLongs[position]; - } - } + Integer getDataInteger(int position); - public Double getDataDouble(int position) { - if (position + 1 > dataDoubles.length) { - throw new IndexOutOfBoundsException(); - } else if (dataDoubles[position] == null) { - return 0D; - } else { - return dataDoubles[position]; - } - } + Boolean getDataBoolean(int position); - public Integer getDataInteger(int position) { - if (position + 1 > dataIntegers.length) { - throw new IndexOutOfBoundsException(); - } else if (dataIntegers[position] == null) { - return 0; - } else { - return dataIntegers[position]; - } - } - - public Boolean getDataBoolean(int position) { - return dataBooleans[position]; - } - - public byte[] getDataBytes(int position) { - return dataBytes[position]; - } - - public String getId() { - return dataStrings[0]; - } - - public void setId(String id) { - setKey(id); - this.dataStrings[0] = id; - } - - public void mergeData(Data newData) { - for (int i = 0; i < stringColumns.length; i++) { - String stringData = stringColumns[i].getOperation().operate(newData.getDataString(i), this.getDataString(i)); - this.dataStrings[i] = stringData; - } - for (int i = 0; i < longColumns.length; i++) { - Long longData = longColumns[i].getOperation().operate(newData.getDataLong(i), this.getDataLong(i)); - this.dataLongs[i] = longData; - } - for (int i = 0; i < doubleColumns.length; i++) { - Double doubleData = doubleColumns[i].getOperation().operate(newData.getDataDouble(i), this.getDataDouble(i)); - this.dataDoubles[i] = doubleData; - } - for (int i = 0; i < integerColumns.length; i++) { - Integer integerData = integerColumns[i].getOperation().operate(newData.getDataInteger(i), this.getDataInteger(i)); - this.dataIntegers[i] = integerData; - } - for (int i = 0; i < booleanColumns.length; i++) { - Boolean booleanData = booleanColumns[i].getOperation().operate(newData.getDataBoolean(i), this.getDataBoolean(i)); - this.dataBooleans[i] = booleanData; - } - for (int i = 0; i < byteColumns.length; i++) { - byte[] byteData = byteColumns[i].getOperation().operate(newData.getDataBytes(i), this.getDataBytes(i)); - this.dataBytes[i] = byteData; - } - } - - @Override public String toString() { - StringBuilder dataStr = new StringBuilder(); - dataStr.append("string: ["); - for (String dataString : dataStrings) { - dataStr.append(dataString).append(","); - } - dataStr.append("], longs: ["); - for (Long dataLong : dataLongs) { - dataStr.append(dataLong).append(","); - } - dataStr.append("], double: ["); - for (Double dataDouble : dataDoubles) { - dataStr.append(dataDouble).append(","); - } - dataStr.append("], integer: ["); - for (Integer dataInteger : dataIntegers) { - dataStr.append(dataInteger).append(","); - } - dataStr.append("], boolean: ["); - for (Boolean dataBoolean : dataBooleans) { - dataStr.append(dataBoolean).append(","); - } - dataStr.append("]"); - return dataStr.toString(); - } + byte[] getDataBytes(int position); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricPersistenceDAO.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/QueueData.java similarity index 72% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricPersistenceDAO.java rename to apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/QueueData.java index 04472b7a3..9036dfd4a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricPersistenceDAO.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/QueueData.java @@ -16,14 +16,16 @@ * */ +package org.apache.skywalking.apm.collector.core.data; -package org.apache.skywalking.apm.collector.storage.dao; - -import org.apache.skywalking.apm.collector.core.data.Data; -import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.core.queue.EndOfBatchContext; /** * @author peng-yongsheng */ -public interface ICpuMetricPersistenceDAO extends IPersistenceDAO { +public interface QueueData { + + EndOfBatchContext getEndOfBatchContext(); + + void setEndOfBatchContext(EndOfBatchContext context); } diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/FlushAndSwitch.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/RemoteData.java similarity index 87% rename from apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/FlushAndSwitch.java rename to apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/RemoteData.java index 40be19212..001397e80 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/FlushAndSwitch.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/RemoteData.java @@ -16,10 +16,11 @@ * */ -package org.apache.skywalking.apm.collector.analysis.worker.model.impl; +package org.apache.skywalking.apm.collector.core.data; /** * @author peng-yongsheng */ -public class FlushAndSwitch { +public interface RemoteData extends Data { + String selectKey(); } diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/StreamData.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/StreamData.java new file mode 100644 index 000000000..f5fb8eade --- /dev/null +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/StreamData.java @@ -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.core.data; + +import org.apache.skywalking.apm.collector.core.queue.EndOfBatchContext; + +/** + * @author peng-yongsheng + */ +public abstract class StreamData extends AbstractData implements RemoteData, QueueData { + + private EndOfBatchContext endOfBatchContext; + + @Override public final EndOfBatchContext getEndOfBatchContext() { + return this.endOfBatchContext; + } + + @Override public final void setEndOfBatchContext(EndOfBatchContext context) { + this.endOfBatchContext = context; + } + + public StreamData(Column[] stringColumns, Column[] longColumns, Column[] doubleColumns, + Column[] integerColumns, Column[] booleanColumns, Column[] byteColumns) { + super(stringColumns, longColumns, doubleColumns, integerColumns, booleanColumns, byteColumns); + } + + @Override public final String selectKey() { + return getMetricId(); + } + + public abstract String getId(); + + public abstract void setId(String id); + + public abstract String getMetricId(); + + public abstract void setMetricId(String metricId); +} diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/TableDefine.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/TableDefine.java index 79ecf9f92..d6791c463 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/TableDefine.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/TableDefine.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.core.data; import java.util.LinkedList; diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/AddOperation.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/AddOperation.java index 959c07f54..937751238 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/AddOperation.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/AddOperation.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.core.data.operator; import org.apache.skywalking.apm.collector.core.data.Operation; diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/CoverOperation.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/CoverOperation.java index 3be1d6a4f..837178887 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/CoverOperation.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/CoverOperation.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.core.data.operator; import org.apache.skywalking.apm.collector.core.data.Operation; diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/MaxOperation.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/MaxOperation.java new file mode 100644 index 000000000..36eda8883 --- /dev/null +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/MaxOperation.java @@ -0,0 +1,63 @@ +/* + * 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.core.data.operator; + +import org.apache.skywalking.apm.collector.core.data.Operation; + +/** + * @author peng-yongsheng + */ +public class MaxOperation implements Operation { + + @Override public String operate(String newValue, String oldValue) { + throw new UnsupportedOperationException("not support string maximum operation"); + } + + @Override public Long operate(Long newValue, Long oldValue) { + if (newValue >= oldValue) { + return newValue; + } else { + return oldValue; + } + } + + @Override public Double operate(Double newValue, Double oldValue) { + if (newValue >= oldValue) { + return newValue; + } else { + return oldValue; + } + } + + @Override public Integer operate(Integer newValue, Integer oldValue) { + if (newValue >= oldValue) { + return newValue; + } else { + return oldValue; + } + } + + @Override public Boolean operate(Boolean newValue, Boolean oldValue) { + throw new UnsupportedOperationException("not support boolean maximum operation"); + } + + @Override public byte[] operate(byte[] newValue, byte[] oldValue) { + throw new UnsupportedOperationException("not support byte maximum operation"); + } +} diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/MinOperation.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/MinOperation.java new file mode 100644 index 000000000..2b0c8a2d7 --- /dev/null +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/MinOperation.java @@ -0,0 +1,63 @@ +/* + * 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.core.data.operator; + +import org.apache.skywalking.apm.collector.core.data.Operation; + +/** + * @author peng-yongsheng + */ +public class MinOperation implements Operation { + + @Override public String operate(String newValue, String oldValue) { + throw new UnsupportedOperationException("not support string minimum operation"); + } + + @Override public Long operate(Long newValue, Long oldValue) { + if (newValue <= oldValue) { + return newValue; + } else { + return oldValue; + } + } + + @Override public Double operate(Double newValue, Double oldValue) { + if (newValue <= oldValue) { + return newValue; + } else { + return oldValue; + } + } + + @Override public Integer operate(Integer newValue, Integer oldValue) { + if (newValue <= oldValue) { + return newValue; + } else { + return oldValue; + } + } + + @Override public Boolean operate(Boolean newValue, Boolean oldValue) { + throw new UnsupportedOperationException("not support boolean minimum operation"); + } + + @Override public byte[] operate(byte[] newValue, byte[] oldValue) { + throw new UnsupportedOperationException("not support byte minimum operation"); + } +} diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/NonOperation.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/NonOperation.java index b3342aef0..adc00d90f 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/NonOperation.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/operator/NonOperation.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.core.data.operator; import org.apache.skywalking.apm.collector.core.data.Operation; diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/queue/EndOfBatchContext.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/queue/EndOfBatchContext.java new file mode 100644 index 000000000..e2507d162 --- /dev/null +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/queue/EndOfBatchContext.java @@ -0,0 +1,39 @@ +/* + * 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.core.queue; + +/** + * @author peng-yongsheng + */ +public class EndOfBatchContext { + + private boolean isEndOfBatch; + + public EndOfBatchContext(boolean isEndOfBatch) { + this.isEndOfBatch = isEndOfBatch; + } + + public boolean isEndOfBatch() { + return isEndOfBatch; + } + + public void setEndOfBatch(boolean endOfBatch) { + isEndOfBatch = endOfBatch; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/MessageHolder.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/storage/TimePyramid.java similarity index 66% rename from apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/MessageHolder.java rename to apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/storage/TimePyramid.java index b990b8d72..5fd286ada 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/impl/MessageHolder.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/storage/TimePyramid.java @@ -16,26 +16,27 @@ * */ - -package org.apache.skywalking.apm.collector.analysis.worker.model.impl; - -import org.apache.skywalking.apm.collector.core.data.EndOfBatchQueueMessage; +package org.apache.skywalking.apm.collector.core.storage; /** * @author peng-yongsheng */ -public class MessageHolder { - private MESSAGE message; +public enum TimePyramid { + Second(0, "second"), Minute(1, "minute"), Hour(2, "hour"), Day(3, "day"), Month(4, "month"); - public MESSAGE getMessage() { - return message; + private final int value; + private final String name; + + TimePyramid(int value, String name) { + this.value = value; + this.name = name; } - public void setMessage(MESSAGE message) { - this.message = message; + public int getValue() { + return value; } - public void reset() { - message = null; + public String getName() { + return name; } } diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/Const.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/Const.java index bcf2fa67e..6030c2bb6 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/Const.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/Const.java @@ -16,17 +16,17 @@ * */ - package org.apache.skywalking.apm.collector.core.util; /** * @author peng-yongsheng */ public class Const { + public static final int NONE = 0; public static final String ID_SPLIT = "_"; - public static final int USER_ID = 1; - public static final int NONE_SERVICE_ID = 1; + public static final int NONE_APPLICATION_ID = 1; public static final int NONE_INSTANCE_ID = 1; + public static final int NONE_SERVICE_ID = 1; public static final String NONE_SERVICE_NAME = "None"; public static final String USER_CODE = "User"; public static final String SEGMENT_SPAN_SPLIT = "S"; diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/EndOfBatchQueueMessage.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/NumberFormatUtils.java similarity index 65% rename from apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/EndOfBatchQueueMessage.java rename to apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/NumberFormatUtils.java index 54319d9b1..43d72fd68 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/EndOfBatchQueueMessage.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/NumberFormatUtils.java @@ -16,26 +16,20 @@ * */ +package org.apache.skywalking.apm.collector.core.util; -package org.apache.skywalking.apm.collector.core.data; +import java.math.RoundingMode; +import java.text.DecimalFormat; /** * @author peng-yongsheng */ -public abstract class EndOfBatchQueueMessage extends AbstractHashMessage { +public class NumberFormatUtils { - private boolean endOfBatch; - - public EndOfBatchQueueMessage(String key) { - super(key); - endOfBatch = false; - } - - public final boolean isEndOfBatch() { - return endOfBatch; - } - - public final void setEndOfBatch(boolean endOfBatch) { - this.endOfBatch = endOfBatch; + public static Double rateNumberFormat(Double rate) { + DecimalFormat decimalFormat = new DecimalFormat("#.00"); + decimalFormat.setRoundingMode(RoundingMode.HALF_UP); + Double formattedRate = Double.valueOf(decimalFormat.format(rate)); + return Double.valueOf(formattedRate); } } diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java index dcbe278fe..e7f8501cf 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.core.util; import java.text.SimpleDateFormat; @@ -63,6 +62,34 @@ public enum TimeBucketUtils { return Long.valueOf(timeStr); } + public long minuteToHour(long minuteBucket) { + return minuteBucket / 100; + } + + public long minuteToDay(long minuteBucket) { + return minuteBucket / 100 / 100; + } + + public long minuteToMonth(long minuteBucket) { + return minuteBucket / 100 / 100 / 100; + } + + public long secondToMinute(long secondBucket) { + return secondBucket / 100; + } + + public long secondToHour(long secondBucket) { + return secondBucket / 100 / 100; + } + + public long secondToDay(long secondBucket) { + return secondBucket / 100 / 100 / 100; + } + + public long secondToMonth(long secondBucket) { + return secondBucket / 100 / 100 / 100 / 100; + } + public long changeTimeBucket2TimeStamp(String timeBucketType, long timeBucket) { if (TimeBucketType.SECOND.name().toLowerCase().equals(timeBucketType.toLowerCase())) { Calendar calendar = Calendar.getInstance(); diff --git a/apm-collector/apm-collector-core/src/main/resources/application-default.yml b/apm-collector/apm-collector-core/src/main/resources/application-default.yml index 117e7bda4..d86a3b1a8 100644 --- a/apm-collector/apm-collector-core/src/main/resources/application-default.yml +++ b/apm-collector/apm-collector-core/src/main/resources/application-default.yml @@ -33,6 +33,13 @@ analysis_alarm: default: configuration: default: + application_apdex_threshold: 2000 + service_error_rate_threshold: 10.00 + service_average_response_time_threshold: 2000 + instance_error_rate_threshold: 10.00 + instance_average_response_time_threshold: 2000 + application_error_rate_threshold: 10.00 + application_average_response_time_threshold: 2000 ui: jetty: host: localhost diff --git a/apm-collector/apm-collector-core/src/test/java/org/apache/skywalking/apm/collector/core/util/NumberFormatUtilsTest.java b/apm-collector/apm-collector-core/src/test/java/org/apache/skywalking/apm/collector/core/util/NumberFormatUtilsTest.java new file mode 100644 index 000000000..e39c1f861 --- /dev/null +++ b/apm-collector/apm-collector-core/src/test/java/org/apache/skywalking/apm/collector/core/util/NumberFormatUtilsTest.java @@ -0,0 +1,46 @@ +/* + * 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.core.util; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author peng-yongsheng + */ +public class NumberFormatUtilsTest { + + @Test + public void testRateNumberFormat() { + Double rate = NumberFormatUtils.rateNumberFormat(12.1111); + Assert.assertEquals(rate, Double.valueOf(12.11)); + + rate = NumberFormatUtils.rateNumberFormat(12.1151); + Assert.assertEquals(rate, Double.valueOf(12.12)); + + rate = NumberFormatUtils.rateNumberFormat(12.1); + Assert.assertEquals(rate, Double.valueOf(12.1)); + + rate = NumberFormatUtils.rateNumberFormat(12.00); + Assert.assertEquals(rate, Double.valueOf(12.00)); + + rate = NumberFormatUtils.rateNumberFormat(4624.00); + Assert.assertEquals(rate, Double.valueOf(4624.00)); + } +} diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/CommonRemoteDataRegisterService.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/CommonRemoteDataRegisterService.java index 81c0ee5be..e1df66448 100644 --- a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/CommonRemoteDataRegisterService.java +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/CommonRemoteDataRegisterService.java @@ -16,12 +16,11 @@ * */ - package org.apache.skywalking.apm.collector.remote.service; import java.util.HashMap; import java.util.Map; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.RemoteData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +32,7 @@ public class CommonRemoteDataRegisterService implements RemoteDataRegisterServic private final Logger logger = LoggerFactory.getLogger(CommonRemoteDataRegisterService.class); private Integer id; - private final Map, Integer> dataClassMapping; + private final Map, Integer> dataClassMapping; private final Map dataInstanceCreatorMapping; public CommonRemoteDataRegisterService() { @@ -42,7 +41,7 @@ public class CommonRemoteDataRegisterService implements RemoteDataRegisterServic this.dataInstanceCreatorMapping = new HashMap<>(); } - @Override public void register(Class dataClass, RemoteDataInstanceCreator instanceCreator) { + @Override public void register(Class dataClass, RemoteDataInstanceCreator instanceCreator) { if (!dataClassMapping.containsKey(dataClass)) { dataClassMapping.put(dataClass, this.id); dataInstanceCreatorMapping.put(this.id, instanceCreator); @@ -53,7 +52,7 @@ public class CommonRemoteDataRegisterService implements RemoteDataRegisterServic } @Override - public Integer getRemoteDataId(Class dataClass) throws RemoteDataMappingIdNotFoundException { + public Integer getRemoteDataId(Class dataClass) throws RemoteDataMappingIdNotFoundException { if (dataClassMapping.containsKey(dataClass)) { return dataClassMapping.get(dataClass); } else { diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteClient.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteClient.java index e4d7d5782..153eaba16 100644 --- a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteClient.java +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteClient.java @@ -16,10 +16,9 @@ * */ - package org.apache.skywalking.apm.collector.remote.service; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.RemoteData; /** * @author peng-yongsheng @@ -27,7 +26,7 @@ import org.apache.skywalking.apm.collector.core.data.Data; public interface RemoteClient extends Comparable { String getAddress(); - void push(int graphId, int nodeId, Data data); + void push(int graphId, int nodeId, RemoteData data); boolean equals(String address); } diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteDataIDGetter.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteDataIDGetter.java index 807d4ec3f..8e993dcf1 100644 --- a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteDataIDGetter.java +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteDataIDGetter.java @@ -16,14 +16,13 @@ * */ - package org.apache.skywalking.apm.collector.remote.service; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.RemoteData; /** * @author peng-yongsheng */ public interface RemoteDataIDGetter { - Integer getRemoteDataId(Class dataClass) throws RemoteDataMappingIdNotFoundException; + Integer getRemoteDataId(Class dataClass) throws RemoteDataMappingIdNotFoundException; } diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteDataRegisterService.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteDataRegisterService.java index 410d5b81d..943b4d31b 100644 --- a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteDataRegisterService.java +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteDataRegisterService.java @@ -16,19 +16,18 @@ * */ - package org.apache.skywalking.apm.collector.remote.service; +import org.apache.skywalking.apm.collector.core.data.RemoteData; import org.apache.skywalking.apm.collector.core.module.Service; -import org.apache.skywalking.apm.collector.core.data.Data; /** * @author peng-yongsheng */ public interface RemoteDataRegisterService extends Service { - void register(Class dataClass, RemoteDataInstanceCreator instanceCreator); + void register(Class dataClass, RemoteDataInstanceCreator instanceCreator); - interface RemoteDataInstanceCreator { - RemoteData createInstance(String id); + interface RemoteDataInstanceCreator { + REMOTE_DATA createInstance(String id); } } diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteDeserializeService.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteDeserializeService.java index 348e85b2e..ef6ad0cf8 100644 --- a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteDeserializeService.java +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteDeserializeService.java @@ -16,14 +16,11 @@ * */ - package org.apache.skywalking.apm.collector.remote.service; -import org.apache.skywalking.apm.collector.core.data.Data; - /** * @author peng-yongsheng */ public interface RemoteDeserializeService { - void deserialize(RemoteData remoteData, Data data); + void deserialize(RemoteData remoteData, org.apache.skywalking.apm.collector.core.data.RemoteData data); } diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteSenderService.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteSenderService.java index d14dc61c0..e20fbad16 100644 --- a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteSenderService.java +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteSenderService.java @@ -16,17 +16,16 @@ * */ - package org.apache.skywalking.apm.collector.remote.service; +import org.apache.skywalking.apm.collector.core.data.RemoteData; import org.apache.skywalking.apm.collector.core.module.Service; -import org.apache.skywalking.apm.collector.core.data.Data; /** * @author peng-yongsheng */ public interface RemoteSenderService extends Service { - Mode send(int graphId, int nodeId, Data data, Selector selector); + Mode send(int graphId, int nodeId, RemoteData remoteData, Selector selector); enum Mode { Remote, Local diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteSerializeService.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteSerializeService.java index 908d99a8d..d7b51064e 100644 --- a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteSerializeService.java +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/apache/skywalking/apm/collector/remote/service/RemoteSerializeService.java @@ -16,14 +16,13 @@ * */ - package org.apache.skywalking.apm.collector.remote.service; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.RemoteData; /** * @author peng-yongsheng */ public interface RemoteSerializeService { - Builder serialize(Data data); + Builder serialize(RemoteData data); } diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/handler/RemoteCommonServiceHandler.java b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/handler/RemoteCommonServiceHandler.java index 36a037889..c9cc8f53e 100644 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/handler/RemoteCommonServiceHandler.java +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/handler/RemoteCommonServiceHandler.java @@ -16,19 +16,17 @@ * */ - package org.apache.skywalking.apm.collector.remote.grpc.handler; import io.grpc.stub.StreamObserver; -import org.apache.skywalking.apm.collector.core.data.Data; 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.util.Const; -import org.apache.skywalking.apm.collector.remote.grpc.service.GRPCRemoteDeserializeService; import org.apache.skywalking.apm.collector.remote.grpc.proto.Empty; import org.apache.skywalking.apm.collector.remote.grpc.proto.RemoteCommonServiceGrpc; import org.apache.skywalking.apm.collector.remote.grpc.proto.RemoteData; import org.apache.skywalking.apm.collector.remote.grpc.proto.RemoteMessage; +import org.apache.skywalking.apm.collector.remote.grpc.service.GRPCRemoteDeserializeService; import org.apache.skywalking.apm.collector.remote.service.RemoteDataInstanceCreatorGetter; import org.apache.skywalking.apm.collector.remote.service.RemoteDataInstanceCreatorNotFoundException; import org.apache.skywalking.apm.collector.server.grpc.GRPCHandler; @@ -60,7 +58,7 @@ public class RemoteCommonServiceHandler extends RemoteCommonServiceGrpc.RemoteCo RemoteData remoteData = message.getRemoteData(); try { - Data output = instanceCreatorGetter.getInstanceCreator(remoteDataId).createInstance(Const.EMPTY_STRING); + org.apache.skywalking.apm.collector.core.data.RemoteData output = instanceCreatorGetter.getInstanceCreator(remoteDataId).createInstance(Const.EMPTY_STRING); service.deserialize(remoteData, output); Next next = GraphManager.INSTANCE.findGraph(graphId).toFinder().findNext(nodeId); next.execute(output); diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClient.java b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClient.java index a120f619e..eda70781d 100644 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClient.java +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClient.java @@ -16,13 +16,11 @@ * */ - package org.apache.skywalking.apm.collector.remote.grpc.service; import io.grpc.stub.StreamObserver; import java.util.List; import org.apache.skywalking.apm.collector.client.grpc.GRPCClient; -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.remote.grpc.proto.Empty; import org.apache.skywalking.apm.collector.remote.grpc.proto.RemoteCommonServiceGrpc; import org.apache.skywalking.apm.collector.remote.grpc.proto.RemoteMessage; @@ -62,7 +60,7 @@ public class GRPCRemoteClient implements RemoteClient { return this.address; } - @Override public void push(int graphId, int nodeId, Data data) { + @Override public void push(int graphId, int nodeId, org.apache.skywalking.apm.collector.core.data.RemoteData data) { try { Integer remoteDataId = remoteDataIDGetter.getRemoteDataId(data.getClass()); RemoteMessage.Builder builder = RemoteMessage.newBuilder(); @@ -72,7 +70,6 @@ public class GRPCRemoteClient implements RemoteClient { builder.setRemoteData(service.serialize(data)); this.carrier.produce(builder.build()); - logger.debug("put remote message into queue, id: {}", data.getId()); } catch (RemoteDataMappingIdNotFoundException e) { logger.error(e.getMessage(), e); } diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClientService.java b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClientService.java index 46fa0d831..3e36a0e2f 100644 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClientService.java +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClientService.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.remote.grpc.service; import org.apache.skywalking.apm.collector.client.ClientException; diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteDeserializeService.java b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteDeserializeService.java index 709c65108..4ef7e5eed 100644 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteDeserializeService.java +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteDeserializeService.java @@ -16,19 +16,18 @@ * */ - package org.apache.skywalking.apm.collector.remote.grpc.service; -import org.apache.skywalking.apm.collector.remote.service.RemoteDeserializeService; -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.remote.grpc.proto.RemoteData; +import org.apache.skywalking.apm.collector.remote.service.RemoteDeserializeService; /** * @author peng-yongsheng */ public class GRPCRemoteDeserializeService implements RemoteDeserializeService { - @Override public void deserialize(RemoteData remoteData, Data data) { + @Override + public void deserialize(RemoteData remoteData, org.apache.skywalking.apm.collector.core.data.RemoteData data) { for (int i = 0; i < remoteData.getDataStringsCount(); i++) { data.setDataString(i, remoteData.getDataStrings(i)); } diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteSenderService.java b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteSenderService.java index fe2827765..00bb61e1c 100644 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteSenderService.java +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteSenderService.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.remote.grpc.service; import java.util.ArrayList; @@ -24,7 +23,7 @@ import java.util.Collections; import java.util.List; import org.apache.skywalking.apm.collector.cluster.ClusterModuleListener; import org.apache.skywalking.apm.collector.core.UnexpectedException; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.RemoteData; import org.apache.skywalking.apm.collector.remote.RemoteModule; import org.apache.skywalking.apm.collector.remote.grpc.RemoteModuleGRPCProvider; import org.apache.skywalking.apm.collector.remote.grpc.service.selector.ForeverFirstSelector; @@ -50,27 +49,27 @@ public class GRPCRemoteSenderService extends ClusterModuleListener implements Re private final int channelSize; private final int bufferSize; - @Override public Mode send(int graphId, int nodeId, Data data, Selector selector) { + @Override public Mode send(int graphId, int nodeId, RemoteData remoteData, Selector selector) { RemoteClient remoteClient; switch (selector) { case HashCode: - remoteClient = hashCodeSelector.select(remoteClients, data); - return sendToRemoteWhenNotSelf(remoteClient, graphId, nodeId, data); + remoteClient = hashCodeSelector.select(remoteClients, remoteData); + return sendToRemoteWhenNotSelf(remoteClient, graphId, nodeId, remoteData); case Rolling: - remoteClient = rollingSelector.select(remoteClients, data); - return sendToRemoteWhenNotSelf(remoteClient, graphId, nodeId, data); + remoteClient = rollingSelector.select(remoteClients, remoteData); + return sendToRemoteWhenNotSelf(remoteClient, graphId, nodeId, remoteData); case ForeverFirst: - remoteClient = foreverFirstSelector.select(remoteClients, data); - return sendToRemoteWhenNotSelf(remoteClient, graphId, nodeId, data); + remoteClient = foreverFirstSelector.select(remoteClients, remoteData); + return sendToRemoteWhenNotSelf(remoteClient, graphId, nodeId, remoteData); } throw new UnexpectedException("Selector not match, Just support hash, rolling, forever first selector."); } - private Mode sendToRemoteWhenNotSelf(RemoteClient remoteClient, int graphId, int nodeId, Data data) { + private Mode sendToRemoteWhenNotSelf(RemoteClient remoteClient, int graphId, int nodeId, RemoteData remoteData) { if (remoteClient.equals(selfAddress)) { return Mode.Local; } else { - remoteClient.push(graphId, nodeId, data); + remoteClient.push(graphId, nodeId, remoteData); return Mode.Remote; } } diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteSerializeService.java b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteSerializeService.java index 762fb9f6b..b4d6a0d49 100644 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteSerializeService.java +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteSerializeService.java @@ -16,10 +16,8 @@ * */ - package org.apache.skywalking.apm.collector.remote.grpc.service; -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.remote.grpc.proto.RemoteData; import org.apache.skywalking.apm.collector.remote.service.RemoteSerializeService; @@ -28,7 +26,7 @@ import org.apache.skywalking.apm.collector.remote.service.RemoteSerializeService */ public class GRPCRemoteSerializeService implements RemoteSerializeService { - @Override public RemoteData.Builder serialize(Data data) { + @Override public RemoteData.Builder serialize(org.apache.skywalking.apm.collector.core.data.RemoteData data) { RemoteData.Builder builder = RemoteData.newBuilder(); for (int i = 0; i < data.getDataStringsCount(); i++) { builder.addDataStrings(data.getDataString(i)); diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/ForeverFirstSelector.java b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/ForeverFirstSelector.java index 0ad2efc61..0820d5ba0 100644 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/ForeverFirstSelector.java +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/ForeverFirstSelector.java @@ -16,11 +16,10 @@ * */ - package org.apache.skywalking.apm.collector.remote.grpc.service.selector; import java.util.List; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.RemoteData; import org.apache.skywalking.apm.collector.remote.service.RemoteClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,7 +31,7 @@ public class ForeverFirstSelector implements RemoteClientSelector { private final Logger logger = LoggerFactory.getLogger(ForeverFirstSelector.class); - @Override public RemoteClient select(List clients, Data message) { + @Override public RemoteClient select(List clients, RemoteData remoteData) { logger.debug("clients size: {}", clients.size()); return clients.get(0); } diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/HashCodeSelector.java b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/HashCodeSelector.java index 613f40e71..ffdc3ae21 100644 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/HashCodeSelector.java +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/HashCodeSelector.java @@ -16,11 +16,10 @@ * */ - package org.apache.skywalking.apm.collector.remote.grpc.service.selector; import java.util.List; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.RemoteData; import org.apache.skywalking.apm.collector.remote.service.RemoteClient; /** @@ -28,9 +27,9 @@ import org.apache.skywalking.apm.collector.remote.service.RemoteClient; */ public class HashCodeSelector implements RemoteClientSelector { - @Override public RemoteClient select(List clients, Data message) { + @Override public RemoteClient select(List clients, RemoteData remoteData) { int size = clients.size(); - int selectIndex = Math.abs(message.getHashCode()) % size; + int selectIndex = Math.abs(remoteData.selectKey().hashCode()) % size; return clients.get(selectIndex); } } diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/RemoteClientSelector.java b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/RemoteClientSelector.java index d5d96cec0..51137d1b6 100644 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/RemoteClientSelector.java +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/RemoteClientSelector.java @@ -16,16 +16,15 @@ * */ - package org.apache.skywalking.apm.collector.remote.grpc.service.selector; import java.util.List; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.RemoteData; import org.apache.skywalking.apm.collector.remote.service.RemoteClient; /** * @author peng-yongsheng */ public interface RemoteClientSelector { - RemoteClient select(List clients, Data message); + RemoteClient select(List clients, RemoteData remoteData); } diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/RollingSelector.java b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/RollingSelector.java index faa8d7975..3a242c596 100644 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/RollingSelector.java +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/selector/RollingSelector.java @@ -16,11 +16,10 @@ * */ - package org.apache.skywalking.apm.collector.remote.grpc.service.selector; import java.util.List; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.RemoteData; import org.apache.skywalking.apm.collector.remote.service.RemoteClient; /** @@ -30,7 +29,7 @@ public class RollingSelector implements RemoteClientSelector { private int index = 0; - @Override public RemoteClient select(List clients, Data message) { + @Override public RemoteClient select(List clients, RemoteData remoteData) { int size = clients.size(); index++; int selectIndex = Math.abs(index) % size; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java index ac0990a0a..5ad1ae98e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java @@ -22,44 +22,99 @@ import java.util.ArrayList; import java.util.List; import org.apache.skywalking.apm.collector.core.module.Module; import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO; -import org.apache.skywalking.apm.collector.storage.dao.IAlertingListPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationCacheDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceCacheDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceReferenceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceNameRegisterDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceReferenceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceReferenceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IInstanceCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.INetworkAddressCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemorySecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.INetworkAddressRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IServiceNameRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMonthMetricPersistenceDAO; /** * @author peng-yongsheng @@ -80,7 +135,7 @@ public class StorageModule extends Module { addRegisterDAO(classes); addPersistenceDAO(classes); addUiDAO(classes); - addAlertingDAO(classes); + addAlarmDAO(classes); return classes.toArray(new Class[] {}); } @@ -89,33 +144,91 @@ public class StorageModule extends Module { classes.add(IApplicationCacheDAO.class); classes.add(IInstanceCacheDAO.class); classes.add(IServiceNameCacheDAO.class); + classes.add(INetworkAddressCacheDAO.class); } private void addRegisterDAO(List classes) { classes.add(IApplicationRegisterDAO.class); classes.add(IInstanceRegisterDAO.class); classes.add(IServiceNameRegisterDAO.class); + classes.add(INetworkAddressRegisterDAO.class); } private void addPersistenceDAO(List classes) { - classes.add(ICpuMetricPersistenceDAO.class); - classes.add(IGCMetricPersistenceDAO.class); - classes.add(IMemoryMetricPersistenceDAO.class); - classes.add(IMemoryPoolMetricPersistenceDAO.class); + classes.add(ICpuSecondMetricPersistenceDAO.class); + classes.add(ICpuMinuteMetricPersistenceDAO.class); + classes.add(ICpuHourMetricPersistenceDAO.class); + classes.add(ICpuDayMetricPersistenceDAO.class); + classes.add(ICpuMonthMetricPersistenceDAO.class); + + classes.add(IGCSecondMetricPersistenceDAO.class); + classes.add(IGCMinuteMetricPersistenceDAO.class); + classes.add(IGCHourMetricPersistenceDAO.class); + classes.add(IGCDayMetricPersistenceDAO.class); + classes.add(IGCMonthMetricPersistenceDAO.class); + + classes.add(IMemorySecondMetricPersistenceDAO.class); + classes.add(IMemoryMinuteMetricPersistenceDAO.class); + classes.add(IMemoryHourMetricPersistenceDAO.class); + classes.add(IMemoryDayMetricPersistenceDAO.class); + classes.add(IMemoryMonthMetricPersistenceDAO.class); + + classes.add(IMemoryPoolSecondMetricPersistenceDAO.class); + classes.add(IMemoryPoolMinuteMetricPersistenceDAO.class); + classes.add(IMemoryPoolHourMetricPersistenceDAO.class); + classes.add(IMemoryPoolDayMetricPersistenceDAO.class); + classes.add(IMemoryPoolMonthMetricPersistenceDAO.class); + + classes.add(IApplicationComponentMinutePersistenceDAO.class); + classes.add(IApplicationComponentHourPersistenceDAO.class); + classes.add(IApplicationComponentDayPersistenceDAO.class); + classes.add(IApplicationComponentMonthPersistenceDAO.class); + + classes.add(IApplicationMappingMinutePersistenceDAO.class); + classes.add(IApplicationMappingHourPersistenceDAO.class); + classes.add(IApplicationMappingDayPersistenceDAO.class); + classes.add(IApplicationMappingMonthPersistenceDAO.class); + + classes.add(IInstanceMappingMinutePersistenceDAO.class); + classes.add(IInstanceMappingHourPersistenceDAO.class); + classes.add(IInstanceMappingDayPersistenceDAO.class); + classes.add(IInstanceMappingMonthPersistenceDAO.class); classes.add(IGlobalTracePersistenceDAO.class); - classes.add(IApplicationComponentPersistenceDAO.class); - classes.add(IApplicationMappingPersistenceDAO.class); - classes.add(IApplicationMetricPersistenceDAO.class); - classes.add(IApplicationReferenceMetricPersistenceDAO.class); + + classes.add(IApplicationMinuteMetricPersistenceDAO.class); + classes.add(IApplicationHourMetricPersistenceDAO.class); + classes.add(IApplicationDayMetricPersistenceDAO.class); + classes.add(IApplicationMonthMetricPersistenceDAO.class); + + classes.add(IApplicationReferenceMinuteMetricPersistenceDAO.class); + classes.add(IApplicationReferenceHourMetricPersistenceDAO.class); + classes.add(IApplicationReferenceDayMetricPersistenceDAO.class); + classes.add(IApplicationReferenceMonthMetricPersistenceDAO.class); + classes.add(ISegmentCostPersistenceDAO.class); classes.add(ISegmentPersistenceDAO.class); - classes.add(IServiceEntryPersistenceDAO.class); - classes.add(IServiceMetricPersistenceDAO.class); - classes.add(IServiceReferenceMetricPersistenceDAO.class); - classes.add(IInstanceMetricPersistenceDAO.class); - classes.add(IInstanceReferenceMetricPersistenceDAO.class); + classes.add(IServiceMinuteMetricPersistenceDAO.class); + classes.add(IServiceHourMetricPersistenceDAO.class); + classes.add(IServiceDayMetricPersistenceDAO.class); + classes.add(IServiceMonthMetricPersistenceDAO.class); + + classes.add(IServiceReferenceMinuteMetricPersistenceDAO.class); + classes.add(IServiceReferenceHourMetricPersistenceDAO.class); + classes.add(IServiceReferenceDayMetricPersistenceDAO.class); + classes.add(IServiceReferenceMonthMetricPersistenceDAO.class); + + classes.add(IInstanceMinuteMetricPersistenceDAO.class); + classes.add(IInstanceHourMetricPersistenceDAO.class); + classes.add(IInstanceDayMetricPersistenceDAO.class); + classes.add(IInstanceMonthMetricPersistenceDAO.class); + + classes.add(IInstanceReferenceMinuteMetricPersistenceDAO.class); + classes.add(IInstanceReferenceHourMetricPersistenceDAO.class); + classes.add(IInstanceReferenceDayMetricPersistenceDAO.class); + classes.add(IInstanceReferenceMonthMetricPersistenceDAO.class); + classes.add(IInstanceHeartBeatPersistenceDAO.class); } @@ -134,11 +247,22 @@ public class StorageModule extends Module { classes.add(IApplicationReferenceMetricUIDAO.class); classes.add(ISegmentCostUIDAO.class); classes.add(ISegmentUIDAO.class); - classes.add(IServiceEntryUIDAO.class); classes.add(IServiceReferenceUIDAO.class); } - private void addAlertingDAO(List classes) { - classes.add(IAlertingListPersistenceDAO.class); + private void addAlarmDAO(List classes) { + classes.add(IServiceReferenceAlarmPersistenceDAO.class); + classes.add(IServiceReferenceAlarmListPersistenceDAO.class); + classes.add(IInstanceReferenceAlarmPersistenceDAO.class); + classes.add(IInstanceReferenceAlarmListPersistenceDAO.class); + classes.add(IApplicationReferenceAlarmPersistenceDAO.class); + classes.add(IApplicationReferenceAlarmListPersistenceDAO.class); + + classes.add(IServiceAlarmPersistenceDAO.class); + classes.add(IServiceAlarmListPersistenceDAO.class); + classes.add(IInstanceAlarmPersistenceDAO.class); + classes.add(IInstanceAlarmListPersistenceDAO.class); + classes.add(IApplicationAlarmPersistenceDAO.class); + classes.add(IApplicationAlarmListPersistenceDAO.class); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/base/dao/IPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/base/dao/IPersistenceDAO.java index 7f6152114..8d02a20a0 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/base/dao/IPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/base/dao/IPersistenceDAO.java @@ -16,20 +16,20 @@ * */ - package org.apache.skywalking.apm.collector.storage.base.dao; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; /** * @author peng-yongsheng */ -public interface IPersistenceDAO extends DAO { - DataImpl get(String id); +public interface IPersistenceDAO extends DAO { - Insert prepareBatchInsert(DataImpl data); + STREAM_DATA get(String id); - Update prepareBatchUpdate(DataImpl data); + INSERT prepareBatchInsert(STREAM_DATA data); + + UPDATE prepareBatchUpdate(STREAM_DATA data); void deleteHistory(Long startTimestamp, Long endTimestamp); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java index efa28f524..a003e5ff2 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; import com.google.gson.JsonArray; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java index ee1dfd81b..5f8e454a4 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; import com.google.gson.JsonArray; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricPersistenceDAO.java deleted file mode 100644 index f97a4ec0b..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricPersistenceDAO.java +++ /dev/null @@ -1,29 +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.storage.dao; - -import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; -import org.apache.skywalking.apm.collector.core.data.Data; - -/** - * @author peng-yongsheng - */ -public interface IApplicationReferenceMetricPersistenceDAO extends IPersistenceDAO { -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java index 356e4eb43..1c32a17cf 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; import com.google.gson.JsonArray; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java index edc249c18..e1d3f9672 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; import com.google.gson.JsonArray; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java index 4074b4e21..823a0f20a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; import com.google.gson.JsonObject; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGlobalTracePersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGlobalTracePersistenceDAO.java index 59d514c99..ae27d2147 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGlobalTracePersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGlobalTracePersistenceDAO.java @@ -16,14 +16,13 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.global.GlobalTrace; /** * @author peng-yongsheng */ -public interface IGlobalTracePersistenceDAO extends IPersistenceDAO { +public interface IGlobalTracePersistenceDAO extends IPersistenceDAO { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGlobalTraceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGlobalTraceUIDAO.java index bda34197f..731c8bbb6 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGlobalTraceUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGlobalTraceUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; import java.util.List; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceHeartBeatPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceHeartBeatPersistenceDAO.java index ec3f2a4eb..95da511c0 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceHeartBeatPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceHeartBeatPersistenceDAO.java @@ -16,14 +16,13 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.register.Instance; /** * @author peng-yongsheng */ -public interface IInstanceHeartBeatPersistenceDAO extends IPersistenceDAO { +public interface IInstanceHeartBeatPersistenceDAO extends IPersistenceDAO { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricPersistenceDAO.java deleted file mode 100644 index 89dec4842..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricPersistenceDAO.java +++ /dev/null @@ -1,29 +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.storage.dao; - -import org.apache.skywalking.apm.collector.core.data.Data; -import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; - -/** - * @author peng-yongsheng - */ -public interface IInstanceMetricPersistenceDAO extends IPersistenceDAO { -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java index 870e86e1f..e1b1d850b 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; import com.google.gson.JsonArray; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceReferenceMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceReferenceMetricPersistenceDAO.java deleted file mode 100644 index 8da65567b..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceReferenceMetricPersistenceDAO.java +++ /dev/null @@ -1,28 +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.storage.dao; - -import org.apache.skywalking.apm.collector.core.data.Data; -import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; - -/** - * @author peng-yongsheng - */ -public interface IInstanceReferenceMetricPersistenceDAO extends IPersistenceDAO { -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java index e8f11b7d4..be7fe7e14 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; import com.google.gson.JsonArray; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricPersistenceDAO.java deleted file mode 100644 index 2b189d203..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricPersistenceDAO.java +++ /dev/null @@ -1,29 +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.storage.dao; - -import org.apache.skywalking.apm.collector.core.data.Data; -import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; - -/** - * @author peng-yongsheng - */ -public interface IMemoryMetricPersistenceDAO extends IPersistenceDAO { -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java index ca3a2465e..d2932f314 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; import com.google.gson.JsonObject; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryPoolMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryPoolMetricPersistenceDAO.java deleted file mode 100644 index c9db92ad8..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryPoolMetricPersistenceDAO.java +++ /dev/null @@ -1,29 +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.storage.dao; - -import org.apache.skywalking.apm.collector.core.data.Data; -import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; - -/** - * @author peng-yongsheng - */ -public interface IMemoryPoolMetricPersistenceDAO extends IPersistenceDAO { -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryPoolMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryPoolMetricUIDAO.java index 97f6a8cd2..2c09d124a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryPoolMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryPoolMetricUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; import com.google.gson.JsonObject; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostPersistenceDAO.java index dda76f683..f93b5c7f3 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostPersistenceDAO.java @@ -16,14 +16,13 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost; /** * @author peng-yongsheng */ -public interface ISegmentCostPersistenceDAO extends IPersistenceDAO { +public interface ISegmentCostPersistenceDAO extends IPersistenceDAO { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostUIDAO.java index 79ee6f865..101cf3715 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; import com.google.gson.JsonObject; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentPersistenceDAO.java index 8712b00ed..803e284c5 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentPersistenceDAO.java @@ -16,14 +16,13 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.segment.Segment; /** * @author peng-yongsheng */ -public interface ISegmentPersistenceDAO extends IPersistenceDAO { +public interface ISegmentPersistenceDAO extends IPersistenceDAO { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentUIDAO.java index a5627639b..ba10c4ddb 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceEntryPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceEntryPersistenceDAO.java deleted file mode 100644 index d86b54779..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceEntryPersistenceDAO.java +++ /dev/null @@ -1,29 +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.storage.dao; - -import org.apache.skywalking.apm.collector.core.data.Data; -import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; - -/** - * @author peng-yongsheng - */ -public interface IServiceEntryPersistenceDAO extends IPersistenceDAO { -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceMetricPersistenceDAO.java deleted file mode 100644 index f9a39cf03..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceMetricPersistenceDAO.java +++ /dev/null @@ -1,29 +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.storage.dao; - -import org.apache.skywalking.apm.collector.core.data.Data; -import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; - -/** - * @author peng-yongsheng - */ -public interface IServiceMetricPersistenceDAO extends IPersistenceDAO { -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceReferenceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceReferenceUIDAO.java index faa776f4f..1ba320d82 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceReferenceUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceReferenceUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.dao; import com.google.gson.JsonObject; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/acp/IApplicationComponentDayPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/acp/IApplicationComponentDayPersistenceDAO.java new file mode 100644 index 000000000..f108ea00b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/acp/IApplicationComponentDayPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.acp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; + +/** + * @author peng-yongsheng + */ +public interface IApplicationComponentDayPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/acp/IApplicationComponentHourPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/acp/IApplicationComponentHourPersistenceDAO.java new file mode 100644 index 000000000..6af2384f7 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/acp/IApplicationComponentHourPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.acp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; + +/** + * @author peng-yongsheng + */ +public interface IApplicationComponentHourPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/acp/IApplicationComponentMinutePersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/acp/IApplicationComponentMinutePersistenceDAO.java new file mode 100644 index 000000000..72cf17ac6 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/acp/IApplicationComponentMinutePersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.acp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; + +/** + * @author peng-yongsheng + */ +public interface IApplicationComponentMinutePersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/acp/IApplicationComponentMonthPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/acp/IApplicationComponentMonthPersistenceDAO.java new file mode 100644 index 000000000..b4268f2e3 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/acp/IApplicationComponentMonthPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.acp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; + +/** + * @author peng-yongsheng + */ +public interface IApplicationComponentMonthPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListPersistenceDAO.java new file mode 100644 index 000000000..a2e83fc36 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.alarm; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; + +/** + * @author peng-yongsheng + */ +public interface IApplicationAlarmListPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmPersistenceDAO.java new file mode 100644 index 000000000..85d6befc7 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.alarm; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm; + +/** + * @author peng-yongsheng + */ +public interface IApplicationAlarmPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationReferenceAlarmListPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationReferenceAlarmListPersistenceDAO.java new file mode 100644 index 000000000..bacdf4435 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationReferenceAlarmListPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.alarm; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarmList; + +/** + * @author peng-yongsheng + */ +public interface IApplicationReferenceAlarmListPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationReferenceAlarmPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationReferenceAlarmPersistenceDAO.java new file mode 100644 index 000000000..22af6a553 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationReferenceAlarmPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.alarm; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarm; + +/** + * @author peng-yongsheng + */ +public interface IApplicationReferenceAlarmPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IInstanceAlarmListPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IInstanceAlarmListPersistenceDAO.java new file mode 100644 index 000000000..81e34144d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IInstanceAlarmListPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.alarm; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmList; + +/** + * @author peng-yongsheng + */ +public interface IInstanceAlarmListPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceReferenceMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IInstanceAlarmPersistenceDAO.java similarity index 77% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceReferenceMetricPersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IInstanceAlarmPersistenceDAO.java index 2df77775c..0acc34fdd 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceReferenceMetricPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IInstanceAlarmPersistenceDAO.java @@ -16,13 +16,13 @@ * */ -package org.apache.skywalking.apm.collector.storage.dao; +package org.apache.skywalking.apm.collector.storage.dao.alarm; -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm; /** * @author peng-yongsheng */ -public interface IServiceReferenceMetricPersistenceDAO extends IPersistenceDAO { +public interface IInstanceAlarmPersistenceDAO extends IPersistenceDAO { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IInstanceReferenceAlarmListPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IInstanceReferenceAlarmListPersistenceDAO.java new file mode 100644 index 000000000..54c806927 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IInstanceReferenceAlarmListPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.alarm; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarmList; + +/** + * @author peng-yongsheng + */ +public interface IInstanceReferenceAlarmListPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IInstanceReferenceAlarmPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IInstanceReferenceAlarmPersistenceDAO.java new file mode 100644 index 000000000..df63ee0dd --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IInstanceReferenceAlarmPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.alarm; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarm; + +/** + * @author peng-yongsheng + */ +public interface IInstanceReferenceAlarmPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IServiceAlarmListPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IServiceAlarmListPersistenceDAO.java new file mode 100644 index 000000000..12b0ff7f6 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IServiceAlarmListPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.alarm; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarmList; + +/** + * @author peng-yongsheng + */ +public interface IServiceAlarmListPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IServiceAlarmPersistenceDAO.java similarity index 77% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentPersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IServiceAlarmPersistenceDAO.java index 865c59dc3..ceda5315e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IServiceAlarmPersistenceDAO.java @@ -16,14 +16,13 @@ * */ +package org.apache.skywalking.apm.collector.storage.dao.alarm; -package org.apache.skywalking.apm.collector.storage.dao; - -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarm; /** * @author peng-yongsheng */ -public interface IApplicationComponentPersistenceDAO extends IPersistenceDAO { +public interface IServiceAlarmPersistenceDAO extends IPersistenceDAO { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IServiceReferenceAlarmListPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IServiceReferenceAlarmListPersistenceDAO.java new file mode 100644 index 000000000..00d45cb23 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IServiceReferenceAlarmListPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.alarm; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarmList; + +/** + * @author peng-yongsheng + */ +public interface IServiceReferenceAlarmListPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IServiceReferenceAlarmPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IServiceReferenceAlarmPersistenceDAO.java new file mode 100644 index 000000000..5da49e57a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IServiceReferenceAlarmPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.alarm; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarm; + +/** + * @author peng-yongsheng + */ +public interface IServiceReferenceAlarmPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/amp/IApplicationDayMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/amp/IApplicationDayMetricPersistenceDAO.java new file mode 100644 index 000000000..5263b64a7 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/amp/IApplicationDayMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.amp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; + +/** + * @author peng-yongsheng + */ +public interface IApplicationDayMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/amp/IApplicationHourMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/amp/IApplicationHourMetricPersistenceDAO.java new file mode 100644 index 000000000..13adca491 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/amp/IApplicationHourMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.amp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; + +/** + * @author peng-yongsheng + */ +public interface IApplicationHourMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/amp/IApplicationMinuteMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/amp/IApplicationMinuteMetricPersistenceDAO.java new file mode 100644 index 000000000..55459d1f9 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/amp/IApplicationMinuteMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.amp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; + +/** + * @author peng-yongsheng + */ +public interface IApplicationMinuteMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/amp/IApplicationMonthMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/amp/IApplicationMonthMetricPersistenceDAO.java new file mode 100644 index 000000000..e6547d84a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/amp/IApplicationMonthMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.amp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; + +/** + * @author peng-yongsheng + */ +public interface IApplicationMonthMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ampp/IApplicationMappingDayPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ampp/IApplicationMappingDayPersistenceDAO.java new file mode 100644 index 000000000..0d0e67cb4 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ampp/IApplicationMappingDayPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.ampp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; + +/** + * @author peng-yongsheng + */ +public interface IApplicationMappingDayPersistenceDAO extends IPersistenceDAO { +} \ No newline at end of file diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ampp/IApplicationMappingHourPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ampp/IApplicationMappingHourPersistenceDAO.java new file mode 100644 index 000000000..bbc3b55c8 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ampp/IApplicationMappingHourPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.ampp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; + +/** + * @author peng-yongsheng + */ +public interface IApplicationMappingHourPersistenceDAO extends IPersistenceDAO { +} \ No newline at end of file diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ampp/IApplicationMappingMinutePersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ampp/IApplicationMappingMinutePersistenceDAO.java new file mode 100644 index 000000000..24d5c38a2 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ampp/IApplicationMappingMinutePersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.ampp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; + +/** + * @author peng-yongsheng + */ +public interface IApplicationMappingMinutePersistenceDAO extends IPersistenceDAO { +} \ No newline at end of file diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ampp/IApplicationMappingMonthPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ampp/IApplicationMappingMonthPersistenceDAO.java new file mode 100644 index 000000000..3e0f6b72f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ampp/IApplicationMappingMonthPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.ampp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; + +/** + * @author peng-yongsheng + */ +public interface IApplicationMappingMonthPersistenceDAO extends IPersistenceDAO { +} \ No newline at end of file diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceDayMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceDayMetricPersistenceDAO.java new file mode 100644 index 000000000..0f2cc394c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceDayMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.armp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IApplicationReferenceDayMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceHourMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceHourMetricPersistenceDAO.java new file mode 100644 index 000000000..9f59debd0 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceHourMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.armp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IApplicationReferenceHourMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMinuteMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMinuteMetricPersistenceDAO.java new file mode 100644 index 000000000..3d140d65e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMinuteMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.armp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IApplicationReferenceMinuteMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMonthMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMonthMetricPersistenceDAO.java new file mode 100644 index 000000000..286a88624 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMonthMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.armp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IApplicationReferenceMonthMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationCacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IApplicationCacheDAO.java similarity index 85% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationCacheDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IApplicationCacheDAO.java index 97c12e45b..3b766ef99 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationCacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IApplicationCacheDAO.java @@ -16,8 +16,7 @@ * */ - -package org.apache.skywalking.apm.collector.storage.dao; +package org.apache.skywalking.apm.collector.storage.dao.cache; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; @@ -25,7 +24,9 @@ import org.apache.skywalking.apm.collector.storage.base.dao.DAO; * @author peng-yongsheng */ public interface IApplicationCacheDAO extends DAO { - int getApplicationId(String applicationCode); + int getApplicationIdByCode(String applicationCode); String getApplicationCode(int applicationId); + + int getApplicationIdByAddressId(int addressId); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceCacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IInstanceCacheDAO.java similarity index 83% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceCacheDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IInstanceCacheDAO.java index 9db572895..b02a9431b 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceCacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IInstanceCacheDAO.java @@ -16,8 +16,7 @@ * */ - -package org.apache.skywalking.apm.collector.storage.dao; +package org.apache.skywalking.apm.collector.storage.dao.cache; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; @@ -27,5 +26,7 @@ import org.apache.skywalking.apm.collector.storage.base.dao.DAO; public interface IInstanceCacheDAO extends DAO { int getApplicationId(int instanceId); - int getInstanceId(int applicationId, String agentUUID); + int getInstanceIdByAgentUUID(int applicationId, String agentUUID); + + int getInstanceIdByAddressId(int applicationId, int addressId); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceEntryUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/INetworkAddressCacheDAO.java similarity index 77% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceEntryUIDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/INetworkAddressCacheDAO.java index d9352a64f..50e758199 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceEntryUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/INetworkAddressCacheDAO.java @@ -16,15 +16,15 @@ * */ +package org.apache.skywalking.apm.collector.storage.dao.cache; -package org.apache.skywalking.apm.collector.storage.dao; - -import com.google.gson.JsonObject; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; /** * @author peng-yongsheng */ -public interface IServiceEntryUIDAO extends DAO { - JsonObject load(int applicationId, String entryServiceName, long startTime, long endTime, int from, int size); +public interface INetworkAddressCacheDAO extends DAO { + int getAddressId(String networkAddress); + + String getAddress(int addressId); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceNameCacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IServiceNameCacheDAO.java similarity index 94% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceNameCacheDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IServiceNameCacheDAO.java index 31b070ab7..9e9ba334b 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceNameCacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IServiceNameCacheDAO.java @@ -16,8 +16,7 @@ * */ - -package org.apache.skywalking.apm.collector.storage.dao; +package org.apache.skywalking.apm.collector.storage.dao.cache; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuDayMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuDayMetricPersistenceDAO.java new file mode 100644 index 000000000..83ef64dda --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuDayMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.cpump; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public interface ICpuDayMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuHourMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuHourMetricPersistenceDAO.java new file mode 100644 index 000000000..0f2685520 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuHourMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.cpump; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public interface ICpuHourMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMinuteMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMinuteMetricPersistenceDAO.java new file mode 100644 index 000000000..edbc21baa --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMinuteMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.cpump; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public interface ICpuMinuteMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMonthMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMonthMetricPersistenceDAO.java new file mode 100644 index 000000000..a83d6c522 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMonthMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.cpump; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public interface ICpuMonthMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuSecondMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuSecondMetricPersistenceDAO.java new file mode 100644 index 000000000..f15e16dbf --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuSecondMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.cpump; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public interface ICpuSecondMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCDayMetricPersistenceDAO.java similarity index 76% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMetricPersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCDayMetricPersistenceDAO.java index 58e31dacb..2b7be6b04 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMetricPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCDayMetricPersistenceDAO.java @@ -16,14 +16,13 @@ * */ +package org.apache.skywalking.apm.collector.storage.dao.gcmp; -package org.apache.skywalking.apm.collector.storage.dao; - -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; /** * @author peng-yongsheng */ -public interface IApplicationMetricPersistenceDAO extends IPersistenceDAO { +public interface IGCDayMetricPersistenceDAO extends IPersistenceDAO { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCHourMetricPersistenceDAO.java similarity index 76% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingPersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCHourMetricPersistenceDAO.java index 8b6145572..5c6e86261 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCHourMetricPersistenceDAO.java @@ -16,14 +16,13 @@ * */ +package org.apache.skywalking.apm.collector.storage.dao.gcmp; -package org.apache.skywalking.apm.collector.storage.dao; - -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; /** * @author peng-yongsheng */ -public interface IApplicationMappingPersistenceDAO extends IPersistenceDAO { +public interface IGCHourMetricPersistenceDAO extends IPersistenceDAO { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCMinuteMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCMinuteMetricPersistenceDAO.java new file mode 100644 index 000000000..62996d7e1 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCMinuteMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.gcmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; + +/** + * @author peng-yongsheng + */ +public interface IGCMinuteMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IAlertingListPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCMonthMetricPersistenceDAO.java similarity index 76% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IAlertingListPersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCMonthMetricPersistenceDAO.java index 6cd20e88d..b3684f1e1 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IAlertingListPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCMonthMetricPersistenceDAO.java @@ -16,14 +16,13 @@ * */ +package org.apache.skywalking.apm.collector.storage.dao.gcmp; -package org.apache.skywalking.apm.collector.storage.dao; - -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; /** * @author peng-yongsheng */ -public interface IAlertingListPersistenceDAO extends IPersistenceDAO { +public interface IGCMonthMetricPersistenceDAO extends IPersistenceDAO { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCSecondMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCSecondMetricPersistenceDAO.java new file mode 100644 index 000000000..2373cff29 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/gcmp/IGCSecondMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.gcmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; + +/** + * @author peng-yongsheng + */ +public interface IGCSecondMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/imp/IInstanceDayMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/imp/IInstanceDayMetricPersistenceDAO.java new file mode 100644 index 000000000..490ee6096 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/imp/IInstanceDayMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.imp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; + +/** + * @author peng-yongsheng + */ +public interface IInstanceDayMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/imp/IInstanceHourMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/imp/IInstanceHourMetricPersistenceDAO.java new file mode 100644 index 000000000..1baa5885f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/imp/IInstanceHourMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.imp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; + +/** + * @author peng-yongsheng + */ +public interface IInstanceHourMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/imp/IInstanceMinuteMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/imp/IInstanceMinuteMetricPersistenceDAO.java new file mode 100644 index 000000000..b8404f4d1 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/imp/IInstanceMinuteMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.imp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; + +/** + * @author peng-yongsheng + */ +public interface IInstanceMinuteMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/imp/IInstanceMonthMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/imp/IInstanceMonthMetricPersistenceDAO.java new file mode 100644 index 000000000..cee600873 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/imp/IInstanceMonthMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.imp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; + +/** + * @author peng-yongsheng + */ +public interface IInstanceMonthMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/impp/IInstanceMappingDayPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/impp/IInstanceMappingDayPersistenceDAO.java new file mode 100644 index 000000000..475ffff8d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/impp/IInstanceMappingDayPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.impp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; + +/** + * @author peng-yongsheng + */ +public interface IInstanceMappingDayPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/impp/IInstanceMappingHourPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/impp/IInstanceMappingHourPersistenceDAO.java new file mode 100644 index 000000000..c70509dcc --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/impp/IInstanceMappingHourPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.impp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; + +/** + * @author peng-yongsheng + */ +public interface IInstanceMappingHourPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/impp/IInstanceMappingMinutePersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/impp/IInstanceMappingMinutePersistenceDAO.java new file mode 100644 index 000000000..ad40bd028 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/impp/IInstanceMappingMinutePersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.impp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; + +/** + * @author peng-yongsheng + */ +public interface IInstanceMappingMinutePersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/impp/IInstanceMappingMonthPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/impp/IInstanceMappingMonthPersistenceDAO.java new file mode 100644 index 000000000..8dad35758 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/impp/IInstanceMappingMonthPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.impp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; + +/** + * @author peng-yongsheng + */ +public interface IInstanceMappingMonthPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/irmp/IInstanceReferenceDayMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/irmp/IInstanceReferenceDayMetricPersistenceDAO.java new file mode 100644 index 000000000..1d2cead68 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/irmp/IInstanceReferenceDayMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.irmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IInstanceReferenceDayMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/irmp/IInstanceReferenceHourMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/irmp/IInstanceReferenceHourMetricPersistenceDAO.java new file mode 100644 index 000000000..bd6f8838e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/irmp/IInstanceReferenceHourMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.irmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IInstanceReferenceHourMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/irmp/IInstanceReferenceMinuteMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/irmp/IInstanceReferenceMinuteMetricPersistenceDAO.java new file mode 100644 index 000000000..b7507cddc --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/irmp/IInstanceReferenceMinuteMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.irmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IInstanceReferenceMinuteMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/irmp/IInstanceReferenceMonthMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/irmp/IInstanceReferenceMonthMetricPersistenceDAO.java new file mode 100644 index 000000000..cae66c845 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/irmp/IInstanceReferenceMonthMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.irmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IInstanceReferenceMonthMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemoryDayMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemoryDayMetricPersistenceDAO.java new file mode 100644 index 000000000..d465b6fba --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemoryDayMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.memorymp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; + +/** + * @author peng-yongsheng + */ +public interface IMemoryDayMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemoryHourMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemoryHourMetricPersistenceDAO.java new file mode 100644 index 000000000..a0f8540e7 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemoryHourMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.memorymp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; + +/** + * @author peng-yongsheng + */ +public interface IMemoryHourMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemoryMinuteMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemoryMinuteMetricPersistenceDAO.java new file mode 100644 index 000000000..ec86e6791 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemoryMinuteMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.memorymp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; + +/** + * @author peng-yongsheng + */ +public interface IMemoryMinuteMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemoryMonthMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemoryMonthMetricPersistenceDAO.java new file mode 100644 index 000000000..09d85c0c1 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemoryMonthMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.memorymp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; + +/** + * @author peng-yongsheng + */ +public interface IMemoryMonthMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemorySecondMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemorySecondMetricPersistenceDAO.java new file mode 100644 index 000000000..47b6588d4 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/memorymp/IMemorySecondMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.memorymp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; + +/** + * @author peng-yongsheng + */ +public interface IMemorySecondMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolDayMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolDayMetricPersistenceDAO.java new file mode 100644 index 000000000..65283914d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolDayMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.mpoolmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public interface IMemoryPoolDayMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolHourMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolHourMetricPersistenceDAO.java new file mode 100644 index 000000000..1ec7b6e3a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolHourMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.mpoolmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public interface IMemoryPoolHourMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolMinuteMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolMinuteMetricPersistenceDAO.java new file mode 100644 index 000000000..ad29d6f7c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolMinuteMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.mpoolmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public interface IMemoryPoolMinuteMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolMonthMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolMonthMetricPersistenceDAO.java new file mode 100644 index 000000000..ea3a77199 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolMonthMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.mpoolmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public interface IMemoryPoolMonthMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolSecondMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolSecondMetricPersistenceDAO.java new file mode 100644 index 000000000..2f7815548 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/mpoolmp/IMemoryPoolSecondMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.mpoolmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; + +/** + * @author peng-yongsheng + */ +public interface IMemoryPoolSecondMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationRegisterDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/register/IApplicationRegisterDAO.java similarity index 94% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationRegisterDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/register/IApplicationRegisterDAO.java index 7e9d045d1..bd67f9e20 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationRegisterDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/register/IApplicationRegisterDAO.java @@ -16,8 +16,7 @@ * */ - -package org.apache.skywalking.apm.collector.storage.dao; +package org.apache.skywalking.apm.collector.storage.dao.register; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; import org.apache.skywalking.apm.collector.storage.table.register.Application; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceRegisterDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/register/IInstanceRegisterDAO.java similarity index 94% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceRegisterDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/register/IInstanceRegisterDAO.java index 3e84e5731..04e0a1bc7 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceRegisterDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/register/IInstanceRegisterDAO.java @@ -16,8 +16,7 @@ * */ - -package org.apache.skywalking.apm.collector.storage.dao; +package org.apache.skywalking.apm.collector.storage.dao.register; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; import org.apache.skywalking.apm.collector.storage.table.register.Instance; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/register/INetworkAddressRegisterDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/register/INetworkAddressRegisterDAO.java new file mode 100644 index 000000000..262b45d0d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/register/INetworkAddressRegisterDAO.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.storage.dao.register; + +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddress; + +/** + * @author peng-yongsheng + */ +public interface INetworkAddressRegisterDAO extends DAO { + int getMaxNetworkAddressId(); + + int getMinNetworkAddressId(); + + void save(NetworkAddress networkAddress); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceNameRegisterDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/register/IServiceNameRegisterDAO.java similarity index 94% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceNameRegisterDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/register/IServiceNameRegisterDAO.java index 8025fe7f1..0c9b8ad4a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceNameRegisterDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/register/IServiceNameRegisterDAO.java @@ -16,8 +16,7 @@ * */ - -package org.apache.skywalking.apm.collector.storage.dao; +package org.apache.skywalking.apm.collector.storage.dao.register; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/smp/IServiceDayMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/smp/IServiceDayMetricPersistenceDAO.java new file mode 100644 index 000000000..fa7b0e6d9 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/smp/IServiceDayMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.smp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; + +/** + * @author peng-yongsheng + */ +public interface IServiceDayMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/smp/IServiceHourMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/smp/IServiceHourMetricPersistenceDAO.java new file mode 100644 index 000000000..44e7b692f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/smp/IServiceHourMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.smp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; + +/** + * @author peng-yongsheng + */ +public interface IServiceHourMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/smp/IServiceMinuteMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/smp/IServiceMinuteMetricPersistenceDAO.java new file mode 100644 index 000000000..dd48b105e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/smp/IServiceMinuteMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.smp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; + +/** + * @author peng-yongsheng + */ +public interface IServiceMinuteMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/smp/IServiceMonthMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/smp/IServiceMonthMetricPersistenceDAO.java new file mode 100644 index 000000000..8c7764b1c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/smp/IServiceMonthMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.smp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; + +/** + * @author peng-yongsheng + */ +public interface IServiceMonthMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/srmp/IServiceReferenceDayMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/srmp/IServiceReferenceDayMetricPersistenceDAO.java new file mode 100644 index 000000000..590f7191d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/srmp/IServiceReferenceDayMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.srmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IServiceReferenceDayMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/srmp/IServiceReferenceHourMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/srmp/IServiceReferenceHourMetricPersistenceDAO.java new file mode 100644 index 000000000..d7329d1aa --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/srmp/IServiceReferenceHourMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.srmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IServiceReferenceHourMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/srmp/IServiceReferenceMinuteMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/srmp/IServiceReferenceMinuteMetricPersistenceDAO.java new file mode 100644 index 000000000..69021ecf9 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/srmp/IServiceReferenceMinuteMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.srmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IServiceReferenceMinuteMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/srmp/IServiceReferenceMonthMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/srmp/IServiceReferenceMonthMetricPersistenceDAO.java new file mode 100644 index 000000000..e3e7eaf73 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/srmp/IServiceReferenceMonthMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.storage.dao.srmp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IServiceReferenceMonthMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/CommonMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/CommonMetricTable.java index 2c47dc0dd..fd7fd8d9f 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/CommonMetricTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/CommonMetricTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table; import org.apache.skywalking.apm.collector.core.data.CommonTable; @@ -25,6 +24,9 @@ import org.apache.skywalking.apm.collector.core.data.CommonTable; * @author peng-yongsheng */ public abstract class CommonMetricTable extends CommonTable { + public static final String COLUMN_APPLICATION_ID = "application_id"; + public static final String COLUMN_INSTANCE_ID = "instance_id"; + public static final String COLUMN_SERVICE_ID = "service_id"; public static final String COLUMN_TRANSACTION_CALLS = "transaction_calls"; public static final String COLUMN_TRANSACTION_ERROR_CALLS = "transaction_error_calls"; public static final String COLUMN_TRANSACTION_DURATION_SUM = "transaction_duration_sum"; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/Metric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/Metric.java new file mode 100644 index 000000000..d2cc541bc --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/Metric.java @@ -0,0 +1,81 @@ +/* + * 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.storage.table; + +/** + * @author peng-yongsheng + */ +public interface Metric { + + Integer getSourceValue(); + + void setSourceValue(Integer sourceValue); + + Long getTimeBucket(); + + void setTimeBucket(Long timeBucket); + + Long getTransactionCalls(); + + void setTransactionCalls(Long transactionCalls); + + Long getTransactionErrorCalls(); + + void setTransactionErrorCalls(Long transactionErrorCalls); + + Long getTransactionDurationSum(); + + void setTransactionDurationSum(Long transactionDurationSum); + + Long getTransactionErrorDurationSum(); + + void setTransactionErrorDurationSum(Long transactionErrorDurationSum); + + Long getBusinessTransactionCalls(); + + void setBusinessTransactionCalls(Long businessTransactionCalls); + + Long getBusinessTransactionErrorCalls(); + + void setBusinessTransactionErrorCalls(Long businessTransactionErrorCalls); + + Long getBusinessTransactionDurationSum(); + + void setBusinessTransactionDurationSum(Long businessTransactionDurationSum); + + Long getBusinessTransactionErrorDurationSum(); + + void setBusinessTransactionErrorDurationSum(Long businessTransactionErrorDurationSum); + + Long getMqTransactionCalls(); + + void setMqTransactionCalls(Long mqTransactionCalls); + + Long getMqTransactionErrorCalls(); + + void setMqTransactionErrorCalls(Long mqTransactionErrorCalls); + + Long getMqTransactionDurationSum(); + + void setMqTransactionDurationSum(Long mqTransactionDurationSum); + + Long getMqTransactionErrorDurationSum(); + + void setMqTransactionErrorDurationSum(Long mqTransactionErrorDurationSum); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/Alarm.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/Alarm.java new file mode 100644 index 000000000..da8c3a0bb --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/Alarm.java @@ -0,0 +1,41 @@ +/* + * 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.storage.table.alarm; + +/** + * @author peng-yongsheng + */ +public interface Alarm { + + Integer getAlarmType(); + + void setAlarmType(Integer alarmType); + + Integer getSourceValue(); + + void setSourceValue(Integer sourceValue); + + Long getLastTimeBucket(); + + void setLastTimeBucket(Long lastTimeBucket); + + String getAlarmContent(); + + void setAlarmContent(String alarmContent); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/AlarmType.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/AlarmType.java new file mode 100644 index 000000000..2f201a7c6 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/AlarmType.java @@ -0,0 +1,36 @@ +/* + * 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.storage.table.alarm; + +/** + * @author peng-yongsheng + */ +public enum AlarmType { + ERROR_RATE(0), SLOW_RTT(1); + + private final int value; + + private AlarmType(int value) { + this.value = value; + } + + public int getValue() { + return value; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarm.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarm.java new file mode 100644 index 000000000..6466a1bb8 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarm.java @@ -0,0 +1,119 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarm extends StreamData implements Alarm { + + private static final Column[] STRING_COLUMNS = { + new Column(ApplicationAlarmTable.COLUMN_ID, new NonOperation()), + new Column(ApplicationAlarmTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(ApplicationAlarmTable.COLUMN_LAST_TIME_BUCKET, new CoverOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(ApplicationAlarmTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(ApplicationAlarmTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(ApplicationAlarmTable.COLUMN_APPLICATION_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public ApplicationAlarm() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + + @Override + public Integer getAlarmType() { + return getDataInteger(0); + } + + @Override + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + @Override + public Integer getSourceValue() { + return getDataInteger(1); + } + + @Override + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getApplicationId() { + return getDataInteger(2); + } + + public void setApplicationId(Integer applicationId) { + setDataInteger(2, applicationId); + } + + @Override + public Long getLastTimeBucket() { + return getDataLong(0); + } + + @Override + public void setLastTimeBucket(Long lastTimeBucket) { + setDataLong(0, lastTimeBucket); + } + + @Override + public String getAlarmContent() { + return getDataString(1); + } + + @Override + public void setAlarmContent(String alarmContent) { + setDataString(1, alarmContent); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarmList.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarmList.java new file mode 100644 index 000000000..1b39153ae --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarmList.java @@ -0,0 +1,111 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmList extends StreamData { + + private static final Column[] STRING_COLUMNS = { + new Column(ApplicationAlarmListTable.COLUMN_ID, new NonOperation()), + new Column(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(ApplicationAlarmListTable.COLUMN_TIME_BUCKET, new NonOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(ApplicationAlarmListTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(ApplicationAlarmListTable.COLUMN_APPLICATION_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public ApplicationAlarmList() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + + public Integer getAlarmType() { + return getDataInteger(0); + } + + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + public Integer getSourceValue() { + return getDataInteger(1); + } + + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getApplicationId() { + return getDataInteger(2); + } + + public void setApplicationId(Integer applicationId) { + setDataInteger(2, applicationId); + } + + public Long getTimeBucket() { + return getDataLong(0); + } + + public void setTimeBucket(Long timeBucket) { + setDataLong(0, timeBucket); + } + + public String getAlarmContent() { + return getDataString(1); + } + + public void setAlarmContent(String alarmContent) { + setDataString(1, alarmContent); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarmListTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarmListTable.java new file mode 100644 index 000000000..4c6e8ec31 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarmListTable.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.storage.table.alarm; + +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListTable extends CommonMetricTable { + public static final String TABLE = "application_alarm_list"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarmTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarmTable.java new file mode 100644 index 000000000..b5986ed58 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarmTable.java @@ -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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmTable extends CommonMetricTable { + public static final String TABLE = "application_alarm"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; + public static final String COLUMN_LAST_TIME_BUCKET = "last_time_bucket"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationReferenceAlarm.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationReferenceAlarm.java new file mode 100644 index 000000000..f4e349054 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationReferenceAlarm.java @@ -0,0 +1,128 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceAlarm extends StreamData implements Alarm { + + private static final Column[] STRING_COLUMNS = { + new Column(ApplicationReferenceAlarmTable.COLUMN_ID, new NonOperation()), + new Column(ApplicationReferenceAlarmTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(ApplicationReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET, new CoverOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(ApplicationReferenceAlarmTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(ApplicationReferenceAlarmTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(ApplicationReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID, new NonOperation()), + new Column(ApplicationReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public ApplicationReferenceAlarm() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + + @Override + public Integer getAlarmType() { + return getDataInteger(0); + } + + @Override + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + @Override + public Integer getSourceValue() { + return getDataInteger(1); + } + + @Override + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getFrontApplicationId() { + return getDataInteger(2); + } + + public void setFrontApplicationId(Integer frontApplicationId) { + setDataInteger(2, frontApplicationId); + } + + public Integer getBehindApplicationId() { + return getDataInteger(3); + } + + public void setBehindApplicationId(Integer behindApplicationId) { + setDataInteger(3, behindApplicationId); + } + + @Override + public Long getLastTimeBucket() { + return getDataLong(0); + } + + @Override + public void setLastTimeBucket(Long lastTimeBucket) { + setDataLong(0, lastTimeBucket); + } + + @Override + public String getAlarmContent() { + return getDataString(1); + } + + @Override + public void setAlarmContent(String alarmContent) { + setDataString(1, alarmContent); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationReferenceAlarmList.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationReferenceAlarmList.java new file mode 100644 index 000000000..19aae305d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationReferenceAlarmList.java @@ -0,0 +1,120 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceAlarmList extends StreamData { + + private static final Column[] STRING_COLUMNS = { + new Column(ApplicationReferenceAlarmListTable.COLUMN_ID, new NonOperation()), + new Column(ApplicationReferenceAlarmListTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(ApplicationReferenceAlarmListTable.COLUMN_TIME_BUCKET, new NonOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(ApplicationReferenceAlarmListTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(ApplicationReferenceAlarmListTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(ApplicationReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID, new NonOperation()), + new Column(ApplicationReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public ApplicationReferenceAlarmList() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + + public Integer getAlarmType() { + return getDataInteger(0); + } + + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + public Integer getSourceValue() { + return getDataInteger(1); + } + + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getFrontApplicationId() { + return getDataInteger(2); + } + + public void setFrontApplicationId(Integer frontApplicationId) { + setDataInteger(2, frontApplicationId); + } + + public Integer getBehindApplicationId() { + return getDataInteger(3); + } + + public void setBehindApplicationId(Integer behindApplicationId) { + setDataInteger(3, behindApplicationId); + } + + public Long getTimeBucket() { + return getDataLong(0); + } + + public void setTimeBucket(Long timeBucket) { + setDataLong(0, timeBucket); + } + + public String getAlarmContent() { + return getDataString(1); + } + + public void setAlarmContent(String alarmContent) { + setDataString(1, alarmContent); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationReferenceAlarmListTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationReferenceAlarmListTable.java new file mode 100644 index 000000000..209c61d88 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationReferenceAlarmListTable.java @@ -0,0 +1,32 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceAlarmListTable extends CommonMetricTable { + public static final String TABLE = "application_reference_alarm_list"; + public static final String COLUMN_FRONT_APPLICATION_ID = "front_application_id"; + public static final String COLUMN_BEHIND_APPLICATION_ID = "behind_application_id"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alerting/AlertingListTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationReferenceAlarmTable.java similarity index 60% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alerting/AlertingListTable.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationReferenceAlarmTable.java index a444fd0f6..8e1e98aec 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alerting/AlertingListTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationReferenceAlarmTable.java @@ -16,21 +16,18 @@ * */ +package org.apache.skywalking.apm.collector.storage.table.alarm; -package org.apache.skywalking.apm.collector.storage.table.alerting; - -import org.apache.skywalking.apm.collector.core.data.CommonTable; +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; /** * @author peng-yongsheng */ -public class AlertingListTable extends CommonTable { - public static final String TABLE = "alerting_list"; - public static final String COLUMN_LAYER = "layer"; - public static final String COLUMN_LAYER_ID = "layer_id"; - public static final String COLUMN_FIRST_TIME_BUCKET = "first_time_bucket"; +public class ApplicationReferenceAlarmTable extends CommonMetricTable { + public static final String TABLE = "application_reference_alarm"; + public static final String COLUMN_FRONT_APPLICATION_ID = "front_application_id"; + public static final String COLUMN_BEHIND_APPLICATION_ID = "behind_application_id"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; public static final String COLUMN_LAST_TIME_BUCKET = "last_time_bucket"; - public static final String COLUMN_EXPECTED = "expected"; - public static final String COLUMN_ACTUAL = "actual"; - public static final String COLUMN_VALID = "valid"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarm.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarm.java new file mode 100644 index 000000000..6badc708b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarm.java @@ -0,0 +1,128 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarm extends StreamData implements Alarm { + + private static final Column[] STRING_COLUMNS = { + new Column(InstanceAlarmTable.COLUMN_ID, new NonOperation()), + new Column(InstanceAlarmTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(InstanceAlarmTable.COLUMN_LAST_TIME_BUCKET, new CoverOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(InstanceAlarmTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(InstanceAlarmTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(InstanceAlarmTable.COLUMN_APPLICATION_ID, new NonOperation()), + new Column(InstanceAlarmTable.COLUMN_INSTANCE_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public InstanceAlarm() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + + @Override + public Integer getAlarmType() { + return getDataInteger(0); + } + + @Override + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + @Override + public Integer getSourceValue() { + return getDataInteger(1); + } + + @Override + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getApplicationId() { + return getDataInteger(2); + } + + public void setApplicationId(Integer applicationId) { + setDataInteger(2, applicationId); + } + + public Integer getInstanceId() { + return getDataInteger(3); + } + + public void setInstanceId(Integer instanceId) { + setDataInteger(3, instanceId); + } + + @Override + public Long getLastTimeBucket() { + return getDataLong(0); + } + + @Override + public void setLastTimeBucket(Long lastTimeBucket) { + setDataLong(0, lastTimeBucket); + } + + @Override + public String getAlarmContent() { + return getDataString(1); + } + + @Override + public void setAlarmContent(String alarmContent) { + setDataString(1, alarmContent); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmList.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmList.java new file mode 100644 index 000000000..a6e011c3a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmList.java @@ -0,0 +1,120 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmList extends StreamData { + + private static final Column[] STRING_COLUMNS = { + new Column(InstanceAlarmListTable.COLUMN_ID, new NonOperation()), + new Column(InstanceAlarmListTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(InstanceAlarmListTable.COLUMN_TIME_BUCKET, new NonOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(InstanceAlarmListTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(InstanceAlarmListTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(InstanceAlarmListTable.COLUMN_APPLICATION_ID, new NonOperation()), + new Column(InstanceAlarmListTable.COLUMN_INSTANCE_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public InstanceAlarmList() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + + public Integer getAlarmType() { + return getDataInteger(0); + } + + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + public Integer getSourceValue() { + return getDataInteger(1); + } + + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getApplicationId() { + return getDataInteger(2); + } + + public void setApplicationId(Integer applicationId) { + setDataInteger(2, applicationId); + } + + public Integer getInstanceId() { + return getDataInteger(3); + } + + public void setInstanceId(Integer instanceId) { + setDataInteger(3, instanceId); + } + + public Long getTimeBucket() { + return getDataLong(0); + } + + public void setTimeBucket(Long timeBucket) { + setDataLong(0, timeBucket); + } + + public String getAlarmContent() { + return getDataString(1); + } + + public void setAlarmContent(String alarmContent) { + setDataString(1, alarmContent); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmListTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmListTable.java new file mode 100644 index 000000000..a7cd8817e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmListTable.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.storage.table.alarm; + +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmListTable extends CommonMetricTable { + public static final String TABLE = "instance_alarm_list"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmTable.java new file mode 100644 index 000000000..54c22cd0b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmTable.java @@ -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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmTable extends CommonMetricTable { + public static final String TABLE = "instance_alarm"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; + public static final String COLUMN_LAST_TIME_BUCKET = "last_time_bucket"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceReferenceAlarm.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceReferenceAlarm.java new file mode 100644 index 000000000..e0c9266ba --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceReferenceAlarm.java @@ -0,0 +1,146 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceAlarm extends StreamData implements Alarm { + + private static final Column[] STRING_COLUMNS = { + new Column(InstanceReferenceAlarmTable.COLUMN_ID, new NonOperation()), + new Column(InstanceReferenceAlarmTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(InstanceReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET, new CoverOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(InstanceReferenceAlarmTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(InstanceReferenceAlarmTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(InstanceReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID, new NonOperation()), + new Column(InstanceReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID, new NonOperation()), + new Column(InstanceReferenceAlarmTable.COLUMN_FRONT_INSTANCE_ID, new NonOperation()), + new Column(InstanceReferenceAlarmTable.COLUMN_BEHIND_INSTANCE_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public InstanceReferenceAlarm() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + + @Override + public Integer getAlarmType() { + return getDataInteger(0); + } + + @Override + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + @Override + public Integer getSourceValue() { + return getDataInteger(1); + } + + @Override + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getFrontApplicationId() { + return getDataInteger(2); + } + + public void setFrontApplicationId(Integer frontApplicationId) { + setDataInteger(2, frontApplicationId); + } + + public Integer getBehindApplicationId() { + return getDataInteger(3); + } + + public void setBehindApplicationId(Integer behindApplicationId) { + setDataInteger(3, behindApplicationId); + } + + public Integer getFrontInstanceId() { + return getDataInteger(4); + } + + public void setFrontInstanceId(Integer frontInstanceId) { + setDataInteger(4, frontInstanceId); + } + + public Integer getBehindInstanceId() { + return getDataInteger(5); + } + + public void setBehindInstanceId(Integer behindInstanceId) { + setDataInteger(5, behindInstanceId); + } + + @Override + public Long getLastTimeBucket() { + return getDataLong(0); + } + + @Override + public void setLastTimeBucket(Long lastTimeBucket) { + setDataLong(0, lastTimeBucket); + } + + @Override + public String getAlarmContent() { + return getDataString(1); + } + + @Override + public void setAlarmContent(String alarmContent) { + setDataString(1, alarmContent); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceReferenceAlarmList.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceReferenceAlarmList.java new file mode 100644 index 000000000..11d8ac50c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceReferenceAlarmList.java @@ -0,0 +1,138 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceAlarmList extends StreamData { + + private static final Column[] STRING_COLUMNS = { + new Column(InstanceReferenceAlarmListTable.COLUMN_ID, new NonOperation()), + new Column(InstanceReferenceAlarmListTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(InstanceReferenceAlarmListTable.COLUMN_TIME_BUCKET, new NonOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(InstanceReferenceAlarmListTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(InstanceReferenceAlarmListTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(InstanceReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID, new NonOperation()), + new Column(InstanceReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID, new NonOperation()), + new Column(InstanceReferenceAlarmListTable.COLUMN_FRONT_INSTANCE_ID, new NonOperation()), + new Column(InstanceReferenceAlarmListTable.COLUMN_BEHIND_INSTANCE_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public InstanceReferenceAlarmList() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + + public Integer getAlarmType() { + return getDataInteger(0); + } + + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + public Integer getSourceValue() { + return getDataInteger(1); + } + + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getFrontApplicationId() { + return getDataInteger(2); + } + + public void setFrontApplicationId(Integer frontApplicationId) { + setDataInteger(2, frontApplicationId); + } + + public Integer getBehindApplicationId() { + return getDataInteger(3); + } + + public void setBehindApplicationId(Integer behindApplicationId) { + setDataInteger(3, behindApplicationId); + } + + public Integer getFrontInstanceId() { + return getDataInteger(4); + } + + public void setFrontInstanceId(Integer frontInstanceId) { + setDataInteger(4, frontInstanceId); + } + + public Integer getBehindInstanceId() { + return getDataInteger(5); + } + + public void setBehindInstanceId(Integer behindInstanceId) { + setDataInteger(5, behindInstanceId); + } + + public Long getTimeBucket() { + return getDataLong(0); + } + + public void setTimeBucket(Long timeBucket) { + setDataLong(0, timeBucket); + } + + public String getAlarmContent() { + return getDataString(1); + } + + public void setAlarmContent(String alarmContent) { + setDataString(1, alarmContent); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceReferenceAlarmListTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceReferenceAlarmListTable.java new file mode 100644 index 000000000..11c18a9ef --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceReferenceAlarmListTable.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.storage.table.alarm; + +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceAlarmListTable extends CommonMetricTable { + public static final String TABLE = "instance_reference_alarm_list"; + public static final String COLUMN_FRONT_INSTANCE_ID = "front_instance_id"; + public static final String COLUMN_BEHIND_INSTANCE_ID = "behind_instance_id"; + public static final String COLUMN_FRONT_APPLICATION_ID = "front_application_id"; + public static final String COLUMN_BEHIND_APPLICATION_ID = "behind_application_id"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceReferenceAlarmTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceReferenceAlarmTable.java new file mode 100644 index 000000000..a68db82a2 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceReferenceAlarmTable.java @@ -0,0 +1,35 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceAlarmTable extends CommonMetricTable { + public static final String TABLE = "instance_reference_alarm"; + public static final String COLUMN_FRONT_INSTANCE_ID = "front_instance_id"; + public static final String COLUMN_BEHIND_INSTANCE_ID = "behind_instance_id"; + public static final String COLUMN_FRONT_APPLICATION_ID = "front_application_id"; + public static final String COLUMN_BEHIND_APPLICATION_ID = "behind_application_id"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; + public static final String COLUMN_LAST_TIME_BUCKET = "last_time_bucket"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceAlarm.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceAlarm.java new file mode 100644 index 000000000..ff470057b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceAlarm.java @@ -0,0 +1,137 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class ServiceAlarm extends StreamData implements Alarm { + + private static final Column[] STRING_COLUMNS = { + new Column(ServiceAlarmTable.COLUMN_ID, new NonOperation()), + new Column(ServiceAlarmTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(ServiceAlarmTable.COLUMN_LAST_TIME_BUCKET, new CoverOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(ServiceAlarmTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(ServiceAlarmTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(ServiceAlarmTable.COLUMN_APPLICATION_ID, new NonOperation()), + new Column(ServiceAlarmTable.COLUMN_INSTANCE_ID, new NonOperation()), + new Column(ServiceAlarmTable.COLUMN_SERVICE_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public ServiceAlarm() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + + @Override + public Integer getAlarmType() { + return getDataInteger(0); + } + + @Override + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + @Override + public Integer getSourceValue() { + return getDataInteger(1); + } + + @Override + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getApplicationId() { + return getDataInteger(2); + } + + public void setApplicationId(Integer applicationId) { + setDataInteger(2, applicationId); + } + + public Integer getInstanceId() { + return getDataInteger(3); + } + + public void setInstanceId(Integer instanceId) { + setDataInteger(3, instanceId); + } + + public Integer getServiceId() { + return getDataInteger(4); + } + + public void setServiceId(Integer serviceId) { + setDataInteger(4, serviceId); + } + + @Override + public Long getLastTimeBucket() { + return getDataLong(0); + } + + @Override + public void setLastTimeBucket(Long lastTimeBucket) { + setDataLong(0, lastTimeBucket); + } + + @Override + public String getAlarmContent() { + return getDataString(1); + } + + @Override + public void setAlarmContent(String alarmContent) { + setDataString(1, alarmContent); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceAlarmList.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceAlarmList.java new file mode 100644 index 000000000..9f242d68c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceAlarmList.java @@ -0,0 +1,129 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class ServiceAlarmList extends StreamData { + + private static final Column[] STRING_COLUMNS = { + new Column(ServiceAlarmListTable.COLUMN_ID, new NonOperation()), + new Column(ServiceAlarmListTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(ServiceAlarmListTable.COLUMN_TIME_BUCKET, new NonOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(ServiceAlarmListTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(ServiceAlarmListTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(ServiceAlarmListTable.COLUMN_APPLICATION_ID, new NonOperation()), + new Column(ServiceAlarmListTable.COLUMN_INSTANCE_ID, new NonOperation()), + new Column(ServiceAlarmListTable.COLUMN_SERVICE_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public ServiceAlarmList() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + + public Integer getAlarmType() { + return getDataInteger(0); + } + + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + public Integer getSourceValue() { + return getDataInteger(1); + } + + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getApplicationId() { + return getDataInteger(2); + } + + public void setApplicationId(Integer applicationId) { + setDataInteger(2, applicationId); + } + + public Integer getInstanceId() { + return getDataInteger(3); + } + + public void setInstanceId(Integer instanceId) { + setDataInteger(3, instanceId); + } + + public Integer getServiceId() { + return getDataInteger(4); + } + + public void setServiceId(Integer serviceId) { + setDataInteger(4, serviceId); + } + + public Long getTimeBucket() { + return getDataLong(0); + } + + public void setTimeBucket(Long timeBucket) { + setDataLong(0, timeBucket); + } + + public String getAlarmContent() { + return getDataString(1); + } + + public void setAlarmContent(String alarmContent) { + setDataString(1, alarmContent); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceAlarmListTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceAlarmListTable.java new file mode 100644 index 000000000..d1802b9db --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceAlarmListTable.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.storage.table.alarm; + +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; + +/** + * @author peng-yongsheng + */ +public class ServiceAlarmListTable extends CommonMetricTable { + public static final String TABLE = "service_alarm_list"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceAlarmTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceAlarmTable.java new file mode 100644 index 000000000..451c18f07 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceAlarmTable.java @@ -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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; + +/** + * @author peng-yongsheng + */ +public class ServiceAlarmTable extends CommonMetricTable { + public static final String TABLE = "service_alarm"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; + public static final String COLUMN_LAST_TIME_BUCKET = "last_time_bucket"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceReferenceAlarm.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceReferenceAlarm.java new file mode 100644 index 000000000..b633fe866 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceReferenceAlarm.java @@ -0,0 +1,164 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceAlarm extends StreamData implements Alarm { + + private static final Column[] STRING_COLUMNS = { + new Column(ServiceReferenceAlarmTable.COLUMN_ID, new NonOperation()), + new Column(ServiceReferenceAlarmTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(ServiceReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET, new CoverOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(ServiceReferenceAlarmTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(ServiceReferenceAlarmTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(ServiceReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID, new NonOperation()), + new Column(ServiceReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID, new NonOperation()), + new Column(ServiceReferenceAlarmTable.COLUMN_FRONT_INSTANCE_ID, new NonOperation()), + new Column(ServiceReferenceAlarmTable.COLUMN_BEHIND_INSTANCE_ID, new NonOperation()), + new Column(ServiceReferenceAlarmTable.COLUMN_FRONT_SERVICE_ID, new NonOperation()), + new Column(ServiceReferenceAlarmTable.COLUMN_BEHIND_SERVICE_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public ServiceReferenceAlarm() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + + @Override + public Integer getAlarmType() { + return getDataInteger(0); + } + + @Override + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + @Override + public Integer getSourceValue() { + return getDataInteger(1); + } + + @Override + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getFrontApplicationId() { + return getDataInteger(2); + } + + public void setFrontApplicationId(Integer frontApplicationId) { + setDataInteger(2, frontApplicationId); + } + + public Integer getBehindApplicationId() { + return getDataInteger(3); + } + + public void setBehindApplicationId(Integer behindApplicationId) { + setDataInteger(3, behindApplicationId); + } + + public Integer getFrontInstanceId() { + return getDataInteger(4); + } + + public void setFrontInstanceId(Integer frontInstanceId) { + setDataInteger(4, frontInstanceId); + } + + public Integer getBehindInstanceId() { + return getDataInteger(5); + } + + public void setBehindInstanceId(Integer behindInstanceId) { + setDataInteger(5, behindInstanceId); + } + + public Integer getFrontServiceId() { + return getDataInteger(6); + } + + public void setFrontServiceId(Integer frontServiceId) { + setDataInteger(6, frontServiceId); + } + + public Integer getBehindServiceId() { + return getDataInteger(7); + } + + public void setBehindServiceId(Integer behindServiceId) { + setDataInteger(7, behindServiceId); + } + + @Override + public Long getLastTimeBucket() { + return getDataLong(0); + } + + @Override + public void setLastTimeBucket(Long lastTimeBucket) { + setDataLong(0, lastTimeBucket); + } + + @Override + public String getAlarmContent() { + return getDataString(1); + } + + @Override + public void setAlarmContent(String alarmContent) { + setDataString(1, alarmContent); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceReferenceAlarmList.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceReferenceAlarmList.java new file mode 100644 index 000000000..4dd4f6c45 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceReferenceAlarmList.java @@ -0,0 +1,156 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceAlarmList extends StreamData { + + private static final Column[] STRING_COLUMNS = { + new Column(ServiceReferenceAlarmListTable.COLUMN_ID, new NonOperation()), + new Column(ServiceReferenceAlarmListTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(ServiceReferenceAlarmListTable.COLUMN_TIME_BUCKET, new NonOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(ServiceReferenceAlarmListTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(ServiceReferenceAlarmListTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(ServiceReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID, new NonOperation()), + new Column(ServiceReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID, new NonOperation()), + new Column(ServiceReferenceAlarmListTable.COLUMN_FRONT_INSTANCE_ID, new NonOperation()), + new Column(ServiceReferenceAlarmListTable.COLUMN_BEHIND_INSTANCE_ID, new NonOperation()), + new Column(ServiceReferenceAlarmListTable.COLUMN_FRONT_SERVICE_ID, new NonOperation()), + new Column(ServiceReferenceAlarmListTable.COLUMN_BEHIND_SERVICE_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public ServiceReferenceAlarmList() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + + public Integer getAlarmType() { + return getDataInteger(0); + } + + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + public Integer getSourceValue() { + return getDataInteger(1); + } + + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getFrontApplicationId() { + return getDataInteger(2); + } + + public void setFrontApplicationId(Integer frontApplicationId) { + setDataInteger(2, frontApplicationId); + } + + public Integer getBehindApplicationId() { + return getDataInteger(3); + } + + public void setBehindApplicationId(Integer behindApplicationId) { + setDataInteger(3, behindApplicationId); + } + + public Integer getFrontInstanceId() { + return getDataInteger(4); + } + + public void setFrontInstanceId(Integer frontInstanceId) { + setDataInteger(4, frontInstanceId); + } + + public Integer getBehindInstanceId() { + return getDataInteger(5); + } + + public void setBehindInstanceId(Integer behindInstanceId) { + setDataInteger(5, behindInstanceId); + } + + public Integer getFrontServiceId() { + return getDataInteger(6); + } + + public void setFrontServiceId(Integer frontServiceId) { + setDataInteger(6, frontServiceId); + } + + public Integer getBehindServiceId() { + return getDataInteger(7); + } + + public void setBehindServiceId(Integer behindServiceId) { + setDataInteger(7, behindServiceId); + } + + public Long getTimeBucket() { + return getDataLong(0); + } + + public void setTimeBucket(Long timeBucket) { + setDataLong(0, timeBucket); + } + + public String getAlarmContent() { + return getDataString(1); + } + + public void setAlarmContent(String alarmContent) { + setDataString(1, alarmContent); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceReferenceAlarmListTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceReferenceAlarmListTable.java new file mode 100644 index 000000000..24674f34a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceReferenceAlarmListTable.java @@ -0,0 +1,36 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceAlarmListTable extends CommonMetricTable { + public static final String TABLE = "service_reference_alarm_list"; + public static final String COLUMN_FRONT_SERVICE_ID = "front_service_id"; + public static final String COLUMN_BEHIND_SERVICE_ID = "behind_service_id"; + public static final String COLUMN_FRONT_INSTANCE_ID = "front_instance_id"; + public static final String COLUMN_BEHIND_INSTANCE_ID = "behind_instance_id"; + public static final String COLUMN_FRONT_APPLICATION_ID = "front_application_id"; + public static final String COLUMN_BEHIND_APPLICATION_ID = "behind_application_id"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceReferenceAlarmTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceReferenceAlarmTable.java new file mode 100644 index 000000000..b04227dce --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ServiceReferenceAlarmTable.java @@ -0,0 +1,37 @@ +/* + * 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.storage.table.alarm; + +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceAlarmTable extends CommonMetricTable { + public static final String TABLE = "service_reference_alarm"; + public static final String COLUMN_FRONT_SERVICE_ID = "front_service_id"; + public static final String COLUMN_BEHIND_SERVICE_ID = "behind_service_id"; + public static final String COLUMN_FRONT_INSTANCE_ID = "front_instance_id"; + public static final String COLUMN_BEHIND_INSTANCE_ID = "behind_instance_id"; + public static final String COLUMN_FRONT_APPLICATION_ID = "front_application_id"; + public static final String COLUMN_BEHIND_APPLICATION_ID = "behind_application_id"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; + public static final String COLUMN_LAST_TIME_BUCKET = "last_time_bucket"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alerting/AlertingList.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alerting/AlertingList.java deleted file mode 100644 index 322740b89..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alerting/AlertingList.java +++ /dev/null @@ -1,114 +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.storage.table.alerting; - -import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; -import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; -import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; - -/** - * @author peng-yongsheng - */ -public class AlertingList extends Data { - - private static final Column[] STRING_COLUMNS = { - new Column(AlertingListTable.COLUMN_ID, new NonOperation()), - }; - - private static final Column[] LONG_COLUMNS = { - new Column(AlertingListTable.COLUMN_FIRST_TIME_BUCKET, new NonOperation()), - new Column(AlertingListTable.COLUMN_LAST_TIME_BUCKET, new CoverOperation()), - }; - private static final Column[] DOUBLE_COLUMNS = {}; - - private static final Column[] INTEGER_COLUMNS = { - new Column(AlertingListTable.COLUMN_LAYER, new CoverOperation()), - new Column(AlertingListTable.COLUMN_LAYER_ID, new CoverOperation()), - new Column(AlertingListTable.COLUMN_EXPECTED, new CoverOperation()), - new Column(AlertingListTable.COLUMN_ACTUAL, new CoverOperation()), - }; - - private static final Column[] BOOLEAN_COLUMNS = { - new Column(AlertingListTable.COLUMN_VALID, new CoverOperation()), - }; - - private static final Column[] BYTE_COLUMNS = {}; - - public AlertingList(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); - } - - public Integer getLayer() { - return getDataInteger(0); - } - - public void setLayer(Integer layer) { - setDataInteger(0, layer); - } - - public Integer getLayerId() { - return getDataInteger(1); - } - - public void setLayerId(Integer layerId) { - setDataInteger(1, layerId); - } - - public Integer getExpected() { - return getDataInteger(2); - } - - public void setExpected(Integer expected) { - setDataInteger(2, expected); - } - - public Integer getActual() { - return getDataInteger(3); - } - - public void setActual(Integer actual) { - setDataInteger(3, actual); - } - - public Long getFirstTimeBucket() { - return getDataLong(0); - } - - public void setFirstTimeBucket(Long firstTimeBucket) { - setDataLong(0, firstTimeBucket); - } - - public Long getLastTimeBucket() { - return getDataLong(1); - } - - public void setLastTimeBucket(Long lastTimeBucket) { - setDataLong(1, lastTimeBucket); - } - - public Boolean getValid() { - return getDataBoolean(0); - } - - public void setValid(Boolean valid) { - setDataBoolean(0, valid); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponent.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponent.java index 34b48445e..7f56e494a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponent.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponent.java @@ -16,37 +16,56 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.application; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class ApplicationComponent extends Data { +public class ApplicationComponent extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(ApplicationComponentTable.COLUMN_ID, new NonOperation()), + new Column(ApplicationComponentTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { new Column(ApplicationComponentTable.COLUMN_TIME_BUCKET, new CoverOperation()), }; + private static final Column[] DOUBLE_COLUMNS = {}; + private static final Column[] INTEGER_COLUMNS = { new Column(ApplicationComponentTable.COLUMN_COMPONENT_ID, new CoverOperation()), new Column(ApplicationComponentTable.COLUMN_PEER_ID, new CoverOperation()), }; private static final Column[] BOOLEAN_COLUMNS = {}; + private static final Column[] BYTE_COLUMNS = {}; - public ApplicationComponent(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public ApplicationComponent() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); } public Long getTimeBucket() { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMapping.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMapping.java index ec091a131..29285fa3a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMapping.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMapping.java @@ -16,37 +16,56 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.application; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class ApplicationMapping extends Data { +public class ApplicationMapping extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(ApplicationMappingTable.COLUMN_ID, new NonOperation()), + new Column(ApplicationMappingTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { new Column(ApplicationMappingTable.COLUMN_TIME_BUCKET, new CoverOperation()), }; + private static final Column[] DOUBLE_COLUMNS = {}; + private static final Column[] INTEGER_COLUMNS = { new Column(ApplicationMappingTable.COLUMN_APPLICATION_ID, new CoverOperation()), new Column(ApplicationMappingTable.COLUMN_ADDRESS_ID, new CoverOperation()), }; private static final Column[] BOOLEAN_COLUMNS = {}; + private static final Column[] BYTE_COLUMNS = {}; - public ApplicationMapping(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public ApplicationMapping() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); } public int getApplicationId() { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMetric.java index 9b294d5c3..08883b214 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMetric.java @@ -16,22 +16,22 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.application; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; -import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; -import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.AddOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; +import org.apache.skywalking.apm.collector.storage.table.Metric; /** * @author peng-yongsheng */ -public class ApplicationMetric extends Data { +public class ApplicationMetric extends StreamData implements Metric { private static final Column[] STRING_COLUMNS = { new Column(ApplicationMetricTable.COLUMN_ID, new NonOperation()), + new Column(ApplicationMetricTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { @@ -57,125 +57,178 @@ public class ApplicationMetric extends Data { private static final Column[] DOUBLE_COLUMNS = {}; private static final Column[] INTEGER_COLUMNS = { - new Column(ApplicationMetricTable.COLUMN_APPLICATION_ID, new CoverOperation()), + new Column(ApplicationMetricTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(ApplicationMetricTable.COLUMN_APPLICATION_ID, new NonOperation()), }; private static final Column[] BOOLEAN_COLUMNS = {}; private static final Column[] BYTE_COLUMNS = {}; - public ApplicationMetric(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public ApplicationMetric() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); } - public int getApplicationId() { + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); + } + + @Override + public Integer getSourceValue() { return getDataInteger(0); } - public void setApplicationId(int applicationId) { - setDataInteger(0, applicationId); + @Override + public void setSourceValue(Integer sourceValue) { + setDataInteger(0, sourceValue); } + public int getApplicationId() { + return getDataInteger(1); + } + + public void setApplicationId(int applicationId) { + setDataInteger(1, applicationId); + } + + @Override public Long getTimeBucket() { return getDataLong(0); } + @Override public void setTimeBucket(Long timeBucket) { setDataLong(0, timeBucket); } + @Override public Long getTransactionCalls() { return getDataLong(1); } + @Override public void setTransactionCalls(Long transactionCalls) { setDataLong(1, transactionCalls); } + @Override public Long getTransactionErrorCalls() { return getDataLong(2); } + @Override public void setTransactionErrorCalls(Long transactionErrorCalls) { setDataLong(2, transactionErrorCalls); } + @Override public Long getTransactionDurationSum() { return getDataLong(3); } + @Override public void setTransactionDurationSum(Long transactionDurationSum) { setDataLong(3, transactionDurationSum); } + @Override public Long getTransactionErrorDurationSum() { return getDataLong(4); } + @Override public void setTransactionErrorDurationSum(Long transactionErrorDurationSum) { setDataLong(4, transactionErrorDurationSum); } + @Override public Long getBusinessTransactionCalls() { return getDataLong(5); } + @Override public void setBusinessTransactionCalls(Long businessTransactionCalls) { setDataLong(5, businessTransactionCalls); } + @Override public Long getBusinessTransactionErrorCalls() { return getDataLong(6); } + @Override public void setBusinessTransactionErrorCalls(Long businessTransactionErrorCalls) { setDataLong(6, businessTransactionErrorCalls); } + @Override public Long getBusinessTransactionDurationSum() { return getDataLong(7); } + @Override public void setBusinessTransactionDurationSum(Long businessTransactionDurationSum) { setDataLong(7, businessTransactionDurationSum); } + @Override public Long getBusinessTransactionErrorDurationSum() { return getDataLong(8); } + @Override public void setBusinessTransactionErrorDurationSum(Long businessTransactionErrorDurationSum) { setDataLong(8, businessTransactionErrorDurationSum); } + @Override public Long getMqTransactionCalls() { return getDataLong(9); } + @Override public void setMqTransactionCalls(Long mqTransactionCalls) { setDataLong(9, mqTransactionCalls); } + @Override public Long getMqTransactionErrorCalls() { return getDataLong(10); } + @Override public void setMqTransactionErrorCalls(Long mqTransactionErrorCalls) { setDataLong(10, mqTransactionErrorCalls); } + @Override public Long getMqTransactionDurationSum() { return getDataLong(11); } + @Override public void setMqTransactionDurationSum(Long mqTransactionDurationSum) { setDataLong(11, mqTransactionDurationSum); } + @Override public Long getMqTransactionErrorDurationSum() { return getDataLong(12); } + @Override public void setMqTransactionErrorDurationSum(Long mqTransactionErrorDurationSum) { setDataLong(12, mqTransactionErrorDurationSum); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetric.java index 6c20173b2..8c567886e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetric.java @@ -16,39 +16,39 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.application; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; -import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.AddOperation; -import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; +import org.apache.skywalking.apm.collector.storage.table.Metric; /** * @author peng-yongsheng */ -public class ApplicationReferenceMetric extends Data { +public class ApplicationReferenceMetric extends StreamData implements Metric { private static final Column[] STRING_COLUMNS = { new Column(ApplicationReferenceMetricTable.COLUMN_ID, new NonOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { - new Column(InstanceMetricTable.COLUMN_TIME_BUCKET, new NonOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, new NonOperation()), - new Column(InstanceMetricTable.COLUMN_TRANSACTION_CALLS, new AddOperation()), - new Column(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, new AddOperation()), - new Column(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, new AddOperation()), - new Column(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()), - new Column(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, new AddOperation()), - new Column(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, new AddOperation()), - new Column(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, new AddOperation()), - new Column(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()), - new Column(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, new AddOperation()), - new Column(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, new AddOperation()), - new Column(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, new AddOperation()), - new Column(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()), new Column(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, new AddOperation()), new Column(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, new AddOperation()), @@ -57,6 +57,7 @@ public class ApplicationReferenceMetric extends Data { private static final Column[] DOUBLE_COLUMNS = {}; private static final Column[] INTEGER_COLUMNS = { + new Column(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, new NonOperation()), new Column(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, new NonOperation()), new Column(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, new NonOperation()), }; @@ -65,126 +66,178 @@ public class ApplicationReferenceMetric extends Data { private static final Column[] BYTE_COLUMNS = {}; - public ApplicationReferenceMetric(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public ApplicationReferenceMetric() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); } - public Integer getFrontApplicationId() { + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); + } + + @Override + public Integer getSourceValue() { return getDataInteger(0); } - public void setFrontApplicationId(Integer frontApplicationId) { - setDataInteger(0, frontApplicationId); + @Override + public void setSourceValue(Integer sourceValue) { + setDataInteger(0, sourceValue); } - public Integer getBehindApplicationId() { + public Integer getFrontApplicationId() { return getDataInteger(1); } - public void setBehindApplicationId(Integer behindApplicationId) { - setDataInteger(1, behindApplicationId); + public void setFrontApplicationId(Integer frontApplicationId) { + setDataInteger(1, frontApplicationId); } + public Integer getBehindApplicationId() { + return getDataInteger(2); + } + + public void setBehindApplicationId(Integer behindApplicationId) { + setDataInteger(2, behindApplicationId); + } + + @Override public Long getTimeBucket() { return getDataLong(0); } + @Override public void setTimeBucket(Long timeBucket) { setDataLong(0, timeBucket); } + @Override public Long getTransactionCalls() { return getDataLong(1); } + @Override public void setTransactionCalls(Long transactionCalls) { setDataLong(1, transactionCalls); } + @Override public Long getTransactionErrorCalls() { return getDataLong(2); } + @Override public void setTransactionErrorCalls(Long transactionErrorCalls) { setDataLong(2, transactionErrorCalls); } + @Override public Long getTransactionDurationSum() { return getDataLong(3); } + @Override public void setTransactionDurationSum(Long transactionDurationSum) { setDataLong(3, transactionDurationSum); } + @Override public Long getTransactionErrorDurationSum() { return getDataLong(4); } + @Override public void setTransactionErrorDurationSum(Long transactionErrorDurationSum) { setDataLong(4, transactionErrorDurationSum); } + @Override public Long getBusinessTransactionCalls() { return getDataLong(5); } + @Override public void setBusinessTransactionCalls(Long businessTransactionCalls) { setDataLong(5, businessTransactionCalls); } + @Override public Long getBusinessTransactionErrorCalls() { return getDataLong(6); } + @Override public void setBusinessTransactionErrorCalls(Long businessTransactionErrorCalls) { setDataLong(6, businessTransactionErrorCalls); } + @Override public Long getBusinessTransactionDurationSum() { return getDataLong(7); } + @Override public void setBusinessTransactionDurationSum(Long businessTransactionDurationSum) { setDataLong(7, businessTransactionDurationSum); } + @Override public Long getBusinessTransactionErrorDurationSum() { return getDataLong(8); } + @Override public void setBusinessTransactionErrorDurationSum(Long businessTransactionErrorDurationSum) { setDataLong(8, businessTransactionErrorDurationSum); } + @Override public Long getMqTransactionCalls() { return getDataLong(9); } + @Override public void setMqTransactionCalls(Long mqTransactionCalls) { setDataLong(9, mqTransactionCalls); } + @Override public Long getMqTransactionErrorCalls() { return getDataLong(10); } + @Override public void setMqTransactionErrorCalls(Long mqTransactionErrorCalls) { setDataLong(10, mqTransactionErrorCalls); } + @Override public Long getMqTransactionDurationSum() { return getDataLong(11); } + @Override public void setMqTransactionDurationSum(Long mqTransactionDurationSum) { setDataLong(11, mqTransactionDurationSum); } + @Override public Long getMqTransactionErrorDurationSum() { return getDataLong(12); } + @Override public void setMqTransactionErrorDurationSum(Long mqTransactionErrorDurationSum) { setDataLong(12, mqTransactionErrorDurationSum); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetricTable.java index 621412797..4034ad564 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetricTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetricTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.application; import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; @@ -25,7 +24,7 @@ import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; * @author peng-yongsheng */ public class ApplicationReferenceMetricTable extends CommonMetricTable { - public static final String TABLE = "application_reference"; + public static final String TABLE = "application_reference_metric"; public static final String COLUMN_FRONT_APPLICATION_ID = "front_application_id"; public static final String COLUMN_BEHIND_APPLICATION_ID = "behind_application_id"; public static final String COLUMN_SATISFIED_COUNT = "satisfied_count"; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/global/GlobalTrace.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/global/GlobalTrace.java index c8ed30ec9..d1a28150d 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/global/GlobalTrace.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/global/GlobalTrace.java @@ -16,18 +16,17 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.global; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class GlobalTrace extends Data { +public class GlobalTrace extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(GlobalTraceTable.COLUMN_ID, new NonOperation()), @@ -45,8 +44,24 @@ public class GlobalTrace extends Data { private static final Column[] BOOLEAN_COLUMNS = {}; private static final Column[] BYTE_COLUMNS = {}; - public GlobalTrace(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public GlobalTrace() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); } public String getSegmentId() { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceEntry.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceMapping.java similarity index 51% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceEntry.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceMapping.java index b97df5a8b..36ec597c2 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceEntry.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceMapping.java @@ -16,78 +16,88 @@ * */ - -package org.apache.skywalking.apm.collector.storage.table.service; +package org.apache.skywalking.apm.collector.storage.table.instance; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class ServiceEntry extends Data { +public class InstanceMapping extends StreamData { private static final Column[] STRING_COLUMNS = { - new Column(ServiceEntryTable.COLUMN_ID, new NonOperation()), - new Column(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, new CoverOperation()), + new Column(InstanceMappingTable.COLUMN_ID, new NonOperation()), + new Column(InstanceMappingTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { - new Column(ServiceEntryTable.COLUMN_REGISTER_TIME, new NonOperation()), - new Column(ServiceEntryTable.COLUMN_NEWEST_TIME, new CoverOperation()), + new Column(InstanceMappingTable.COLUMN_TIME_BUCKET, new CoverOperation()), }; + private static final Column[] DOUBLE_COLUMNS = {}; + private static final Column[] INTEGER_COLUMNS = { - new Column(ServiceEntryTable.COLUMN_APPLICATION_ID, new CoverOperation()), - new Column(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, new CoverOperation()), + new Column(InstanceMappingTable.COLUMN_APPLICATION_ID, new CoverOperation()), + new Column(InstanceMappingTable.COLUMN_INSTANCE_ID, new CoverOperation()), + new Column(InstanceMappingTable.COLUMN_ADDRESS_ID, new CoverOperation()), }; private static final Column[] BOOLEAN_COLUMNS = {}; + private static final Column[] BYTE_COLUMNS = {}; - public ServiceEntry(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public InstanceMapping() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); } - public String getEntryServiceName() { + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { return getDataString(1); } - public void setEntryServiceName(String entryServiceName) { - setDataString(1, entryServiceName); + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); } - public Long getRegisterTime() { - return getDataLong(0); - } - - public void setRegisterTime(Long registerTime) { - setDataLong(0, registerTime); - } - - public Long getNewestTime() { - return getDataLong(1); - } - - public void setNewestTime(Long newestTime) { - setDataLong(1, newestTime); - } - - public Integer getApplicationId() { + public int getApplicationId() { return getDataInteger(0); } - public void setApplicationId(Integer applicationId) { + public void setApplicationId(int applicationId) { setDataInteger(0, applicationId); } - public Integer getEntryServiceId() { + public int getInstanceId() { return getDataInteger(1); } - public void setEntryServiceId(Integer entryServiceId) { - setDataInteger(1, entryServiceId); + public void setInstanceId(int instanceId) { + setDataInteger(1, instanceId); + } + + public int getAddressId() { + return getDataInteger(2); + } + + public void setAddressId(int addressId) { + setDataInteger(2, addressId); + } + + public long getTimeBucket() { + return getDataLong(0); + } + + public void setTimeBucket(long timeBucket) { + setDataLong(0, timeBucket); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceEntryTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceMappingTable.java similarity index 67% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceEntryTable.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceMappingTable.java index ae984edb3..609e389fa 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceEntryTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceMappingTable.java @@ -16,19 +16,16 @@ * */ - -package org.apache.skywalking.apm.collector.storage.table.service; +package org.apache.skywalking.apm.collector.storage.table.instance; import org.apache.skywalking.apm.collector.core.data.CommonTable; /** * @author peng-yongsheng */ -public class ServiceEntryTable extends CommonTable { - public static final String TABLE = "service_entry"; +public class InstanceMappingTable extends CommonTable { + public static final String TABLE = "instance_mapping"; public static final String COLUMN_APPLICATION_ID = "application_id"; - public static final String COLUMN_ENTRY_SERVICE_ID = "entry_service_id"; - public static final String COLUMN_ENTRY_SERVICE_NAME = "entry_service_name"; - public static final String COLUMN_REGISTER_TIME = "register_time"; - public static final String COLUMN_NEWEST_TIME = "newest_time"; + public static final String COLUMN_INSTANCE_ID = "instance_id"; + public static final String COLUMN_ADDRESS_ID = "address_id"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceMetric.java index c04df5c0c..c9975257e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceMetric.java @@ -16,22 +16,23 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.instance; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.AddOperation; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; +import org.apache.skywalking.apm.collector.storage.table.Metric; /** * @author peng-yongsheng */ -public class InstanceMetric extends Data { +public class InstanceMetric extends StreamData implements Metric { private static final Column[] STRING_COLUMNS = { new Column(InstanceMetricTable.COLUMN_ID, new NonOperation()), + new Column(InstanceMetricTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { @@ -54,133 +55,187 @@ public class InstanceMetric extends Data { private static final Column[] DOUBLE_COLUMNS = {}; private static final Column[] INTEGER_COLUMNS = { + new Column(InstanceMetricTable.COLUMN_SOURCE_VALUE, new CoverOperation()), new Column(InstanceMetricTable.COLUMN_APPLICATION_ID, new CoverOperation()), new Column(InstanceMetricTable.COLUMN_INSTANCE_ID, new CoverOperation()), }; private static final Column[] BOOLEAN_COLUMNS = {}; + private static final Column[] BYTE_COLUMNS = {}; - public InstanceMetric(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public InstanceMetric() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); } - public Integer getApplicationId() { + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); + } + + @Override + public Integer getSourceValue() { return getDataInteger(0); } - public void setApplicationId(Integer applicationId) { - setDataInteger(0, applicationId); + @Override + public void setSourceValue(Integer sourceValue) { + setDataInteger(0, sourceValue); } - public Integer getInstanceId() { + public Integer getApplicationId() { return getDataInteger(1); } - public void setInstanceId(Integer instanceId) { - setDataInteger(1, instanceId); + public void setApplicationId(Integer applicationId) { + setDataInteger(1, applicationId); } + public Integer getInstanceId() { + return getDataInteger(2); + } + + public void setInstanceId(Integer instanceId) { + setDataInteger(2, instanceId); + } + + @Override public Long getTimeBucket() { return getDataLong(0); } + @Override public void setTimeBucket(Long timeBucket) { setDataLong(0, timeBucket); } + @Override public Long getTransactionCalls() { return getDataLong(1); } + @Override public void setTransactionCalls(Long transactionCalls) { setDataLong(1, transactionCalls); } + @Override public Long getTransactionErrorCalls() { return getDataLong(2); } + @Override public void setTransactionErrorCalls(Long transactionErrorCalls) { setDataLong(2, transactionErrorCalls); } + @Override public Long getTransactionDurationSum() { return getDataLong(3); } + @Override public void setTransactionDurationSum(Long transactionDurationSum) { setDataLong(3, transactionDurationSum); } + @Override public Long getTransactionErrorDurationSum() { return getDataLong(4); } + @Override public void setTransactionErrorDurationSum(Long transactionErrorDurationSum) { setDataLong(4, transactionErrorDurationSum); } + @Override public Long getBusinessTransactionCalls() { return getDataLong(5); } + @Override public void setBusinessTransactionCalls(Long businessTransactionCalls) { setDataLong(5, businessTransactionCalls); } + @Override public Long getBusinessTransactionErrorCalls() { return getDataLong(6); } + @Override public void setBusinessTransactionErrorCalls(Long businessTransactionErrorCalls) { setDataLong(6, businessTransactionErrorCalls); } + @Override public Long getBusinessTransactionDurationSum() { return getDataLong(7); } + @Override public void setBusinessTransactionDurationSum(Long businessTransactionDurationSum) { setDataLong(7, businessTransactionDurationSum); } + @Override public Long getBusinessTransactionErrorDurationSum() { return getDataLong(8); } + @Override public void setBusinessTransactionErrorDurationSum(Long businessTransactionErrorDurationSum) { setDataLong(8, businessTransactionErrorDurationSum); } + @Override public Long getMqTransactionCalls() { return getDataLong(9); } + @Override public void setMqTransactionCalls(Long mqTransactionCalls) { setDataLong(9, mqTransactionCalls); } + @Override public Long getMqTransactionErrorCalls() { return getDataLong(10); } + @Override public void setMqTransactionErrorCalls(Long mqTransactionErrorCalls) { setDataLong(10, mqTransactionErrorCalls); } + @Override public Long getMqTransactionDurationSum() { return getDataLong(11); } + @Override public void setMqTransactionDurationSum(Long mqTransactionDurationSum) { setDataLong(11, mqTransactionDurationSum); } + @Override public Long getMqTransactionErrorDurationSum() { return getDataLong(12); } + @Override public void setMqTransactionErrorDurationSum(Long mqTransactionErrorDurationSum) { setDataLong(12, mqTransactionErrorDurationSum); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceReferenceMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceReferenceMetric.java index fb92bf52d..c05e1a784 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceReferenceMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceReferenceMetric.java @@ -16,21 +16,22 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.instance; -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.AddOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; +import org.apache.skywalking.apm.collector.storage.table.Metric; /** * @author peng-yongsheng */ -public class InstanceReferenceMetric extends Data { +public class InstanceReferenceMetric extends StreamData implements Metric { private static final Column[] STRING_COLUMNS = { new Column(InstanceReferenceMetricTable.COLUMN_ID, new NonOperation()), + new Column(InstanceReferenceMetricTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { @@ -53,143 +54,205 @@ public class InstanceReferenceMetric extends Data { private static final Column[] DOUBLE_COLUMNS = {}; private static final Column[] INTEGER_COLUMNS = { + new Column(InstanceReferenceMetricTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(InstanceReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, new NonOperation()), + new Column(InstanceReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, new NonOperation()), new Column(InstanceReferenceMetricTable.COLUMN_FRONT_INSTANCE_ID, new NonOperation()), new Column(InstanceReferenceMetricTable.COLUMN_BEHIND_INSTANCE_ID, new NonOperation()), - new Column(InstanceReferenceMetricTable.COLUMN_SOURCE_VALUE, new NonOperation()), }; private static final Column[] BOOLEAN_COLUMNS = {}; private static final Column[] BYTE_COLUMNS = {}; - public InstanceReferenceMetric(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public InstanceReferenceMetric() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); } - public Integer getFrontInstanceId() { + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); + } + + @Override + public Integer getSourceValue() { return getDataInteger(0); } - public void setFrontInstanceId(Integer frontInstanceId) { - setDataInteger(0, frontInstanceId); + @Override + public void setSourceValue(Integer sourceValue) { + setDataInteger(0, sourceValue); } - public Integer getBehindInstanceId() { + public Integer getFrontApplicationId() { return getDataInteger(1); } - public void setBehindInstanceId(Integer behindInstanceId) { - setDataInteger(1, behindInstanceId); + public void setFrontApplicationId(Integer frontApplicationId) { + setDataInteger(1, frontApplicationId); } - public Integer getSourceValue() { + public Integer getBehindApplicationId() { return getDataInteger(2); } - public void setSourceValue(Integer sourceValue) { - setDataInteger(2, sourceValue); + public void setBehindApplicationId(Integer behindApplicationId) { + setDataInteger(2, behindApplicationId); } + public Integer getFrontInstanceId() { + return getDataInteger(3); + } + + public void setFrontInstanceId(Integer frontInstanceId) { + setDataInteger(3, frontInstanceId); + } + + public Integer getBehindInstanceId() { + return getDataInteger(4); + } + + public void setBehindInstanceId(Integer behindInstanceId) { + setDataInteger(4, behindInstanceId); + } + + @Override public Long getTimeBucket() { return getDataLong(0); } + @Override public void setTimeBucket(Long timeBucket) { setDataLong(0, timeBucket); } + @Override public Long getTransactionCalls() { return getDataLong(1); } + @Override public void setTransactionCalls(Long transactionCalls) { setDataLong(1, transactionCalls); } + @Override public Long getTransactionErrorCalls() { return getDataLong(2); } + @Override public void setTransactionErrorCalls(Long transactionErrorCalls) { setDataLong(2, transactionErrorCalls); } + @Override public Long getTransactionDurationSum() { return getDataLong(3); } + @Override public void setTransactionDurationSum(Long transactionDurationSum) { setDataLong(3, transactionDurationSum); } + @Override public Long getTransactionErrorDurationSum() { return getDataLong(4); } + @Override public void setTransactionErrorDurationSum(Long transactionErrorDurationSum) { setDataLong(4, transactionErrorDurationSum); } + @Override public Long getBusinessTransactionCalls() { return getDataLong(5); } + @Override public void setBusinessTransactionCalls(Long businessTransactionCalls) { setDataLong(5, businessTransactionCalls); } + @Override public Long getBusinessTransactionErrorCalls() { return getDataLong(6); } + @Override public void setBusinessTransactionErrorCalls(Long businessTransactionErrorCalls) { setDataLong(6, businessTransactionErrorCalls); } + @Override public Long getBusinessTransactionDurationSum() { return getDataLong(7); } + @Override public void setBusinessTransactionDurationSum(Long businessTransactionDurationSum) { setDataLong(7, businessTransactionDurationSum); } + @Override public Long getBusinessTransactionErrorDurationSum() { return getDataLong(8); } + @Override public void setBusinessTransactionErrorDurationSum(Long businessTransactionErrorDurationSum) { setDataLong(8, businessTransactionErrorDurationSum); } + @Override public Long getMqTransactionCalls() { return getDataLong(9); } + @Override public void setMqTransactionCalls(Long mqTransactionCalls) { setDataLong(9, mqTransactionCalls); } + @Override public Long getMqTransactionErrorCalls() { return getDataLong(10); } + @Override public void setMqTransactionErrorCalls(Long mqTransactionErrorCalls) { setDataLong(10, mqTransactionErrorCalls); } + @Override public Long getMqTransactionDurationSum() { return getDataLong(11); } + @Override public void setMqTransactionDurationSum(Long mqTransactionDurationSum) { setDataLong(11, mqTransactionDurationSum); } + @Override public Long getMqTransactionErrorDurationSum() { return getDataLong(12); } + @Override public void setMqTransactionErrorDurationSum(Long mqTransactionErrorDurationSum) { setDataLong(12, mqTransactionErrorDurationSum); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceReferenceMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceReferenceMetricTable.java index c4f824aea..b2dbe1781 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceReferenceMetricTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/instance/InstanceReferenceMetricTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.instance; import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; @@ -28,4 +27,6 @@ public class InstanceReferenceMetricTable extends CommonMetricTable { public static final String TABLE = "instance_reference_metric"; public static final String COLUMN_FRONT_INSTANCE_ID = "front_instance_id"; public static final String COLUMN_BEHIND_INSTANCE_ID = "behind_instance_id"; + public static final String COLUMN_FRONT_APPLICATION_ID = "front_application_id"; + public static final String COLUMN_BEHIND_APPLICATION_ID = "behind_application_id"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/CpuMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/CpuMetric.java index 3cfb4b6d7..67ecd6ecc 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/CpuMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/CpuMetric.java @@ -16,11 +16,10 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.jvm; -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.AddOperation; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; @@ -28,13 +27,15 @@ import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class CpuMetric extends Data { +public class CpuMetric extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(CpuMetricTable.COLUMN_ID, new NonOperation()), + new Column(CpuMetricTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { + new Column(CpuMetricTable.COLUMN_TIMES, new AddOperation()), new Column(CpuMetricTable.COLUMN_TIME_BUCKET, new CoverOperation()), }; @@ -49,8 +50,24 @@ public class CpuMetric extends Data { private static final Column[] BOOLEAN_COLUMNS = {}; private static final Column[] BYTE_COLUMNS = {}; - public CpuMetric(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public CpuMetric() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); } public Integer getInstanceId() { @@ -69,11 +86,19 @@ public class CpuMetric extends Data { setDataDouble(0, usagePercent); } - public Long getTimeBucket() { + public Long getTimes() { return getDataLong(0); } + public void setTimes(Long times) { + setDataLong(0, times); + } + + public Long getTimeBucket() { + return getDataLong(1); + } + public void setTimeBucket(Long timeBucket) { - setDataLong(0, timeBucket); + setDataLong(1, timeBucket); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/CpuMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/CpuMetricTable.java index 31e83c564..1f4ef5798 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/CpuMetricTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/CpuMetricTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.jvm; import org.apache.skywalking.apm.collector.core.data.CommonTable; @@ -28,4 +27,5 @@ public class CpuMetricTable extends CommonTable { public static final String TABLE = "cpu_metric"; public static final String COLUMN_INSTANCE_ID = "instance_id"; public static final String COLUMN_USAGE_PERCENT = "usage_percent"; + public static final String COLUMN_TIMES = "times"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/GCMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/GCMetric.java index bad0fe3c7..3e4f59218 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/GCMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/GCMetric.java @@ -16,26 +16,27 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.jvm; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.AddOperation; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class GCMetric extends Data { +public class GCMetric extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(GCMetricTable.COLUMN_ID, new NonOperation()), + new Column(GCMetricTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { - new Column(GCMetricTable.COLUMN_COUNT, new CoverOperation()), - new Column(GCMetricTable.COLUMN_TIME, new CoverOperation()), + new Column(GCMetricTable.COLUMN_COUNT, new AddOperation()), + new Column(GCMetricTable.COLUMN_TIMES, new AddOperation()), new Column(GCMetricTable.COLUMN_TIME_BUCKET, new CoverOperation()), }; @@ -50,8 +51,24 @@ public class GCMetric extends Data { private static final Column[] BOOLEAN_COLUMNS = {}; private static final Column[] BYTE_COLUMNS = {}; - public GCMetric(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public GCMetric() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); } public Long getCount() { @@ -62,12 +79,12 @@ public class GCMetric extends Data { setDataLong(0, count); } - public Long getTime() { + public Long getTimes() { return getDataLong(1); } - public void setTime(Long time) { - setDataLong(1, time); + public void setTimes(Long times) { + setDataLong(1, times); } public Long getTimeBucket() { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/GCMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/GCMetricTable.java index eb42e1527..7644364ed 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/GCMetricTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/GCMetricTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.jvm; import org.apache.skywalking.apm.collector.core.data.CommonTable; @@ -29,5 +28,5 @@ public class GCMetricTable extends CommonTable { public static final String COLUMN_INSTANCE_ID = "instance_id"; public static final String COLUMN_PHRASE = "phrase"; public static final String COLUMN_COUNT = "count"; - public static final String COLUMN_TIME = "time"; + public static final String COLUMN_TIMES = "times"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryMetric.java index cf342ec8c..52123d4ee 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryMetric.java @@ -16,29 +16,33 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.jvm; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.AddOperation; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.MaxOperation; +import org.apache.skywalking.apm.collector.core.data.operator.MinOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class MemoryMetric extends Data { +public class MemoryMetric extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(MemoryMetricTable.COLUMN_ID, new NonOperation()), + new Column(MemoryMetricTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { - new Column(MemoryMetricTable.COLUMN_INIT, new CoverOperation()), - new Column(MemoryMetricTable.COLUMN_MAX, new CoverOperation()), - new Column(MemoryMetricTable.COLUMN_USED, new CoverOperation()), - new Column(MemoryMetricTable.COLUMN_COMMITTED, new CoverOperation()), - new Column(MemoryMetricTable.COLUMN_TIME_BUCKET, new CoverOperation()), + new Column(MemoryMetricTable.COLUMN_INIT, new MinOperation()), + new Column(MemoryMetricTable.COLUMN_MAX, new MaxOperation()), + new Column(MemoryMetricTable.COLUMN_USED, new AddOperation()), + new Column(MemoryMetricTable.COLUMN_COMMITTED, new AddOperation()), + new Column(MemoryMetricTable.COLUMN_TIMES, new AddOperation()), + new Column(MemoryMetricTable.COLUMN_TIME_BUCKET, new NonOperation()), }; private static final Column[] DOUBLE_COLUMNS = { @@ -53,8 +57,24 @@ public class MemoryMetric extends Data { }; private static final Column[] BYTE_COLUMNS = {}; - public MemoryMetric(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public MemoryMetric() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); } public Long getInit() { @@ -89,12 +109,20 @@ public class MemoryMetric extends Data { setDataLong(3, committed); } - public Long getTimeBucket() { + public Long getTimes() { return getDataLong(4); } + public void setTimes(Long times) { + setDataLong(4, times); + } + + public Long getTimeBucket() { + return getDataLong(5); + } + public void setTimeBucket(Long timeBucket) { - setDataLong(4, timeBucket); + setDataLong(5, timeBucket); } public Boolean getIsHeap() { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryMetricTable.java index 447668013..84ba732e8 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryMetricTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryMetricTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.jvm; import org.apache.skywalking.apm.collector.core.data.CommonTable; @@ -32,4 +31,5 @@ public class MemoryMetricTable extends CommonTable { public static final String COLUMN_MAX = "max"; public static final String COLUMN_USED = "used"; public static final String COLUMN_COMMITTED = "committed"; + public static final String COLUMN_TIMES = "times"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryPoolMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryPoolMetric.java index a75274432..b270b8d9a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryPoolMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryPoolMetric.java @@ -16,44 +16,65 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.jvm; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.AddOperation; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.MaxOperation; +import org.apache.skywalking.apm.collector.core.data.operator.MinOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class MemoryPoolMetric extends Data { +public class MemoryPoolMetric extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(MemoryPoolMetricTable.COLUMN_ID, new NonOperation()), + new Column(MemoryPoolMetricTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { - new Column(MemoryPoolMetricTable.COLUMN_INIT, new CoverOperation()), - new Column(MemoryPoolMetricTable.COLUMN_MAX, new CoverOperation()), - new Column(MemoryPoolMetricTable.COLUMN_USED, new CoverOperation()), - new Column(MemoryPoolMetricTable.COLUMN_COMMITTED, new CoverOperation()), - new Column(MemoryPoolMetricTable.COLUMN_TIME_BUCKET, new CoverOperation()), + new Column(MemoryPoolMetricTable.COLUMN_INIT, new MinOperation()), + new Column(MemoryPoolMetricTable.COLUMN_MAX, new MaxOperation()), + new Column(MemoryPoolMetricTable.COLUMN_USED, new AddOperation()), + new Column(MemoryPoolMetricTable.COLUMN_COMMITTED, new AddOperation()), + new Column(MemoryPoolMetricTable.COLUMN_TIMES, new AddOperation()), + new Column(MemoryPoolMetricTable.COLUMN_TIME_BUCKET, new NonOperation()), }; private static final Column[] DOUBLE_COLUMNS = { }; private static final Column[] INTEGER_COLUMNS = { - new Column(MemoryPoolMetricTable.COLUMN_INSTANCE_ID, new CoverOperation()), + new Column(MemoryPoolMetricTable.COLUMN_INSTANCE_ID, new NonOperation()), new Column(MemoryPoolMetricTable.COLUMN_POOL_TYPE, new CoverOperation()), }; private static final Column[] BOOLEAN_COLUMNS = {}; + private static final Column[] BYTE_COLUMNS = {}; - public MemoryPoolMetric(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public MemoryPoolMetric() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); } public Long getInit() { @@ -88,12 +109,20 @@ public class MemoryPoolMetric extends Data { setDataLong(3, committed); } - public Long getTimeBucket() { + public Long getTimes() { return getDataLong(4); } + public void setTimes(Long times) { + setDataLong(4, times); + } + + public Long getTimeBucket() { + return getDataLong(5); + } + public void setTimeBucket(Long timeBucket) { - setDataLong(4, timeBucket); + setDataLong(5, timeBucket); } public Integer getInstanceId() { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryPoolMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryPoolMetricTable.java index e1e854d4e..700e006c7 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryPoolMetricTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/MemoryPoolMetricTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.jvm; import org.apache.skywalking.apm.collector.core.data.CommonTable; @@ -32,4 +31,5 @@ public class MemoryPoolMetricTable extends CommonTable { public static final String COLUMN_MAX = "max"; public static final String COLUMN_USED = "used"; public static final String COLUMN_COMMITTED = "committed"; + public static final String COLUMN_TIMES = "times"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/Application.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/Application.java index 0a38adad6..53546a924 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/Application.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/Application.java @@ -16,18 +16,17 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.register; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class Application extends Data { +public class Application extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(ApplicationTable.COLUMN_ID, new NonOperation()), @@ -35,16 +34,38 @@ public class Application extends Data { }; private static final Column[] LONG_COLUMNS = {}; + private static final Column[] DOUBLE_COLUMNS = {}; + private static final Column[] INTEGER_COLUMNS = { new Column(ApplicationTable.COLUMN_APPLICATION_ID, new CoverOperation()), + new Column(ApplicationTable.COLUMN_ADDRESS_ID, new CoverOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = { + new Column(ApplicationTable.COLUMN_IS_ADDRESS, new CoverOperation()), }; - private static final Column[] BOOLEAN_COLUMNS = {}; private static final Column[] BYTE_COLUMNS = {}; - public Application(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public Application() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); } public String getApplicationCode() { @@ -62,4 +83,20 @@ public class Application extends Data { public void setApplicationId(int applicationId) { setDataInteger(0, applicationId); } + + public int getAddressId() { + return getDataInteger(1); + } + + public void setAddressId(int addressId) { + setDataInteger(1, addressId); + } + + public boolean getIsAddress() { + return getDataBoolean(0); + } + + public void setIsAddress(boolean isAddress) { + setDataBoolean(0, isAddress); + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ApplicationTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ApplicationTable.java index 31939185b..abb5b5905 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ApplicationTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ApplicationTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.register; import org.apache.skywalking.apm.collector.core.data.CommonTable; @@ -28,4 +27,6 @@ public class ApplicationTable extends CommonTable { public static final String TABLE = "application"; public static final String COLUMN_APPLICATION_CODE = "application_code"; public static final String COLUMN_APPLICATION_ID = "application_id"; + public static final String COLUMN_IS_ADDRESS = "is_address"; + public static final String COLUMN_ADDRESS_ID = "address_id"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/Instance.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/Instance.java index cf6bcae0d..19dcc758e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/Instance.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/Instance.java @@ -16,18 +16,17 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.register; -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class Instance extends Data { +public class Instance extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(InstanceTable.COLUMN_ID, new NonOperation()), @@ -39,23 +38,41 @@ public class Instance extends Data { new Column(InstanceTable.COLUMN_REGISTER_TIME, new CoverOperation()), new Column(InstanceTable.COLUMN_HEARTBEAT_TIME, new CoverOperation()), }; + private static final Column[] DOUBLE_COLUMNS = {}; + private static final Column[] INTEGER_COLUMNS = { new Column(InstanceTable.COLUMN_APPLICATION_ID, new CoverOperation()), new Column(InstanceTable.COLUMN_INSTANCE_ID, new CoverOperation()), + new Column(InstanceTable.COLUMN_ADDRESS_ID, new CoverOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = { + new Column(InstanceTable.COLUMN_IS_ADDRESS, new CoverOperation()), }; - private static final Column[] BOOLEAN_COLUMNS = {}; private static final Column[] BYTE_COLUMNS = {}; - public Instance(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public Instance() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); } - public String getId() { + @Override public String getId() { return getDataString(0); } + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + public int getApplicationId() { return getDataInteger(0); } @@ -103,4 +120,20 @@ public class Instance extends Data { public void setOsInfo(String osInfo) { setDataString(2, osInfo); } + + public int getAddressId() { + return getDataInteger(2); + } + + public void setAddressId(int addressId) { + setDataInteger(2, addressId); + } + + public boolean getIsAddress() { + return getDataBoolean(0); + } + + public void setIsAddress(boolean isAddress) { + setDataBoolean(0, isAddress); + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/InstanceTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/InstanceTable.java index 473860093..10779e762 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/InstanceTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/InstanceTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.register; import org.apache.skywalking.apm.collector.core.data.CommonTable; @@ -32,4 +31,6 @@ public class InstanceTable extends CommonTable { public static final String COLUMN_INSTANCE_ID = "instance_id"; public static final String COLUMN_HEARTBEAT_TIME = "heartbeat_time"; public static final String COLUMN_OS_INFO = "os_info"; + public static final String COLUMN_IS_ADDRESS = "is_address"; + public static final String COLUMN_ADDRESS_ID = "address_id"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddress.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddress.java new file mode 100644 index 000000000..55d1fe6f0 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddress.java @@ -0,0 +1,83 @@ +/* + * 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.storage.table.register; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class NetworkAddress extends StreamData { + + private static final Column[] STRING_COLUMNS = { + new Column(NetworkAddressTable.COLUMN_ID, new NonOperation()), + new Column(NetworkAddressTable.COLUMN_NETWORK_ADDRESS, new NonOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(NetworkAddressTable.COLUMN_ADDRESS_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public NetworkAddress() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); + } + + public String getNetworkAddress() { + return getDataString(1); + } + + public void setNetworkAddress(String networkAddress) { + setDataString(1, networkAddress); + } + + public Integer getAddressId() { + return getDataInteger(0); + } + + public void setAddressId(Integer addressId) { + setDataInteger(0, addressId); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddressTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddressTable.java new file mode 100644 index 000000000..97ffe2e76 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddressTable.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.storage.table.register; + +import org.apache.skywalking.apm.collector.core.data.CommonTable; + +/** + * @author peng-yongsheng + */ +public class NetworkAddressTable extends CommonTable { + public static final String TABLE = "network_address"; + public static final String COLUMN_NETWORK_ADDRESS = "network_address"; + public static final String COLUMN_ADDRESS_ID = "address_id"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ServiceName.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ServiceName.java index e95028742..d68f71d36 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ServiceName.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ServiceName.java @@ -16,18 +16,17 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.register; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class ServiceName extends Data { +public class ServiceName extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(ServiceNameTable.COLUMN_ID, new NonOperation()), @@ -44,8 +43,24 @@ public class ServiceName extends Data { private static final Column[] BOOLEAN_COLUMNS = {}; private static final Column[] BYTE_COLUMNS = {}; - public ServiceName(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public ServiceName() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); } public String getServiceName() { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/Segment.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/Segment.java index a59c5ab9c..acb29929a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/Segment.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/Segment.java @@ -16,18 +16,17 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.segment; -import org.apache.skywalking.apm.collector.core.data.Data; import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class Segment extends Data { +public class Segment extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(SegmentTable.COLUMN_ID, new NonOperation()), @@ -45,8 +44,24 @@ public class Segment extends Data { new Column(SegmentTable.COLUMN_DATA_BINARY, new CoverOperation()), }; - public Segment(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public Segment() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); } public byte[] getDataBinary() { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentCost.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentCost.java index 51011dfcc..4dbd7e5da 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentCost.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentCost.java @@ -16,18 +16,17 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.segment; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class SegmentCost extends Data { +public class SegmentCost extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(SegmentCostTable.COLUMN_ID, new NonOperation()), @@ -51,8 +50,24 @@ public class SegmentCost extends Data { }; private static final Column[] BYTE_COLUMNS = {}; - public SegmentCost(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public SegmentCost() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getId(); + } + + @Override public void setMetricId(String metricId) { + setId(metricId); } public String getSegmentId() { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceMetric.java index 757b7b57d..f4cf9639f 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceMetric.java @@ -16,21 +16,22 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.service; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; -import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.AddOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; +import org.apache.skywalking.apm.collector.storage.table.Metric; /** * @author peng-yongsheng */ -public class ServiceMetric extends Data { +public class ServiceMetric extends StreamData implements Metric { private static final Column[] STRING_COLUMNS = { new Column(ServiceMetricTable.COLUMN_ID, new NonOperation()), + new Column(ServiceMetricTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { @@ -53,6 +54,9 @@ public class ServiceMetric extends Data { private static final Column[] DOUBLE_COLUMNS = {}; private static final Column[] INTEGER_COLUMNS = { + new Column(ServiceMetricTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(ServiceMetricTable.COLUMN_APPLICATION_ID, new NonOperation()), + new Column(ServiceMetricTable.COLUMN_INSTANCE_ID, new NonOperation()), new Column(ServiceMetricTable.COLUMN_SERVICE_ID, new NonOperation()), }; @@ -60,118 +64,186 @@ public class ServiceMetric extends Data { private static final Column[] BYTE_COLUMNS = {}; - public ServiceMetric(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public ServiceMetric() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); } - public Integer getServiceId() { + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); + } + + @Override + public Integer getSourceValue() { return getDataInteger(0); } - public void setServiceId(Integer serviceId) { - setDataInteger(0, serviceId); + @Override + public void setSourceValue(Integer sourceValue) { + setDataInteger(0, sourceValue); } + public Integer getApplicationId() { + return getDataInteger(1); + } + + public void setApplicationId(Integer applicationId) { + setDataInteger(1, applicationId); + } + + public Integer getInstanceId() { + return getDataInteger(2); + } + + public void setInstanceId(Integer instanceId) { + setDataInteger(2, instanceId); + } + + public Integer getServiceId() { + return getDataInteger(3); + } + + public void setServiceId(Integer serviceId) { + setDataInteger(3, serviceId); + } + + @Override public Long getTimeBucket() { return getDataLong(0); } + @Override public void setTimeBucket(Long timeBucket) { setDataLong(0, timeBucket); } + @Override public Long getTransactionCalls() { return getDataLong(1); } + @Override public void setTransactionCalls(Long transactionCalls) { setDataLong(1, transactionCalls); } + @Override public Long getTransactionErrorCalls() { return getDataLong(2); } + @Override public void setTransactionErrorCalls(Long transactionErrorCalls) { setDataLong(2, transactionErrorCalls); } + @Override public Long getTransactionDurationSum() { return getDataLong(3); } + @Override public void setTransactionDurationSum(Long transactionDurationSum) { setDataLong(3, transactionDurationSum); } + @Override public Long getTransactionErrorDurationSum() { return getDataLong(4); } + @Override public void setTransactionErrorDurationSum(Long transactionErrorDurationSum) { setDataLong(4, transactionErrorDurationSum); } + @Override public Long getBusinessTransactionCalls() { return getDataLong(5); } + @Override public void setBusinessTransactionCalls(Long businessTransactionCalls) { setDataLong(5, businessTransactionCalls); } + @Override public Long getBusinessTransactionErrorCalls() { return getDataLong(6); } + @Override public void setBusinessTransactionErrorCalls(Long businessTransactionErrorCalls) { setDataLong(6, businessTransactionErrorCalls); } + @Override public Long getBusinessTransactionDurationSum() { return getDataLong(7); } + @Override public void setBusinessTransactionDurationSum(Long businessTransactionDurationSum) { setDataLong(7, businessTransactionDurationSum); } + @Override public Long getBusinessTransactionErrorDurationSum() { return getDataLong(8); } + @Override public void setBusinessTransactionErrorDurationSum(Long businessTransactionErrorDurationSum) { setDataLong(8, businessTransactionErrorDurationSum); } + @Override public Long getMqTransactionCalls() { return getDataLong(9); } + @Override public void setMqTransactionCalls(Long mqTransactionCalls) { setDataLong(9, mqTransactionCalls); } + @Override public Long getMqTransactionErrorCalls() { return getDataLong(10); } + @Override public void setMqTransactionErrorCalls(Long mqTransactionErrorCalls) { setDataLong(10, mqTransactionErrorCalls); } + @Override public Long getMqTransactionDurationSum() { return getDataLong(11); } + @Override public void setMqTransactionDurationSum(Long mqTransactionDurationSum) { setDataLong(11, mqTransactionDurationSum); } + @Override public Long getMqTransactionErrorDurationSum() { return getDataLong(12); } + @Override public void setMqTransactionErrorDurationSum(Long mqTransactionErrorDurationSum) { setDataLong(12, mqTransactionErrorDurationSum); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceMetricTable.java index 289e5920f..c17b1e727 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceMetricTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceMetricTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.service; import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; @@ -26,5 +25,4 @@ import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; */ public class ServiceMetricTable extends CommonMetricTable { public static final String TABLE = "service_metric"; - public static final String COLUMN_SERVICE_ID = "service_id"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceReferenceMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceReferenceMetric.java index 569a90a9d..ae1fe2f2a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceReferenceMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceReferenceMetric.java @@ -16,21 +16,22 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.service; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.AddOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; +import org.apache.skywalking.apm.collector.storage.table.Metric; /** * @author peng-yongsheng */ -public class ServiceReferenceMetric extends Data { +public class ServiceReferenceMetric extends StreamData implements Metric { private static final Column[] STRING_COLUMNS = { new Column(ServiceReferenceMetricTable.COLUMN_ID, new NonOperation()), + new Column(ServiceReferenceMetricTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { @@ -53,31 +54,50 @@ public class ServiceReferenceMetric extends Data { private static final Column[] DOUBLE_COLUMNS = {}; private static final Column[] INTEGER_COLUMNS = { - new Column(ServiceReferenceMetricTable.COLUMN_ENTRY_SERVICE_ID, new NonOperation()), + new Column(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, new NonOperation()), new Column(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, new NonOperation()), - new Column(ServiceReferenceMetricTable.COLUMN_ENTRY_INSTANCE_ID, new NonOperation()), new Column(ServiceReferenceMetricTable.COLUMN_FRONT_INSTANCE_ID, new NonOperation()), new Column(ServiceReferenceMetricTable.COLUMN_BEHIND_INSTANCE_ID, new NonOperation()), - new Column(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(ServiceReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, new NonOperation()), + new Column(ServiceReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, new NonOperation()), }; private static final Column[] BOOLEAN_COLUMNS = {}; private static final Column[] BYTE_COLUMNS = {}; - public ServiceReferenceMetric(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public ServiceReferenceMetric() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); } - public Integer getEntryServiceId() { + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); + } + + @Override + public Integer getSourceValue() { return getDataInteger(0); } - public void setEntryServiceId(Integer entryServiceId) { - setDataInteger(0, entryServiceId); + @Override + public void setSourceValue(Integer sourceValue) { + setDataInteger(0, sourceValue); } public Integer getFrontServiceId() { @@ -96,138 +116,164 @@ public class ServiceReferenceMetric extends Data { setDataInteger(2, behindServiceId); } - public Integer getEntryInstanceId() { + public Integer getFrontInstanceId() { return getDataInteger(3); } - public void setEntryInstanceId(Integer entryInstanceId) { - setDataInteger(3, entryInstanceId); - } - - public Integer getFrontInstanceId() { - return getDataInteger(4); - } - public void setFrontInstanceId(Integer frontInstanceId) { - setDataInteger(4, frontInstanceId); + setDataInteger(3, frontInstanceId); } public Integer getBehindInstanceId() { - return getDataInteger(5); + return getDataInteger(4); } public void setBehindInstanceId(Integer behindInstanceId) { - setDataInteger(5, behindInstanceId); + setDataInteger(4, behindInstanceId); } - public Integer getSourceValue() { + public Integer getFrontApplicationId() { + return getDataInteger(5); + } + + public void setFrontApplicationId(Integer frontApplicationId) { + setDataInteger(5, frontApplicationId); + } + + public Integer getBehindApplicationId() { return getDataInteger(6); } - public void setSourceValue(Integer sourceValue) { - setDataInteger(6, sourceValue); + public void setBehindApplicationId(Integer behindApplicationId) { + setDataInteger(6, behindApplicationId); } + @Override public Long getTimeBucket() { return getDataLong(0); } + @Override public void setTimeBucket(Long timeBucket) { setDataLong(0, timeBucket); } + @Override public Long getTransactionCalls() { return getDataLong(1); } + @Override public void setTransactionCalls(Long transactionCalls) { setDataLong(1, transactionCalls); } + @Override public Long getTransactionErrorCalls() { return getDataLong(2); } + @Override public void setTransactionErrorCalls(Long transactionErrorCalls) { setDataLong(2, transactionErrorCalls); } + @Override public Long getTransactionDurationSum() { return getDataLong(3); } + @Override public void setTransactionDurationSum(Long transactionDurationSum) { setDataLong(3, transactionDurationSum); } + @Override public Long getTransactionErrorDurationSum() { return getDataLong(4); } + @Override public void setTransactionErrorDurationSum(Long transactionErrorDurationSum) { setDataLong(4, transactionErrorDurationSum); } + @Override public Long getBusinessTransactionCalls() { return getDataLong(5); } + @Override public void setBusinessTransactionCalls(Long businessTransactionCalls) { setDataLong(5, businessTransactionCalls); } + @Override public Long getBusinessTransactionErrorCalls() { return getDataLong(6); } + @Override public void setBusinessTransactionErrorCalls(Long businessTransactionErrorCalls) { setDataLong(6, businessTransactionErrorCalls); } + @Override public Long getBusinessTransactionDurationSum() { return getDataLong(7); } + @Override public void setBusinessTransactionDurationSum(Long businessTransactionDurationSum) { setDataLong(7, businessTransactionDurationSum); } + @Override public Long getBusinessTransactionErrorDurationSum() { return getDataLong(8); } + @Override public void setBusinessTransactionErrorDurationSum(Long businessTransactionErrorDurationSum) { setDataLong(8, businessTransactionErrorDurationSum); } + @Override public Long getMqTransactionCalls() { return getDataLong(9); } + @Override public void setMqTransactionCalls(Long mqTransactionCalls) { setDataLong(9, mqTransactionCalls); } + @Override public Long getMqTransactionErrorCalls() { return getDataLong(10); } + @Override public void setMqTransactionErrorCalls(Long mqTransactionErrorCalls) { setDataLong(10, mqTransactionErrorCalls); } + @Override public Long getMqTransactionDurationSum() { return getDataLong(11); } + @Override public void setMqTransactionDurationSum(Long mqTransactionDurationSum) { setDataLong(11, mqTransactionDurationSum); } + @Override public Long getMqTransactionErrorDurationSum() { return getDataLong(12); } + @Override public void setMqTransactionErrorDurationSum(Long mqTransactionErrorDurationSum) { setDataLong(12, mqTransactionErrorDurationSum); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceReferenceMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceReferenceMetricTable.java index eb68b2f7f..6599290e3 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceReferenceMetricTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/service/ServiceReferenceMetricTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.service; import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; @@ -26,10 +25,10 @@ import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; */ public class ServiceReferenceMetricTable extends CommonMetricTable { public static final String TABLE = "service_reference_metric"; - public static final String COLUMN_ENTRY_SERVICE_ID = "entry_service_id"; - public static final String COLUMN_ENTRY_INSTANCE_ID = "entry_instance_id"; public static final String COLUMN_FRONT_SERVICE_ID = "front_service_id"; public static final String COLUMN_FRONT_INSTANCE_ID = "front_instance_id"; + public static final String COLUMN_FRONT_APPLICATION_ID = "front_application_id"; public static final String COLUMN_BEHIND_SERVICE_ID = "behind_service_id"; public static final String COLUMN_BEHIND_INSTANCE_ID = "behind_instance_id"; + public static final String COLUMN_BEHIND_APPLICATION_ID = "behind_application_id"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/DataTTLKeeperTimer.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/DataTTLKeeperTimer.java index 6114a3b24..13f354843 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/DataTTLKeeperTimer.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/DataTTLKeeperTimer.java @@ -19,23 +19,22 @@ package org.apache.skywalking.apm.collector.storage.es; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.*; + import java.util.Calendar; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemorySecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO; /** * @author peng-yongsheng @@ -79,16 +78,16 @@ public class DataTTLKeeperTimer { } private void deleteJVMRelatedData(long startTimestamp, long endTimestamp) { - ICpuMetricPersistenceDAO cpuMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ICpuMetricPersistenceDAO.class); + ICpuSecondMetricPersistenceDAO cpuMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ICpuSecondMetricPersistenceDAO.class); cpuMetricPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); - IGCMetricPersistenceDAO gcMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IGCMetricPersistenceDAO.class); + IGCSecondMetricPersistenceDAO gcMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IGCSecondMetricPersistenceDAO.class); gcMetricPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); - IMemoryMetricPersistenceDAO memoryMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IMemoryMetricPersistenceDAO.class); + IMemorySecondMetricPersistenceDAO memoryMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IMemorySecondMetricPersistenceDAO.class); memoryMetricPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); - IMemoryPoolMetricPersistenceDAO memoryPoolMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IMemoryPoolMetricPersistenceDAO.class); + IMemoryPoolSecondMetricPersistenceDAO memoryPoolMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IMemoryPoolSecondMetricPersistenceDAO.class); memoryPoolMetricPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); } @@ -96,16 +95,16 @@ public class DataTTLKeeperTimer { IGlobalTracePersistenceDAO globalTracePersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IGlobalTracePersistenceDAO.class); globalTracePersistenceDAO.deleteHistory(startTimestamp, endTimestamp); - IInstanceMetricPersistenceDAO instanceMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceMetricPersistenceDAO.class); + IInstanceMinuteMetricPersistenceDAO instanceMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceMinuteMetricPersistenceDAO.class); instanceMetricPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); - IApplicationComponentPersistenceDAO applicationComponentPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationComponentPersistenceDAO.class); + IApplicationComponentMinutePersistenceDAO applicationComponentPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationComponentMinutePersistenceDAO.class); applicationComponentPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); - IApplicationMappingPersistenceDAO applicationMappingPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMappingPersistenceDAO.class); + IApplicationMappingMinutePersistenceDAO applicationMappingPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMappingMinutePersistenceDAO.class); applicationMappingPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); - IApplicationReferenceMetricPersistenceDAO applicationReferenceMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMetricPersistenceDAO.class); + IApplicationReferenceMinuteMetricPersistenceDAO applicationReferenceMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMinuteMetricPersistenceDAO.class); applicationReferenceMetricPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); ISegmentCostPersistenceDAO segmentCostPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentCostPersistenceDAO.class); @@ -114,7 +113,7 @@ public class DataTTLKeeperTimer { ISegmentPersistenceDAO segmentPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentPersistenceDAO.class); segmentPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); - IServiceReferenceMetricPersistenceDAO serviceReferencePersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IServiceReferenceMetricPersistenceDAO.class); + IServiceReferenceMinuteMetricPersistenceDAO serviceReferencePersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IServiceReferenceMinuteMetricPersistenceDAO.class); serviceReferencePersistenceDAO.deleteHistory(startTimestamp, endTimestamp); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java index 23cc98b47..4ada2c763 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java @@ -31,84 +31,194 @@ import org.apache.skywalking.apm.collector.core.module.ServiceNotProvidedExcepti import org.apache.skywalking.apm.collector.storage.StorageException; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO; -import org.apache.skywalking.apm.collector.storage.dao.IAlertingListPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationCacheDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceCacheDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceReferenceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceNameRegisterDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceReferenceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceReferenceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IInstanceCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.INetworkAddressCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemorySecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.INetworkAddressRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IServiceNameRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMonthMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.BatchEsDAO; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchStorageInstaller; -import org.apache.skywalking.apm.collector.storage.es.dao.AlertingListEsPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationComponentEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationComponentEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationEsCacheDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationEsRegisterDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationMappingEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationMappingEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationMetricEsPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationReferenceMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationReferenceMetricEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.CpuMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.CpuMetricEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.GCMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.GCMetricEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.GlobalTraceEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.GlobalTraceEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.InstanceEsCacheDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.InstanceEsRegisterDAO; import org.apache.skywalking.apm.collector.storage.es.dao.InstanceEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.InstanceHeartBeatEsPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.InstanceMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.InstanceMetricEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.InstanceReferenceMetricEsPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.MemoryMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.MemoryMetricEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.MemoryPoolMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.MemoryPoolMetricEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.SegmentCostEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.SegmentCostEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.SegmentEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.SegmentEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ServiceEntryEsPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ServiceEntryEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ServiceMetricEsPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ServiceNameEsCacheDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ServiceNameEsRegisterDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ServiceReferenceEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ServiceReferenceMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentDayEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentHourEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentMinuteEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentMonthEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ApplicationAlarmEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ApplicationAlarmListEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ApplicationReferenceAlarmEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ApplicationReferenceAlarmListEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.InstanceAlarmEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.InstanceAlarmListEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.InstanceReferenceAlarmEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.InstanceReferenceAlarmListEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ServiceAlarmEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ServiceAlarmListEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ServiceReferenceAlarmEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ServiceReferenceAlarmListEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.amp.ApplicationDayMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.amp.ApplicationHourMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.amp.ApplicationMinuteMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.amp.ApplicationMonthMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ampp.ApplicationMappingDayEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ampp.ApplicationMappingHourEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ampp.ApplicationMappingMinuteEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ampp.ApplicationMappingMonthEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.armp.ApplicationReferenceDayMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.armp.ApplicationReferenceHourMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.armp.ApplicationReferenceMinuteMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.armp.ApplicationReferenceMonthMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.cache.ApplicationEsCacheDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.cache.InstanceEsCacheDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.cache.NetworkAddressEsCacheDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.cache.ServiceNameEsCacheDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.cpump.CpuDayMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.cpump.CpuHourMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.cpump.CpuMinuteMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.cpump.CpuMonthMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.cpump.CpuSecondMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.gcmp.GCDayMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.gcmp.GCHourMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.gcmp.GCMinuteMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.gcmp.GCMonthMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.gcmp.GCSecondMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.imp.InstanceDayMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.imp.InstanceHourMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.imp.InstanceMinuteMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.imp.InstanceMonthMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.impp.InstanceMappingDayEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.impp.InstanceMappingHourEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.impp.InstanceMappingMinuteEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.impp.InstanceMappingMonthEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.irmp.InstanceReferenceDayMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.irmp.InstanceReferenceHourMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.irmp.InstanceReferenceMinuteMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.irmp.InstanceReferenceMonthMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.memorymp.MemoryDayMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.memorymp.MemoryHourMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.memorymp.MemoryMinuteMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.memorymp.MemoryMonthMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.memorymp.MemorySecondMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.mpoolmp.MemoryPoolDayMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.mpoolmp.MemoryPoolHourMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.mpoolmp.MemoryPoolMinuteMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.mpoolmp.MemoryPoolMonthMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.mpoolmp.MemoryPoolSecondMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.register.ApplicationEsRegisterDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.register.InstanceEsRegisterDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.register.NetworkAddressRegisterEsDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.register.ServiceNameEsRegisterDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.smp.ServiceDayMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.smp.ServiceHourMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.smp.ServiceMinuteMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.smp.ServiceMonthMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceDayMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceHourMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceMinuteMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceMonthMetricEsPersistenceDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -149,7 +259,7 @@ public class StorageModuleEsProvider extends ModuleProvider { registerRegisterDAO(); registerPersistenceDAO(); registerUiDAO(); - registerAlertingDAO(); + registerAlarmDAO(); } @Override public void start(Properties config) throws ServiceNotProvidedException { @@ -188,33 +298,91 @@ public class StorageModuleEsProvider extends ModuleProvider { this.registerServiceImplementation(IApplicationCacheDAO.class, new ApplicationEsCacheDAO(elasticSearchClient)); this.registerServiceImplementation(IInstanceCacheDAO.class, new InstanceEsCacheDAO(elasticSearchClient)); this.registerServiceImplementation(IServiceNameCacheDAO.class, new ServiceNameEsCacheDAO(elasticSearchClient)); + this.registerServiceImplementation(INetworkAddressCacheDAO.class, new NetworkAddressEsCacheDAO(elasticSearchClient)); } private void registerRegisterDAO() throws ServiceNotProvidedException { + this.registerServiceImplementation(INetworkAddressRegisterDAO.class, new NetworkAddressRegisterEsDAO(elasticSearchClient)); this.registerServiceImplementation(IApplicationRegisterDAO.class, new ApplicationEsRegisterDAO(elasticSearchClient)); this.registerServiceImplementation(IInstanceRegisterDAO.class, new InstanceEsRegisterDAO(elasticSearchClient)); this.registerServiceImplementation(IServiceNameRegisterDAO.class, new ServiceNameEsRegisterDAO(elasticSearchClient)); } private void registerPersistenceDAO() throws ServiceNotProvidedException { - this.registerServiceImplementation(ICpuMetricPersistenceDAO.class, new CpuMetricEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(IGCMetricPersistenceDAO.class, new GCMetricEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(IMemoryMetricPersistenceDAO.class, new MemoryMetricEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(IMemoryPoolMetricPersistenceDAO.class, new MemoryPoolMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(ICpuSecondMetricPersistenceDAO.class, new CpuSecondMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(ICpuMinuteMetricPersistenceDAO.class, new CpuMinuteMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(ICpuHourMetricPersistenceDAO.class, new CpuHourMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(ICpuDayMetricPersistenceDAO.class, new CpuDayMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(ICpuMonthMetricPersistenceDAO.class, new CpuMonthMetricEsPersistenceDAO(elasticSearchClient)); + + this.registerServiceImplementation(IGCSecondMetricPersistenceDAO.class, new GCSecondMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IGCMinuteMetricPersistenceDAO.class, new GCMinuteMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IGCHourMetricPersistenceDAO.class, new GCHourMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IGCDayMetricPersistenceDAO.class, new GCDayMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IGCMonthMetricPersistenceDAO.class, new GCMonthMetricEsPersistenceDAO(elasticSearchClient)); + + this.registerServiceImplementation(IMemorySecondMetricPersistenceDAO.class, new MemorySecondMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IMemoryMinuteMetricPersistenceDAO.class, new MemoryMinuteMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IMemoryHourMetricPersistenceDAO.class, new MemoryHourMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IMemoryDayMetricPersistenceDAO.class, new MemoryDayMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IMemoryMonthMetricPersistenceDAO.class, new MemoryMonthMetricEsPersistenceDAO(elasticSearchClient)); + + this.registerServiceImplementation(IMemoryPoolSecondMetricPersistenceDAO.class, new MemoryPoolSecondMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IMemoryPoolMinuteMetricPersistenceDAO.class, new MemoryPoolMinuteMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IMemoryPoolHourMetricPersistenceDAO.class, new MemoryPoolHourMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IMemoryPoolDayMetricPersistenceDAO.class, new MemoryPoolDayMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IMemoryPoolMonthMetricPersistenceDAO.class, new MemoryPoolMonthMetricEsPersistenceDAO(elasticSearchClient)); + + this.registerServiceImplementation(IApplicationComponentMinutePersistenceDAO.class, new ApplicationComponentMinuteEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationComponentHourPersistenceDAO.class, new ApplicationComponentHourEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationComponentDayPersistenceDAO.class, new ApplicationComponentDayEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationComponentMonthPersistenceDAO.class, new ApplicationComponentMonthEsPersistenceDAO(elasticSearchClient)); + + this.registerServiceImplementation(IApplicationMappingMinutePersistenceDAO.class, new ApplicationMappingMinuteEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationMappingHourPersistenceDAO.class, new ApplicationMappingHourEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationMappingDayPersistenceDAO.class, new ApplicationMappingDayEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationMappingMonthPersistenceDAO.class, new ApplicationMappingMonthEsPersistenceDAO(elasticSearchClient)); + + this.registerServiceImplementation(IInstanceMappingMinutePersistenceDAO.class, new InstanceMappingMinuteEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceMappingHourPersistenceDAO.class, new InstanceMappingHourEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceMappingDayPersistenceDAO.class, new InstanceMappingDayEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceMappingMonthPersistenceDAO.class, new InstanceMappingMonthEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IGlobalTracePersistenceDAO.class, new GlobalTraceEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(IApplicationComponentPersistenceDAO.class, new ApplicationComponentEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(IApplicationMappingPersistenceDAO.class, new ApplicationMappingEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(IApplicationMetricPersistenceDAO.class, new ApplicationMetricEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(IApplicationReferenceMetricPersistenceDAO.class, new ApplicationReferenceMetricEsPersistenceDAO(elasticSearchClient)); + + this.registerServiceImplementation(IApplicationMinuteMetricPersistenceDAO.class, new ApplicationMinuteMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationHourMetricPersistenceDAO.class, new ApplicationHourMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationDayMetricPersistenceDAO.class, new ApplicationDayMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationMonthMetricPersistenceDAO.class, new ApplicationMonthMetricEsPersistenceDAO(elasticSearchClient)); + + this.registerServiceImplementation(IApplicationReferenceMinuteMetricPersistenceDAO.class, new ApplicationReferenceMinuteMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationReferenceHourMetricPersistenceDAO.class, new ApplicationReferenceHourMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationReferenceDayMetricPersistenceDAO.class, new ApplicationReferenceDayMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationReferenceMonthMetricPersistenceDAO.class, new ApplicationReferenceMonthMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(IServiceEntryPersistenceDAO.class, new ServiceEntryEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(IServiceMetricPersistenceDAO.class, new ServiceMetricEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(IServiceReferenceMetricPersistenceDAO.class, new ServiceReferenceMetricEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(IInstanceMetricPersistenceDAO.class, new InstanceMetricEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(IInstanceReferenceMetricPersistenceDAO.class, new InstanceReferenceMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IServiceMinuteMetricPersistenceDAO.class, new ServiceMinuteMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IServiceHourMetricPersistenceDAO.class, new ServiceHourMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IServiceDayMetricPersistenceDAO.class, new ServiceDayMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IServiceMonthMetricPersistenceDAO.class, new ServiceMonthMetricEsPersistenceDAO(elasticSearchClient)); + + this.registerServiceImplementation(IServiceReferenceMinuteMetricPersistenceDAO.class, new ServiceReferenceMinuteMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IServiceReferenceHourMetricPersistenceDAO.class, new ServiceReferenceHourMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IServiceReferenceDayMetricPersistenceDAO.class, new ServiceReferenceDayMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IServiceReferenceMonthMetricPersistenceDAO.class, new ServiceReferenceMonthMetricEsPersistenceDAO(elasticSearchClient)); + + this.registerServiceImplementation(IInstanceMinuteMetricPersistenceDAO.class, new InstanceMinuteMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceHourMetricPersistenceDAO.class, new InstanceHourMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceDayMetricPersistenceDAO.class, new InstanceDayMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceMonthMetricPersistenceDAO.class, new InstanceMonthMetricEsPersistenceDAO(elasticSearchClient)); + + this.registerServiceImplementation(IInstanceReferenceMinuteMetricPersistenceDAO.class, new InstanceReferenceMinuteMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceReferenceHourMetricPersistenceDAO.class, new InstanceReferenceHourMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceReferenceDayMetricPersistenceDAO.class, new InstanceReferenceDayMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceReferenceMonthMetricPersistenceDAO.class, new InstanceReferenceMonthMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceHeartBeatPersistenceDAO.class, new InstanceHeartBeatEsPersistenceDAO(elasticSearchClient)); } @@ -233,11 +401,22 @@ public class StorageModuleEsProvider extends ModuleProvider { this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(ISegmentCostUIDAO.class, new SegmentCostEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentEsUIDAO(elasticSearchClient)); - this.registerServiceImplementation(IServiceEntryUIDAO.class, new ServiceEntryEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(IServiceReferenceUIDAO.class, new ServiceReferenceEsUIDAO(elasticSearchClient)); } - private void registerAlertingDAO() throws ServiceNotProvidedException { - this.registerServiceImplementation(IAlertingListPersistenceDAO.class, new AlertingListEsPersistenceDAO(elasticSearchClient)); + private void registerAlarmDAO() throws ServiceNotProvidedException { + this.registerServiceImplementation(IServiceReferenceAlarmPersistenceDAO.class, new ServiceReferenceAlarmEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IServiceReferenceAlarmListPersistenceDAO.class, new ServiceReferenceAlarmListEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceReferenceAlarmPersistenceDAO.class, new InstanceReferenceAlarmEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceReferenceAlarmListPersistenceDAO.class, new InstanceReferenceAlarmListEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationReferenceAlarmPersistenceDAO.class, new ApplicationReferenceAlarmEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationReferenceAlarmListPersistenceDAO.class, new ApplicationReferenceAlarmListEsPersistenceDAO(elasticSearchClient)); + + this.registerServiceImplementation(IServiceAlarmPersistenceDAO.class, new ServiceAlarmEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IServiceAlarmListPersistenceDAO.class, new ServiceAlarmListEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceAlarmPersistenceDAO.class, new InstanceAlarmEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IInstanceAlarmListPersistenceDAO.class, new InstanceAlarmListEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationAlarmPersistenceDAO.class, new ApplicationAlarmEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationAlarmListPersistenceDAO.class, new ApplicationAlarmListEsPersistenceDAO(elasticSearchClient)); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsRegistration.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsRegistration.java index ba4e41dae..97c822e5e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsRegistration.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsRegistration.java @@ -16,11 +16,10 @@ * */ - package org.apache.skywalking.apm.collector.storage.es; -import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.cluster.ModuleRegistration; +import org.apache.skywalking.apm.collector.core.util.Const; /** * @author peng-yongsheng diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/base/dao/AbstractPersistenceEsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/base/dao/AbstractPersistenceEsDAO.java new file mode 100644 index 000000000..43cae44ce --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/base/dao/AbstractPersistenceEsDAO.java @@ -0,0 +1,83 @@ +/* + * 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.storage.es.base.dao; + +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractPersistenceEsDAO extends EsDAO implements IPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(AbstractPersistenceEsDAO.class); + + protected AbstractPersistenceEsDAO(ElasticSearchClient client) { + super(client); + } + + protected abstract STREAM_DATA esDataToStreamData(Map source); + + protected abstract String tableName(); + + @Override public final STREAM_DATA get(String id) { + GetResponse getResponse = getClient().prepareGet(tableName(), id).get(); + if (getResponse.isExists()) { + return esDataToStreamData(getResponse.getSource()); + } else { + return null; + } + } + + protected abstract Map esStreamDataToEsData(STREAM_DATA streamData); + + @Override public final IndexRequestBuilder prepareBatchInsert(STREAM_DATA streamData) { + Map source = esStreamDataToEsData(streamData); + return getClient().prepareIndex(tableName(), streamData.getId()).setSource(source); + } + + @Override public final UpdateRequestBuilder prepareBatchUpdate(STREAM_DATA streamData) { + Map source = esStreamDataToEsData(streamData); + return getClient().prepareUpdate(tableName(), streamData.getId()).setDoc(source); + } + + protected abstract String timeBucketColumnNameForDelete(); + + @Override public final void deleteHistory(Long startTimestamp, Long endTimestamp) { + long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); + long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); + BulkByScrollResponse response = getClient().prepareDelete() + .filter(QueryBuilders.rangeQuery(timeBucketColumnNameForDelete()).gte(startTimeBucket).lte(endTimeBucket)) + .source(tableName()) + .get(); + + long deleted = response.getDeleted(); + logger.info("Delete {} rows history from {} index.", deleted, tableName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/base/dao/BatchEsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/base/dao/BatchEsDAO.java index 9c94701f4..0e7e146f3 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/base/dao/BatchEsDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/base/dao/BatchEsDAO.java @@ -16,17 +16,16 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.base.dao; import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.CollectionUtils; +import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO; import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,15 +45,14 @@ public class BatchEsDAO extends EsDAO implements IBatchDAO { logger.debug("bulk data size: {}", batchCollection.size()); if (CollectionUtils.isNotEmpty(batchCollection)) { - for (int i = 0; i < batchCollection.size(); i++) { - Object builder = batchCollection.get(i); + batchCollection.forEach(builder -> { if (builder instanceof IndexRequestBuilder) { bulkRequest.add((IndexRequestBuilder)builder); } if (builder instanceof UpdateRequestBuilder) { bulkRequest.add((UpdateRequestBuilder)builder); } - } + }); BulkResponse bulkResponse = bulkRequest.execute().actionGet(); if (bulkResponse.hasFailures()) { diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/base/dao/EsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/base/dao/EsDAO.java index 95ea3e4d8..0b10629e6 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/base/dao/EsDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/base/dao/EsDAO.java @@ -16,9 +16,10 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.base.dao; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.base.dao.AbstractDAO; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.search.aggregations.AggregationBuilders; @@ -26,8 +27,6 @@ import org.elasticsearch.search.aggregations.metrics.max.Max; import org.elasticsearch.search.aggregations.metrics.max.MaxAggregationBuilder; import org.elasticsearch.search.aggregations.metrics.min.Min; import org.elasticsearch.search.aggregations.metrics.min.MinAggregationBuilder; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.base.dao.AbstractDAO; /** * @author peng-yongsheng @@ -38,7 +37,7 @@ public abstract class EsDAO extends AbstractDAO { super(client); } - public final int getMaxId(String indexName, String columnName) { + protected final int getMaxId(String indexName, String columnName) { ElasticSearchClient client = getClient(); SearchRequestBuilder searchRequestBuilder = client.prepareSearch(indexName); searchRequestBuilder.setTypes("type"); @@ -57,7 +56,7 @@ public abstract class EsDAO extends AbstractDAO { } } - public final int getMinId(String indexName, String columnName) { + protected final int getMinId(String indexName, String columnName) { ElasticSearchClient client = getClient(); SearchRequestBuilder searchRequestBuilder = client.prepareSearch(indexName); searchRequestBuilder.setTypes("type"); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/AlertingListEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/AlertingListEsPersistenceDAO.java deleted file mode 100644 index ee5cee8c7..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/AlertingListEsPersistenceDAO.java +++ /dev/null @@ -1,104 +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.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -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.table.alerting.AlertingListTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class AlertingListEsPersistenceDAO extends EsDAO implements IAlertingListPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(AlertingListEsPersistenceDAO.class); - - public AlertingListEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public AlertingList get(String id) { - GetResponse getResponse = getClient().prepareGet(AlertingListTable.TABLE, id).get(); - if (getResponse.isExists()) { - AlertingList alertingList = new AlertingList(id); - Map source = getResponse.getSource(); - alertingList.setLayer(((Number)source.get(AlertingListTable.COLUMN_LAYER)).intValue()); - alertingList.setLayerId(((Number)source.get(AlertingListTable.COLUMN_LAYER_ID)).intValue()); - alertingList.setFirstTimeBucket(((Number)source.get(AlertingListTable.COLUMN_FIRST_TIME_BUCKET)).longValue()); - alertingList.setLastTimeBucket(((Number)source.get(AlertingListTable.COLUMN_LAST_TIME_BUCKET)).longValue()); - alertingList.setExpected(((Number)source.get(AlertingListTable.COLUMN_EXPECTED)).intValue()); - alertingList.setActual(((Number)source.get(AlertingListTable.COLUMN_ACTUAL)).intValue()); - alertingList.setValid((Boolean)source.get(AlertingListTable.COLUMN_VALID)); - return alertingList; - } else { - return null; - } - } - - @Override public IndexRequestBuilder prepareBatchInsert(AlertingList data) { - Map source = new HashMap<>(); - source.put(AlertingListTable.COLUMN_LAYER, data.getLayer()); - source.put(AlertingListTable.COLUMN_LAYER_ID, data.getLayerId()); - source.put(AlertingListTable.COLUMN_FIRST_TIME_BUCKET, data.getFirstTimeBucket()); - source.put(AlertingListTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); - source.put(AlertingListTable.COLUMN_EXPECTED, data.getExpected()); - source.put(AlertingListTable.COLUMN_ACTUAL, data.getActual()); - source.put(AlertingListTable.COLUMN_VALID, data.getValid()); - - return getClient().prepareIndex(AlertingListTable.TABLE, data.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(AlertingList data) { - Map source = new HashMap<>(); - source.put(AlertingListTable.COLUMN_LAYER, data.getLayer()); - source.put(AlertingListTable.COLUMN_LAYER_ID, data.getLayerId()); - source.put(AlertingListTable.COLUMN_FIRST_TIME_BUCKET, data.getFirstTimeBucket()); - source.put(AlertingListTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); - source.put(AlertingListTable.COLUMN_EXPECTED, data.getExpected()); - source.put(AlertingListTable.COLUMN_ACTUAL, data.getActual()); - source.put(AlertingListTable.COLUMN_VALID, data.getValid()); - - return getClient().prepareUpdate(AlertingListTable.TABLE, data.getId()).setDoc(source); - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(AlertingListTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(AlertingListTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, AlertingListTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java index f9400bbf8..d77825ec2 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java @@ -16,13 +16,14 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentMinuteEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -30,7 +31,6 @@ import org.elasticsearch.action.search.SearchType; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory; */ public class ApplicationComponentEsUIDAO extends EsDAO implements IApplicationComponentUIDAO { - private final Logger logger = LoggerFactory.getLogger(ApplicationComponentEsPersistenceDAO.class); + private final Logger logger = LoggerFactory.getLogger(ApplicationComponentMinuteEsPersistenceDAO.class); public ApplicationComponentEsUIDAO(ElasticSearchClient client) { super(client); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsPersistenceDAO.java deleted file mode 100644 index 22df0ac7a..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsPersistenceDAO.java +++ /dev/null @@ -1,91 +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.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class ApplicationMappingEsPersistenceDAO extends EsDAO implements IApplicationMappingPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(ApplicationMappingEsPersistenceDAO.class); - - public ApplicationMappingEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public ApplicationMapping get(String id) { - GetResponse getResponse = getClient().prepareGet(ApplicationMappingTable.TABLE, id).get(); - if (getResponse.isExists()) { - ApplicationMapping applicationMapping = new ApplicationMapping(id); - Map source = getResponse.getSource(); - applicationMapping.setApplicationId(((Number)source.get(ApplicationMappingTable.COLUMN_APPLICATION_ID)).intValue()); - applicationMapping.setAddressId(((Number)source.get(ApplicationMappingTable.COLUMN_ADDRESS_ID)).intValue()); - applicationMapping.setTimeBucket(((Number)source.get(ApplicationMappingTable.COLUMN_TIME_BUCKET)).longValue()); - return applicationMapping; - } else { - return null; - } - } - - @Override public IndexRequestBuilder prepareBatchInsert(ApplicationMapping data) { - Map source = new HashMap<>(); - source.put(ApplicationMappingTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - source.put(ApplicationMappingTable.COLUMN_ADDRESS_ID, data.getAddressId()); - source.put(ApplicationMappingTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareIndex(ApplicationMappingTable.TABLE, data.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(ApplicationMapping data) { - Map source = new HashMap<>(); - source.put(ApplicationMappingTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - source.put(ApplicationMappingTable.COLUMN_ADDRESS_ID, data.getAddressId()); - source.put(ApplicationMappingTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - return getClient().prepareUpdate(ApplicationMappingTable.TABLE, data.getId()).setDoc(source); - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(ApplicationMappingTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(ApplicationMappingTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, ApplicationMappingTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java index d3a8d3f56..4bb7ae6fa 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java @@ -16,12 +16,12 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; import org.elasticsearch.action.search.SearchRequestBuilder; @@ -30,7 +30,6 @@ import org.elasticsearch.action.search.SearchType; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMetricEsPersistenceDAO.java deleted file mode 100644 index 40e8bed3b..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMetricEsPersistenceDAO.java +++ /dev/null @@ -1,145 +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.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class ApplicationMetricEsPersistenceDAO extends EsDAO implements IApplicationMetricPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(ApplicationMetricEsPersistenceDAO.class); - - public ApplicationMetricEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public ApplicationMetric get(String id) { - GetResponse getResponse = getClient().prepareGet(ApplicationMetricTable.TABLE, id).get(); - if (getResponse.isExists()) { - ApplicationMetric applicationMetric = new ApplicationMetric(id); - Map source = getResponse.getSource(); - applicationMetric.setApplicationId(((Number)source.get(ApplicationMetricTable.COLUMN_APPLICATION_ID)).intValue()); - - applicationMetric.setTransactionCalls(((Number)source.get(ApplicationMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); - applicationMetric.setTransactionErrorCalls(((Number)source.get(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); - applicationMetric.setTransactionDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); - applicationMetric.setTransactionErrorDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - applicationMetric.setBusinessTransactionCalls(((Number)source.get(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); - applicationMetric.setBusinessTransactionErrorCalls(((Number)source.get(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); - applicationMetric.setBusinessTransactionDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); - applicationMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - applicationMetric.setMqTransactionCalls(((Number)source.get(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); - applicationMetric.setMqTransactionErrorCalls(((Number)source.get(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); - applicationMetric.setMqTransactionDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); - applicationMetric.setMqTransactionErrorDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - applicationMetric.setSatisfiedCount(((Number)source.get(ApplicationMetricTable.COLUMN_SATISFIED_COUNT)).longValue()); - applicationMetric.setToleratingCount(((Number)source.get(ApplicationMetricTable.COLUMN_TOLERATING_COUNT)).longValue()); - applicationMetric.setFrustratedCount(((Number)source.get(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT)).longValue()); - applicationMetric.setTimeBucket(((Number)source.get(ApplicationMetricTable.COLUMN_TIME_BUCKET)).longValue()); - return applicationMetric; - } else { - return null; - } - } - - @Override public IndexRequestBuilder prepareBatchInsert(ApplicationMetric data) { - Map source = new HashMap<>(); - source.put(ApplicationMetricTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - - source.put(ApplicationMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(ApplicationMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - source.put(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount()); - source.put(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount()); - source.put(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount()); - source.put(ApplicationMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareIndex(ApplicationMetricTable.TABLE, data.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(ApplicationMetric data) { - Map source = new HashMap<>(); - source.put(ApplicationMetricTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - - source.put(ApplicationMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(ApplicationMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - source.put(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount()); - source.put(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount()); - source.put(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount()); - - return getClient().prepareUpdate(ApplicationMetricTable.TABLE, data.getId()).setDoc(source); - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(ApplicationMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(ApplicationMetricTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, ApplicationMetricTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsPersistenceDAO.java deleted file mode 100644 index fda42a7ec..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsPersistenceDAO.java +++ /dev/null @@ -1,149 +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.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class ApplicationReferenceMetricEsPersistenceDAO extends EsDAO implements IApplicationReferenceMetricPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceMetricEsPersistenceDAO.class); - - public ApplicationReferenceMetricEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public ApplicationReferenceMetric get(String id) { - GetResponse getResponse = getClient().prepareGet(ApplicationReferenceMetricTable.TABLE, id).get(); - if (getResponse.isExists()) { - ApplicationReferenceMetric applicationReferenceMetric = new ApplicationReferenceMetric(id); - Map source = getResponse.getSource(); - applicationReferenceMetric.setFrontApplicationId(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID)).intValue()); - applicationReferenceMetric.setBehindApplicationId(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID)).intValue()); - - applicationReferenceMetric.setTransactionCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); - applicationReferenceMetric.setTransactionErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); - applicationReferenceMetric.setTransactionDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); - applicationReferenceMetric.setTransactionErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - applicationReferenceMetric.setBusinessTransactionCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); - applicationReferenceMetric.setBusinessTransactionErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); - applicationReferenceMetric.setBusinessTransactionDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); - applicationReferenceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - applicationReferenceMetric.setMqTransactionCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); - applicationReferenceMetric.setMqTransactionErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); - applicationReferenceMetric.setMqTransactionDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); - applicationReferenceMetric.setMqTransactionErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - applicationReferenceMetric.setSatisfiedCount(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT)).longValue()); - applicationReferenceMetric.setToleratingCount(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT)).longValue()); - applicationReferenceMetric.setFrustratedCount(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT)).longValue()); - applicationReferenceMetric.setTimeBucket(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET)).longValue()); - return applicationReferenceMetric; - } else { - return null; - } - } - - @Override public IndexRequestBuilder prepareBatchInsert(ApplicationReferenceMetric data) { - Map source = new HashMap<>(); - source.put(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); - source.put(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); - - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - source.put(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount()); - source.put(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount()); - source.put(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount()); - source.put(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareIndex(ApplicationReferenceMetricTable.TABLE, data.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(ApplicationReferenceMetric data) { - Map source = new HashMap<>(); - source.put(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); - source.put(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); - - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - source.put(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount()); - source.put(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount()); - source.put(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount()); - source.put(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareUpdate(ApplicationReferenceMetricTable.TABLE, data.getId()).setDoc(source); - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(ApplicationReferenceMetricTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, ApplicationReferenceMetricTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java index 8497d27c7..a7011b111 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java @@ -16,10 +16,12 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -27,9 +29,6 @@ import org.elasticsearch.action.search.SearchType; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsPersistenceDAO.java deleted file mode 100644 index af71c4175..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsPersistenceDAO.java +++ /dev/null @@ -1,77 +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.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; -import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class CpuMetricEsPersistenceDAO extends EsDAO implements ICpuMetricPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(CpuMetricEsPersistenceDAO.class); - - public CpuMetricEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public CpuMetric get(String id) { - return null; - } - - @Override public IndexRequestBuilder prepareBatchInsert(CpuMetric cpuMetric) { - Map source = new HashMap<>(); - source.put(CpuMetricTable.COLUMN_INSTANCE_ID, cpuMetric.getInstanceId()); - source.put(CpuMetricTable.COLUMN_USAGE_PERCENT, cpuMetric.getUsagePercent()); - source.put(CpuMetricTable.COLUMN_TIME_BUCKET, cpuMetric.getTimeBucket()); - - logger.debug("prepare cpu metric batch insert, getId: {}", cpuMetric.getId()); - return getClient().prepareIndex(CpuMetricTable.TABLE, cpuMetric.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(CpuMetric cpuMetric) { - return null; - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(CpuMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(CpuMetricTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, CpuMetricTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java index b454bbe40..9ca846133 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java @@ -16,20 +16,19 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; 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.dao.ICpuMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; /** * @author peng-yongsheng diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsPersistenceDAO.java deleted file mode 100644 index 09bd24b54..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsPersistenceDAO.java +++ /dev/null @@ -1,78 +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.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; -import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class GCMetricEsPersistenceDAO extends EsDAO implements IGCMetricPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(GCMetricEsPersistenceDAO.class); - - public GCMetricEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public GCMetric get(String id) { - return null; - } - - @Override public IndexRequestBuilder prepareBatchInsert(GCMetric gcMetric) { - Map source = new HashMap<>(); - source.put(GCMetricTable.COLUMN_INSTANCE_ID, gcMetric.getInstanceId()); - source.put(GCMetricTable.COLUMN_PHRASE, gcMetric.getPhrase()); - source.put(GCMetricTable.COLUMN_COUNT, gcMetric.getCount()); - source.put(GCMetricTable.COLUMN_TIME, gcMetric.getTime()); - source.put(GCMetricTable.COLUMN_TIME_BUCKET, gcMetric.getTimeBucket()); - - return getClient().prepareIndex(GCMetricTable.TABLE, gcMetric.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(GCMetric gcMetric) { - return null; - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(GCMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(GCMetricTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, GCMetricTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java index 6e3702a61..068955095 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java @@ -16,14 +16,17 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; 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.dao.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; +import org.apache.skywalking.apm.network.proto.GCPhrase; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequestBuilder; @@ -36,10 +39,6 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.metrics.sum.Sum; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; -import org.apache.skywalking.apm.network.proto.GCPhrase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GlobalTraceEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GlobalTraceEsPersistenceDAO.java index 0a2802148..2b9f23a94 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GlobalTraceEsPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GlobalTraceEsPersistenceDAO.java @@ -16,22 +16,21 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.UnexpectedException; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.global.GlobalTrace; +import org.apache.skywalking.apm.collector.storage.table.global.GlobalTraceTable; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.update.UpdateRequestBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.table.global.GlobalTraceTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GlobalTraceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GlobalTraceEsUIDAO.java index 9af56e871..fdf2cc661 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GlobalTraceEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GlobalTraceEsUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import java.util.ArrayList; @@ -24,12 +23,12 @@ import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.global.GlobalTraceTable; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; -import org.apache.skywalking.apm.collector.storage.table.global.GlobalTraceTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java index d936492d5..358650a76 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; @@ -24,6 +23,8 @@ import com.google.gson.JsonObject; import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; @@ -42,8 +43,6 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCount; import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortMode; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -129,7 +128,8 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO { GetRequestBuilder requestBuilder = getClient().prepareGet(InstanceTable.TABLE, String.valueOf(instanceId)); GetResponse getResponse = requestBuilder.get(); if (getResponse.isExists()) { - Instance instance = new Instance(getResponse.getId()); + Instance instance = new Instance(); + instance.setId(getResponse.getId()); instance.setApplicationId(((Number)getResponse.getSource().get(InstanceTable.COLUMN_APPLICATION_ID)).intValue()); instance.setAgentUUID((String)getResponse.getSource().get(InstanceTable.COLUMN_AGENT_UUID)); instance.setRegisterTime(((Number)getResponse.getSource().get(InstanceTable.COLUMN_REGISTER_TIME)).longValue()); @@ -157,7 +157,8 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO { List instanceList = new LinkedList<>(); for (SearchHit searchHit : searchHits) { - Instance instance = new Instance(searchHit.getId()); + Instance instance = new Instance(); + instance.setId(searchHit.getId()); instance.setApplicationId(((Number)searchHit.getSource().get(InstanceTable.COLUMN_APPLICATION_ID)).intValue()); instance.setHeartBeatTime(((Number)searchHit.getSource().get(InstanceTable.COLUMN_HEARTBEAT_TIME)).longValue()); instance.setInstanceId(((Number)searchHit.getSource().get(InstanceTable.COLUMN_INSTANCE_ID)).intValue()); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceHeartBeatEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceHeartBeatEsPersistenceDAO.java index d823ee0c2..373070135 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceHeartBeatEsPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceHeartBeatEsPersistenceDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import java.util.HashMap; @@ -47,10 +46,12 @@ public class InstanceHeartBeatEsPersistenceDAO extends EsDAO implements IInstanc @Override public Instance get(String id) { GetResponse getResponse = getClient().prepareGet(InstanceTable.TABLE, id).get(); if (getResponse.isExists()) { - Instance instance = new Instance(id); Map source = getResponse.getSource(); - instance.setInstanceId((Integer)source.get(InstanceTable.COLUMN_INSTANCE_ID)); - instance.setHeartBeatTime((Long)source.get(InstanceTable.COLUMN_HEARTBEAT_TIME)); + + Instance instance = new Instance(); + instance.setId(id); + instance.setInstanceId(((Number)source.get(InstanceTable.COLUMN_INSTANCE_ID)).intValue()); + instance.setHeartBeatTime(((Number)source.get(InstanceTable.COLUMN_HEARTBEAT_TIME)).longValue()); logger.debug("getId: {} is exists", id); return instance; } else { diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsPersistenceDAO.java deleted file mode 100644 index 0a61ecb31..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsPersistenceDAO.java +++ /dev/null @@ -1,142 +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.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class InstanceMetricEsPersistenceDAO extends EsDAO implements IInstanceMetricPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(InstanceMetricEsPersistenceDAO.class); - - public InstanceMetricEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public InstanceMetric get(String id) { - GetResponse getResponse = getClient().prepareGet(InstanceMetricTable.TABLE, id).get(); - if (getResponse.isExists()) { - logger.debug("getId: {} is exist", id); - InstanceMetric instanceMetric = new InstanceMetric(id); - Map source = getResponse.getSource(); - instanceMetric.setApplicationId((Integer)source.get(InstanceMetricTable.COLUMN_APPLICATION_ID)); - instanceMetric.setInstanceId((Integer)source.get(InstanceMetricTable.COLUMN_INSTANCE_ID)); - - instanceMetric.setTransactionCalls(((Number)source.get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); - instanceMetric.setTransactionErrorCalls(((Number)source.get(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); - instanceMetric.setTransactionDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); - instanceMetric.setTransactionErrorDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - instanceMetric.setBusinessTransactionCalls(((Number)source.get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); - instanceMetric.setBusinessTransactionErrorCalls(((Number)source.get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); - instanceMetric.setBusinessTransactionDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); - instanceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - instanceMetric.setMqTransactionCalls(((Number)source.get(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); - instanceMetric.setMqTransactionErrorCalls(((Number)source.get(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); - instanceMetric.setMqTransactionDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); - instanceMetric.setMqTransactionErrorDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - instanceMetric.setTimeBucket(((Number)source.get(InstanceMetricTable.COLUMN_TIME_BUCKET)).longValue()); - - return instanceMetric; - } else { - return null; - } - } - - @Override public IndexRequestBuilder prepareBatchInsert(InstanceMetric data) { - Map source = new HashMap<>(); - source.put(InstanceMetricTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - source.put(InstanceMetricTable.COLUMN_INSTANCE_ID, data.getInstanceId()); - - source.put(InstanceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - source.put(InstanceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareIndex(InstanceMetricTable.TABLE, data.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(InstanceMetric data) { - Map source = new HashMap<>(); - source.put(InstanceMetricTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - source.put(InstanceMetricTable.COLUMN_INSTANCE_ID, data.getInstanceId()); - - source.put(InstanceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - source.put(InstanceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareUpdate(InstanceMetricTable.TABLE, data.getId()).setDoc(source); - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(InstanceMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(InstanceMetricTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, InstanceMetricTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java index 4e6b78a2e..de6657339 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java @@ -16,13 +16,15 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; 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.dao.IInstanceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequestBuilder; @@ -35,9 +37,6 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.metrics.sum.Sum; import org.elasticsearch.search.sort.SortOrder; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; /** * @author peng-yongsheng diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceReferenceMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceReferenceMetricEsPersistenceDAO.java deleted file mode 100644 index 81b05e5bc..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceReferenceMetricEsPersistenceDAO.java +++ /dev/null @@ -1,141 +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.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceReferenceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; -import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetricTable; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class InstanceReferenceMetricEsPersistenceDAO extends EsDAO implements IInstanceReferenceMetricPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(InstanceReferenceMetricEsPersistenceDAO.class); - - public InstanceReferenceMetricEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public InstanceReferenceMetric get(String id) { - GetResponse getResponse = getClient().prepareGet(InstanceReferenceMetricTable.TABLE, id).get(); - if (getResponse.isExists()) { - logger.debug("getId: {} is exist", id); - InstanceReferenceMetric instanceReferenceMetric = new InstanceReferenceMetric(id); - Map source = getResponse.getSource(); - instanceReferenceMetric.setFrontInstanceId((Integer)source.get(InstanceReferenceMetricTable.COLUMN_FRONT_INSTANCE_ID)); - instanceReferenceMetric.setBehindInstanceId((Integer)source.get(InstanceReferenceMetricTable.COLUMN_BEHIND_INSTANCE_ID)); - - instanceReferenceMetric.setTransactionCalls(((Number)source.get(InstanceReferenceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); - instanceReferenceMetric.setTransactionErrorCalls(((Number)source.get(InstanceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); - instanceReferenceMetric.setTransactionDurationSum(((Number)source.get(InstanceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); - instanceReferenceMetric.setTransactionErrorDurationSum(((Number)source.get(InstanceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - instanceReferenceMetric.setBusinessTransactionCalls(((Number)source.get(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); - instanceReferenceMetric.setBusinessTransactionErrorCalls(((Number)source.get(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); - instanceReferenceMetric.setBusinessTransactionDurationSum(((Number)source.get(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); - instanceReferenceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - instanceReferenceMetric.setMqTransactionCalls(((Number)source.get(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); - instanceReferenceMetric.setMqTransactionErrorCalls(((Number)source.get(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); - instanceReferenceMetric.setMqTransactionDurationSum(((Number)source.get(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); - instanceReferenceMetric.setMqTransactionErrorDurationSum(((Number)source.get(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - instanceReferenceMetric.setTimeBucket(((Number)source.get(InstanceReferenceMetricTable.COLUMN_TIME_BUCKET)).longValue()); - - return instanceReferenceMetric; - } else { - return null; - } - } - - @Override public IndexRequestBuilder prepareBatchInsert(InstanceReferenceMetric data) { - Map source = new HashMap<>(); - source.put(InstanceReferenceMetricTable.COLUMN_FRONT_INSTANCE_ID, data.getFrontInstanceId()); - source.put(InstanceReferenceMetricTable.COLUMN_BEHIND_INSTANCE_ID, data.getBehindInstanceId()); - - source.put(InstanceReferenceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(InstanceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(InstanceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(InstanceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - source.put(InstanceReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareIndex(InstanceReferenceMetricTable.TABLE, data.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(InstanceReferenceMetric data) { - Map source = new HashMap<>(); - source.put(InstanceReferenceMetricTable.COLUMN_FRONT_INSTANCE_ID, data.getFrontInstanceId()); - source.put(InstanceReferenceMetricTable.COLUMN_BEHIND_INSTANCE_ID, data.getBehindInstanceId()); - - source.put(InstanceReferenceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(InstanceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(InstanceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(InstanceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - source.put(InstanceReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareUpdate(InstanceReferenceMetricTable.TABLE, data.getId()).setDoc(source); - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(InstanceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(InstanceReferenceMetricTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, InstanceReferenceMetricTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsPersistenceDAO.java deleted file mode 100644 index 60e5d79df..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsPersistenceDAO.java +++ /dev/null @@ -1,80 +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.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class MemoryMetricEsPersistenceDAO extends EsDAO implements IMemoryMetricPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(MemoryMetricEsPersistenceDAO.class); - - public MemoryMetricEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public MemoryMetric get(String id) { - return null; - } - - @Override public IndexRequestBuilder prepareBatchInsert(MemoryMetric data) { - Map source = new HashMap<>(); - source.put(MemoryMetricTable.COLUMN_INSTANCE_ID, data.getInstanceId()); - source.put(MemoryMetricTable.COLUMN_IS_HEAP, data.getIsHeap()); - source.put(MemoryMetricTable.COLUMN_INIT, data.getInit()); - source.put(MemoryMetricTable.COLUMN_MAX, data.getMax()); - source.put(MemoryMetricTable.COLUMN_USED, data.getUsed()); - source.put(MemoryMetricTable.COLUMN_COMMITTED, data.getCommitted()); - source.put(MemoryMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareIndex(MemoryMetricTable.TABLE, data.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(MemoryMetric data) { - return null; - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(MemoryMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(MemoryMetricTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, MemoryMetricTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java index 6468db907..8caa326e7 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java @@ -16,21 +16,20 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; 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.dao.IMemoryMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; /** * @author peng-yongsheng diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsPersistenceDAO.java deleted file mode 100644 index de691182e..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsPersistenceDAO.java +++ /dev/null @@ -1,80 +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.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class MemoryPoolMetricEsPersistenceDAO extends EsDAO implements IMemoryPoolMetricPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(MemoryPoolMetricEsPersistenceDAO.class); - - public MemoryPoolMetricEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public MemoryPoolMetric get(String id) { - return null; - } - - @Override public IndexRequestBuilder prepareBatchInsert(MemoryPoolMetric data) { - Map source = new HashMap<>(); - source.put(MemoryPoolMetricTable.COLUMN_INSTANCE_ID, data.getInstanceId()); - source.put(MemoryPoolMetricTable.COLUMN_POOL_TYPE, data.getPoolType()); - source.put(MemoryPoolMetricTable.COLUMN_INIT, data.getInit()); - source.put(MemoryPoolMetricTable.COLUMN_MAX, data.getMax()); - source.put(MemoryPoolMetricTable.COLUMN_USED, data.getUsed()); - source.put(MemoryPoolMetricTable.COLUMN_COMMITTED, data.getCommitted()); - source.put(MemoryPoolMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareIndex(MemoryPoolMetricTable.TABLE, data.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(MemoryPoolMetric data) { - return null; - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(MemoryPoolMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(MemoryPoolMetricTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, MemoryPoolMetricTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsUIDAO.java index 6ad62636f..dc5b4b333 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsUIDAO.java @@ -16,21 +16,20 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; 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.dao.IMemoryPoolMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; /** * @author peng-yongsheng diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsPersistenceDAO.java index aced6722c..847e8b562 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsPersistenceDAO.java @@ -16,21 +16,20 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost; import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.update.UpdateRequestBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsUIDAO.java index 98d1bd58f..a99c8bbbb 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsUIDAO.java @@ -16,13 +16,17 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.CollectionUtils; +import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; @@ -32,11 +36,6 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.RangeQueryBuilder; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.sort.SortOrder; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.CollectionUtils; -import org.apache.skywalking.apm.collector.core.util.StringUtils; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; /** * @author peng-yongsheng diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentEsPersistenceDAO.java index 1f8bda56b..61bb6ad52 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentEsPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentEsPersistenceDAO.java @@ -16,22 +16,21 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import java.util.Base64; import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.segment.Segment; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentTable; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.update.UpdateRequestBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.table.segment.Segment; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentEsUIDAO.java index bd2e64832..22c20683f 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentEsUIDAO.java @@ -16,19 +16,18 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.protobuf.InvalidProtocolBufferException; import java.util.Base64; import java.util.Map; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.elasticsearch.action.get.GetResponse; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.segment.SegmentTable; import org.apache.skywalking.apm.network.proto.TraceSegmentObject; +import org.elasticsearch.action.get.GetResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceEntryEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceEntryEsPersistenceDAO.java deleted file mode 100644 index eb978213c..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceEntryEsPersistenceDAO.java +++ /dev/null @@ -1,81 +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.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryPersistenceDAO; - -/** - * @author peng-yongsheng - */ -public class ServiceEntryEsPersistenceDAO extends EsDAO implements IServiceEntryPersistenceDAO { - - public ServiceEntryEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public ServiceEntry get(String id) { - GetResponse getResponse = getClient().prepareGet(ServiceEntryTable.TABLE, id).get(); - if (getResponse.isExists()) { - ServiceEntry serviceEntry = new ServiceEntry(id); - Map source = getResponse.getSource(); - serviceEntry.setApplicationId(((Number)source.get(ServiceEntryTable.COLUMN_APPLICATION_ID)).intValue()); - serviceEntry.setEntryServiceId(((Number)source.get(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID)).intValue()); - serviceEntry.setEntryServiceName((String)source.get(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME)); - serviceEntry.setRegisterTime(((Number)source.get(ServiceEntryTable.COLUMN_REGISTER_TIME)).longValue()); - serviceEntry.setNewestTime(((Number)source.get(ServiceEntryTable.COLUMN_NEWEST_TIME)).longValue()); - return serviceEntry; - } else { - return null; - } - } - - @Override public IndexRequestBuilder prepareBatchInsert(ServiceEntry data) { - Map source = new HashMap<>(); - source.put(ServiceEntryTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, data.getEntryServiceId()); - source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, data.getEntryServiceName()); - source.put(ServiceEntryTable.COLUMN_REGISTER_TIME, data.getRegisterTime()); - source.put(ServiceEntryTable.COLUMN_NEWEST_TIME, data.getNewestTime()); - return getClient().prepareIndex(ServiceEntryTable.TABLE, data.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(ServiceEntry data) { - Map source = new HashMap<>(); - source.put(ServiceEntryTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, data.getEntryServiceId()); - source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, data.getEntryServiceName()); - source.put(ServiceEntryTable.COLUMN_REGISTER_TIME, data.getRegisterTime()); - source.put(ServiceEntryTable.COLUMN_NEWEST_TIME, data.getNewestTime()); - - return getClient().prepareUpdate(ServiceEntryTable.TABLE, data.getId()).setDoc(source); - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceEntryEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceEntryEsUIDAO.java deleted file mode 100644 index d9fff3976..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceEntryEsUIDAO.java +++ /dev/null @@ -1,99 +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.storage.es.dao; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.SearchHits; -import org.elasticsearch.search.sort.SortBuilders; -import org.elasticsearch.search.sort.SortOrder; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; -import org.apache.skywalking.apm.collector.core.util.StringUtils; - -/** - * @author peng-yongsheng - */ -public class ServiceEntryEsUIDAO extends EsDAO implements IServiceEntryUIDAO { - - public ServiceEntryEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override - public JsonObject load(int applicationId, String entryServiceName, long startTime, long endTime, int from, - int size) { - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(ServiceEntryTable.TABLE); - searchRequestBuilder.setTypes(ServiceEntryTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - - BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); - boolQueryBuilder.must().add(QueryBuilders.rangeQuery(ServiceEntryTable.COLUMN_REGISTER_TIME).lte(endTime)); - boolQueryBuilder.must().add(QueryBuilders.rangeQuery(ServiceEntryTable.COLUMN_NEWEST_TIME).gte(startTime)); - - if (applicationId != 0) { - boolQueryBuilder.must().add(QueryBuilders.matchQuery(ServiceEntryTable.COLUMN_APPLICATION_ID, applicationId)); - } - if (StringUtils.isNotEmpty(entryServiceName)) { - boolQueryBuilder.must().add(QueryBuilders.matchQuery(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, entryServiceName)); - } - - searchRequestBuilder.setQuery(boolQueryBuilder); - searchRequestBuilder.setSize(size); - searchRequestBuilder.setFrom(from); - searchRequestBuilder.addSort(SortBuilders.fieldSort(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME).order(SortOrder.ASC)); - - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - - return parseResponse(searchResponse); - } - - private JsonObject parseResponse(SearchResponse searchResponse) { - SearchHits searchHits = searchResponse.getHits(); - - JsonArray serviceArray = new JsonArray(); - for (SearchHit searchHit : searchHits.getHits()) { - int applicationId = ((Number)searchHit.getSource().get(ServiceEntryTable.COLUMN_APPLICATION_ID)).intValue(); - int entryServiceId = ((Number)searchHit.getSource().get(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID)).intValue(); - String entryServiceName = (String)searchHit.getSource().get(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME); - - JsonObject row = new JsonObject(); - row.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID), entryServiceId); - row.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME), entryServiceName); - row.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_APPLICATION_ID), applicationId); - serviceArray.add(row); - } - - JsonObject response = new JsonObject(); - response.addProperty("total", searchHits.totalHits); - response.add("array", serviceArray); - - return response; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceMetricEsPersistenceDAO.java deleted file mode 100644 index 6d12fd920..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceMetricEsPersistenceDAO.java +++ /dev/null @@ -1,137 +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.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.storage.dao.IServiceMetricPersistenceDAO; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class ServiceMetricEsPersistenceDAO extends EsDAO implements IServiceMetricPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(ServiceMetricEsPersistenceDAO.class); - - public ServiceMetricEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public ServiceMetric get(String id) { - GetResponse getResponse = getClient().prepareGet(ServiceMetricTable.TABLE, id).get(); - if (getResponse.isExists()) { - ServiceMetric serviceMetric = new ServiceMetric(id); - Map source = getResponse.getSource(); - serviceMetric.setServiceId(((Number)source.get(ServiceMetricTable.COLUMN_SERVICE_ID)).intValue()); - - serviceMetric.setTransactionCalls(((Number)source.get(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); - serviceMetric.setTransactionErrorCalls(((Number)source.get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); - serviceMetric.setTransactionDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); - serviceMetric.setTransactionErrorDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - serviceMetric.setBusinessTransactionCalls(((Number)source.get(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); - serviceMetric.setBusinessTransactionErrorCalls(((Number)source.get(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); - serviceMetric.setBusinessTransactionDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); - serviceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - serviceMetric.setMqTransactionCalls(((Number)source.get(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); - serviceMetric.setMqTransactionErrorCalls(((Number)source.get(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); - serviceMetric.setMqTransactionDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); - serviceMetric.setMqTransactionErrorDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - serviceMetric.setTimeBucket(((Number)source.get(ServiceMetricTable.COLUMN_TIME_BUCKET)).longValue()); - return serviceMetric; - } else { - return null; - } - } - - @Override public IndexRequestBuilder prepareBatchInsert(ServiceMetric data) { - Map source = new HashMap<>(); - source.put(ServiceMetricTable.COLUMN_SERVICE_ID, data.getServiceId()); - - source.put(ServiceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - source.put(ServiceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareIndex(ServiceMetricTable.TABLE, data.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(ServiceMetric data) { - Map source = new HashMap<>(); - source.put(ServiceMetricTable.COLUMN_SERVICE_ID, data.getServiceId()); - - source.put(ServiceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - source.put(ServiceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareUpdate(ServiceMetricTable.TABLE, data.getId()).setDoc(source); - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(ServiceMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(ServiceMetricTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, ServiceMetricTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceReferenceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceReferenceEsUIDAO.java index 1d622ea98..ff24c32d3 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceReferenceEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceReferenceEsUIDAO.java @@ -16,14 +16,15 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonObject; import java.util.LinkedHashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; import org.elasticsearch.action.search.SearchRequestBuilder; @@ -34,8 +35,6 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.metrics.sum.Sum; -import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; -import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,7 +58,6 @@ public class ServiceReferenceEsUIDAO extends EsDAO implements IServiceReferenceU BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); boolQuery.must().add(QueryBuilders.rangeQuery(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); boolQuery.must().add(QueryBuilders.rangeQuery(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); - boolQuery.must().add(QueryBuilders.matchQuery(ServiceReferenceMetricTable.COLUMN_ENTRY_SERVICE_ID, entryServiceId)); searchRequestBuilder.setQuery(boolQuery); searchRequestBuilder.setSize(0); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceReferenceMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceReferenceMetricEsPersistenceDAO.java deleted file mode 100644 index b14dbe72b..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceReferenceMetricEsPersistenceDAO.java +++ /dev/null @@ -1,145 +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.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class ServiceReferenceMetricEsPersistenceDAO extends EsDAO implements IServiceReferenceMetricPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(ServiceReferenceMetricEsPersistenceDAO.class); - - public ServiceReferenceMetricEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public ServiceReferenceMetric get(String id) { - GetResponse getResponse = getClient().prepareGet(ServiceReferenceMetricTable.TABLE, id).get(); - if (getResponse.isExists()) { - ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(id); - Map source = getResponse.getSource(); - serviceReferenceMetric.setEntryServiceId(((Number)source.get(ServiceReferenceMetricTable.COLUMN_ENTRY_SERVICE_ID)).intValue()); - serviceReferenceMetric.setFrontServiceId(((Number)source.get(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)).intValue()); - serviceReferenceMetric.setBehindServiceId(((Number)source.get(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)).intValue()); - serviceReferenceMetric.setSourceValue(((Number)source.get(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE)).intValue()); - - serviceReferenceMetric.setTransactionCalls(((Number)source.get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); - serviceReferenceMetric.setTransactionErrorCalls(((Number)source.get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); - serviceReferenceMetric.setTransactionDurationSum(((Number)source.get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); - serviceReferenceMetric.setTransactionErrorDurationSum(((Number)source.get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - serviceReferenceMetric.setBusinessTransactionCalls(((Number)source.get(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); - serviceReferenceMetric.setBusinessTransactionErrorCalls(((Number)source.get(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); - serviceReferenceMetric.setBusinessTransactionDurationSum(((Number)source.get(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); - serviceReferenceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - serviceReferenceMetric.setMqTransactionCalls(((Number)source.get(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); - serviceReferenceMetric.setMqTransactionErrorCalls(((Number)source.get(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); - serviceReferenceMetric.setMqTransactionDurationSum(((Number)source.get(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); - serviceReferenceMetric.setMqTransactionErrorDurationSum(((Number)source.get(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - serviceReferenceMetric.setTimeBucket(((Number)source.get(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET)).longValue()); - return serviceReferenceMetric; - } else { - return null; - } - } - - @Override public IndexRequestBuilder prepareBatchInsert(ServiceReferenceMetric data) { - Map source = new HashMap<>(); - source.put(ServiceReferenceMetricTable.COLUMN_ENTRY_SERVICE_ID, data.getEntryServiceId()); - source.put(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, data.getFrontServiceId()); - source.put(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, data.getBehindServiceId()); - source.put(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); - - source.put(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - source.put(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareIndex(ServiceReferenceMetricTable.TABLE, data.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(ServiceReferenceMetric data) { - Map source = new HashMap<>(); - source.put(ServiceReferenceMetricTable.COLUMN_ENTRY_SERVICE_ID, data.getEntryServiceId()); - source.put(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, data.getFrontServiceId()); - source.put(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, data.getBehindServiceId()); - source.put(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); - - source.put(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - source.put(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareUpdate(ServiceReferenceMetricTable.TABLE, data.getId()).setDoc(source); - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(ServiceReferenceMetricTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, ServiceReferenceMetricTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/AbstractApplicationComponentEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/AbstractApplicationComponentEsPersistenceDAO.java new file mode 100644 index 000000000..e729b4b78 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/AbstractApplicationComponentEsPersistenceDAO.java @@ -0,0 +1,63 @@ +/* + * 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.storage.es.dao.acp; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractApplicationComponentEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractApplicationComponentEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return ApplicationComponentTable.COLUMN_TIME_BUCKET; + } + + @Override protected final ApplicationComponent esDataToStreamData(Map source) { + ApplicationComponent applicationComponent = new ApplicationComponent(); + applicationComponent.setId((String)source.get(ApplicationComponentTable.COLUMN_ID)); + applicationComponent.setMetricId((String)source.get(ApplicationComponentTable.COLUMN_METRIC_ID)); + + applicationComponent.setComponentId(((Number)source.get(ApplicationComponentTable.COLUMN_COMPONENT_ID)).intValue()); + applicationComponent.setPeerId(((Number)source.get(ApplicationComponentTable.COLUMN_PEER_ID)).intValue()); + applicationComponent.setTimeBucket(((Number)source.get(ApplicationComponentTable.COLUMN_TIME_BUCKET)).longValue()); + return applicationComponent; + } + + @Override protected final Map esStreamDataToEsData(ApplicationComponent streamData) { + Map source = new HashMap<>(); + source.put(ApplicationComponentTable.COLUMN_ID, streamData.getId()); + source.put(ApplicationComponentTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(ApplicationComponentTable.COLUMN_COMPONENT_ID, streamData.getComponentId()); + source.put(ApplicationComponentTable.COLUMN_PEER_ID, streamData.getPeerId()); + source.put(ApplicationComponentTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/ApplicationComponentDayEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/ApplicationComponentDayEsPersistenceDAO.java new file mode 100644 index 000000000..1f1b7ca2c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/ApplicationComponentDayEsPersistenceDAO.java @@ -0,0 +1,46 @@ +/* + * 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.storage.es.dao.acp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentDayEsPersistenceDAO extends AbstractApplicationComponentEsPersistenceDAO implements IApplicationComponentDayPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationComponentDayEsPersistenceDAO.class); + + public ApplicationComponentDayEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/ApplicationComponentHourEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/ApplicationComponentHourEsPersistenceDAO.java new file mode 100644 index 000000000..a6be4e959 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/ApplicationComponentHourEsPersistenceDAO.java @@ -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.storage.es.dao.acp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentHourEsPersistenceDAO extends AbstractApplicationComponentEsPersistenceDAO implements IApplicationComponentHourPersistenceDAO { + + public ApplicationComponentHourEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/ApplicationComponentMinuteEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/ApplicationComponentMinuteEsPersistenceDAO.java new file mode 100644 index 000000000..0b0bc83eb --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/ApplicationComponentMinuteEsPersistenceDAO.java @@ -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.storage.es.dao.acp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentMinuteEsPersistenceDAO extends AbstractApplicationComponentEsPersistenceDAO implements IApplicationComponentMinutePersistenceDAO { + + public ApplicationComponentMinuteEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/ApplicationComponentMonthEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/ApplicationComponentMonthEsPersistenceDAO.java new file mode 100644 index 000000000..2ee5eb3ff --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/ApplicationComponentMonthEsPersistenceDAO.java @@ -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.storage.es.dao.acp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentMonthEsPersistenceDAO extends AbstractApplicationComponentEsPersistenceDAO implements IApplicationComponentMonthPersistenceDAO { + + public ApplicationComponentMonthEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmEsPersistenceDAO.java new file mode 100644 index 000000000..4e3b058ab --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmEsPersistenceDAO.java @@ -0,0 +1,105 @@ +/* + * 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.storage.es.dao.alarm; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmTable; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmEsPersistenceDAO extends EsDAO implements IApplicationAlarmPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationAlarmEsPersistenceDAO.class); + + public ApplicationAlarmEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public ApplicationAlarm get(String id) { + GetResponse getResponse = getClient().prepareGet(ApplicationAlarmTable.TABLE, id).get(); + if (getResponse.isExists()) { + ApplicationAlarm instanceAlarm = new ApplicationAlarm(); + instanceAlarm.setId(id); + + Map source = getResponse.getSource(); + instanceAlarm.setApplicationId(((Number)source.get(ApplicationAlarmTable.COLUMN_APPLICATION_ID)).intValue()); + instanceAlarm.setSourceValue(((Number)source.get(ApplicationAlarmTable.COLUMN_SOURCE_VALUE)).intValue()); + + instanceAlarm.setAlarmType(((Number)source.get(ApplicationAlarmTable.COLUMN_ALARM_TYPE)).intValue()); + instanceAlarm.setAlarmContent((String)source.get(ApplicationAlarmTable.COLUMN_ALARM_CONTENT)); + + instanceAlarm.setLastTimeBucket(((Number)source.get(ApplicationAlarmTable.COLUMN_LAST_TIME_BUCKET)).longValue()); + return instanceAlarm; + } else { + return null; + } + } + + @Override public IndexRequestBuilder prepareBatchInsert(ApplicationAlarm data) { + Map source = new HashMap<>(); + source.put(ApplicationAlarmTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(ApplicationAlarmTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ApplicationAlarmTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ApplicationAlarmTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ApplicationAlarmTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); + + return getClient().prepareIndex(ApplicationAlarmTable.TABLE, data.getId()).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(ApplicationAlarm data) { + Map source = new HashMap<>(); + source.put(ApplicationAlarmTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(ApplicationAlarmTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ApplicationAlarmTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ApplicationAlarmTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ApplicationAlarmTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); + + return getClient().prepareUpdate(ApplicationAlarmTable.TABLE, data.getId()).setDoc(source); + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); + long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); + BulkByScrollResponse response = getClient().prepareDelete() + .filter(QueryBuilders.rangeQuery(ApplicationAlarmTable.COLUMN_LAST_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) + .source(ApplicationAlarmTable.TABLE) + .get(); + + long deleted = response.getDeleted(); + logger.info("Delete {} rows history from {} index.", deleted, ApplicationAlarmTable.TABLE); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsPersistenceDAO.java similarity index 50% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsPersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsPersistenceDAO.java index 863387f50..92b635727 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsPersistenceDAO.java @@ -16,77 +16,89 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.dao; +package org.apache.skywalking.apm.collector.storage.es.dao.alarm; import java.util.HashMap; import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.update.UpdateRequestBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ -public class ApplicationComponentEsPersistenceDAO extends EsDAO implements IApplicationComponentPersistenceDAO { +public class ApplicationAlarmListEsPersistenceDAO extends EsDAO implements IApplicationAlarmListPersistenceDAO { - private final Logger logger = LoggerFactory.getLogger(ApplicationComponentEsPersistenceDAO.class); + private final Logger logger = LoggerFactory.getLogger(ApplicationAlarmListEsPersistenceDAO.class); - public ApplicationComponentEsPersistenceDAO(ElasticSearchClient client) { + public ApplicationAlarmListEsPersistenceDAO(ElasticSearchClient client) { super(client); } - @Override public ApplicationComponent get(String id) { - GetResponse getResponse = getClient().prepareGet(ApplicationComponentTable.TABLE, id).get(); + @Override public ApplicationAlarmList get(String id) { + GetResponse getResponse = getClient().prepareGet(ApplicationAlarmListTable.TABLE, id).get(); if (getResponse.isExists()) { - ApplicationComponent applicationComponent = new ApplicationComponent(id); + ApplicationAlarmList applicationAlarmList = new ApplicationAlarmList(); + applicationAlarmList.setId(id); Map source = getResponse.getSource(); - applicationComponent.setComponentId(((Number)source.get(ApplicationComponentTable.COLUMN_COMPONENT_ID)).intValue()); - applicationComponent.setPeerId(((Number)source.get(ApplicationComponentTable.COLUMN_PEER_ID)).intValue()); - applicationComponent.setTimeBucket((Long)source.get(ApplicationComponentTable.COLUMN_TIME_BUCKET)); - return applicationComponent; + applicationAlarmList.setApplicationId(((Number)source.get(ApplicationAlarmListTable.COLUMN_APPLICATION_ID)).intValue()); + applicationAlarmList.setSourceValue(((Number)source.get(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE)).intValue()); + + applicationAlarmList.setAlarmType(((Number)source.get(ApplicationAlarmListTable.COLUMN_ALARM_TYPE)).intValue()); + applicationAlarmList.setAlarmContent((String)source.get(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT)); + + applicationAlarmList.setTimeBucket(((Number)source.get(ApplicationAlarmListTable.COLUMN_TIME_BUCKET)).longValue()); + return applicationAlarmList; } else { return null; } } - @Override public IndexRequestBuilder prepareBatchInsert(ApplicationComponent data) { + @Override public IndexRequestBuilder prepareBatchInsert(ApplicationAlarmList data) { Map source = new HashMap<>(); - source.put(ApplicationComponentTable.COLUMN_COMPONENT_ID, data.getComponentId()); - source.put(ApplicationComponentTable.COLUMN_PEER_ID, data.getPeerId()); - source.put(ApplicationComponentTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + source.put(ApplicationAlarmListTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); - return getClient().prepareIndex(ApplicationComponentTable.TABLE, data.getId()).setSource(source); + source.put(ApplicationAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ApplicationAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + + return getClient().prepareIndex(ApplicationAlarmListTable.TABLE, data.getId()).setSource(source); } - @Override public UpdateRequestBuilder prepareBatchUpdate(ApplicationComponent data) { + @Override public UpdateRequestBuilder prepareBatchUpdate(ApplicationAlarmList data) { Map source = new HashMap<>(); - source.put(ApplicationComponentTable.COLUMN_COMPONENT_ID, data.getComponentId()); - source.put(ApplicationComponentTable.COLUMN_PEER_ID, data.getPeerId()); - source.put(ApplicationComponentTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + source.put(ApplicationAlarmListTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); - return getClient().prepareUpdate(ApplicationComponentTable.TABLE, data.getId()).setDoc(source); + source.put(ApplicationAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ApplicationAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + + return getClient().prepareUpdate(ApplicationAlarmListTable.TABLE, data.getId()).setDoc(source); } @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(ApplicationComponentTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(ApplicationComponentTable.TABLE) + .filter(QueryBuilders.rangeQuery(ApplicationAlarmListTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) + .source(ApplicationAlarmListTable.TABLE) .get(); long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, ApplicationComponentTable.TABLE); + logger.info("Delete {} rows history from {} index.", deleted, ApplicationAlarmListTable.TABLE); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationReferenceAlarmEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationReferenceAlarmEsPersistenceDAO.java new file mode 100644 index 000000000..30cb14beb --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationReferenceAlarmEsPersistenceDAO.java @@ -0,0 +1,107 @@ +/* + * 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.storage.es.dao.alarm; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarm; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarmTable; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceAlarmEsPersistenceDAO extends EsDAO implements IApplicationReferenceAlarmPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceAlarmEsPersistenceDAO.class); + + public ApplicationReferenceAlarmEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public ApplicationReferenceAlarm get(String id) { + GetResponse getResponse = getClient().prepareGet(ApplicationReferenceAlarmTable.TABLE, id).get(); + if (getResponse.isExists()) { + ApplicationReferenceAlarm applicationReferenceAlarm = new ApplicationReferenceAlarm(); + applicationReferenceAlarm.setId(id); + Map source = getResponse.getSource(); + applicationReferenceAlarm.setFrontApplicationId(((Number)source.get(ApplicationReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID)).intValue()); + applicationReferenceAlarm.setBehindApplicationId(((Number)source.get(ApplicationReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID)).intValue()); + applicationReferenceAlarm.setSourceValue(((Number)source.get(ApplicationReferenceAlarmTable.COLUMN_SOURCE_VALUE)).intValue()); + + applicationReferenceAlarm.setAlarmType(((Number)source.get(ApplicationReferenceAlarmTable.COLUMN_ALARM_TYPE)).intValue()); + applicationReferenceAlarm.setAlarmContent((String)source.get(ApplicationReferenceAlarmTable.COLUMN_ALARM_CONTENT)); + + applicationReferenceAlarm.setLastTimeBucket(((Number)source.get(ApplicationReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET)).longValue()); + return applicationReferenceAlarm; + } else { + return null; + } + } + + @Override public IndexRequestBuilder prepareBatchInsert(ApplicationReferenceAlarm data) { + Map source = new HashMap<>(); + source.put(ApplicationReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); + source.put(ApplicationReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); + source.put(ApplicationReferenceAlarmTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ApplicationReferenceAlarmTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ApplicationReferenceAlarmTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ApplicationReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); + + return getClient().prepareIndex(ApplicationReferenceAlarmTable.TABLE, data.getId()).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(ApplicationReferenceAlarm data) { + Map source = new HashMap<>(); + source.put(ApplicationReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); + source.put(ApplicationReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); + source.put(ApplicationReferenceAlarmTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ApplicationReferenceAlarmTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ApplicationReferenceAlarmTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ApplicationReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); + + return getClient().prepareUpdate(ApplicationReferenceAlarmTable.TABLE, data.getId()).setDoc(source); + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); + long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); + BulkByScrollResponse response = getClient().prepareDelete() + .filter(QueryBuilders.rangeQuery(ApplicationReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) + .source(ApplicationReferenceAlarmTable.TABLE) + .get(); + + long deleted = response.getDeleted(); + logger.info("Delete {} rows history from {} index.", deleted, ApplicationReferenceAlarmTable.TABLE); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationReferenceAlarmListEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationReferenceAlarmListEsPersistenceDAO.java new file mode 100644 index 000000000..4b7469cc8 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationReferenceAlarmListEsPersistenceDAO.java @@ -0,0 +1,107 @@ +/* + * 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.storage.es.dao.alarm; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarmListTable; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceAlarmListEsPersistenceDAO extends EsDAO implements IApplicationReferenceAlarmListPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceAlarmListEsPersistenceDAO.class); + + public ApplicationReferenceAlarmListEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public ApplicationReferenceAlarmList get(String id) { + GetResponse getResponse = getClient().prepareGet(ApplicationReferenceAlarmListTable.TABLE, id).get(); + if (getResponse.isExists()) { + ApplicationReferenceAlarmList applicationReferenceAlarmList = new ApplicationReferenceAlarmList(); + applicationReferenceAlarmList.setId(id); + Map source = getResponse.getSource(); + applicationReferenceAlarmList.setFrontApplicationId(((Number)source.get(ApplicationReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID)).intValue()); + applicationReferenceAlarmList.setBehindApplicationId(((Number)source.get(ApplicationReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID)).intValue()); + applicationReferenceAlarmList.setSourceValue(((Number)source.get(ApplicationReferenceAlarmListTable.COLUMN_SOURCE_VALUE)).intValue()); + + applicationReferenceAlarmList.setAlarmType(((Number)source.get(ApplicationReferenceAlarmListTable.COLUMN_ALARM_TYPE)).intValue()); + applicationReferenceAlarmList.setAlarmContent((String)source.get(ApplicationReferenceAlarmListTable.COLUMN_ALARM_CONTENT)); + + applicationReferenceAlarmList.setTimeBucket(((Number)source.get(ApplicationReferenceAlarmListTable.COLUMN_TIME_BUCKET)).longValue()); + return applicationReferenceAlarmList; + } else { + return null; + } + } + + @Override public IndexRequestBuilder prepareBatchInsert(ApplicationReferenceAlarmList data) { + Map source = new HashMap<>(); + source.put(ApplicationReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); + source.put(ApplicationReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); + source.put(ApplicationReferenceAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ApplicationReferenceAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ApplicationReferenceAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ApplicationReferenceAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + + return getClient().prepareIndex(ApplicationReferenceAlarmListTable.TABLE, data.getId()).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(ApplicationReferenceAlarmList data) { + Map source = new HashMap<>(); + source.put(ApplicationReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); + source.put(ApplicationReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); + source.put(ApplicationReferenceAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ApplicationReferenceAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ApplicationReferenceAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ApplicationReferenceAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + + return getClient().prepareUpdate(ApplicationReferenceAlarmListTable.TABLE, data.getId()).setDoc(source); + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); + long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); + BulkByScrollResponse response = getClient().prepareDelete() + .filter(QueryBuilders.rangeQuery(ApplicationReferenceAlarmListTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) + .source(ApplicationReferenceAlarmListTable.TABLE) + .get(); + + long deleted = response.getDeleted(); + logger.info("Delete {} rows history from {} index.", deleted, ApplicationReferenceAlarmListTable.TABLE); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/InstanceAlarmEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/InstanceAlarmEsPersistenceDAO.java new file mode 100644 index 000000000..64631c623 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/InstanceAlarmEsPersistenceDAO.java @@ -0,0 +1,107 @@ +/* + * 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.storage.es.dao.alarm; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmTable; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmEsPersistenceDAO extends EsDAO implements IInstanceAlarmPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceAlarmEsPersistenceDAO.class); + + public InstanceAlarmEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public InstanceAlarm get(String id) { + GetResponse getResponse = getClient().prepareGet(InstanceAlarmTable.TABLE, id).get(); + if (getResponse.isExists()) { + InstanceAlarm instanceAlarm = new InstanceAlarm(); + instanceAlarm.setId(id); + Map source = getResponse.getSource(); + instanceAlarm.setApplicationId(((Number)source.get(InstanceAlarmTable.COLUMN_APPLICATION_ID)).intValue()); + instanceAlarm.setInstanceId(((Number)source.get(InstanceAlarmTable.COLUMN_INSTANCE_ID)).intValue()); + instanceAlarm.setSourceValue(((Number)source.get(InstanceAlarmTable.COLUMN_SOURCE_VALUE)).intValue()); + + instanceAlarm.setAlarmType(((Number)source.get(InstanceAlarmTable.COLUMN_ALARM_TYPE)).intValue()); + instanceAlarm.setAlarmContent((String)source.get(InstanceAlarmTable.COLUMN_ALARM_CONTENT)); + + instanceAlarm.setLastTimeBucket(((Number)source.get(InstanceAlarmTable.COLUMN_LAST_TIME_BUCKET)).longValue()); + return instanceAlarm; + } else { + return null; + } + } + + @Override public IndexRequestBuilder prepareBatchInsert(InstanceAlarm data) { + Map source = new HashMap<>(); + source.put(InstanceAlarmTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(InstanceAlarmTable.COLUMN_INSTANCE_ID, data.getInstanceId()); + source.put(InstanceAlarmTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(InstanceAlarmTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(InstanceAlarmTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(InstanceAlarmTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); + + return getClient().prepareIndex(InstanceAlarmTable.TABLE, data.getId()).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(InstanceAlarm data) { + Map source = new HashMap<>(); + source.put(InstanceAlarmTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(InstanceAlarmTable.COLUMN_INSTANCE_ID, data.getInstanceId()); + source.put(InstanceAlarmTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(InstanceAlarmTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(InstanceAlarmTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(InstanceAlarmTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); + + return getClient().prepareUpdate(InstanceAlarmTable.TABLE, data.getId()).setDoc(source); + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); + long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); + BulkByScrollResponse response = getClient().prepareDelete() + .filter(QueryBuilders.rangeQuery(InstanceAlarmTable.COLUMN_LAST_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) + .source(InstanceAlarmTable.TABLE) + .get(); + + long deleted = response.getDeleted(); + logger.info("Delete {} rows history from {} index.", deleted, InstanceAlarmTable.TABLE); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/InstanceAlarmListEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/InstanceAlarmListEsPersistenceDAO.java new file mode 100644 index 000000000..47cefae90 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/InstanceAlarmListEsPersistenceDAO.java @@ -0,0 +1,107 @@ +/* + * 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.storage.es.dao.alarm; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmListTable; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmListEsPersistenceDAO extends EsDAO implements IInstanceAlarmListPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceAlarmListEsPersistenceDAO.class); + + public InstanceAlarmListEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public InstanceAlarmList get(String id) { + GetResponse getResponse = getClient().prepareGet(InstanceAlarmListTable.TABLE, id).get(); + if (getResponse.isExists()) { + InstanceAlarmList instanceAlarmList = new InstanceAlarmList(); + instanceAlarmList.setId(id); + Map source = getResponse.getSource(); + instanceAlarmList.setApplicationId(((Number)source.get(InstanceAlarmListTable.COLUMN_APPLICATION_ID)).intValue()); + instanceAlarmList.setInstanceId(((Number)source.get(InstanceAlarmListTable.COLUMN_INSTANCE_ID)).intValue()); + instanceAlarmList.setSourceValue(((Number)source.get(InstanceAlarmListTable.COLUMN_SOURCE_VALUE)).intValue()); + + instanceAlarmList.setAlarmType(((Number)source.get(InstanceAlarmListTable.COLUMN_ALARM_TYPE)).intValue()); + instanceAlarmList.setAlarmContent((String)source.get(InstanceAlarmListTable.COLUMN_ALARM_CONTENT)); + + instanceAlarmList.setTimeBucket(((Number)source.get(InstanceAlarmListTable.COLUMN_TIME_BUCKET)).longValue()); + return instanceAlarmList; + } else { + return null; + } + } + + @Override public IndexRequestBuilder prepareBatchInsert(InstanceAlarmList data) { + Map source = new HashMap<>(); + source.put(InstanceAlarmListTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(InstanceAlarmListTable.COLUMN_INSTANCE_ID, data.getInstanceId()); + source.put(InstanceAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(InstanceAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(InstanceAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(InstanceAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + + return getClient().prepareIndex(InstanceAlarmListTable.TABLE, data.getId()).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(InstanceAlarmList data) { + Map source = new HashMap<>(); + source.put(InstanceAlarmListTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(InstanceAlarmListTable.COLUMN_INSTANCE_ID, data.getInstanceId()); + source.put(InstanceAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(InstanceAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(InstanceAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(InstanceAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + + return getClient().prepareUpdate(InstanceAlarmListTable.TABLE, data.getId()).setDoc(source); + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); + long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); + BulkByScrollResponse response = getClient().prepareDelete() + .filter(QueryBuilders.rangeQuery(InstanceAlarmListTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) + .source(InstanceAlarmListTable.TABLE) + .get(); + + long deleted = response.getDeleted(); + logger.info("Delete {} rows history from {} index.", deleted, InstanceAlarmListTable.TABLE); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/InstanceReferenceAlarmEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/InstanceReferenceAlarmEsPersistenceDAO.java new file mode 100644 index 000000000..fd12f43f9 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/InstanceReferenceAlarmEsPersistenceDAO.java @@ -0,0 +1,113 @@ +/* + * 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.storage.es.dao.alarm; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceReferenceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarm; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarmTable; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceAlarmEsPersistenceDAO extends EsDAO implements IInstanceReferenceAlarmPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceReferenceAlarmEsPersistenceDAO.class); + + public InstanceReferenceAlarmEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public InstanceReferenceAlarm get(String id) { + GetResponse getResponse = getClient().prepareGet(InstanceReferenceAlarmTable.TABLE, id).get(); + if (getResponse.isExists()) { + InstanceReferenceAlarm instanceReferenceAlarm = new InstanceReferenceAlarm(); + instanceReferenceAlarm.setId(id); + Map source = getResponse.getSource(); + instanceReferenceAlarm.setFrontApplicationId(((Number)source.get(InstanceReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID)).intValue()); + instanceReferenceAlarm.setBehindApplicationId(((Number)source.get(InstanceReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID)).intValue()); + instanceReferenceAlarm.setFrontInstanceId(((Number)source.get(InstanceReferenceAlarmTable.COLUMN_FRONT_INSTANCE_ID)).intValue()); + instanceReferenceAlarm.setBehindInstanceId(((Number)source.get(InstanceReferenceAlarmTable.COLUMN_BEHIND_INSTANCE_ID)).intValue()); + instanceReferenceAlarm.setSourceValue(((Number)source.get(InstanceReferenceAlarmTable.COLUMN_SOURCE_VALUE)).intValue()); + + instanceReferenceAlarm.setAlarmType(((Number)source.get(InstanceReferenceAlarmTable.COLUMN_ALARM_TYPE)).intValue()); + instanceReferenceAlarm.setAlarmContent((String)source.get(InstanceReferenceAlarmTable.COLUMN_ALARM_CONTENT)); + + instanceReferenceAlarm.setLastTimeBucket(((Number)source.get(InstanceReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET)).longValue()); + return instanceReferenceAlarm; + } else { + return null; + } + } + + @Override public IndexRequestBuilder prepareBatchInsert(InstanceReferenceAlarm data) { + Map source = new HashMap<>(); + source.put(InstanceReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); + source.put(InstanceReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); + source.put(InstanceReferenceAlarmTable.COLUMN_FRONT_INSTANCE_ID, data.getFrontInstanceId()); + source.put(InstanceReferenceAlarmTable.COLUMN_BEHIND_INSTANCE_ID, data.getBehindInstanceId()); + source.put(InstanceReferenceAlarmTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(InstanceReferenceAlarmTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(InstanceReferenceAlarmTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(InstanceReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); + + return getClient().prepareIndex(InstanceReferenceAlarmTable.TABLE, data.getId()).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(InstanceReferenceAlarm data) { + Map source = new HashMap<>(); + source.put(InstanceReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); + source.put(InstanceReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); + source.put(InstanceReferenceAlarmTable.COLUMN_FRONT_INSTANCE_ID, data.getFrontInstanceId()); + source.put(InstanceReferenceAlarmTable.COLUMN_BEHIND_INSTANCE_ID, data.getBehindInstanceId()); + source.put(InstanceReferenceAlarmTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(InstanceReferenceAlarmTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(InstanceReferenceAlarmTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(InstanceReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); + + return getClient().prepareUpdate(InstanceReferenceAlarmTable.TABLE, data.getId()).setDoc(source); + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); + long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); + BulkByScrollResponse response = getClient().prepareDelete() + .filter(QueryBuilders.rangeQuery(InstanceReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) + .source(InstanceReferenceAlarmTable.TABLE) + .get(); + + long deleted = response.getDeleted(); + logger.info("Delete {} rows history from {} index.", deleted, InstanceReferenceAlarmTable.TABLE); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/InstanceReferenceAlarmListEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/InstanceReferenceAlarmListEsPersistenceDAO.java new file mode 100644 index 000000000..77388491a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/InstanceReferenceAlarmListEsPersistenceDAO.java @@ -0,0 +1,113 @@ +/* + * 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.storage.es.dao.alarm; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarmListTable; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceAlarmListEsPersistenceDAO extends EsDAO implements IInstanceReferenceAlarmListPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceReferenceAlarmListEsPersistenceDAO.class); + + public InstanceReferenceAlarmListEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public InstanceReferenceAlarmList get(String id) { + GetResponse getResponse = getClient().prepareGet(InstanceReferenceAlarmListTable.TABLE, id).get(); + if (getResponse.isExists()) { + InstanceReferenceAlarmList serviceReferenceAlarmList = new InstanceReferenceAlarmList(); + serviceReferenceAlarmList.setId(id); + Map source = getResponse.getSource(); + serviceReferenceAlarmList.setFrontApplicationId(((Number)source.get(InstanceReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID)).intValue()); + serviceReferenceAlarmList.setBehindApplicationId(((Number)source.get(InstanceReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID)).intValue()); + serviceReferenceAlarmList.setFrontInstanceId(((Number)source.get(InstanceReferenceAlarmListTable.COLUMN_FRONT_INSTANCE_ID)).intValue()); + serviceReferenceAlarmList.setBehindInstanceId(((Number)source.get(InstanceReferenceAlarmListTable.COLUMN_BEHIND_INSTANCE_ID)).intValue()); + serviceReferenceAlarmList.setSourceValue(((Number)source.get(InstanceReferenceAlarmListTable.COLUMN_SOURCE_VALUE)).intValue()); + + serviceReferenceAlarmList.setAlarmType(((Number)source.get(InstanceReferenceAlarmListTable.COLUMN_ALARM_TYPE)).intValue()); + serviceReferenceAlarmList.setAlarmContent((String)source.get(InstanceReferenceAlarmListTable.COLUMN_ALARM_CONTENT)); + + serviceReferenceAlarmList.setTimeBucket(((Number)source.get(InstanceReferenceAlarmListTable.COLUMN_TIME_BUCKET)).longValue()); + return serviceReferenceAlarmList; + } else { + return null; + } + } + + @Override public IndexRequestBuilder prepareBatchInsert(InstanceReferenceAlarmList data) { + Map source = new HashMap<>(); + source.put(InstanceReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); + source.put(InstanceReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); + source.put(InstanceReferenceAlarmListTable.COLUMN_FRONT_INSTANCE_ID, data.getFrontInstanceId()); + source.put(InstanceReferenceAlarmListTable.COLUMN_BEHIND_INSTANCE_ID, data.getBehindInstanceId()); + source.put(InstanceReferenceAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(InstanceReferenceAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(InstanceReferenceAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(InstanceReferenceAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + + return getClient().prepareIndex(InstanceReferenceAlarmListTable.TABLE, data.getId()).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(InstanceReferenceAlarmList data) { + Map source = new HashMap<>(); + source.put(InstanceReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); + source.put(InstanceReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); + source.put(InstanceReferenceAlarmListTable.COLUMN_FRONT_INSTANCE_ID, data.getFrontInstanceId()); + source.put(InstanceReferenceAlarmListTable.COLUMN_BEHIND_INSTANCE_ID, data.getBehindInstanceId()); + source.put(InstanceReferenceAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(InstanceReferenceAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(InstanceReferenceAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(InstanceReferenceAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + + return getClient().prepareUpdate(InstanceReferenceAlarmListTable.TABLE, data.getId()).setDoc(source); + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); + long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); + BulkByScrollResponse response = getClient().prepareDelete() + .filter(QueryBuilders.rangeQuery(InstanceReferenceAlarmListTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) + .source(InstanceReferenceAlarmListTable.TABLE) + .get(); + + long deleted = response.getDeleted(); + logger.info("Delete {} rows history from {} index.", deleted, InstanceReferenceAlarmListTable.TABLE); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ServiceAlarmEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ServiceAlarmEsPersistenceDAO.java new file mode 100644 index 000000000..44d826563 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ServiceAlarmEsPersistenceDAO.java @@ -0,0 +1,110 @@ +/* + * 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.storage.es.dao.alarm; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarm; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarmTable; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ServiceAlarmEsPersistenceDAO extends EsDAO implements IServiceAlarmPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ServiceAlarmEsPersistenceDAO.class); + + public ServiceAlarmEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public ServiceAlarm get(String id) { + GetResponse getResponse = getClient().prepareGet(ServiceAlarmTable.TABLE, id).get(); + if (getResponse.isExists()) { + ServiceAlarm serviceAlarm = new ServiceAlarm(); + serviceAlarm.setId(id); + Map source = getResponse.getSource(); + serviceAlarm.setApplicationId(((Number)source.get(ServiceAlarmTable.COLUMN_APPLICATION_ID)).intValue()); + serviceAlarm.setInstanceId(((Number)source.get(ServiceAlarmTable.COLUMN_INSTANCE_ID)).intValue()); + serviceAlarm.setServiceId(((Number)source.get(ServiceAlarmTable.COLUMN_SERVICE_ID)).intValue()); + serviceAlarm.setSourceValue(((Number)source.get(ServiceAlarmTable.COLUMN_SOURCE_VALUE)).intValue()); + + serviceAlarm.setAlarmType(((Number)source.get(ServiceAlarmTable.COLUMN_ALARM_TYPE)).intValue()); + serviceAlarm.setAlarmContent((String)source.get(ServiceAlarmTable.COLUMN_ALARM_CONTENT)); + + serviceAlarm.setLastTimeBucket(((Number)source.get(ServiceAlarmTable.COLUMN_LAST_TIME_BUCKET)).longValue()); + return serviceAlarm; + } else { + return null; + } + } + + @Override public IndexRequestBuilder prepareBatchInsert(ServiceAlarm data) { + Map source = new HashMap<>(); + source.put(ServiceAlarmTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(ServiceAlarmTable.COLUMN_INSTANCE_ID, data.getInstanceId()); + source.put(ServiceAlarmTable.COLUMN_SERVICE_ID, data.getServiceId()); + source.put(ServiceAlarmTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ServiceAlarmTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ServiceAlarmTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ServiceAlarmTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); + + return getClient().prepareIndex(ServiceAlarmTable.TABLE, data.getId()).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(ServiceAlarm data) { + Map source = new HashMap<>(); + source.put(ServiceAlarmTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(ServiceAlarmTable.COLUMN_INSTANCE_ID, data.getInstanceId()); + source.put(ServiceAlarmTable.COLUMN_SERVICE_ID, data.getServiceId()); + source.put(ServiceAlarmTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ServiceAlarmTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ServiceAlarmTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ServiceAlarmTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); + + return getClient().prepareUpdate(ServiceAlarmTable.TABLE, data.getId()).setDoc(source); + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); + long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); + BulkByScrollResponse response = getClient().prepareDelete() + .filter(QueryBuilders.rangeQuery(ServiceAlarmTable.COLUMN_LAST_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) + .source(ServiceAlarmTable.TABLE) + .get(); + + long deleted = response.getDeleted(); + logger.info("Delete {} rows history from {} index.", deleted, ServiceAlarmTable.TABLE); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ServiceAlarmListEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ServiceAlarmListEsPersistenceDAO.java new file mode 100644 index 000000000..56bf3c80e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ServiceAlarmListEsPersistenceDAO.java @@ -0,0 +1,110 @@ +/* + * 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.storage.es.dao.alarm; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarmListTable; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ServiceAlarmListEsPersistenceDAO extends EsDAO implements IServiceAlarmListPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ServiceAlarmListEsPersistenceDAO.class); + + public ServiceAlarmListEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public ServiceAlarmList get(String id) { + GetResponse getResponse = getClient().prepareGet(ServiceAlarmListTable.TABLE, id).get(); + if (getResponse.isExists()) { + ServiceAlarmList serviceAlarmList = new ServiceAlarmList(); + serviceAlarmList.setId(id); + Map source = getResponse.getSource(); + serviceAlarmList.setApplicationId(((Number)source.get(ServiceAlarmListTable.COLUMN_APPLICATION_ID)).intValue()); + serviceAlarmList.setInstanceId(((Number)source.get(ServiceAlarmListTable.COLUMN_INSTANCE_ID)).intValue()); + serviceAlarmList.setServiceId(((Number)source.get(ServiceAlarmListTable.COLUMN_SERVICE_ID)).intValue()); + serviceAlarmList.setSourceValue(((Number)source.get(ServiceAlarmListTable.COLUMN_SOURCE_VALUE)).intValue()); + + serviceAlarmList.setAlarmType(((Number)source.get(ServiceAlarmListTable.COLUMN_ALARM_TYPE)).intValue()); + serviceAlarmList.setAlarmContent((String)source.get(ServiceAlarmListTable.COLUMN_ALARM_CONTENT)); + + serviceAlarmList.setTimeBucket(((Number)source.get(ServiceAlarmListTable.COLUMN_TIME_BUCKET)).longValue()); + return serviceAlarmList; + } else { + return null; + } + } + + @Override public IndexRequestBuilder prepareBatchInsert(ServiceAlarmList data) { + Map source = new HashMap<>(); + source.put(ServiceAlarmListTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(ServiceAlarmListTable.COLUMN_INSTANCE_ID, data.getInstanceId()); + source.put(ServiceAlarmListTable.COLUMN_SERVICE_ID, data.getServiceId()); + source.put(ServiceAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ServiceAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ServiceAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ServiceAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + + return getClient().prepareIndex(ServiceAlarmListTable.TABLE, data.getId()).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(ServiceAlarmList data) { + Map source = new HashMap<>(); + source.put(ServiceAlarmListTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(ServiceAlarmListTable.COLUMN_INSTANCE_ID, data.getInstanceId()); + source.put(ServiceAlarmListTable.COLUMN_SERVICE_ID, data.getServiceId()); + source.put(ServiceAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ServiceAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ServiceAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ServiceAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + + return getClient().prepareUpdate(ServiceAlarmListTable.TABLE, data.getId()).setDoc(source); + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); + long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); + BulkByScrollResponse response = getClient().prepareDelete() + .filter(QueryBuilders.rangeQuery(ServiceAlarmListTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) + .source(ServiceAlarmListTable.TABLE) + .get(); + + long deleted = response.getDeleted(); + logger.info("Delete {} rows history from {} index.", deleted, ServiceAlarmListTable.TABLE); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ServiceReferenceAlarmEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ServiceReferenceAlarmEsPersistenceDAO.java new file mode 100644 index 000000000..6934afc9a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ServiceReferenceAlarmEsPersistenceDAO.java @@ -0,0 +1,119 @@ +/* + * 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.storage.es.dao.alarm; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceReferenceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarm; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarmTable; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceAlarmEsPersistenceDAO extends EsDAO implements IServiceReferenceAlarmPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ServiceReferenceAlarmEsPersistenceDAO.class); + + public ServiceReferenceAlarmEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public ServiceReferenceAlarm get(String id) { + GetResponse getResponse = getClient().prepareGet(ServiceReferenceAlarmTable.TABLE, id).get(); + if (getResponse.isExists()) { + ServiceReferenceAlarm serviceReferenceAlarm = new ServiceReferenceAlarm(); + serviceReferenceAlarm.setId(id); + Map source = getResponse.getSource(); + serviceReferenceAlarm.setFrontApplicationId(((Number)source.get(ServiceReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID)).intValue()); + serviceReferenceAlarm.setBehindApplicationId(((Number)source.get(ServiceReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID)).intValue()); + serviceReferenceAlarm.setFrontInstanceId(((Number)source.get(ServiceReferenceAlarmTable.COLUMN_FRONT_INSTANCE_ID)).intValue()); + serviceReferenceAlarm.setBehindInstanceId(((Number)source.get(ServiceReferenceAlarmTable.COLUMN_BEHIND_INSTANCE_ID)).intValue()); + serviceReferenceAlarm.setFrontServiceId(((Number)source.get(ServiceReferenceAlarmTable.COLUMN_FRONT_SERVICE_ID)).intValue()); + serviceReferenceAlarm.setBehindServiceId(((Number)source.get(ServiceReferenceAlarmTable.COLUMN_BEHIND_SERVICE_ID)).intValue()); + serviceReferenceAlarm.setSourceValue(((Number)source.get(ServiceReferenceAlarmTable.COLUMN_SOURCE_VALUE)).intValue()); + + serviceReferenceAlarm.setAlarmType(((Number)source.get(ServiceReferenceAlarmTable.COLUMN_ALARM_TYPE)).intValue()); + serviceReferenceAlarm.setAlarmContent((String)source.get(ServiceReferenceAlarmTable.COLUMN_ALARM_CONTENT)); + + serviceReferenceAlarm.setLastTimeBucket(((Number)source.get(ServiceReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET)).longValue()); + return serviceReferenceAlarm; + } else { + return null; + } + } + + @Override public IndexRequestBuilder prepareBatchInsert(ServiceReferenceAlarm data) { + Map source = new HashMap<>(); + source.put(ServiceReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); + source.put(ServiceReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); + source.put(ServiceReferenceAlarmTable.COLUMN_FRONT_INSTANCE_ID, data.getFrontInstanceId()); + source.put(ServiceReferenceAlarmTable.COLUMN_BEHIND_INSTANCE_ID, data.getBehindInstanceId()); + source.put(ServiceReferenceAlarmTable.COLUMN_FRONT_SERVICE_ID, data.getFrontServiceId()); + source.put(ServiceReferenceAlarmTable.COLUMN_BEHIND_SERVICE_ID, data.getBehindServiceId()); + source.put(ServiceReferenceAlarmTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ServiceReferenceAlarmTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ServiceReferenceAlarmTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ServiceReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); + + return getClient().prepareIndex(ServiceReferenceAlarmTable.TABLE, data.getId()).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(ServiceReferenceAlarm data) { + Map source = new HashMap<>(); + source.put(ServiceReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); + source.put(ServiceReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); + source.put(ServiceReferenceAlarmTable.COLUMN_FRONT_INSTANCE_ID, data.getFrontInstanceId()); + source.put(ServiceReferenceAlarmTable.COLUMN_BEHIND_INSTANCE_ID, data.getBehindInstanceId()); + source.put(ServiceReferenceAlarmTable.COLUMN_FRONT_SERVICE_ID, data.getFrontServiceId()); + source.put(ServiceReferenceAlarmTable.COLUMN_BEHIND_SERVICE_ID, data.getBehindServiceId()); + source.put(ServiceReferenceAlarmTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ServiceReferenceAlarmTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ServiceReferenceAlarmTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ServiceReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); + + return getClient().prepareUpdate(ServiceReferenceAlarmTable.TABLE, data.getId()).setDoc(source); + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); + long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); + BulkByScrollResponse response = getClient().prepareDelete() + .filter(QueryBuilders.rangeQuery(ServiceReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) + .source(ServiceReferenceAlarmTable.TABLE) + .get(); + + long deleted = response.getDeleted(); + logger.info("Delete {} rows history from {} index.", deleted, ServiceReferenceAlarmTable.TABLE); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ServiceReferenceAlarmListEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ServiceReferenceAlarmListEsPersistenceDAO.java new file mode 100644 index 000000000..b3a8e4e5a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ServiceReferenceAlarmListEsPersistenceDAO.java @@ -0,0 +1,119 @@ +/* + * 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.storage.es.dao.alarm; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarmListTable; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceAlarmListEsPersistenceDAO extends EsDAO implements IServiceReferenceAlarmListPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ServiceReferenceAlarmListEsPersistenceDAO.class); + + public ServiceReferenceAlarmListEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public ServiceReferenceAlarmList get(String id) { + GetResponse getResponse = getClient().prepareGet(ServiceReferenceAlarmListTable.TABLE, id).get(); + if (getResponse.isExists()) { + ServiceReferenceAlarmList serviceReferenceAlarmList = new ServiceReferenceAlarmList(); + serviceReferenceAlarmList.setId(id); + Map source = getResponse.getSource(); + serviceReferenceAlarmList.setFrontApplicationId(((Number)source.get(ServiceReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID)).intValue()); + serviceReferenceAlarmList.setBehindApplicationId(((Number)source.get(ServiceReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID)).intValue()); + serviceReferenceAlarmList.setFrontInstanceId(((Number)source.get(ServiceReferenceAlarmListTable.COLUMN_FRONT_INSTANCE_ID)).intValue()); + serviceReferenceAlarmList.setBehindInstanceId(((Number)source.get(ServiceReferenceAlarmListTable.COLUMN_BEHIND_INSTANCE_ID)).intValue()); + serviceReferenceAlarmList.setFrontServiceId(((Number)source.get(ServiceReferenceAlarmListTable.COLUMN_FRONT_SERVICE_ID)).intValue()); + serviceReferenceAlarmList.setBehindServiceId(((Number)source.get(ServiceReferenceAlarmListTable.COLUMN_BEHIND_SERVICE_ID)).intValue()); + serviceReferenceAlarmList.setSourceValue(((Number)source.get(ServiceReferenceAlarmListTable.COLUMN_SOURCE_VALUE)).intValue()); + + serviceReferenceAlarmList.setAlarmType(((Number)source.get(ServiceReferenceAlarmListTable.COLUMN_ALARM_TYPE)).intValue()); + serviceReferenceAlarmList.setAlarmContent((String)source.get(ServiceReferenceAlarmListTable.COLUMN_ALARM_CONTENT)); + + serviceReferenceAlarmList.setTimeBucket(((Number)source.get(ServiceReferenceAlarmListTable.COLUMN_TIME_BUCKET)).longValue()); + return serviceReferenceAlarmList; + } else { + return null; + } + } + + @Override public IndexRequestBuilder prepareBatchInsert(ServiceReferenceAlarmList data) { + Map source = new HashMap<>(); + source.put(ServiceReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); + source.put(ServiceReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); + source.put(ServiceReferenceAlarmListTable.COLUMN_FRONT_INSTANCE_ID, data.getFrontInstanceId()); + source.put(ServiceReferenceAlarmListTable.COLUMN_BEHIND_INSTANCE_ID, data.getBehindInstanceId()); + source.put(ServiceReferenceAlarmListTable.COLUMN_FRONT_SERVICE_ID, data.getFrontServiceId()); + source.put(ServiceReferenceAlarmListTable.COLUMN_BEHIND_SERVICE_ID, data.getBehindServiceId()); + source.put(ServiceReferenceAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ServiceReferenceAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ServiceReferenceAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ServiceReferenceAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + + return getClient().prepareIndex(ServiceReferenceAlarmListTable.TABLE, data.getId()).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(ServiceReferenceAlarmList data) { + Map source = new HashMap<>(); + source.put(ServiceReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); + source.put(ServiceReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); + source.put(ServiceReferenceAlarmListTable.COLUMN_FRONT_INSTANCE_ID, data.getFrontInstanceId()); + source.put(ServiceReferenceAlarmListTable.COLUMN_BEHIND_INSTANCE_ID, data.getBehindInstanceId()); + source.put(ServiceReferenceAlarmListTable.COLUMN_FRONT_SERVICE_ID, data.getFrontServiceId()); + source.put(ServiceReferenceAlarmListTable.COLUMN_BEHIND_SERVICE_ID, data.getBehindServiceId()); + source.put(ServiceReferenceAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); + + source.put(ServiceReferenceAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); + source.put(ServiceReferenceAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); + + source.put(ServiceReferenceAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + + return getClient().prepareUpdate(ServiceReferenceAlarmListTable.TABLE, data.getId()).setDoc(source); + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); + long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); + BulkByScrollResponse response = getClient().prepareDelete() + .filter(QueryBuilders.rangeQuery(ServiceReferenceAlarmListTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) + .source(ServiceReferenceAlarmListTable.TABLE) + .get(); + + long deleted = response.getDeleted(); + logger.info("Delete {} rows history from {} index.", deleted, ServiceReferenceAlarmListTable.TABLE); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/AbstractApplicationMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/AbstractApplicationMetricEsPersistenceDAO.java new file mode 100644 index 000000000..55c66f7bd --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/AbstractApplicationMetricEsPersistenceDAO.java @@ -0,0 +1,102 @@ +/* + * 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.storage.es.dao.amp; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractApplicationMetricEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractApplicationMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return ApplicationMetricTable.COLUMN_TIME_BUCKET; + } + + @Override protected final ApplicationMetric esDataToStreamData(Map source) { + ApplicationMetric applicationMetric = new ApplicationMetric(); + applicationMetric.setId((String)source.get(ApplicationMetricTable.COLUMN_ID)); + applicationMetric.setMetricId((String)source.get(ApplicationMetricTable.COLUMN_METRIC_ID)); + + applicationMetric.setApplicationId(((Number)source.get(ApplicationMetricTable.COLUMN_APPLICATION_ID)).intValue()); + applicationMetric.setSourceValue(((Number)source.get(ApplicationMetricTable.COLUMN_SOURCE_VALUE)).intValue()); + + applicationMetric.setTransactionCalls(((Number)source.get(ApplicationMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); + applicationMetric.setTransactionErrorCalls(((Number)source.get(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); + applicationMetric.setTransactionDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); + applicationMetric.setTransactionErrorDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + applicationMetric.setBusinessTransactionCalls(((Number)source.get(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); + applicationMetric.setBusinessTransactionErrorCalls(((Number)source.get(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); + applicationMetric.setBusinessTransactionDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); + applicationMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + applicationMetric.setMqTransactionCalls(((Number)source.get(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); + applicationMetric.setMqTransactionErrorCalls(((Number)source.get(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); + applicationMetric.setMqTransactionDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); + applicationMetric.setMqTransactionErrorDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + applicationMetric.setSatisfiedCount(((Number)source.get(ApplicationMetricTable.COLUMN_SATISFIED_COUNT)).longValue()); + applicationMetric.setToleratingCount(((Number)source.get(ApplicationMetricTable.COLUMN_TOLERATING_COUNT)).longValue()); + applicationMetric.setFrustratedCount(((Number)source.get(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT)).longValue()); + applicationMetric.setTimeBucket(((Number)source.get(ApplicationMetricTable.COLUMN_TIME_BUCKET)).longValue()); + + return applicationMetric; + } + + @Override protected final Map esStreamDataToEsData(ApplicationMetric streamData) { + Map source = new HashMap<>(); + source.put(ApplicationMetricTable.COLUMN_ID, streamData.getId()); + source.put(ApplicationMetricTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(ApplicationMetricTable.COLUMN_APPLICATION_ID, streamData.getApplicationId()); + source.put(ApplicationMetricTable.COLUMN_SOURCE_VALUE, streamData.getSourceValue()); + + source.put(ApplicationMetricTable.COLUMN_TRANSACTION_CALLS, streamData.getTransactionCalls()); + source.put(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, streamData.getTransactionErrorCalls()); + source.put(ApplicationMetricTable.COLUMN_TRANSACTION_DURATION_SUM, streamData.getTransactionDurationSum()); + source.put(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, streamData.getTransactionErrorDurationSum()); + + source.put(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, streamData.getBusinessTransactionCalls()); + source.put(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, streamData.getBusinessTransactionErrorCalls()); + source.put(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, streamData.getBusinessTransactionDurationSum()); + source.put(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, streamData.getBusinessTransactionErrorDurationSum()); + + source.put(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_CALLS, streamData.getMqTransactionCalls()); + source.put(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, streamData.getMqTransactionErrorCalls()); + source.put(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, streamData.getMqTransactionDurationSum()); + source.put(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, streamData.getMqTransactionErrorDurationSum()); + + source.put(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, streamData.getSatisfiedCount()); + source.put(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, streamData.getToleratingCount()); + source.put(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, streamData.getFrustratedCount()); + source.put(ApplicationMetricTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/ApplicationDayMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/ApplicationDayMetricEsPersistenceDAO.java new file mode 100644 index 000000000..8d77c13e1 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/ApplicationDayMetricEsPersistenceDAO.java @@ -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.storage.es.dao.amp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationDayMetricEsPersistenceDAO extends AbstractApplicationMetricEsPersistenceDAO implements IApplicationDayMetricPersistenceDAO { + + public ApplicationDayMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/ApplicationHourMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/ApplicationHourMetricEsPersistenceDAO.java new file mode 100644 index 000000000..c7a21b617 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/ApplicationHourMetricEsPersistenceDAO.java @@ -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.storage.es.dao.amp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationHourMetricEsPersistenceDAO extends AbstractApplicationMetricEsPersistenceDAO implements IApplicationHourMetricPersistenceDAO { + + public ApplicationHourMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/ApplicationMinuteMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/ApplicationMinuteMetricEsPersistenceDAO.java new file mode 100644 index 000000000..8008e316b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/ApplicationMinuteMetricEsPersistenceDAO.java @@ -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.storage.es.dao.amp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationMinuteMetricEsPersistenceDAO extends AbstractApplicationMetricEsPersistenceDAO implements IApplicationMinuteMetricPersistenceDAO { + + public ApplicationMinuteMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/ApplicationMonthMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/ApplicationMonthMetricEsPersistenceDAO.java new file mode 100644 index 000000000..b644d3b40 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/amp/ApplicationMonthMetricEsPersistenceDAO.java @@ -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.storage.es.dao.amp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationMonthMetricEsPersistenceDAO extends AbstractApplicationMetricEsPersistenceDAO implements IApplicationMonthMetricPersistenceDAO { + + public ApplicationMonthMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/AbstractApplicationMappingEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/AbstractApplicationMappingEsPersistenceDAO.java new file mode 100644 index 000000000..4bea4052e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/AbstractApplicationMappingEsPersistenceDAO.java @@ -0,0 +1,63 @@ +/* + * 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.storage.es.dao.ampp; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractApplicationMappingEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractApplicationMappingEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return ApplicationMappingTable.COLUMN_TIME_BUCKET; + } + + @Override protected final ApplicationMapping esDataToStreamData(Map source) { + ApplicationMapping applicationMapping = new ApplicationMapping(); + applicationMapping.setId((String)source.get(ApplicationMappingTable.COLUMN_ID)); + applicationMapping.setMetricId((String)source.get(ApplicationMappingTable.COLUMN_METRIC_ID)); + + applicationMapping.setApplicationId(((Number)source.get(ApplicationMappingTable.COLUMN_APPLICATION_ID)).intValue()); + applicationMapping.setAddressId(((Number)source.get(ApplicationMappingTable.COLUMN_ADDRESS_ID)).intValue()); + applicationMapping.setTimeBucket(((Number)source.get(ApplicationMappingTable.COLUMN_TIME_BUCKET)).longValue()); + return applicationMapping; + } + + @Override protected final Map esStreamDataToEsData(ApplicationMapping streamData) { + Map source = new HashMap<>(); + source.put(ApplicationMappingTable.COLUMN_ID, streamData.getId()); + source.put(ApplicationMappingTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(ApplicationMappingTable.COLUMN_APPLICATION_ID, streamData.getApplicationId()); + source.put(ApplicationMappingTable.COLUMN_ADDRESS_ID, streamData.getAddressId()); + source.put(ApplicationMappingTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/ApplicationMappingDayEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/ApplicationMappingDayEsPersistenceDAO.java new file mode 100644 index 000000000..9d6e2b827 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/ApplicationMappingDayEsPersistenceDAO.java @@ -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.storage.es.dao.ampp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingDayEsPersistenceDAO extends AbstractApplicationMappingEsPersistenceDAO implements IApplicationMappingDayPersistenceDAO { + + public ApplicationMappingDayEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/ApplicationMappingHourEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/ApplicationMappingHourEsPersistenceDAO.java new file mode 100644 index 000000000..1d349ee20 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/ApplicationMappingHourEsPersistenceDAO.java @@ -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.storage.es.dao.ampp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingHourEsPersistenceDAO extends AbstractApplicationMappingEsPersistenceDAO implements IApplicationMappingHourPersistenceDAO { + + public ApplicationMappingHourEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/ApplicationMappingMinuteEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/ApplicationMappingMinuteEsPersistenceDAO.java new file mode 100644 index 000000000..41a950a5a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/ApplicationMappingMinuteEsPersistenceDAO.java @@ -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.storage.es.dao.ampp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingMinuteEsPersistenceDAO extends AbstractApplicationMappingEsPersistenceDAO implements IApplicationMappingMinutePersistenceDAO { + + public ApplicationMappingMinuteEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/ApplicationMappingMonthEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/ApplicationMappingMonthEsPersistenceDAO.java new file mode 100644 index 000000000..27855d353 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/ApplicationMappingMonthEsPersistenceDAO.java @@ -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.storage.es.dao.ampp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingMonthEsPersistenceDAO extends AbstractApplicationMappingEsPersistenceDAO implements IApplicationMappingMonthPersistenceDAO { + + public ApplicationMappingMonthEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/AbstractApplicationReferenceMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/AbstractApplicationReferenceMetricEsPersistenceDAO.java new file mode 100644 index 000000000..dbb6bb747 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/AbstractApplicationReferenceMetricEsPersistenceDAO.java @@ -0,0 +1,105 @@ +/* + * 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.storage.es.dao.armp; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractApplicationReferenceMetricEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractApplicationReferenceMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET; + } + + @Override protected final ApplicationReferenceMetric esDataToStreamData(Map source) { + ApplicationReferenceMetric applicationReferenceMetric = new ApplicationReferenceMetric(); + applicationReferenceMetric.setId((String)source.get(ApplicationReferenceMetricTable.COLUMN_ID)); + applicationReferenceMetric.setMetricId((String)source.get(ApplicationReferenceMetricTable.COLUMN_METRIC_ID)); + + applicationReferenceMetric.setFrontApplicationId(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID)).intValue()); + applicationReferenceMetric.setBehindApplicationId(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID)).intValue()); + applicationReferenceMetric.setSourceValue(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE)).intValue()); + + applicationReferenceMetric.setTransactionCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); + applicationReferenceMetric.setTransactionErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); + applicationReferenceMetric.setTransactionDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); + applicationReferenceMetric.setTransactionErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + applicationReferenceMetric.setBusinessTransactionCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); + applicationReferenceMetric.setBusinessTransactionErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); + applicationReferenceMetric.setBusinessTransactionDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); + applicationReferenceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + applicationReferenceMetric.setMqTransactionCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); + applicationReferenceMetric.setMqTransactionErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); + applicationReferenceMetric.setMqTransactionDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); + applicationReferenceMetric.setMqTransactionErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + applicationReferenceMetric.setSatisfiedCount(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT)).longValue()); + applicationReferenceMetric.setToleratingCount(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT)).longValue()); + applicationReferenceMetric.setFrustratedCount(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT)).longValue()); + + applicationReferenceMetric.setTimeBucket(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET)).longValue()); + return applicationReferenceMetric; + } + + @Override protected final Map esStreamDataToEsData(ApplicationReferenceMetric streamData) { + Map source = new HashMap<>(); + source.put(ApplicationReferenceMetricTable.COLUMN_ID, streamData.getId()); + source.put(ApplicationReferenceMetricTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, streamData.getFrontApplicationId()); + source.put(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, streamData.getBehindApplicationId()); + source.put(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, streamData.getSourceValue()); + + source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS, streamData.getTransactionCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, streamData.getTransactionErrorCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, streamData.getTransactionDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, streamData.getTransactionErrorDurationSum()); + + source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, streamData.getBusinessTransactionCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, streamData.getBusinessTransactionErrorCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, streamData.getBusinessTransactionDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, streamData.getBusinessTransactionErrorDurationSum()); + + source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, streamData.getMqTransactionCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, streamData.getMqTransactionErrorCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, streamData.getMqTransactionDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, streamData.getMqTransactionErrorDurationSum()); + + source.put(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, streamData.getSatisfiedCount()); + source.put(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, streamData.getToleratingCount()); + source.put(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, streamData.getFrustratedCount()); + + source.put(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceDayMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceDayMetricEsPersistenceDAO.java new file mode 100644 index 000000000..457d53d57 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceDayMetricEsPersistenceDAO.java @@ -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.storage.es.dao.armp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceDayMetricEsPersistenceDAO extends AbstractApplicationReferenceMetricEsPersistenceDAO implements IApplicationReferenceDayMetricPersistenceDAO { + + public ApplicationReferenceDayMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceHourMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceHourMetricEsPersistenceDAO.java new file mode 100644 index 000000000..ca99be26a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceHourMetricEsPersistenceDAO.java @@ -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.storage.es.dao.armp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceHourMetricEsPersistenceDAO extends AbstractApplicationReferenceMetricEsPersistenceDAO implements IApplicationReferenceHourMetricPersistenceDAO { + + public ApplicationReferenceHourMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMinuteMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMinuteMetricEsPersistenceDAO.java new file mode 100644 index 000000000..39036c4aa --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMinuteMetricEsPersistenceDAO.java @@ -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.storage.es.dao.armp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMinuteMetricEsPersistenceDAO extends AbstractApplicationReferenceMetricEsPersistenceDAO implements IApplicationReferenceMinuteMetricPersistenceDAO { + + public ApplicationReferenceMinuteMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMonthMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMonthMetricEsPersistenceDAO.java new file mode 100644 index 000000000..46c1d0598 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMonthMetricEsPersistenceDAO.java @@ -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.storage.es.dao.armp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMonthMetricEsPersistenceDAO extends AbstractApplicationReferenceMetricEsPersistenceDAO implements IApplicationReferenceMonthMetricPersistenceDAO { + + public ApplicationReferenceMonthMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ApplicationEsCacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ApplicationEsCacheDAO.java new file mode 100644 index 000000000..6f98af3cf --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ApplicationEsCacheDAO.java @@ -0,0 +1,103 @@ +/* + * 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.storage.es.dao.cache; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable; +import org.elasticsearch.action.get.GetRequestBuilder; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ApplicationEsCacheDAO extends EsDAO implements IApplicationCacheDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationEsCacheDAO.class); + + public ApplicationEsCacheDAO(ElasticSearchClient client) { + super(client); + } + + @Override public int getApplicationIdByCode(String applicationCode) { + ElasticSearchClient client = getClient(); + + SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ApplicationTable.TABLE); + searchRequestBuilder.setTypes("type"); + searchRequestBuilder.setSearchType(SearchType.QUERY_THEN_FETCH); + + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); + boolQueryBuilder.must().add(QueryBuilders.termQuery(ApplicationTable.COLUMN_APPLICATION_CODE, applicationCode)); + boolQueryBuilder.must().add(QueryBuilders.termQuery(ApplicationTable.COLUMN_IS_ADDRESS, false)); + + searchRequestBuilder.setQuery(boolQueryBuilder); + searchRequestBuilder.setSize(1); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + if (searchResponse.getHits().totalHits > 0) { + SearchHit searchHit = searchResponse.getHits().iterator().next(); + return (int)searchHit.getSource().get(ApplicationTable.COLUMN_APPLICATION_ID); + } + return 0; + } + + @Override public String getApplicationCode(int applicationId) { + logger.debug("get application code, applicationId: {}", applicationId); + ElasticSearchClient client = getClient(); + GetRequestBuilder getRequestBuilder = client.prepareGet(ApplicationTable.TABLE, String.valueOf(applicationId)); + + GetResponse getResponse = getRequestBuilder.get(); + if (getResponse.isExists()) { + return (String)getResponse.getSource().get(ApplicationTable.COLUMN_APPLICATION_CODE); + } + return Const.EMPTY_STRING; + } + + @Override public int getApplicationIdByAddressId(int addressId) { + ElasticSearchClient client = getClient(); + + SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ApplicationTable.TABLE); + searchRequestBuilder.setTypes("type"); + searchRequestBuilder.setSearchType(SearchType.QUERY_THEN_FETCH); + + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); + boolQueryBuilder.must().add(QueryBuilders.termQuery(ApplicationTable.COLUMN_ADDRESS_ID, addressId)); + boolQueryBuilder.must().add(QueryBuilders.termQuery(ApplicationTable.COLUMN_IS_ADDRESS, true)); + + searchRequestBuilder.setQuery(boolQueryBuilder); + searchRequestBuilder.setSize(1); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + if (searchResponse.getHits().totalHits > 0) { + SearchHit searchHit = searchResponse.getHits().iterator().next(); + return (int)searchHit.getSource().get(ApplicationTable.COLUMN_APPLICATION_ID); + } + return 0; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsCacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/InstanceEsCacheDAO.java similarity index 67% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsCacheDAO.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/InstanceEsCacheDAO.java index a44a1ac81..185bd7769 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsCacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/InstanceEsCacheDAO.java @@ -16,11 +16,10 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.dao; +package org.apache.skywalking.apm.collector.storage.es.dao.cache; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IInstanceCacheDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; import org.elasticsearch.action.get.GetResponse; @@ -53,7 +52,7 @@ public class InstanceEsCacheDAO extends EsDAO implements IInstanceCacheDAO { } } - @Override public int getInstanceId(int applicationId, String agentUUID) { + @Override public int getInstanceIdByAgentUUID(int applicationId, String agentUUID) { ElasticSearchClient client = getClient(); SearchRequestBuilder searchRequestBuilder = client.prepareSearch(InstanceTable.TABLE); @@ -62,6 +61,28 @@ public class InstanceEsCacheDAO extends EsDAO implements IInstanceCacheDAO { BoolQueryBuilder builder = QueryBuilders.boolQuery(); builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationId)); builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_AGENT_UUID, agentUUID)); + builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, false)); + searchRequestBuilder.setQuery(builder); + searchRequestBuilder.setSize(1); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + if (searchResponse.getHits().totalHits > 0) { + SearchHit searchHit = searchResponse.getHits().iterator().next(); + return (int)searchHit.getSource().get(InstanceTable.COLUMN_INSTANCE_ID); + } + return 0; + } + + @Override public int getInstanceIdByAddressId(int applicationId, int addressId) { + ElasticSearchClient client = getClient(); + + SearchRequestBuilder searchRequestBuilder = client.prepareSearch(InstanceTable.TABLE); + searchRequestBuilder.setTypes("type"); + searchRequestBuilder.setSearchType(SearchType.QUERY_THEN_FETCH); + BoolQueryBuilder builder = QueryBuilders.boolQuery(); + builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationId)); + builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_ADDRESS_ID, addressId)); + builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, true)); searchRequestBuilder.setQuery(builder); searchRequestBuilder.setSize(1); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationEsCacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/NetworkAddressEsCacheDAO.java similarity index 69% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationEsCacheDAO.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/NetworkAddressEsCacheDAO.java index 99b5a00a9..a0d501668 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationEsCacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/NetworkAddressEsCacheDAO.java @@ -16,9 +16,13 @@ * */ +package org.apache.skywalking.apm.collector.storage.es.dao.cache; -package org.apache.skywalking.apm.collector.storage.es.dao; - +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.cache.INetworkAddressCacheDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddressTable; import org.elasticsearch.action.get.GetRequestBuilder; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.search.SearchRequestBuilder; @@ -26,50 +30,45 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationCacheDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ -public class ApplicationEsCacheDAO extends EsDAO implements IApplicationCacheDAO { +public class NetworkAddressEsCacheDAO extends EsDAO implements INetworkAddressCacheDAO { - private final Logger logger = LoggerFactory.getLogger(ApplicationEsCacheDAO.class); + private final Logger logger = LoggerFactory.getLogger(NetworkAddressEsCacheDAO.class); - public ApplicationEsCacheDAO(ElasticSearchClient client) { + public NetworkAddressEsCacheDAO(ElasticSearchClient client) { super(client); } - @Override public int getApplicationId(String applicationCode) { + @Override public int getAddressId(String networkAddress) { ElasticSearchClient client = getClient(); - SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ApplicationTable.TABLE); + SearchRequestBuilder searchRequestBuilder = client.prepareSearch(NetworkAddressTable.TABLE); searchRequestBuilder.setTypes("type"); searchRequestBuilder.setSearchType(SearchType.QUERY_THEN_FETCH); - searchRequestBuilder.setQuery(QueryBuilders.termQuery(ApplicationTable.COLUMN_APPLICATION_CODE, applicationCode)); + searchRequestBuilder.setQuery(QueryBuilders.termQuery(NetworkAddressTable.COLUMN_NETWORK_ADDRESS, networkAddress)); searchRequestBuilder.setSize(1); SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); if (searchResponse.getHits().totalHits > 0) { SearchHit searchHit = searchResponse.getHits().iterator().next(); - return (int)searchHit.getSource().get(ApplicationTable.COLUMN_APPLICATION_ID); + return (int)searchHit.getSource().get(NetworkAddressTable.COLUMN_ADDRESS_ID); } return 0; } - @Override public String getApplicationCode(int applicationId) { - logger.debug("get application code, applicationId: {}", applicationId); + @Override public String getAddress(int addressId) { + logger.debug("get network address, address id: {}", addressId); ElasticSearchClient client = getClient(); - GetRequestBuilder getRequestBuilder = client.prepareGet(ApplicationTable.TABLE, String.valueOf(applicationId)); + GetRequestBuilder getRequestBuilder = client.prepareGet(NetworkAddressTable.TABLE, String.valueOf(addressId)); GetResponse getResponse = getRequestBuilder.get(); if (getResponse.isExists()) { - return (String)getResponse.getSource().get(ApplicationTable.COLUMN_APPLICATION_CODE); + return (String)getResponse.getSource().get(NetworkAddressTable.COLUMN_NETWORK_ADDRESS); } return Const.EMPTY_STRING; } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceNameEsCacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ServiceNameEsCacheDAO.java similarity index 95% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceNameEsCacheDAO.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ServiceNameEsCacheDAO.java index 1e26967f3..5a4fb8aef 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceNameEsCacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ServiceNameEsCacheDAO.java @@ -16,12 +16,11 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.dao; +package org.apache.skywalking.apm.collector.storage.es.dao.cache; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable; import org.elasticsearch.action.get.GetRequestBuilder; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/AbstractCpuMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/AbstractCpuMetricEsPersistenceDAO.java new file mode 100644 index 000000000..33ce89121 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/AbstractCpuMetricEsPersistenceDAO.java @@ -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.storage.es.dao.cpump; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractCpuMetricEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractCpuMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return CpuMetricTable.COLUMN_TIME_BUCKET; + } + + @Override protected final CpuMetric esDataToStreamData(Map source) { + CpuMetric cpuMetric = new CpuMetric(); + cpuMetric.setId((String)source.get(CpuMetricTable.COLUMN_ID)); + cpuMetric.setMetricId((String)source.get(CpuMetricTable.COLUMN_METRIC_ID)); + + cpuMetric.setInstanceId(((Number)source.get(CpuMetricTable.COLUMN_INSTANCE_ID)).intValue()); + + cpuMetric.setUsagePercent(((Number)source.get(CpuMetricTable.COLUMN_USAGE_PERCENT)).doubleValue()); + cpuMetric.setTimes(((Number)source.get(CpuMetricTable.COLUMN_TIMES)).longValue()); + cpuMetric.setTimeBucket(((Number)source.get(CpuMetricTable.COLUMN_TIME_BUCKET)).longValue()); + + return cpuMetric; + } + + @Override protected final Map esStreamDataToEsData(CpuMetric streamData) { + Map source = new HashMap<>(); + source.put(CpuMetricTable.COLUMN_ID, streamData.getId()); + source.put(CpuMetricTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(CpuMetricTable.COLUMN_INSTANCE_ID, streamData.getInstanceId()); + source.put(CpuMetricTable.COLUMN_USAGE_PERCENT, streamData.getUsagePercent()); + source.put(CpuMetricTable.COLUMN_TIMES, streamData.getTimes()); + source.put(CpuMetricTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuDayMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuDayMetricEsPersistenceDAO.java new file mode 100644 index 000000000..3ddb77e8e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuDayMetricEsPersistenceDAO.java @@ -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.storage.es.dao.cpump; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class CpuDayMetricEsPersistenceDAO extends AbstractCpuMetricEsPersistenceDAO implements ICpuDayMetricPersistenceDAO { + + public CpuDayMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return CpuMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuHourMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuHourMetricEsPersistenceDAO.java new file mode 100644 index 000000000..fc46b8b29 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuHourMetricEsPersistenceDAO.java @@ -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.storage.es.dao.cpump; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class CpuHourMetricEsPersistenceDAO extends AbstractCpuMetricEsPersistenceDAO implements ICpuHourMetricPersistenceDAO { + + public CpuHourMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return CpuMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuMinuteMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuMinuteMetricEsPersistenceDAO.java new file mode 100644 index 000000000..02e2cdda2 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuMinuteMetricEsPersistenceDAO.java @@ -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.storage.es.dao.cpump; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class CpuMinuteMetricEsPersistenceDAO extends AbstractCpuMetricEsPersistenceDAO implements ICpuMinuteMetricPersistenceDAO { + + public CpuMinuteMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return CpuMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuMonthMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuMonthMetricEsPersistenceDAO.java new file mode 100644 index 000000000..1a69fe165 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuMonthMetricEsPersistenceDAO.java @@ -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.storage.es.dao.cpump; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class CpuMonthMetricEsPersistenceDAO extends AbstractCpuMetricEsPersistenceDAO implements ICpuMonthMetricPersistenceDAO { + + public CpuMonthMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return CpuMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuSecondMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuSecondMetricEsPersistenceDAO.java new file mode 100644 index 000000000..78850b191 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuSecondMetricEsPersistenceDAO.java @@ -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.storage.es.dao.cpump; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class CpuSecondMetricEsPersistenceDAO extends AbstractCpuMetricEsPersistenceDAO implements ICpuSecondMetricPersistenceDAO { + + public CpuSecondMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return CpuMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Second.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/AbstractGCMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/AbstractGCMetricEsPersistenceDAO.java new file mode 100644 index 000000000..b87d5fb33 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/AbstractGCMetricEsPersistenceDAO.java @@ -0,0 +1,70 @@ +/* + * 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.storage.es.dao.gcmp; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractGCMetricEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractGCMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return GCMetricTable.COLUMN_TIME_BUCKET; + } + + @Override protected final GCMetric esDataToStreamData(Map source) { + GCMetric gcMetric = new GCMetric(); + gcMetric.setId((String)source.get(GCMetricTable.COLUMN_ID)); + gcMetric.setMetricId((String)source.get(GCMetricTable.COLUMN_METRIC_ID)); + + gcMetric.setInstanceId(((Number)source.get(GCMetricTable.COLUMN_INSTANCE_ID)).intValue()); + gcMetric.setPhrase(((Number)source.get(GCMetricTable.COLUMN_PHRASE)).intValue()); + + gcMetric.setCount(((Number)source.get(GCMetricTable.COLUMN_COUNT)).longValue()); + gcMetric.setTimes(((Number)source.get(GCMetricTable.COLUMN_TIMES)).longValue()); + + gcMetric.setTimeBucket(((Number)source.get(GCMetricTable.COLUMN_TIME_BUCKET)).longValue()); + + return gcMetric; + } + + @Override protected final Map esStreamDataToEsData(GCMetric streamData) { + Map source = new HashMap<>(); + source.put(GCMetricTable.COLUMN_ID, streamData.getId()); + source.put(GCMetricTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(GCMetricTable.COLUMN_INSTANCE_ID, streamData.getInstanceId()); + source.put(GCMetricTable.COLUMN_PHRASE, streamData.getPhrase()); + source.put(GCMetricTable.COLUMN_COUNT, streamData.getCount()); + source.put(GCMetricTable.COLUMN_TIMES, streamData.getTimes()); + source.put(GCMetricTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCDayMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCDayMetricEsPersistenceDAO.java new file mode 100644 index 000000000..213a937ef --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCDayMetricEsPersistenceDAO.java @@ -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.storage.es.dao.gcmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class GCDayMetricEsPersistenceDAO extends AbstractGCMetricEsPersistenceDAO implements IGCDayMetricPersistenceDAO { + + public GCDayMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return GCMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCHourMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCHourMetricEsPersistenceDAO.java new file mode 100644 index 000000000..6ed12489b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCHourMetricEsPersistenceDAO.java @@ -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.storage.es.dao.gcmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class GCHourMetricEsPersistenceDAO extends AbstractGCMetricEsPersistenceDAO implements IGCHourMetricPersistenceDAO { + + public GCHourMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return GCMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCMinuteMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCMinuteMetricEsPersistenceDAO.java new file mode 100644 index 000000000..1a7fbfaaf --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCMinuteMetricEsPersistenceDAO.java @@ -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.storage.es.dao.gcmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class GCMinuteMetricEsPersistenceDAO extends AbstractGCMetricEsPersistenceDAO implements IGCMinuteMetricPersistenceDAO { + + public GCMinuteMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return GCMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCMonthMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCMonthMetricEsPersistenceDAO.java new file mode 100644 index 000000000..7b09af017 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCMonthMetricEsPersistenceDAO.java @@ -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.storage.es.dao.gcmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class GCMonthMetricEsPersistenceDAO extends AbstractGCMetricEsPersistenceDAO implements IGCMonthMetricPersistenceDAO { + + public GCMonthMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return GCMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCSecondMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCSecondMetricEsPersistenceDAO.java new file mode 100644 index 000000000..92da1c5b5 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/gcmp/GCSecondMetricEsPersistenceDAO.java @@ -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.storage.es.dao.gcmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class GCSecondMetricEsPersistenceDAO extends AbstractGCMetricEsPersistenceDAO implements IGCSecondMetricPersistenceDAO { + + public GCSecondMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return GCMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Second.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/AbstractInstanceMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/AbstractInstanceMetricEsPersistenceDAO.java new file mode 100644 index 000000000..626545de6 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/AbstractInstanceMetricEsPersistenceDAO.java @@ -0,0 +1,99 @@ +/* + * 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.storage.es.dao.imp; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractInstanceMetricEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractInstanceMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return InstanceMetricTable.COLUMN_TIME_BUCKET; + } + + @Override protected final InstanceMetric esDataToStreamData(Map source) { + InstanceMetric instanceMetric = new InstanceMetric(); + + instanceMetric.setId((String)source.get(InstanceMetricTable.COLUMN_ID)); + instanceMetric.setMetricId((String)source.get(InstanceMetricTable.COLUMN_METRIC_ID)); + instanceMetric.setApplicationId((Integer)source.get(InstanceMetricTable.COLUMN_APPLICATION_ID)); + instanceMetric.setInstanceId((Integer)source.get(InstanceMetricTable.COLUMN_INSTANCE_ID)); + instanceMetric.setSourceValue((Integer)source.get(InstanceMetricTable.COLUMN_SOURCE_VALUE)); + + instanceMetric.setTransactionCalls(((Number)source.get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); + instanceMetric.setTransactionErrorCalls(((Number)source.get(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); + instanceMetric.setTransactionDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); + instanceMetric.setTransactionErrorDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + instanceMetric.setBusinessTransactionCalls(((Number)source.get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); + instanceMetric.setBusinessTransactionErrorCalls(((Number)source.get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); + instanceMetric.setBusinessTransactionDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); + instanceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + instanceMetric.setMqTransactionCalls(((Number)source.get(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); + instanceMetric.setMqTransactionErrorCalls(((Number)source.get(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); + instanceMetric.setMqTransactionDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); + instanceMetric.setMqTransactionErrorDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + instanceMetric.setTimeBucket(((Number)source.get(InstanceMetricTable.COLUMN_TIME_BUCKET)).longValue()); + return instanceMetric; + } + + @Override protected final Map esStreamDataToEsData(InstanceMetric streamData) { + Map source = new HashMap<>(); + source.put(InstanceMetricTable.COLUMN_ID, streamData.getId()); + source.put(InstanceMetricTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(InstanceMetricTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(InstanceMetricTable.COLUMN_APPLICATION_ID, streamData.getApplicationId()); + source.put(InstanceMetricTable.COLUMN_INSTANCE_ID, streamData.getInstanceId()); + source.put(InstanceMetricTable.COLUMN_SOURCE_VALUE, streamData.getSourceValue()); + + source.put(InstanceMetricTable.COLUMN_TRANSACTION_CALLS, streamData.getTransactionCalls()); + source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, streamData.getTransactionErrorCalls()); + source.put(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, streamData.getTransactionDurationSum()); + source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, streamData.getTransactionErrorDurationSum()); + + source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, streamData.getBusinessTransactionCalls()); + source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, streamData.getBusinessTransactionErrorCalls()); + source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, streamData.getBusinessTransactionDurationSum()); + source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, streamData.getBusinessTransactionErrorDurationSum()); + + source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, streamData.getMqTransactionCalls()); + source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, streamData.getMqTransactionErrorCalls()); + source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, streamData.getMqTransactionDurationSum()); + source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, streamData.getMqTransactionErrorDurationSum()); + + source.put(InstanceMetricTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/InstanceDayMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/InstanceDayMetricEsPersistenceDAO.java new file mode 100644 index 000000000..ae46e6e56 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/InstanceDayMetricEsPersistenceDAO.java @@ -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.storage.es.dao.imp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class InstanceDayMetricEsPersistenceDAO extends AbstractInstanceMetricEsPersistenceDAO implements IInstanceDayMetricPersistenceDAO { + + public InstanceDayMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return InstanceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/InstanceHourMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/InstanceHourMetricEsPersistenceDAO.java new file mode 100644 index 000000000..22146814c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/InstanceHourMetricEsPersistenceDAO.java @@ -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.storage.es.dao.imp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class InstanceHourMetricEsPersistenceDAO extends AbstractInstanceMetricEsPersistenceDAO implements IInstanceHourMetricPersistenceDAO { + + public InstanceHourMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return InstanceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/InstanceMinuteMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/InstanceMinuteMetricEsPersistenceDAO.java new file mode 100644 index 000000000..6f3027678 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/InstanceMinuteMetricEsPersistenceDAO.java @@ -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.storage.es.dao.imp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class InstanceMinuteMetricEsPersistenceDAO extends AbstractInstanceMetricEsPersistenceDAO implements IInstanceMinuteMetricPersistenceDAO { + + public InstanceMinuteMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return InstanceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/InstanceMonthMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/InstanceMonthMetricEsPersistenceDAO.java new file mode 100644 index 000000000..d34e7ea03 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/imp/InstanceMonthMetricEsPersistenceDAO.java @@ -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.storage.es.dao.imp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class InstanceMonthMetricEsPersistenceDAO extends AbstractInstanceMetricEsPersistenceDAO implements IInstanceMonthMetricPersistenceDAO { + + public InstanceMonthMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return InstanceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/AbstractInstanceMappingEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/AbstractInstanceMappingEsPersistenceDAO.java new file mode 100644 index 000000000..76372ef11 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/AbstractInstanceMappingEsPersistenceDAO.java @@ -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.storage.es.dao.impp; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractInstanceMappingEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractInstanceMappingEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return InstanceMappingTable.COLUMN_TIME_BUCKET; + } + + @Override protected final InstanceMapping esDataToStreamData(Map source) { + InstanceMapping instanceMapping = new InstanceMapping(); + instanceMapping.setId((String)source.get(InstanceMappingTable.COLUMN_ID)); + instanceMapping.setMetricId((String)source.get(InstanceMappingTable.COLUMN_METRIC_ID)); + + instanceMapping.setApplicationId(((Number)source.get(InstanceMappingTable.COLUMN_APPLICATION_ID)).intValue()); + instanceMapping.setInstanceId(((Number)source.get(InstanceMappingTable.COLUMN_INSTANCE_ID)).intValue()); + instanceMapping.setAddressId(((Number)source.get(InstanceMappingTable.COLUMN_ADDRESS_ID)).intValue()); + instanceMapping.setTimeBucket(((Number)source.get(InstanceMappingTable.COLUMN_TIME_BUCKET)).longValue()); + return instanceMapping; + } + + @Override protected final Map esStreamDataToEsData(InstanceMapping streamData) { + Map source = new HashMap<>(); + source.put(InstanceMappingTable.COLUMN_ID, streamData.getId()); + source.put(InstanceMappingTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(InstanceMappingTable.COLUMN_APPLICATION_ID, streamData.getApplicationId()); + source.put(InstanceMappingTable.COLUMN_INSTANCE_ID, streamData.getInstanceId()); + source.put(InstanceMappingTable.COLUMN_ADDRESS_ID, streamData.getAddressId()); + source.put(InstanceMappingTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/InstanceMappingDayEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/InstanceMappingDayEsPersistenceDAO.java new file mode 100644 index 000000000..e1d7dcf92 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/InstanceMappingDayEsPersistenceDAO.java @@ -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.storage.es.dao.impp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingDayEsPersistenceDAO extends AbstractInstanceMappingEsPersistenceDAO implements IInstanceMappingDayPersistenceDAO { + + public InstanceMappingDayEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return InstanceMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/InstanceMappingHourEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/InstanceMappingHourEsPersistenceDAO.java new file mode 100644 index 000000000..0a17c6491 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/InstanceMappingHourEsPersistenceDAO.java @@ -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.storage.es.dao.impp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingHourEsPersistenceDAO extends AbstractInstanceMappingEsPersistenceDAO implements IInstanceMappingHourPersistenceDAO { + + public InstanceMappingHourEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return InstanceMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/InstanceMappingMinuteEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/InstanceMappingMinuteEsPersistenceDAO.java new file mode 100644 index 000000000..613a9b0a5 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/InstanceMappingMinuteEsPersistenceDAO.java @@ -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.storage.es.dao.impp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingMinuteEsPersistenceDAO extends AbstractInstanceMappingEsPersistenceDAO implements IInstanceMappingMinutePersistenceDAO { + + public InstanceMappingMinuteEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return InstanceMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/InstanceMappingMonthEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/InstanceMappingMonthEsPersistenceDAO.java new file mode 100644 index 000000000..04d0bd1aa --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/impp/InstanceMappingMonthEsPersistenceDAO.java @@ -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.storage.es.dao.impp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingMonthEsPersistenceDAO extends AbstractInstanceMappingEsPersistenceDAO implements IInstanceMappingMonthPersistenceDAO { + + public InstanceMappingMonthEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return InstanceMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/AbstractInstanceReferenceMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/AbstractInstanceReferenceMetricEsPersistenceDAO.java new file mode 100644 index 000000000..fbabc2d42 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/AbstractInstanceReferenceMetricEsPersistenceDAO.java @@ -0,0 +1,101 @@ +/* + * 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.storage.es.dao.irmp; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractInstanceReferenceMetricEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractInstanceReferenceMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return InstanceReferenceMetricTable.COLUMN_TIME_BUCKET; + } + + @Override protected final InstanceReferenceMetric esDataToStreamData(Map source) { + InstanceReferenceMetric instanceReferenceMetric = new InstanceReferenceMetric(); + instanceReferenceMetric.setId((String)source.get(InstanceReferenceMetricTable.COLUMN_ID)); + instanceReferenceMetric.setMetricId((String)source.get(InstanceReferenceMetricTable.COLUMN_METRIC_ID)); + + instanceReferenceMetric.setFrontApplicationId((Integer)source.get(InstanceReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID)); + instanceReferenceMetric.setBehindApplicationId((Integer)source.get(InstanceReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID)); + instanceReferenceMetric.setFrontInstanceId((Integer)source.get(InstanceReferenceMetricTable.COLUMN_FRONT_INSTANCE_ID)); + instanceReferenceMetric.setBehindInstanceId((Integer)source.get(InstanceReferenceMetricTable.COLUMN_BEHIND_INSTANCE_ID)); + instanceReferenceMetric.setSourceValue((Integer)source.get(InstanceReferenceMetricTable.COLUMN_SOURCE_VALUE)); + + instanceReferenceMetric.setTransactionCalls(((Number)source.get(InstanceReferenceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); + instanceReferenceMetric.setTransactionErrorCalls(((Number)source.get(InstanceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); + instanceReferenceMetric.setTransactionDurationSum(((Number)source.get(InstanceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); + instanceReferenceMetric.setTransactionErrorDurationSum(((Number)source.get(InstanceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + instanceReferenceMetric.setBusinessTransactionCalls(((Number)source.get(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); + instanceReferenceMetric.setBusinessTransactionErrorCalls(((Number)source.get(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); + instanceReferenceMetric.setBusinessTransactionDurationSum(((Number)source.get(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); + instanceReferenceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + instanceReferenceMetric.setMqTransactionCalls(((Number)source.get(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); + instanceReferenceMetric.setMqTransactionErrorCalls(((Number)source.get(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); + instanceReferenceMetric.setMqTransactionDurationSum(((Number)source.get(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); + instanceReferenceMetric.setMqTransactionErrorDurationSum(((Number)source.get(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + instanceReferenceMetric.setTimeBucket(((Number)source.get(InstanceReferenceMetricTable.COLUMN_TIME_BUCKET)).longValue()); + return instanceReferenceMetric; + } + + @Override protected final Map esStreamDataToEsData(InstanceReferenceMetric streamData) { + Map source = new HashMap<>(); + source.put(InstanceReferenceMetricTable.COLUMN_ID, streamData.getId()); + source.put(InstanceReferenceMetricTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(InstanceReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, streamData.getFrontApplicationId()); + source.put(InstanceReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, streamData.getBehindApplicationId()); + source.put(InstanceReferenceMetricTable.COLUMN_FRONT_INSTANCE_ID, streamData.getFrontInstanceId()); + source.put(InstanceReferenceMetricTable.COLUMN_BEHIND_INSTANCE_ID, streamData.getBehindInstanceId()); + source.put(InstanceReferenceMetricTable.COLUMN_SOURCE_VALUE, streamData.getSourceValue()); + + source.put(InstanceReferenceMetricTable.COLUMN_TRANSACTION_CALLS, streamData.getTransactionCalls()); + source.put(InstanceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, streamData.getTransactionErrorCalls()); + source.put(InstanceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, streamData.getTransactionDurationSum()); + source.put(InstanceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, streamData.getTransactionErrorDurationSum()); + + source.put(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, streamData.getBusinessTransactionCalls()); + source.put(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, streamData.getBusinessTransactionErrorCalls()); + source.put(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, streamData.getBusinessTransactionDurationSum()); + source.put(InstanceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, streamData.getBusinessTransactionErrorDurationSum()); + + source.put(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, streamData.getMqTransactionCalls()); + source.put(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, streamData.getMqTransactionErrorCalls()); + source.put(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, streamData.getMqTransactionDurationSum()); + source.put(InstanceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, streamData.getMqTransactionErrorDurationSum()); + + source.put(InstanceReferenceMetricTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/InstanceReferenceDayMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/InstanceReferenceDayMetricEsPersistenceDAO.java new file mode 100644 index 000000000..c9eefd6e3 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/InstanceReferenceDayMetricEsPersistenceDAO.java @@ -0,0 +1,46 @@ +/* + * 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.storage.es.dao.irmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceDayMetricEsPersistenceDAO extends AbstractInstanceReferenceMetricEsPersistenceDAO implements IInstanceReferenceDayMetricPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceReferenceDayMetricEsPersistenceDAO.class); + + public InstanceReferenceDayMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return InstanceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/InstanceReferenceHourMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/InstanceReferenceHourMetricEsPersistenceDAO.java new file mode 100644 index 000000000..898557d01 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/InstanceReferenceHourMetricEsPersistenceDAO.java @@ -0,0 +1,46 @@ +/* + * 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.storage.es.dao.irmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceHourMetricEsPersistenceDAO extends AbstractInstanceReferenceMetricEsPersistenceDAO implements IInstanceReferenceHourMetricPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceReferenceHourMetricEsPersistenceDAO.class); + + public InstanceReferenceHourMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return InstanceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/InstanceReferenceMinuteMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/InstanceReferenceMinuteMetricEsPersistenceDAO.java new file mode 100644 index 000000000..85d43c2af --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/InstanceReferenceMinuteMetricEsPersistenceDAO.java @@ -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.storage.es.dao.irmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceMinuteMetricEsPersistenceDAO extends AbstractInstanceReferenceMetricEsPersistenceDAO implements IInstanceReferenceMinuteMetricPersistenceDAO { + + public InstanceReferenceMinuteMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return InstanceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/InstanceReferenceMonthMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/InstanceReferenceMonthMetricEsPersistenceDAO.java new file mode 100644 index 000000000..b9d763770 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/irmp/InstanceReferenceMonthMetricEsPersistenceDAO.java @@ -0,0 +1,46 @@ +/* + * 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.storage.es.dao.irmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceMonthMetricEsPersistenceDAO extends AbstractInstanceReferenceMetricEsPersistenceDAO implements IInstanceReferenceMonthMetricPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceReferenceMonthMetricEsPersistenceDAO.class); + + public InstanceReferenceMonthMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return InstanceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/AbstractMemoryMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/AbstractMemoryMetricEsPersistenceDAO.java new file mode 100644 index 000000000..d9d9ab175 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/AbstractMemoryMetricEsPersistenceDAO.java @@ -0,0 +1,75 @@ +/* + * 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.storage.es.dao.memorymp; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractMemoryMetricEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractMemoryMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return MemoryMetricTable.COLUMN_TIME_BUCKET; + } + + @Override protected final MemoryMetric esDataToStreamData(Map source) { + MemoryMetric memoryMetric = new MemoryMetric(); + memoryMetric.setId((String)source.get(MemoryMetricTable.COLUMN_ID)); + memoryMetric.setMetricId((String)source.get(MemoryMetricTable.COLUMN_METRIC_ID)); + + memoryMetric.setInstanceId(((Number)source.get(MemoryMetricTable.COLUMN_INSTANCE_ID)).intValue()); + memoryMetric.setIsHeap((Boolean)source.get(MemoryMetricTable.COLUMN_IS_HEAP)); + + memoryMetric.setInit(((Number)source.get(MemoryMetricTable.COLUMN_INIT)).longValue()); + memoryMetric.setMax(((Number)source.get(MemoryMetricTable.COLUMN_MAX)).longValue()); + memoryMetric.setUsed(((Number)source.get(MemoryMetricTable.COLUMN_USED)).longValue()); + memoryMetric.setCommitted(((Number)source.get(MemoryMetricTable.COLUMN_COMMITTED)).longValue()); + memoryMetric.setTimes(((Number)source.get(MemoryMetricTable.COLUMN_TIMES)).longValue()); + + memoryMetric.setTimeBucket(((Number)source.get(MemoryMetricTable.COLUMN_TIME_BUCKET)).longValue()); + return memoryMetric; + } + + @Override protected final Map esStreamDataToEsData(MemoryMetric streamData) { + Map source = new HashMap<>(); + source.put(MemoryMetricTable.COLUMN_ID, streamData.getId()); + source.put(MemoryMetricTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(MemoryMetricTable.COLUMN_INSTANCE_ID, streamData.getInstanceId()); + source.put(MemoryMetricTable.COLUMN_IS_HEAP, streamData.getIsHeap()); + source.put(MemoryMetricTable.COLUMN_INIT, streamData.getInit()); + source.put(MemoryMetricTable.COLUMN_MAX, streamData.getMax()); + source.put(MemoryMetricTable.COLUMN_USED, streamData.getUsed()); + source.put(MemoryMetricTable.COLUMN_COMMITTED, streamData.getCommitted()); + source.put(MemoryMetricTable.COLUMN_TIMES, streamData.getTimes()); + source.put(MemoryMetricTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemoryDayMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemoryDayMetricEsPersistenceDAO.java new file mode 100644 index 000000000..662f48179 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemoryDayMetricEsPersistenceDAO.java @@ -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.storage.es.dao.memorymp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class MemoryDayMetricEsPersistenceDAO extends AbstractMemoryMetricEsPersistenceDAO implements IMemoryDayMetricPersistenceDAO { + + public MemoryDayMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return MemoryMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemoryHourMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemoryHourMetricEsPersistenceDAO.java new file mode 100644 index 000000000..5d5e70dc1 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemoryHourMetricEsPersistenceDAO.java @@ -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.storage.es.dao.memorymp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class MemoryHourMetricEsPersistenceDAO extends AbstractMemoryMetricEsPersistenceDAO implements IMemoryHourMetricPersistenceDAO { + + public MemoryHourMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return MemoryMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemoryMinuteMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemoryMinuteMetricEsPersistenceDAO.java new file mode 100644 index 000000000..574b50300 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemoryMinuteMetricEsPersistenceDAO.java @@ -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.storage.es.dao.memorymp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class MemoryMinuteMetricEsPersistenceDAO extends AbstractMemoryMetricEsPersistenceDAO implements IMemoryMinuteMetricPersistenceDAO { + + public MemoryMinuteMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return MemoryMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemoryMonthMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemoryMonthMetricEsPersistenceDAO.java new file mode 100644 index 000000000..2f6e3317e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemoryMonthMetricEsPersistenceDAO.java @@ -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.storage.es.dao.memorymp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemoryMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class MemoryMonthMetricEsPersistenceDAO extends AbstractMemoryMetricEsPersistenceDAO implements IMemoryMonthMetricPersistenceDAO { + + public MemoryMonthMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return MemoryMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemorySecondMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemorySecondMetricEsPersistenceDAO.java new file mode 100644 index 000000000..4db96397a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/memorymp/MemorySecondMetricEsPersistenceDAO.java @@ -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.storage.es.dao.memorymp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemorySecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class MemorySecondMetricEsPersistenceDAO extends AbstractMemoryMetricEsPersistenceDAO implements IMemorySecondMetricPersistenceDAO { + + public MemorySecondMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return MemoryMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Second.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/AbstractMemoryPoolMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/AbstractMemoryPoolMetricEsPersistenceDAO.java new file mode 100644 index 000000000..cc2244100 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/AbstractMemoryPoolMetricEsPersistenceDAO.java @@ -0,0 +1,75 @@ +/* + * 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.storage.es.dao.mpoolmp; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractMemoryPoolMetricEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractMemoryPoolMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return MemoryPoolMetricTable.COLUMN_TIME_BUCKET; + } + + @Override protected final MemoryPoolMetric esDataToStreamData(Map source) { + MemoryPoolMetric memoryPoolMetric = new MemoryPoolMetric(); + memoryPoolMetric.setId((String)source.get(MemoryPoolMetricTable.COLUMN_ID)); + memoryPoolMetric.setMetricId((String)source.get(MemoryPoolMetricTable.COLUMN_METRIC_ID)); + + memoryPoolMetric.setInstanceId(((Number)source.get(MemoryPoolMetricTable.COLUMN_INSTANCE_ID)).intValue()); + memoryPoolMetric.setPoolType(((Number)source.get(MemoryPoolMetricTable.COLUMN_POOL_TYPE)).intValue()); + + memoryPoolMetric.setInit(((Number)source.get(MemoryPoolMetricTable.COLUMN_INIT)).longValue()); + memoryPoolMetric.setMax(((Number)source.get(MemoryPoolMetricTable.COLUMN_MAX)).longValue()); + memoryPoolMetric.setUsed(((Number)source.get(MemoryPoolMetricTable.COLUMN_USED)).longValue()); + memoryPoolMetric.setCommitted(((Number)source.get(MemoryPoolMetricTable.COLUMN_COMMITTED)).longValue()); + memoryPoolMetric.setTimes(((Number)source.get(MemoryPoolMetricTable.COLUMN_TIMES)).longValue()); + + memoryPoolMetric.setTimeBucket(((Number)source.get(MemoryPoolMetricTable.COLUMN_TIME_BUCKET)).longValue()); + return memoryPoolMetric; + } + + @Override protected final Map esStreamDataToEsData(MemoryPoolMetric streamData) { + Map source = new HashMap<>(); + source.put(MemoryPoolMetricTable.COLUMN_ID, streamData.getId()); + source.put(MemoryPoolMetricTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(MemoryPoolMetricTable.COLUMN_INSTANCE_ID, streamData.getInstanceId()); + source.put(MemoryPoolMetricTable.COLUMN_POOL_TYPE, streamData.getPoolType()); + source.put(MemoryPoolMetricTable.COLUMN_INIT, streamData.getInit()); + source.put(MemoryPoolMetricTable.COLUMN_MAX, streamData.getMax()); + source.put(MemoryPoolMetricTable.COLUMN_USED, streamData.getUsed()); + source.put(MemoryPoolMetricTable.COLUMN_COMMITTED, streamData.getCommitted()); + source.put(MemoryPoolMetricTable.COLUMN_TIMES, streamData.getTimes()); + source.put(MemoryPoolMetricTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolDayMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolDayMetricEsPersistenceDAO.java new file mode 100644 index 000000000..5a5657a0e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolDayMetricEsPersistenceDAO.java @@ -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.storage.es.dao.mpoolmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolDayMetricEsPersistenceDAO extends AbstractMemoryPoolMetricEsPersistenceDAO implements IMemoryPoolDayMetricPersistenceDAO { + + public MemoryPoolDayMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return MemoryPoolMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolHourMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolHourMetricEsPersistenceDAO.java new file mode 100644 index 000000000..83b5b4c8a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolHourMetricEsPersistenceDAO.java @@ -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.storage.es.dao.mpoolmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolHourMetricEsPersistenceDAO extends AbstractMemoryPoolMetricEsPersistenceDAO implements IMemoryPoolHourMetricPersistenceDAO { + + public MemoryPoolHourMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return MemoryPoolMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolMinuteMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolMinuteMetricEsPersistenceDAO.java new file mode 100644 index 000000000..877857bf2 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolMinuteMetricEsPersistenceDAO.java @@ -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.storage.es.dao.mpoolmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolMinuteMetricEsPersistenceDAO extends AbstractMemoryPoolMetricEsPersistenceDAO implements IMemoryPoolMinuteMetricPersistenceDAO { + + public MemoryPoolMinuteMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return MemoryPoolMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolMonthMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolMonthMetricEsPersistenceDAO.java new file mode 100644 index 000000000..41b2683f7 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolMonthMetricEsPersistenceDAO.java @@ -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.storage.es.dao.mpoolmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolMonthMetricEsPersistenceDAO extends AbstractMemoryPoolMetricEsPersistenceDAO implements IMemoryPoolMonthMetricPersistenceDAO { + + public MemoryPoolMonthMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return MemoryPoolMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolSecondMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolSecondMetricEsPersistenceDAO.java new file mode 100644 index 000000000..11e4e4b5e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/mpoolmp/MemoryPoolSecondMetricEsPersistenceDAO.java @@ -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.storage.es.dao.mpoolmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolSecondMetricEsPersistenceDAO extends AbstractMemoryPoolMetricEsPersistenceDAO implements IMemoryPoolSecondMetricPersistenceDAO { + + public MemoryPoolSecondMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return MemoryPoolMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Second.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationEsRegisterDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/ApplicationEsRegisterDAO.java similarity index 89% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationEsRegisterDAO.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/ApplicationEsRegisterDAO.java index 2add40521..ce962b73a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationEsRegisterDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/ApplicationEsRegisterDAO.java @@ -16,13 +16,12 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.dao; +package org.apache.skywalking.apm.collector.storage.es.dao.register; import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegisterDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.register.Application; import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable; @@ -56,6 +55,8 @@ public class ApplicationEsRegisterDAO extends EsDAO implements IApplicationRegis Map source = new HashMap<>(); source.put(ApplicationTable.COLUMN_APPLICATION_CODE, application.getApplicationCode()); source.put(ApplicationTable.COLUMN_APPLICATION_ID, application.getApplicationId()); + source.put(ApplicationTable.COLUMN_ADDRESS_ID, application.getAddressId()); + source.put(ApplicationTable.COLUMN_IS_ADDRESS, application.getIsAddress()); IndexResponse response = client.prepareIndex(ApplicationTable.TABLE, application.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get(); logger.debug("save application register info, application getId: {}, application code: {}, status: {}", application.getApplicationId(), application.getApplicationCode(), response.status().name()); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsRegisterDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/InstanceEsRegisterDAO.java similarity index 92% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsRegisterDAO.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/InstanceEsRegisterDAO.java index 52a7c094e..1d5619f85 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsRegisterDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/InstanceEsRegisterDAO.java @@ -16,13 +16,12 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.dao; +package org.apache.skywalking.apm.collector.storage.es.dao.register; import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; @@ -61,6 +60,8 @@ public class InstanceEsRegisterDAO extends EsDAO implements IInstanceRegisterDAO source.put(InstanceTable.COLUMN_REGISTER_TIME, instance.getRegisterTime()); source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, instance.getHeartBeatTime()); source.put(InstanceTable.COLUMN_OS_INFO, instance.getOsInfo()); + source.put(InstanceTable.COLUMN_ADDRESS_ID, instance.getAddressId()); + source.put(InstanceTable.COLUMN_IS_ADDRESS, instance.getIsAddress()); IndexResponse response = client.prepareIndex(InstanceTable.TABLE, instance.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get(); logger.debug("save instance register info, application getId: {}, agentUUID: {}, status: {}", instance.getApplicationId(), instance.getAgentUUID(), response.status().name()); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/NetworkAddressRegisterEsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/NetworkAddressRegisterEsDAO.java new file mode 100644 index 000000000..051a8ea30 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/NetworkAddressRegisterEsDAO.java @@ -0,0 +1,62 @@ +/* + * 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.storage.es.dao.register; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.dao.register.INetworkAddressRegisterDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddress; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddressTable; +import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.support.WriteRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class NetworkAddressRegisterEsDAO extends EsDAO implements INetworkAddressRegisterDAO { + + private final Logger logger = LoggerFactory.getLogger(NetworkAddressRegisterEsDAO.class); + + public NetworkAddressRegisterEsDAO(ElasticSearchClient client) { + super(client); + } + + @Override public int getMaxNetworkAddressId() { + return getMaxId(NetworkAddressTable.TABLE, NetworkAddressTable.COLUMN_ADDRESS_ID); + } + + @Override public int getMinNetworkAddressId() { + return getMinId(NetworkAddressTable.TABLE, NetworkAddressTable.COLUMN_ADDRESS_ID); + } + + @Override public void save(NetworkAddress networkAddress) { + logger.debug("save network address register info, address getId: {}, network address code: {}", networkAddress.getId(), networkAddress.getNetworkAddress()); + ElasticSearchClient client = getClient(); + Map source = new HashMap<>(); + source.put(NetworkAddressTable.COLUMN_NETWORK_ADDRESS, networkAddress.getNetworkAddress()); + source.put(NetworkAddressTable.COLUMN_ADDRESS_ID, networkAddress.getAddressId()); + + IndexResponse response = client.prepareIndex(NetworkAddressTable.TABLE, networkAddress.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get(); + logger.debug("save network address register info, address getId: {}, network address code: {}, status: {}", networkAddress.getAddressId(), networkAddress.getNetworkAddress(), response.status().name()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceNameEsRegisterDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/ServiceNameEsRegisterDAO.java similarity index 94% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceNameEsRegisterDAO.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/ServiceNameEsRegisterDAO.java index 483842cf9..1dc315f81 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceNameEsRegisterDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/ServiceNameEsRegisterDAO.java @@ -16,18 +16,17 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.dao; +package org.apache.skywalking.apm.collector.storage.es.dao.register; import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IServiceNameRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IServiceNameRegisterDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.support.WriteRequest; -import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/AbstractServiceMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/AbstractServiceMetricEsPersistenceDAO.java new file mode 100644 index 000000000..7ca567681 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/AbstractServiceMetricEsPersistenceDAO.java @@ -0,0 +1,99 @@ +/* + * 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.storage.es.dao.smp; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractServiceMetricEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractServiceMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return ServiceMetricTable.COLUMN_TIME_BUCKET; + } + + @Override protected final ServiceMetric esDataToStreamData(Map source) { + ServiceMetric serviceMetric = new ServiceMetric(); + serviceMetric.setId((String)source.get(ServiceMetricTable.COLUMN_ID)); + serviceMetric.setMetricId((String)source.get(ServiceMetricTable.COLUMN_METRIC_ID)); + + serviceMetric.setApplicationId(((Number)source.get(ServiceMetricTable.COLUMN_APPLICATION_ID)).intValue()); + serviceMetric.setInstanceId(((Number)source.get(ServiceMetricTable.COLUMN_INSTANCE_ID)).intValue()); + serviceMetric.setServiceId(((Number)source.get(ServiceMetricTable.COLUMN_SERVICE_ID)).intValue()); + serviceMetric.setSourceValue(((Number)source.get(ServiceMetricTable.COLUMN_SOURCE_VALUE)).intValue()); + + serviceMetric.setTransactionCalls(((Number)source.get(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); + serviceMetric.setTransactionErrorCalls(((Number)source.get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); + serviceMetric.setTransactionDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); + serviceMetric.setTransactionErrorDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + serviceMetric.setBusinessTransactionCalls(((Number)source.get(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); + serviceMetric.setBusinessTransactionErrorCalls(((Number)source.get(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); + serviceMetric.setBusinessTransactionDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); + serviceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + serviceMetric.setMqTransactionCalls(((Number)source.get(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); + serviceMetric.setMqTransactionErrorCalls(((Number)source.get(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); + serviceMetric.setMqTransactionDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); + serviceMetric.setMqTransactionErrorDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + serviceMetric.setTimeBucket(((Number)source.get(ServiceMetricTable.COLUMN_TIME_BUCKET)).longValue()); + return serviceMetric; + } + + @Override protected final Map esStreamDataToEsData(ServiceMetric streamData) { + Map source = new HashMap<>(); + source.put(ServiceMetricTable.COLUMN_ID, streamData.getId()); + source.put(ServiceMetricTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(ServiceMetricTable.COLUMN_APPLICATION_ID, streamData.getApplicationId()); + source.put(ServiceMetricTable.COLUMN_INSTANCE_ID, streamData.getInstanceId()); + source.put(ServiceMetricTable.COLUMN_SERVICE_ID, streamData.getServiceId()); + source.put(ServiceMetricTable.COLUMN_SOURCE_VALUE, streamData.getSourceValue()); + + source.put(ServiceMetricTable.COLUMN_TRANSACTION_CALLS, streamData.getTransactionCalls()); + source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, streamData.getTransactionErrorCalls()); + source.put(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, streamData.getTransactionDurationSum()); + source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, streamData.getTransactionErrorDurationSum()); + + source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, streamData.getBusinessTransactionCalls()); + source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, streamData.getBusinessTransactionErrorCalls()); + source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, streamData.getBusinessTransactionDurationSum()); + source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, streamData.getBusinessTransactionErrorDurationSum()); + + source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, streamData.getMqTransactionCalls()); + source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, streamData.getMqTransactionErrorCalls()); + source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, streamData.getMqTransactionDurationSum()); + source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, streamData.getMqTransactionErrorDurationSum()); + + source.put(ServiceMetricTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/ServiceDayMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/ServiceDayMetricEsPersistenceDAO.java new file mode 100644 index 000000000..65213117e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/ServiceDayMetricEsPersistenceDAO.java @@ -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.storage.es.dao.smp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ServiceDayMetricEsPersistenceDAO extends AbstractServiceMetricEsPersistenceDAO implements IServiceDayMetricPersistenceDAO { + + public ServiceDayMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ServiceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/ServiceHourMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/ServiceHourMetricEsPersistenceDAO.java new file mode 100644 index 000000000..8ad29c970 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/ServiceHourMetricEsPersistenceDAO.java @@ -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.storage.es.dao.smp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ServiceHourMetricEsPersistenceDAO extends AbstractServiceMetricEsPersistenceDAO implements IServiceHourMetricPersistenceDAO { + + public ServiceHourMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ServiceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/ServiceMinuteMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/ServiceMinuteMetricEsPersistenceDAO.java new file mode 100644 index 000000000..13b3079d0 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/ServiceMinuteMetricEsPersistenceDAO.java @@ -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.storage.es.dao.smp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ServiceMinuteMetricEsPersistenceDAO extends AbstractServiceMetricEsPersistenceDAO implements IServiceMinuteMetricPersistenceDAO { + + public ServiceMinuteMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ServiceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/ServiceMonthMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/ServiceMonthMetricEsPersistenceDAO.java new file mode 100644 index 000000000..d94cce29d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/smp/ServiceMonthMetricEsPersistenceDAO.java @@ -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.storage.es.dao.smp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ServiceMonthMetricEsPersistenceDAO extends AbstractServiceMetricEsPersistenceDAO implements IServiceMonthMetricPersistenceDAO { + + public ServiceMonthMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ServiceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/AbstractServiceReferenceMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/AbstractServiceReferenceMetricEsPersistenceDAO.java new file mode 100644 index 000000000..564fb53ea --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/AbstractServiceReferenceMetricEsPersistenceDAO.java @@ -0,0 +1,105 @@ +/* + * 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.storage.es.dao.srmp; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractServiceReferenceMetricEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractServiceReferenceMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return ServiceReferenceMetricTable.COLUMN_TIME_BUCKET; + } + + @Override protected final ServiceReferenceMetric esDataToStreamData(Map source) { + ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(); + serviceReferenceMetric.setId((String)source.get(ServiceReferenceMetricTable.COLUMN_ID)); + serviceReferenceMetric.setMetricId((String)source.get(ServiceReferenceMetricTable.COLUMN_METRIC_ID)); + + serviceReferenceMetric.setFrontApplicationId(((Number)source.get(ServiceReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID)).intValue()); + serviceReferenceMetric.setBehindApplicationId(((Number)source.get(ServiceReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID)).intValue()); + serviceReferenceMetric.setFrontInstanceId(((Number)source.get(ServiceReferenceMetricTable.COLUMN_FRONT_INSTANCE_ID)).intValue()); + serviceReferenceMetric.setBehindInstanceId(((Number)source.get(ServiceReferenceMetricTable.COLUMN_BEHIND_INSTANCE_ID)).intValue()); + serviceReferenceMetric.setFrontServiceId(((Number)source.get(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)).intValue()); + serviceReferenceMetric.setBehindServiceId(((Number)source.get(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)).intValue()); + serviceReferenceMetric.setSourceValue(((Number)source.get(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE)).intValue()); + + serviceReferenceMetric.setTransactionCalls(((Number)source.get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); + serviceReferenceMetric.setTransactionErrorCalls(((Number)source.get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); + serviceReferenceMetric.setTransactionDurationSum(((Number)source.get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); + serviceReferenceMetric.setTransactionErrorDurationSum(((Number)source.get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + serviceReferenceMetric.setBusinessTransactionCalls(((Number)source.get(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); + serviceReferenceMetric.setBusinessTransactionErrorCalls(((Number)source.get(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); + serviceReferenceMetric.setBusinessTransactionDurationSum(((Number)source.get(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); + serviceReferenceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + serviceReferenceMetric.setMqTransactionCalls(((Number)source.get(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); + serviceReferenceMetric.setMqTransactionErrorCalls(((Number)source.get(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); + serviceReferenceMetric.setMqTransactionDurationSum(((Number)source.get(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); + serviceReferenceMetric.setMqTransactionErrorDurationSum(((Number)source.get(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + serviceReferenceMetric.setTimeBucket(((Number)source.get(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET)).longValue()); + return serviceReferenceMetric; + } + + @Override protected final Map esStreamDataToEsData(ServiceReferenceMetric streamData) { + Map source = new HashMap<>(); + source.put(ServiceReferenceMetricTable.COLUMN_ID, streamData.getId()); + source.put(ServiceReferenceMetricTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(ServiceReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, streamData.getFrontApplicationId()); + source.put(ServiceReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, streamData.getBehindApplicationId()); + source.put(ServiceReferenceMetricTable.COLUMN_FRONT_INSTANCE_ID, streamData.getFrontInstanceId()); + source.put(ServiceReferenceMetricTable.COLUMN_BEHIND_INSTANCE_ID, streamData.getBehindInstanceId()); + source.put(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, streamData.getFrontServiceId()); + source.put(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, streamData.getBehindServiceId()); + source.put(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE, streamData.getSourceValue()); + + source.put(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS, streamData.getTransactionCalls()); + source.put(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, streamData.getTransactionErrorCalls()); + source.put(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, streamData.getTransactionDurationSum()); + source.put(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, streamData.getTransactionErrorDurationSum()); + + source.put(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, streamData.getBusinessTransactionCalls()); + source.put(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, streamData.getBusinessTransactionErrorCalls()); + source.put(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, streamData.getBusinessTransactionDurationSum()); + source.put(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, streamData.getBusinessTransactionErrorDurationSum()); + + source.put(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, streamData.getMqTransactionCalls()); + source.put(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, streamData.getMqTransactionErrorCalls()); + source.put(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, streamData.getMqTransactionDurationSum()); + source.put(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, streamData.getMqTransactionErrorDurationSum()); + + source.put(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/ServiceReferenceDayMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/ServiceReferenceDayMetricEsPersistenceDAO.java new file mode 100644 index 000000000..262d362a5 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/ServiceReferenceDayMetricEsPersistenceDAO.java @@ -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.storage.es.dao.srmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceDayMetricEsPersistenceDAO extends AbstractServiceReferenceMetricEsPersistenceDAO implements IServiceReferenceDayMetricPersistenceDAO { + + public ServiceReferenceDayMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public String tableName() { + return ServiceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/ServiceReferenceHourMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/ServiceReferenceHourMetricEsPersistenceDAO.java new file mode 100644 index 000000000..2a71ca02e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/ServiceReferenceHourMetricEsPersistenceDAO.java @@ -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.storage.es.dao.srmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceHourMetricEsPersistenceDAO extends AbstractServiceReferenceMetricEsPersistenceDAO implements IServiceReferenceHourMetricPersistenceDAO { + + public ServiceReferenceHourMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public String tableName() { + return ServiceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/ServiceReferenceMinuteMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/ServiceReferenceMinuteMetricEsPersistenceDAO.java new file mode 100644 index 000000000..f0de6b14c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/ServiceReferenceMinuteMetricEsPersistenceDAO.java @@ -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.storage.es.dao.srmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceMinuteMetricEsPersistenceDAO extends AbstractServiceReferenceMetricEsPersistenceDAO implements IServiceReferenceMinuteMetricPersistenceDAO { + + public ServiceReferenceMinuteMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public String tableName() { + return ServiceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/ServiceReferenceMonthMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/ServiceReferenceMonthMetricEsPersistenceDAO.java new file mode 100644 index 000000000..74d64a683 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/srmp/ServiceReferenceMonthMetricEsPersistenceDAO.java @@ -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.storage.es.dao.srmp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceMonthMetricEsPersistenceDAO extends AbstractServiceReferenceMetricEsPersistenceDAO implements IServiceReferenceMonthMetricPersistenceDAO { + + public ServiceReferenceMonthMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override public String tableName() { + return ServiceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/GlobalTraceEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/GlobalTraceEsTableDefine.java index 60e0bb508..dd7233fcc 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/GlobalTraceEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/GlobalTraceEsTableDefine.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.define; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/SegmentEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/SegmentEsTableDefine.java index 14f261304..fbec27d9f 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/SegmentEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/SegmentEsTableDefine.java @@ -16,12 +16,11 @@ * */ - package org.apache.skywalking.apm.collector.storage.es.define; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentTable; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentTable; /** * @author peng-yongsheng diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ServiceEntryEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmEsTableDefine.java similarity index 54% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ServiceEntryEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmEsTableDefine.java index a779ebb3c..1c0cd6285 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ServiceEntryEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmEsTableDefine.java @@ -16,20 +16,19 @@ * */ +package org.apache.skywalking.apm.collector.storage.es.define.alarm; -package org.apache.skywalking.apm.collector.storage.es.define; - -import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmTable; /** * @author peng-yongsheng */ -public class ServiceEntryEsTableDefine extends ElasticSearchTableDefine { +public class ApplicationAlarmEsTableDefine extends ElasticSearchTableDefine { - public ServiceEntryEsTableDefine() { - super(ServiceEntryTable.TABLE); + public ApplicationAlarmEsTableDefine() { + super(ApplicationAlarmTable.TABLE); } @Override public int refreshInterval() { @@ -37,10 +36,13 @@ public class ServiceEntryEsTableDefine extends ElasticSearchTableDefine { } @Override public void initialize() { - addColumn(new ElasticSearchColumnDefine(ServiceEntryTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, ElasticSearchColumnDefine.Type.Text.name())); - addColumn(new ElasticSearchColumnDefine(ServiceEntryTable.COLUMN_REGISTER_TIME, ElasticSearchColumnDefine.Type.Long.name())); - addColumn(new ElasticSearchColumnDefine(ServiceEntryTable.COLUMN_NEWEST_TIME, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationAlarmTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationAlarmTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationAlarmTable.COLUMN_ALARM_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationAlarmTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationAlarmTable.COLUMN_LAST_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListEsTableDefine.java new file mode 100644 index 000000000..d89582079 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListEsTableDefine.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.storage.es.define.alarm; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListEsTableDefine extends ElasticSearchTableDefine { + + public ApplicationAlarmListEsTableDefine() { + super(ApplicationAlarmListTable.TABLE); + } + + @Override public int refreshInterval() { + return 2; + } + + @Override public void initialize() { + addColumn(new ElasticSearchColumnDefine(ApplicationAlarmListTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationAlarmListTable.COLUMN_ALARM_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationAlarmListTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationReferenceAlarmEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationReferenceAlarmEsTableDefine.java new file mode 100644 index 000000000..4f987d2cf --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationReferenceAlarmEsTableDefine.java @@ -0,0 +1,49 @@ +/* + * 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.storage.es.define.alarm; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarmTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceAlarmEsTableDefine extends ElasticSearchTableDefine { + + public ApplicationReferenceAlarmEsTableDefine() { + super(ApplicationReferenceAlarmTable.TABLE); + } + + @Override public int refreshInterval() { + return 2; + } + + @Override public void initialize() { + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceAlarmTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceAlarmTable.COLUMN_ALARM_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceAlarmTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationReferenceAlarmListEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationReferenceAlarmListEsTableDefine.java new file mode 100644 index 000000000..18c8e5438 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationReferenceAlarmListEsTableDefine.java @@ -0,0 +1,49 @@ +/* + * 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.storage.es.define.alarm; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceAlarmListEsTableDefine extends ElasticSearchTableDefine { + + public ApplicationReferenceAlarmListEsTableDefine() { + super(ApplicationReferenceAlarmListTable.TABLE); + } + + @Override public int refreshInterval() { + return 2; + } + + @Override public void initialize() { + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceAlarmListTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceAlarmListTable.COLUMN_ALARM_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceAlarmListTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceAlarmListTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/InstanceAlarmEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/InstanceAlarmEsTableDefine.java new file mode 100644 index 000000000..85949d0a1 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/InstanceAlarmEsTableDefine.java @@ -0,0 +1,49 @@ +/* + * 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.storage.es.define.alarm; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmTable; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmEsTableDefine extends ElasticSearchTableDefine { + + public InstanceAlarmEsTableDefine() { + super(InstanceAlarmTable.TABLE); + } + + @Override public int refreshInterval() { + return 2; + } + + @Override public void initialize() { + addColumn(new ElasticSearchColumnDefine(InstanceAlarmTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceAlarmTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(InstanceAlarmTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceAlarmTable.COLUMN_ALARM_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(InstanceAlarmTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); + + addColumn(new ElasticSearchColumnDefine(InstanceAlarmTable.COLUMN_LAST_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/InstanceAlarmListEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/InstanceAlarmListEsTableDefine.java new file mode 100644 index 000000000..824477361 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/InstanceAlarmListEsTableDefine.java @@ -0,0 +1,49 @@ +/* + * 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.storage.es.define.alarm; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmListEsTableDefine extends ElasticSearchTableDefine { + + public InstanceAlarmListEsTableDefine() { + super(InstanceAlarmListTable.TABLE); + } + + @Override public int refreshInterval() { + return 2; + } + + @Override public void initialize() { + addColumn(new ElasticSearchColumnDefine(InstanceAlarmListTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceAlarmListTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(InstanceAlarmListTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceAlarmListTable.COLUMN_ALARM_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(InstanceAlarmListTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); + + addColumn(new ElasticSearchColumnDefine(InstanceAlarmListTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/InstanceReferenceAlarmEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/InstanceReferenceAlarmEsTableDefine.java new file mode 100644 index 000000000..5199f7df6 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/InstanceReferenceAlarmEsTableDefine.java @@ -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.storage.es.define.alarm; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarmTable; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceAlarmEsTableDefine extends ElasticSearchTableDefine { + + public InstanceReferenceAlarmEsTableDefine() { + super(InstanceReferenceAlarmTable.TABLE); + } + + @Override public int refreshInterval() { + return 2; + } + + @Override public void initialize() { + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmTable.COLUMN_FRONT_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmTable.COLUMN_BEHIND_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmTable.COLUMN_ALARM_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); + + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/InstanceReferenceAlarmListEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/InstanceReferenceAlarmListEsTableDefine.java new file mode 100644 index 000000000..fd498054d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/InstanceReferenceAlarmListEsTableDefine.java @@ -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.storage.es.define.alarm; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceAlarmListEsTableDefine extends ElasticSearchTableDefine { + + public InstanceReferenceAlarmListEsTableDefine() { + super(InstanceReferenceAlarmListTable.TABLE); + } + + @Override public int refreshInterval() { + return 2; + } + + @Override public void initialize() { + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmListTable.COLUMN_FRONT_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmListTable.COLUMN_BEHIND_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmListTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmListTable.COLUMN_ALARM_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmListTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); + + addColumn(new ElasticSearchColumnDefine(InstanceReferenceAlarmListTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/AlertingListEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ServiceAlarmEsTableDefine.java similarity index 51% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/AlertingListEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ServiceAlarmEsTableDefine.java index facf9b1cb..21ffe65e0 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/AlertingListEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ServiceAlarmEsTableDefine.java @@ -16,20 +16,19 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.define; +package org.apache.skywalking.apm.collector.storage.es.define.alarm; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; -import org.apache.skywalking.apm.collector.storage.table.alerting.AlertingListTable; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarmTable; /** * @author peng-yongsheng */ -public class AlertingListEsTableDefine extends ElasticSearchTableDefine { +public class ServiceAlarmEsTableDefine extends ElasticSearchTableDefine { - public AlertingListEsTableDefine() { - super(AlertingListTable.TABLE); + public ServiceAlarmEsTableDefine() { + super(ServiceAlarmTable.TABLE); } @Override public int refreshInterval() { @@ -37,12 +36,15 @@ public class AlertingListEsTableDefine extends ElasticSearchTableDefine { } @Override public void initialize() { - addColumn(new ElasticSearchColumnDefine(AlertingListTable.COLUMN_LAYER, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(AlertingListTable.COLUMN_LAYER_ID, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(AlertingListTable.COLUMN_FIRST_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); - addColumn(new ElasticSearchColumnDefine(AlertingListTable.COLUMN_LAST_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); - addColumn(new ElasticSearchColumnDefine(AlertingListTable.COLUMN_EXPECTED, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(AlertingListTable.COLUMN_ACTUAL, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(AlertingListTable.COLUMN_VALID, ElasticSearchColumnDefine.Type.Boolean.name())); + addColumn(new ElasticSearchColumnDefine(ServiceAlarmTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceAlarmTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceAlarmTable.COLUMN_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ServiceAlarmTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceAlarmTable.COLUMN_ALARM_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ServiceAlarmTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); + + addColumn(new ElasticSearchColumnDefine(ServiceAlarmTable.COLUMN_LAST_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ServiceAlarmListEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ServiceAlarmListEsTableDefine.java new file mode 100644 index 000000000..eafa55b0a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ServiceAlarmListEsTableDefine.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.storage.es.define.alarm; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ServiceAlarmListEsTableDefine extends ElasticSearchTableDefine { + + public ServiceAlarmListEsTableDefine() { + super(ServiceAlarmListTable.TABLE); + } + + @Override public int refreshInterval() { + return 2; + } + + @Override public void initialize() { + addColumn(new ElasticSearchColumnDefine(ServiceAlarmListTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceAlarmListTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceAlarmListTable.COLUMN_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ServiceAlarmListTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceAlarmListTable.COLUMN_ALARM_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ServiceAlarmListTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); + + addColumn(new ElasticSearchColumnDefine(ServiceAlarmListTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ServiceReferenceAlarmEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ServiceReferenceAlarmEsTableDefine.java new file mode 100644 index 000000000..d6653b789 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ServiceReferenceAlarmEsTableDefine.java @@ -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.storage.es.define.alarm; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarmTable; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceAlarmEsTableDefine extends ElasticSearchTableDefine { + + public ServiceReferenceAlarmEsTableDefine() { + super(ServiceReferenceAlarmTable.TABLE); + } + + @Override public int refreshInterval() { + return 2; + } + + @Override public void initialize() { + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmTable.COLUMN_FRONT_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmTable.COLUMN_BEHIND_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmTable.COLUMN_FRONT_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmTable.COLUMN_BEHIND_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmTable.COLUMN_FRONT_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmTable.COLUMN_BEHIND_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmTable.COLUMN_ALARM_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); + + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmTable.COLUMN_LAST_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ServiceReferenceAlarmListEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ServiceReferenceAlarmListEsTableDefine.java new file mode 100644 index 000000000..dc5c8d356 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ServiceReferenceAlarmListEsTableDefine.java @@ -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.storage.es.define.alarm; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceAlarmListEsTableDefine extends ElasticSearchTableDefine { + + public ServiceReferenceAlarmListEsTableDefine() { + super(ServiceReferenceAlarmListTable.TABLE); + } + + @Override public int refreshInterval() { + return 2; + } + + @Override public void initialize() { + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmListTable.COLUMN_FRONT_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmListTable.COLUMN_BEHIND_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmListTable.COLUMN_FRONT_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmListTable.COLUMN_BEHIND_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmListTable.COLUMN_FRONT_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmListTable.COLUMN_BEHIND_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmListTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmListTable.COLUMN_ALARM_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmListTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); + + addColumn(new ElasticSearchColumnDefine(ServiceReferenceAlarmListTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/AbstractApplicationMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/AbstractApplicationMetricEsTableDefine.java new file mode 100644 index 000000000..3b8e36c05 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/AbstractApplicationMetricEsTableDefine.java @@ -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.storage.es.define.amp; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractApplicationMetricEsTableDefine extends ElasticSearchTableDefine { + + public AbstractApplicationMetricEsTableDefine(String name) { + super(name); + } + + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_TRANSACTION_CALLS, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_TRANSACTION_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_CALLS, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, ElasticSearchColumnDefine.Type.Long.name())); + + addColumn(new ElasticSearchColumnDefine(ApplicationMetricTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/ApplicationDayMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/ApplicationDayMetricEsTableDefine.java new file mode 100644 index 000000000..6885f6dad --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/ApplicationDayMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.amp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationDayMetricEsTableDefine extends AbstractApplicationMetricEsTableDefine { + + public ApplicationDayMetricEsTableDefine() { + super(ApplicationMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/ApplicationHourMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/ApplicationHourMetricEsTableDefine.java new file mode 100644 index 000000000..9f073c7c2 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/ApplicationHourMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.amp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationHourMetricEsTableDefine extends AbstractApplicationMetricEsTableDefine { + + public ApplicationHourMetricEsTableDefine() { + super(ApplicationMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/ApplicationMinuteMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/ApplicationMinuteMetricEsTableDefine.java new file mode 100644 index 000000000..f877ad9d4 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/ApplicationMinuteMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.amp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationMinuteMetricEsTableDefine extends AbstractApplicationMetricEsTableDefine { + + public ApplicationMinuteMetricEsTableDefine() { + super(ApplicationMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/ApplicationMonthMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/ApplicationMonthMetricEsTableDefine.java new file mode 100644 index 000000000..2c348fec8 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/amp/ApplicationMonthMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.amp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationMonthMetricEsTableDefine extends AbstractApplicationMetricEsTableDefine { + + public ApplicationMonthMetricEsTableDefine() { + super(ApplicationMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ApplicationComponentEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/AbstractApplicationComponentEsTableDefine.java similarity index 78% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ApplicationComponentEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/AbstractApplicationComponentEsTableDefine.java index 19f749880..1a7bb53d2 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ApplicationComponentEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/AbstractApplicationComponentEsTableDefine.java @@ -16,27 +16,23 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.define; +package org.apache.skywalking.apm.collector.storage.es.define.appcomp; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; /** * @author peng-yongsheng */ -public class ApplicationComponentEsTableDefine extends ElasticSearchTableDefine { +public abstract class AbstractApplicationComponentEsTableDefine extends ElasticSearchTableDefine { - public ApplicationComponentEsTableDefine() { - super(ApplicationComponentTable.TABLE); + AbstractApplicationComponentEsTableDefine(String name) { + super(name); } - @Override public int refreshInterval() { - return 2; - } - - @Override public void initialize() { + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(ApplicationComponentTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); addColumn(new ElasticSearchColumnDefine(ApplicationComponentTable.COLUMN_COMPONENT_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ApplicationComponentTable.COLUMN_PEER_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ApplicationComponentTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/ApplicationComponentDayEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/ApplicationComponentDayEsTableDefine.java new file mode 100644 index 000000000..2f8aee8f9 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/ApplicationComponentDayEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.appcomp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentDayEsTableDefine extends AbstractApplicationComponentEsTableDefine { + + public ApplicationComponentDayEsTableDefine() { + super(ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/ApplicationComponentHourEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/ApplicationComponentHourEsTableDefine.java new file mode 100644 index 000000000..5a41d1abb --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/ApplicationComponentHourEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.appcomp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentHourEsTableDefine extends AbstractApplicationComponentEsTableDefine { + + public ApplicationComponentHourEsTableDefine() { + super(ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/ApplicationComponentMinuteEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/ApplicationComponentMinuteEsTableDefine.java new file mode 100644 index 000000000..0fc4e3e35 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/ApplicationComponentMinuteEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.appcomp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentMinuteEsTableDefine extends AbstractApplicationComponentEsTableDefine { + + public ApplicationComponentMinuteEsTableDefine() { + super(ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/ApplicationComponentMonthEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/ApplicationComponentMonthEsTableDefine.java new file mode 100644 index 000000000..a4e1573ad --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/ApplicationComponentMonthEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.appcomp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentMonthEsTableDefine extends AbstractApplicationComponentEsTableDefine { + + public ApplicationComponentMonthEsTableDefine() { + super(ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ApplicationMappingEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/AbstractApplicationMappingEsTableDefine.java similarity index 78% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ApplicationMappingEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/AbstractApplicationMappingEsTableDefine.java index 8c900af7b..df044ef49 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ApplicationMappingEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/AbstractApplicationMappingEsTableDefine.java @@ -16,27 +16,23 @@ * */ +package org.apache.skywalking.apm.collector.storage.es.define.appmapping; -package org.apache.skywalking.apm.collector.storage.es.define; - -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; /** * @author peng-yongsheng */ -public class ApplicationMappingEsTableDefine extends ElasticSearchTableDefine { +public abstract class AbstractApplicationMappingEsTableDefine extends ElasticSearchTableDefine { - public ApplicationMappingEsTableDefine() { - super(ApplicationMappingTable.TABLE); + AbstractApplicationMappingEsTableDefine(String name) { + super(name); } - @Override public int refreshInterval() { - return 2; - } - - @Override public void initialize() { + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(ApplicationMappingTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); addColumn(new ElasticSearchColumnDefine(ApplicationMappingTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ApplicationMappingTable.COLUMN_ADDRESS_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ApplicationMappingTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/ApplicationMappingDayEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/ApplicationMappingDayEsTableDefine.java new file mode 100644 index 000000000..8e35df849 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/ApplicationMappingDayEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.appmapping; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingDayEsTableDefine extends AbstractApplicationMappingEsTableDefine { + + public ApplicationMappingDayEsTableDefine() { + super(ApplicationMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/ApplicationMappingHourEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/ApplicationMappingHourEsTableDefine.java new file mode 100644 index 000000000..3c7442e13 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/ApplicationMappingHourEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.appmapping; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingHourEsTableDefine extends AbstractApplicationMappingEsTableDefine { + + public ApplicationMappingHourEsTableDefine() { + super(ApplicationMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/ApplicationMappingMinuteEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/ApplicationMappingMinuteEsTableDefine.java new file mode 100644 index 000000000..a099f58db --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/ApplicationMappingMinuteEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.appmapping; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingMinuteEsTableDefine extends AbstractApplicationMappingEsTableDefine { + + public ApplicationMappingMinuteEsTableDefine() { + super(ApplicationMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/ApplicationMappingMonthEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/ApplicationMappingMonthEsTableDefine.java new file mode 100644 index 000000000..f6561f835 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/ApplicationMappingMonthEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.appmapping; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingMonthEsTableDefine extends AbstractApplicationMappingEsTableDefine { + + public ApplicationMappingMonthEsTableDefine() { + super(ApplicationMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ApplicationReferenceMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/AbstractApplicationReferenceMetricEsTableDefine.java similarity index 84% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ApplicationReferenceMetricEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/AbstractApplicationReferenceMetricEsTableDefine.java index 1568d59ff..aa3358512 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ApplicationReferenceMetricEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/AbstractApplicationReferenceMetricEsTableDefine.java @@ -16,8 +16,7 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.define; +package org.apache.skywalking.apm.collector.storage.es.define.armp; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; @@ -26,19 +25,18 @@ import org.apache.skywalking.apm.collector.storage.table.application.Application /** * @author peng-yongsheng */ -public class ApplicationReferenceMetricEsTableDefine extends ElasticSearchTableDefine { +public abstract class AbstractApplicationReferenceMetricEsTableDefine extends ElasticSearchTableDefine { - public ApplicationReferenceMetricEsTableDefine() { - super(ApplicationReferenceMetricTable.TABLE); + public AbstractApplicationReferenceMetricEsTableDefine(String name) { + super(name); } - @Override public int refreshInterval() { - return 2; - } - - @Override public void initialize() { + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name())); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/ApplicationReferenceDayMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/ApplicationReferenceDayMetricEsTableDefine.java new file mode 100644 index 000000000..3f297578a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/ApplicationReferenceDayMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.armp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceDayMetricEsTableDefine extends AbstractApplicationReferenceMetricEsTableDefine { + + public ApplicationReferenceDayMetricEsTableDefine() { + super(ApplicationReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/ApplicationReferenceHourMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/ApplicationReferenceHourMetricEsTableDefine.java new file mode 100644 index 000000000..6fde37dca --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/ApplicationReferenceHourMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.armp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceHourMetricEsTableDefine extends AbstractApplicationReferenceMetricEsTableDefine { + + public ApplicationReferenceHourMetricEsTableDefine() { + super(ApplicationReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/ApplicationReferenceMinuteMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/ApplicationReferenceMinuteMetricEsTableDefine.java new file mode 100644 index 000000000..a55ba6a26 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/ApplicationReferenceMinuteMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.armp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMinuteMetricEsTableDefine extends AbstractApplicationReferenceMetricEsTableDefine { + + public ApplicationReferenceMinuteMetricEsTableDefine() { + super(ApplicationReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/ApplicationReferenceMonthMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/ApplicationReferenceMonthMetricEsTableDefine.java new file mode 100644 index 000000000..7b241a931 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/armp/ApplicationReferenceMonthMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.armp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMonthMetricEsTableDefine extends AbstractApplicationReferenceMetricEsTableDefine { + + public ApplicationReferenceMonthMetricEsTableDefine() { + super(ApplicationReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/CpuMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/AbstractCpuMetricEsTableDefine.java similarity index 69% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/CpuMetricEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/AbstractCpuMetricEsTableDefine.java index 0179ddfb7..61b39134f 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/CpuMetricEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/AbstractCpuMetricEsTableDefine.java @@ -16,8 +16,7 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.define; +package org.apache.skywalking.apm.collector.storage.es.define.cpu; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; @@ -26,19 +25,18 @@ import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; /** * @author peng-yongsheng */ -public class CpuMetricEsTableDefine extends ElasticSearchTableDefine { +public abstract class AbstractCpuMetricEsTableDefine extends ElasticSearchTableDefine { - public CpuMetricEsTableDefine() { - super(CpuMetricTable.TABLE); + public AbstractCpuMetricEsTableDefine(String name) { + super(name); } - @Override public int refreshInterval() { - return 1; - } - - @Override public void initialize() { + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(CpuMetricTable.COLUMN_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(CpuMetricTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); addColumn(new ElasticSearchColumnDefine(CpuMetricTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(CpuMetricTable.COLUMN_USAGE_PERCENT, ElasticSearchColumnDefine.Type.Double.name())); + addColumn(new ElasticSearchColumnDefine(CpuMetricTable.COLUMN_TIMES, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(CpuMetricTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuDayMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuDayMetricEsTableDefine.java new file mode 100644 index 000000000..6ca9215b0 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuDayMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.cpu; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; + +/** + * @author peng-yongsheng + */ +public class CpuDayMetricEsTableDefine extends AbstractCpuMetricEsTableDefine { + + public CpuDayMetricEsTableDefine() { + super(CpuMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuHourMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuHourMetricEsTableDefine.java new file mode 100644 index 000000000..85d4cb32c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuHourMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.cpu; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; + +/** + * @author peng-yongsheng + */ +public class CpuHourMetricEsTableDefine extends AbstractCpuMetricEsTableDefine { + + public CpuHourMetricEsTableDefine() { + super(CpuMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuMinuteMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuMinuteMetricEsTableDefine.java new file mode 100644 index 000000000..37f9de474 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuMinuteMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.cpu; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; + +/** + * @author peng-yongsheng + */ +public class CpuMinuteMetricEsTableDefine extends AbstractCpuMetricEsTableDefine { + + public CpuMinuteMetricEsTableDefine() { + super(CpuMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuMonthMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuMonthMetricEsTableDefine.java new file mode 100644 index 000000000..017d988b7 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuMonthMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.cpu; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; + +/** + * @author peng-yongsheng + */ +public class CpuMonthMetricEsTableDefine extends AbstractCpuMetricEsTableDefine { + + public CpuMonthMetricEsTableDefine() { + super(CpuMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuSecondMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuSecondMetricEsTableDefine.java new file mode 100644 index 000000000..c84e89c07 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/cpu/CpuSecondMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.cpu; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; + +/** + * @author peng-yongsheng + */ +public class CpuSecondMetricEsTableDefine extends AbstractCpuMetricEsTableDefine { + + public CpuSecondMetricEsTableDefine() { + super(CpuMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Second.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/GCMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/AbstractGCMetricEsTableDefine.java similarity index 74% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/GCMetricEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/AbstractGCMetricEsTableDefine.java index 235eed56c..efbdc7fd0 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/GCMetricEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/AbstractGCMetricEsTableDefine.java @@ -16,31 +16,28 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.define; +package org.apache.skywalking.apm.collector.storage.es.define.gc; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; -import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; /** * @author peng-yongsheng */ -public class GCMetricEsTableDefine extends ElasticSearchTableDefine { +public abstract class AbstractGCMetricEsTableDefine extends ElasticSearchTableDefine { - public GCMetricEsTableDefine() { - super(GCMetricTable.TABLE); + public AbstractGCMetricEsTableDefine(String name) { + super(name); } - @Override public int refreshInterval() { - return 1; - } - - @Override public void initialize() { + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(GCMetricTable.COLUMN_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(GCMetricTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); addColumn(new ElasticSearchColumnDefine(GCMetricTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(GCMetricTable.COLUMN_PHRASE, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(GCMetricTable.COLUMN_COUNT, ElasticSearchColumnDefine.Type.Long.name())); - addColumn(new ElasticSearchColumnDefine(GCMetricTable.COLUMN_TIME, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(GCMetricTable.COLUMN_TIMES, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(GCMetricTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); } } diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/AbstractHashMessage.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCDayMetricEsTableDefine.java similarity index 61% rename from apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/AbstractHashMessage.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCDayMetricEsTableDefine.java index 51b9714da..7cc793382 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/AbstractHashMessage.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCDayMetricEsTableDefine.java @@ -16,29 +16,22 @@ * */ +package org.apache.skywalking.apm.collector.storage.es.define.gc; -package org.apache.skywalking.apm.collector.core.data; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; /** - * The AbstractHashMessage implementations represent aggregate message, - * which use to aggregate metric. - *

- * * @author peng-yongsheng - * @since v3.0-2017 */ -public abstract class AbstractHashMessage { - private int hashCode; +public class GCDayMetricEsTableDefine extends AbstractGCMetricEsTableDefine { - public AbstractHashMessage(String key) { - this.hashCode = key.hashCode(); + public GCDayMetricEsTableDefine() { + super(GCMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); } - public int getHashCode() { - return hashCode; - } - - public void setKey(String key) { - this.hashCode = key.hashCode(); + @Override public int refreshInterval() { + return 1; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCHourMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCHourMetricEsTableDefine.java new file mode 100644 index 000000000..d5bcbfc72 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCHourMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.gc; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; + +/** + * @author peng-yongsheng + */ +public class GCHourMetricEsTableDefine extends AbstractGCMetricEsTableDefine { + + public GCHourMetricEsTableDefine() { + super(GCMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCMinuteMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCMinuteMetricEsTableDefine.java new file mode 100644 index 000000000..ef0cefb3f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCMinuteMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.gc; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; + +/** + * @author peng-yongsheng + */ +public class GCMinuteMetricEsTableDefine extends AbstractGCMetricEsTableDefine { + + public GCMinuteMetricEsTableDefine() { + super(GCMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCMonthMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCMonthMetricEsTableDefine.java new file mode 100644 index 000000000..c10763571 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCMonthMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.gc; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; + +/** + * @author peng-yongsheng + */ +public class GCMonthMetricEsTableDefine extends AbstractGCMetricEsTableDefine { + + public GCMonthMetricEsTableDefine() { + super(GCMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCSecondMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCSecondMetricEsTableDefine.java new file mode 100644 index 000000000..b9d4800b7 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/gc/GCSecondMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.gc; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; + +/** + * @author peng-yongsheng + */ +public class GCSecondMetricEsTableDefine extends AbstractGCMetricEsTableDefine { + + public GCSecondMetricEsTableDefine() { + super(GCMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Second.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/InstanceMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/AbstractInstanceMetricEsTableDefine.java similarity index 82% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/InstanceMetricEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/AbstractInstanceMetricEsTableDefine.java index 1b6ce3c92..1e232ef1a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/InstanceMetricEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/AbstractInstanceMetricEsTableDefine.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.apm.collector.storage.es.define; +package org.apache.skywalking.apm.collector.storage.es.define.imp; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; @@ -25,19 +25,18 @@ import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric /** * @author peng-yongsheng */ -public class InstanceMetricEsTableDefine extends ElasticSearchTableDefine { +public abstract class AbstractInstanceMetricEsTableDefine extends ElasticSearchTableDefine { - public InstanceMetricEsTableDefine() { - super(InstanceMetricTable.TABLE); + public AbstractInstanceMetricEsTableDefine(String name) { + super(name); } - @Override public int refreshInterval() { - return 2; - } - - @Override public void initialize() { + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_TRANSACTION_CALLS, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name())); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/InstanceDayMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/InstanceDayMetricEsTableDefine.java new file mode 100644 index 000000000..ae9a8995b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/InstanceDayMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.imp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceDayMetricEsTableDefine extends AbstractInstanceMetricEsTableDefine { + + public InstanceDayMetricEsTableDefine() { + super(InstanceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/InstanceHourMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/InstanceHourMetricEsTableDefine.java new file mode 100644 index 000000000..51a48c0c7 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/InstanceHourMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.imp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceHourMetricEsTableDefine extends AbstractInstanceMetricEsTableDefine { + + public InstanceHourMetricEsTableDefine() { + super(InstanceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/InstanceMinuteMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/InstanceMinuteMetricEsTableDefine.java new file mode 100644 index 000000000..ce0dce50c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/InstanceMinuteMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.imp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceMinuteMetricEsTableDefine extends AbstractInstanceMetricEsTableDefine { + + public InstanceMinuteMetricEsTableDefine() { + super(InstanceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/InstanceMonthMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/InstanceMonthMetricEsTableDefine.java new file mode 100644 index 000000000..da37fb58b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/imp/InstanceMonthMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.imp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceMonthMetricEsTableDefine extends AbstractInstanceMetricEsTableDefine { + + public InstanceMonthMetricEsTableDefine() { + super(InstanceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/AbstractInstanceMappingEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/AbstractInstanceMappingEsTableDefine.java new file mode 100644 index 000000000..556d91072 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/AbstractInstanceMappingEsTableDefine.java @@ -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.storage.es.define.instmapping; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractInstanceMappingEsTableDefine extends ElasticSearchTableDefine { + + AbstractInstanceMappingEsTableDefine(String name) { + super(name); + } + + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(InstanceMappingTable.COLUMN_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(InstanceMappingTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(InstanceMappingTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceMappingTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceMappingTable.COLUMN_ADDRESS_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceMappingTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/InstanceMappingDayEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/InstanceMappingDayEsTableDefine.java new file mode 100644 index 000000000..ebcd9071f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/InstanceMappingDayEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.instmapping; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingDayEsTableDefine extends AbstractInstanceMappingEsTableDefine { + + public InstanceMappingDayEsTableDefine() { + super(InstanceMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/InstanceMappingHourEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/InstanceMappingHourEsTableDefine.java new file mode 100644 index 000000000..3aa685874 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/InstanceMappingHourEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.instmapping; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingHourEsTableDefine extends AbstractInstanceMappingEsTableDefine { + + public InstanceMappingHourEsTableDefine() { + super(InstanceMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/InstanceMappingMinuteEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/InstanceMappingMinuteEsTableDefine.java new file mode 100644 index 000000000..eb3d9183d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/InstanceMappingMinuteEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.instmapping; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingMinuteEsTableDefine extends AbstractInstanceMappingEsTableDefine { + + public InstanceMappingMinuteEsTableDefine() { + super(InstanceMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/InstanceMappingMonthEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/InstanceMappingMonthEsTableDefine.java new file mode 100644 index 000000000..f98bce863 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/instmapping/InstanceMappingMonthEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.instmapping; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingMonthEsTableDefine extends AbstractInstanceMappingEsTableDefine { + + public InstanceMappingMonthEsTableDefine() { + super(InstanceMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/InstanceReferenceMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/AbstractInstanceReferenceMetricEsTableDefine.java similarity index 82% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/InstanceReferenceMetricEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/AbstractInstanceReferenceMetricEsTableDefine.java index c4d197dda..b3ed11cf7 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/InstanceReferenceMetricEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/AbstractInstanceReferenceMetricEsTableDefine.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.apm.collector.storage.es.define; +package org.apache.skywalking.apm.collector.storage.es.define.irmp; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; @@ -25,19 +25,18 @@ import org.apache.skywalking.apm.collector.storage.table.instance.InstanceRefere /** * @author peng-yongsheng */ -public class InstanceReferenceMetricEsTableDefine extends ElasticSearchTableDefine { +public abstract class AbstractInstanceReferenceMetricEsTableDefine extends ElasticSearchTableDefine { - public InstanceReferenceMetricEsTableDefine() { - super(InstanceReferenceMetricTable.TABLE); + public AbstractInstanceReferenceMetricEsTableDefine(String name) { + super(name); } - @Override public int refreshInterval() { - return 2; - } - - @Override public void initialize() { + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(InstanceReferenceMetricTable.COLUMN_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(InstanceReferenceMetricTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); addColumn(new ElasticSearchColumnDefine(InstanceReferenceMetricTable.COLUMN_FRONT_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(InstanceReferenceMetricTable.COLUMN_BEHIND_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceReferenceMetricTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(InstanceReferenceMetricTable.COLUMN_TRANSACTION_CALLS, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(InstanceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name())); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/InstanceReferenceDayMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/InstanceReferenceDayMetricEsTableDefine.java new file mode 100644 index 000000000..e633c972e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/InstanceReferenceDayMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.irmp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceDayMetricEsTableDefine extends AbstractInstanceReferenceMetricEsTableDefine { + + public InstanceReferenceDayMetricEsTableDefine() { + super(InstanceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/InstanceReferenceHourMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/InstanceReferenceHourMetricEsTableDefine.java new file mode 100644 index 000000000..09db9ae74 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/InstanceReferenceHourMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.irmp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceHourMetricEsTableDefine extends AbstractInstanceReferenceMetricEsTableDefine { + + public InstanceReferenceHourMetricEsTableDefine() { + super(InstanceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/InstanceReferenceMinuteMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/InstanceReferenceMinuteMetricEsTableDefine.java new file mode 100644 index 000000000..a8046b40c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/InstanceReferenceMinuteMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.irmp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceMinuteMetricEsTableDefine extends AbstractInstanceReferenceMetricEsTableDefine { + + public InstanceReferenceMinuteMetricEsTableDefine() { + super(InstanceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/InstanceReferenceMonthMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/InstanceReferenceMonthMetricEsTableDefine.java new file mode 100644 index 000000000..90360ef3e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/irmp/InstanceReferenceMonthMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.irmp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceMonthMetricEsTableDefine extends AbstractInstanceReferenceMetricEsTableDefine { + + public InstanceReferenceMonthMetricEsTableDefine() { + super(InstanceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/MemoryMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/AbstractMemoryMetricEsTableDefine.java similarity index 71% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/MemoryMetricEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/AbstractMemoryMetricEsTableDefine.java index d06f117c9..f7b4d1b1d 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/MemoryMetricEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/AbstractMemoryMetricEsTableDefine.java @@ -16,8 +16,7 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.define; +package org.apache.skywalking.apm.collector.storage.es.define.memory; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; @@ -26,23 +25,23 @@ import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; /** * @author peng-yongsheng */ -public class MemoryMetricEsTableDefine extends ElasticSearchTableDefine { +public abstract class AbstractMemoryMetricEsTableDefine extends ElasticSearchTableDefine { - public MemoryMetricEsTableDefine() { - super(MemoryMetricTable.TABLE); + public AbstractMemoryMetricEsTableDefine(String name) { + super(name); } - @Override public int refreshInterval() { - return 1; - } - - @Override public void initialize() { + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(MemoryMetricTable.COLUMN_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(MemoryMetricTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(MemoryMetricTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(MemoryMetricTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(MemoryMetricTable.COLUMN_IS_HEAP, ElasticSearchColumnDefine.Type.Boolean.name())); addColumn(new ElasticSearchColumnDefine(MemoryMetricTable.COLUMN_INIT, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(MemoryMetricTable.COLUMN_MAX, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(MemoryMetricTable.COLUMN_USED, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(MemoryMetricTable.COLUMN_COMMITTED, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(MemoryMetricTable.COLUMN_TIMES, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(MemoryMetricTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemoryDayMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemoryDayMetricEsTableDefine.java new file mode 100644 index 000000000..b785d5314 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemoryDayMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.memory; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; + +/** + * @author peng-yongsheng + */ +public class MemoryDayMetricEsTableDefine extends AbstractMemoryMetricEsTableDefine { + + public MemoryDayMetricEsTableDefine() { + super(MemoryMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemoryHourMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemoryHourMetricEsTableDefine.java new file mode 100644 index 000000000..d52e1c644 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemoryHourMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.memory; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; + +/** + * @author peng-yongsheng + */ +public class MemoryHourMetricEsTableDefine extends AbstractMemoryMetricEsTableDefine { + + public MemoryHourMetricEsTableDefine() { + super(MemoryMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemoryMinuteMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemoryMinuteMetricEsTableDefine.java new file mode 100644 index 000000000..171f0538d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemoryMinuteMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.memory; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; + +/** + * @author peng-yongsheng + */ +public class MemoryMinuteMetricEsTableDefine extends AbstractMemoryMetricEsTableDefine { + + public MemoryMinuteMetricEsTableDefine() { + super(MemoryMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemoryMonthMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemoryMonthMetricEsTableDefine.java new file mode 100644 index 000000000..3d9f8ae2a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemoryMonthMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.memory; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; + +/** + * @author peng-yongsheng + */ +public class MemoryMonthMetricEsTableDefine extends AbstractMemoryMetricEsTableDefine { + + public MemoryMonthMetricEsTableDefine() { + super(MemoryMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemorySecondMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemorySecondMetricEsTableDefine.java new file mode 100644 index 000000000..4614b896b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/memory/MemorySecondMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.memory; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; + +/** + * @author peng-yongsheng + */ +public class MemorySecondMetricEsTableDefine extends AbstractMemoryMetricEsTableDefine { + + public MemorySecondMetricEsTableDefine() { + super(MemoryMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Second.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/MemoryPoolMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/AbstractMemoryPoolMetricEsTableDefine.java similarity index 75% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/MemoryPoolMetricEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/AbstractMemoryPoolMetricEsTableDefine.java index 2ee6e853d..37d213e0e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/MemoryPoolMetricEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/AbstractMemoryPoolMetricEsTableDefine.java @@ -16,8 +16,7 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.define; +package org.apache.skywalking.apm.collector.storage.es.define.mpool; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; @@ -26,23 +25,26 @@ import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTab /** * @author peng-yongsheng */ -public class MemoryPoolMetricEsTableDefine extends ElasticSearchTableDefine { +public abstract class AbstractMemoryPoolMetricEsTableDefine extends ElasticSearchTableDefine { - public MemoryPoolMetricEsTableDefine() { - super(MemoryPoolMetricTable.TABLE); + public AbstractMemoryPoolMetricEsTableDefine(String name) { + super(name); } @Override public int refreshInterval() { return 1; } - @Override public void initialize() { + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(MemoryPoolMetricTable.COLUMN_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(MemoryPoolMetricTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); addColumn(new ElasticSearchColumnDefine(MemoryPoolMetricTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(MemoryPoolMetricTable.COLUMN_POOL_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(MemoryPoolMetricTable.COLUMN_INIT, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(MemoryPoolMetricTable.COLUMN_MAX, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(MemoryPoolMetricTable.COLUMN_USED, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(MemoryPoolMetricTable.COLUMN_COMMITTED, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(MemoryPoolMetricTable.COLUMN_TIMES, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(MemoryPoolMetricTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolDayMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolDayMetricEsTableDefine.java new file mode 100644 index 000000000..fcccfc893 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolDayMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.mpool; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolDayMetricEsTableDefine extends AbstractMemoryPoolMetricEsTableDefine { + + public MemoryPoolDayMetricEsTableDefine() { + super(MemoryPoolMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolHourMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolHourMetricEsTableDefine.java new file mode 100644 index 000000000..03c28ca3e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolHourMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.mpool; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolHourMetricEsTableDefine extends AbstractMemoryPoolMetricEsTableDefine { + + public MemoryPoolHourMetricEsTableDefine() { + super(MemoryPoolMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolMinuteMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolMinuteMetricEsTableDefine.java new file mode 100644 index 000000000..0f2ca0983 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolMinuteMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.mpool; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolMinuteMetricEsTableDefine extends AbstractMemoryPoolMetricEsTableDefine { + + public MemoryPoolMinuteMetricEsTableDefine() { + super(MemoryPoolMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolMonthMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolMonthMetricEsTableDefine.java new file mode 100644 index 000000000..e062411ea --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolMonthMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.mpool; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolMonthMetricEsTableDefine extends AbstractMemoryPoolMetricEsTableDefine { + + public MemoryPoolMonthMetricEsTableDefine() { + super(MemoryPoolMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolSecondMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolSecondMetricEsTableDefine.java new file mode 100644 index 000000000..69478e90d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/mpool/MemoryPoolSecondMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.mpool; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolSecondMetricEsTableDefine extends AbstractMemoryPoolMetricEsTableDefine { + + public MemoryPoolSecondMetricEsTableDefine() { + super(MemoryPoolMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Second.getName()); + } + + @Override public int refreshInterval() { + return 1; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ApplicationEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ApplicationEsTableDefine.java similarity index 83% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ApplicationEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ApplicationEsTableDefine.java index c4effaac5..7564b0bc2 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ApplicationEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ApplicationEsTableDefine.java @@ -16,8 +16,7 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.define; +package org.apache.skywalking.apm.collector.storage.es.define.register; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; @@ -39,5 +38,7 @@ public class ApplicationEsTableDefine extends ElasticSearchTableDefine { @Override public void initialize() { addColumn(new ElasticSearchColumnDefine(ApplicationTable.COLUMN_APPLICATION_CODE, ElasticSearchColumnDefine.Type.Keyword.name())); addColumn(new ElasticSearchColumnDefine(ApplicationTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationTable.COLUMN_ADDRESS_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationTable.COLUMN_IS_ADDRESS, ElasticSearchColumnDefine.Type.Boolean.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/InstanceEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/InstanceEsTableDefine.java similarity index 86% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/InstanceEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/InstanceEsTableDefine.java index 8b2696578..9a7ec7c93 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/InstanceEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/InstanceEsTableDefine.java @@ -16,12 +16,11 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.define; +package org.apache.skywalking.apm.collector.storage.es.define.register; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; -import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; /** * @author peng-yongsheng @@ -43,5 +42,7 @@ public class InstanceEsTableDefine extends ElasticSearchTableDefine { addColumn(new ElasticSearchColumnDefine(InstanceTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(InstanceTable.COLUMN_HEARTBEAT_TIME, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(InstanceTable.COLUMN_OS_INFO, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(InstanceTable.COLUMN_ADDRESS_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(InstanceTable.COLUMN_IS_ADDRESS, ElasticSearchColumnDefine.Type.Boolean.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/NetworkAddressEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/NetworkAddressEsTableDefine.java new file mode 100644 index 000000000..59f1f4f41 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/NetworkAddressEsTableDefine.java @@ -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.storage.es.define.register; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddressTable; + +/** + * @author peng-yongsheng + */ +public class NetworkAddressEsTableDefine extends ElasticSearchTableDefine { + + public NetworkAddressEsTableDefine() { + super(NetworkAddressTable.TABLE); + } + + @Override public int refreshInterval() { + return 1; + } + + @Override public void initialize() { + addColumn(new ElasticSearchColumnDefine(NetworkAddressTable.COLUMN_NETWORK_ADDRESS, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(NetworkAddressTable.COLUMN_ADDRESS_ID, ElasticSearchColumnDefine.Type.Integer.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ServiceNameEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ServiceNameEsTableDefine.java similarity index 96% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ServiceNameEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ServiceNameEsTableDefine.java index 90159e474..f15707bec 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ServiceNameEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ServiceNameEsTableDefine.java @@ -16,8 +16,7 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.define; +package org.apache.skywalking.apm.collector.storage.es.define.register; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ServiceMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/AbstractServiceMetricEsTableDefine.java similarity index 82% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ServiceMetricEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/AbstractServiceMetricEsTableDefine.java index d4e9756b3..7d4aa5418 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ServiceMetricEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/AbstractServiceMetricEsTableDefine.java @@ -16,8 +16,7 @@ * */ - -package org.apache.skywalking.apm.collector.storage.es.define; +package org.apache.skywalking.apm.collector.storage.es.define.smp; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; @@ -26,18 +25,17 @@ import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTa /** * @author peng-yongsheng */ -public class ServiceMetricEsTableDefine extends ElasticSearchTableDefine { +public abstract class AbstractServiceMetricEsTableDefine extends ElasticSearchTableDefine { - public ServiceMetricEsTableDefine() { - super(ServiceMetricTable.TABLE); + public AbstractServiceMetricEsTableDefine(String name) { + super(name); } - @Override public int refreshInterval() { - return 2; - } - - @Override public void initialize() { + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_TRANSACTION_CALLS, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name())); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/ServiceDayMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/ServiceDayMetricEsTableDefine.java new file mode 100644 index 000000000..f10d8e1dd --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/ServiceDayMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.smp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; + +/** + * @author peng-yongsheng + */ +public class ServiceDayMetricEsTableDefine extends AbstractServiceMetricEsTableDefine { + + public ServiceDayMetricEsTableDefine() { + super(ServiceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/ServiceHourMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/ServiceHourMetricEsTableDefine.java new file mode 100644 index 000000000..337d38d80 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/ServiceHourMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.smp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; + +/** + * @author peng-yongsheng + */ +public class ServiceHourMetricEsTableDefine extends AbstractServiceMetricEsTableDefine { + + public ServiceHourMetricEsTableDefine() { + super(ServiceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/ServiceMinuteMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/ServiceMinuteMetricEsTableDefine.java new file mode 100644 index 000000000..714b6a714 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/ServiceMinuteMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.smp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; + +/** + * @author peng-yongsheng + */ +public class ServiceMinuteMetricEsTableDefine extends AbstractServiceMetricEsTableDefine { + + public ServiceMinuteMetricEsTableDefine() { + super(ServiceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/ServiceMonthMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/ServiceMonthMetricEsTableDefine.java new file mode 100644 index 000000000..073aebce8 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/smp/ServiceMonthMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.smp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; + +/** + * @author peng-yongsheng + */ +public class ServiceMonthMetricEsTableDefine extends AbstractServiceMetricEsTableDefine { + + public ServiceMonthMetricEsTableDefine() { + super(ServiceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ServiceReferenceMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/AbstractServiceReferenceMetricEsTableDefine.java similarity index 89% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ServiceReferenceMetricEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/AbstractServiceReferenceMetricEsTableDefine.java index f011410f3..c4c791a5c 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/ServiceReferenceMetricEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/AbstractServiceReferenceMetricEsTableDefine.java @@ -16,28 +16,24 @@ * */ +package org.apache.skywalking.apm.collector.storage.es.define.srmp; -package org.apache.skywalking.apm.collector.storage.es.define; - -import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; /** * @author peng-yongsheng */ -public class ServiceReferenceMetricEsTableDefine extends ElasticSearchTableDefine { +public abstract class AbstractServiceReferenceMetricEsTableDefine extends ElasticSearchTableDefine { - public ServiceReferenceMetricEsTableDefine() { - super(ServiceReferenceMetricTable.TABLE); + public AbstractServiceReferenceMetricEsTableDefine(String name) { + super(name); } - @Override public int refreshInterval() { - return 2; - } + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(ServiceReferenceMetricTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); - @Override public void initialize() { - addColumn(new ElasticSearchColumnDefine(ServiceReferenceMetricTable.COLUMN_ENTRY_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/ServiceReferenceDayMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/ServiceReferenceDayMetricEsTableDefine.java new file mode 100644 index 000000000..f7ed7ae0b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/ServiceReferenceDayMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.srmp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceDayMetricEsTableDefine extends AbstractServiceReferenceMetricEsTableDefine { + + public ServiceReferenceDayMetricEsTableDefine() { + super(ServiceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/ServiceReferenceHourMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/ServiceReferenceHourMetricEsTableDefine.java new file mode 100644 index 000000000..2ebf04e84 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/ServiceReferenceHourMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.srmp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceHourMetricEsTableDefine extends AbstractServiceReferenceMetricEsTableDefine { + + public ServiceReferenceHourMetricEsTableDefine() { + super(ServiceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/ServiceReferenceMinuteMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/ServiceReferenceMinuteMetricEsTableDefine.java new file mode 100644 index 000000000..9030753e4 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/ServiceReferenceMinuteMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.srmp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceMinuteMetricEsTableDefine extends AbstractServiceReferenceMetricEsTableDefine { + + public ServiceReferenceMinuteMetricEsTableDefine() { + super(ServiceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/ServiceReferenceMonthMetricEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/ServiceReferenceMonthMetricEsTableDefine.java new file mode 100644 index 000000000..147b3be12 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/srmp/ServiceReferenceMonthMetricEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.storage.es.define.srmp; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceMonthMetricEsTableDefine extends AbstractServiceReferenceMetricEsTableDefine { + + public ServiceReferenceMonthMetricEsTableDefine() { + super(ServiceReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define index ae718e3cf..d016737fb 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define @@ -1,19 +1,90 @@ -org.apache.skywalking.apm.collector.storage.es.define.ApplicationEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.InstanceEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.InstanceMetricEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.InstanceReferenceMetricEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.ServiceNameEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.CpuMetricEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.GCMetricEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.MemoryMetricEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.MemoryPoolMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.register.ApplicationEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.register.InstanceEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.register.ServiceNameEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.register.NetworkAddressEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.appcomp.ApplicationComponentMinuteEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.appcomp.ApplicationComponentHourEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.appcomp.ApplicationComponentDayEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.appcomp.ApplicationComponentMonthEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.appmapping.ApplicationMappingMinuteEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.appmapping.ApplicationMappingHourEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.appmapping.ApplicationMappingDayEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.appmapping.ApplicationMappingMonthEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.instmapping.InstanceMappingMinuteEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.instmapping.InstanceMappingHourEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.instmapping.InstanceMappingDayEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.instmapping.InstanceMappingMonthEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.srmp.ServiceReferenceMinuteMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.srmp.ServiceReferenceHourMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.srmp.ServiceReferenceDayMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.srmp.ServiceReferenceMonthMetricEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.smp.ServiceMinuteMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.smp.ServiceHourMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.smp.ServiceDayMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.smp.ServiceMonthMetricEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.irmp.InstanceReferenceMinuteMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.irmp.InstanceReferenceHourMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.irmp.InstanceReferenceDayMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.irmp.InstanceReferenceMonthMetricEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.imp.InstanceMinuteMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.imp.InstanceHourMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.imp.InstanceDayMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.imp.InstanceMonthMetricEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.armp.ApplicationReferenceMinuteMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.armp.ApplicationReferenceHourMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.armp.ApplicationReferenceDayMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.armp.ApplicationReferenceMonthMetricEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.amp.ApplicationMinuteMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.amp.ApplicationHourMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.amp.ApplicationDayMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.amp.ApplicationMonthMetricEsTableDefine + org.apache.skywalking.apm.collector.storage.es.define.GlobalTraceEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.ApplicationComponentEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.ApplicationMappingEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.ApplicationReferenceMetricEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.SegmentCostEsTableDefine org.apache.skywalking.apm.collector.storage.es.define.SegmentEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.ServiceEntryEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.ServiceMetricEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.ServiceReferenceMetricEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.AlertingListEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.SegmentCostEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationAlarmEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationAlarmListEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationReferenceAlarmEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationReferenceAlarmListEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.InstanceAlarmEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.InstanceAlarmListEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.InstanceReferenceAlarmEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.InstanceReferenceAlarmListEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.ServiceAlarmEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.ServiceAlarmListEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.ServiceReferenceAlarmEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.ServiceReferenceAlarmListEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.mpool.MemoryPoolSecondMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.mpool.MemoryPoolMinuteMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.mpool.MemoryPoolHourMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.mpool.MemoryPoolDayMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.mpool.MemoryPoolMonthMetricEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.memory.MemorySecondMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.memory.MemoryMinuteMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.memory.MemoryHourMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.memory.MemoryDayMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.memory.MemoryMonthMetricEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.gc.GCSecondMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.gc.GCMinuteMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.gc.GCHourMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.gc.GCDayMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.gc.GCMonthMetricEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.cpu.CpuSecondMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.cpu.CpuMinuteMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.cpu.CpuHourMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.cpu.CpuDayMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.cpu.CpuMonthMetricEsTableDefine \ No newline at end of file diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java index 376063f9e..640071dbf 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java @@ -27,82 +27,106 @@ import org.apache.skywalking.apm.collector.core.module.ServiceNotProvidedExcepti import org.apache.skywalking.apm.collector.storage.StorageException; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO; -import org.apache.skywalking.apm.collector.storage.dao.IAlertingListPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationCacheDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IInstanceCacheDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceReferenceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceReferenceAlarmPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.INetworkAddressCacheDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceNameRegisterDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceReferenceAlarmPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.gcmp.IGCSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemorySecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.INetworkAddressRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IServiceNameRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.BatchH2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2StorageInstaller; -import org.apache.skywalking.apm.collector.storage.h2.dao.AlertingListH2PersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationAlarmH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationAlarmListH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2MinutePersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationH2CacheDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationH2RegisterDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2MinutePersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationMetricH2PersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationMinuteMetricH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceAlarmH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceAlarmListH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.CpuMetricH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMinuteMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.CpuMetricH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.GCMetricH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.CpuSecondMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.GCMetricH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.GCSecondMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceAlarmH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceAlarmListH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceH2CacheDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceH2RegisterDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceHeartBeatH2PersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMetricH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMappingH2MinutePersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMetricH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMinuteMetricH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceReferenceAlarmH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceReferenceAlarmListH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceReferenceMetricH2PersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.MemoryMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.MemoryMetricH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.MemoryPoolMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.MemoryPoolMetricH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.MemoryPoolSecondMetricH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.MemorySecondMetricH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.NetworkAddressH2CacheDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.NetworkAddressRegisterH2DAO; import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentCostH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentCostH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceEntryH2PersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceEntryH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceMetricH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceAlarmH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceAlarmListH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceMinuteMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceNameH2CacheDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceNameH2RegisterDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceReferenceAlarmH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceReferenceAlarmListH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceReferenceH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceReferenceMetricH2PersistenceDAO; import org.slf4j.Logger; @@ -140,7 +164,7 @@ public class StorageModuleH2Provider extends ModuleProvider { registerRegisterDAO(); registerPersistenceDAO(); registerUiDAO(); - registerAlertingDAO(); + registerAlarmDAO(); } @Override public void start(Properties config) throws ServiceNotProvidedException { @@ -166,34 +190,36 @@ public class StorageModuleH2Provider extends ModuleProvider { this.registerServiceImplementation(IApplicationCacheDAO.class, new ApplicationH2CacheDAO(h2Client)); this.registerServiceImplementation(IInstanceCacheDAO.class, new InstanceH2CacheDAO(h2Client)); this.registerServiceImplementation(IServiceNameCacheDAO.class, new ServiceNameH2CacheDAO(h2Client)); + this.registerServiceImplementation(INetworkAddressCacheDAO.class, new NetworkAddressH2CacheDAO(h2Client)); } private void registerRegisterDAO() throws ServiceNotProvidedException { + this.registerServiceImplementation(INetworkAddressRegisterDAO.class, new NetworkAddressRegisterH2DAO(h2Client)); this.registerServiceImplementation(IApplicationRegisterDAO.class, new ApplicationH2RegisterDAO(h2Client)); this.registerServiceImplementation(IInstanceRegisterDAO.class, new InstanceH2RegisterDAO(h2Client)); this.registerServiceImplementation(IServiceNameRegisterDAO.class, new ServiceNameH2RegisterDAO(h2Client)); } private void registerPersistenceDAO() throws ServiceNotProvidedException { - this.registerServiceImplementation(ICpuMetricPersistenceDAO.class, new CpuMetricH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(IGCMetricPersistenceDAO.class, new GCMetricH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(IMemoryMetricPersistenceDAO.class, new MemoryMetricH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(IMemoryPoolMetricPersistenceDAO.class, new MemoryPoolMetricH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(ICpuSecondMetricPersistenceDAO.class, new CpuSecondMetricH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IGCSecondMetricPersistenceDAO.class, new GCSecondMetricH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IMemorySecondMetricPersistenceDAO.class, new MemorySecondMetricH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IMemoryPoolSecondMetricPersistenceDAO.class, new MemoryPoolSecondMetricH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IGlobalTracePersistenceDAO.class, new GlobalTraceH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(IApplicationComponentPersistenceDAO.class, new ApplicationComponentH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(IApplicationMappingPersistenceDAO.class, new ApplicationMappingH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(IApplicationMetricPersistenceDAO.class, new ApplicationMetricH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(IApplicationReferenceMetricPersistenceDAO.class, new ApplicationReferenceMetricH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IApplicationComponentMinutePersistenceDAO.class, new ApplicationComponentH2MinutePersistenceDAO(h2Client)); + this.registerServiceImplementation(IApplicationMappingMinutePersistenceDAO.class, new ApplicationMappingH2MinutePersistenceDAO(h2Client)); + this.registerServiceImplementation(IApplicationMinuteMetricPersistenceDAO.class, new ApplicationMinuteMetricH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IApplicationReferenceMinuteMetricPersistenceDAO.class, new ApplicationReferenceMinuteMetricH2PersistenceDAO(h2Client)); this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostH2PersistenceDAO(h2Client)); this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(IServiceEntryPersistenceDAO.class, new ServiceEntryH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(IServiceMetricPersistenceDAO.class, new ServiceMetricH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(IServiceReferenceMetricPersistenceDAO.class, new ServiceReferenceMetricH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IServiceMinuteMetricPersistenceDAO.class, new ServiceMinuteMetricH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IServiceReferenceMinuteMetricPersistenceDAO.class, new ServiceReferenceMetricH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IInstanceMinuteMetricPersistenceDAO.class, new InstanceMinuteMetricH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IInstanceReferenceMinuteMetricPersistenceDAO.class, new InstanceReferenceMetricH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IInstanceMappingMinutePersistenceDAO.class, new InstanceMappingH2MinutePersistenceDAO(h2Client)); this.registerServiceImplementation(IInstanceHeartBeatPersistenceDAO.class, new InstanceHeartBeatH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(IInstanceReferenceMetricPersistenceDAO.class, new InstanceReferenceMetricH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(IInstanceMetricPersistenceDAO.class, new InstanceMetricH2PersistenceDAO(h2Client)); } private void registerUiDAO() throws ServiceNotProvidedException { @@ -211,11 +237,22 @@ public class StorageModuleH2Provider extends ModuleProvider { this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricH2UIDAO(h2Client)); this.registerServiceImplementation(ISegmentCostUIDAO.class, new SegmentCostH2UIDAO(h2Client)); this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentH2UIDAO(h2Client)); - this.registerServiceImplementation(IServiceEntryUIDAO.class, new ServiceEntryH2UIDAO(h2Client)); this.registerServiceImplementation(IServiceReferenceUIDAO.class, new ServiceReferenceH2UIDAO(h2Client)); } - private void registerAlertingDAO() throws ServiceNotProvidedException { - this.registerServiceImplementation(IAlertingListPersistenceDAO.class, new AlertingListH2PersistenceDAO(h2Client)); + private void registerAlarmDAO() throws ServiceNotProvidedException { + this.registerServiceImplementation(IServiceReferenceAlarmPersistenceDAO.class, new ServiceReferenceAlarmH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IServiceReferenceAlarmListPersistenceDAO.class, new ServiceReferenceAlarmListH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IInstanceReferenceAlarmPersistenceDAO.class, new InstanceReferenceAlarmH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IInstanceReferenceAlarmListPersistenceDAO.class, new InstanceReferenceAlarmListH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IApplicationReferenceAlarmPersistenceDAO.class, new ApplicationReferenceAlarmH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IApplicationReferenceAlarmListPersistenceDAO.class, new ApplicationReferenceAlarmListH2PersistenceDAO(h2Client)); + + this.registerServiceImplementation(IServiceAlarmPersistenceDAO.class, new ServiceAlarmH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IServiceAlarmListPersistenceDAO.class, new ServiceAlarmListH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IInstanceAlarmPersistenceDAO.class, new InstanceAlarmH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IInstanceAlarmListPersistenceDAO.class, new InstanceAlarmListH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IApplicationAlarmPersistenceDAO.class, new ApplicationAlarmH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IApplicationAlarmListPersistenceDAO.class, new ApplicationAlarmListH2PersistenceDAO(h2Client)); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/AlertingListH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/AlertingListH2PersistenceDAO.java deleted file mode 100644 index 8b175f2d5..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/AlertingListH2PersistenceDAO.java +++ /dev/null @@ -1,113 +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.storage.h2.dao; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.storage.dao.IAlertingListPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; -import org.apache.skywalking.apm.collector.storage.table.alerting.AlertingList; -import org.apache.skywalking.apm.collector.storage.table.alerting.AlertingListTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class AlertingListH2PersistenceDAO extends H2DAO implements IAlertingListPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(AlertingListH2PersistenceDAO.class); - - private static final String GET_SQL = "select * from {0} where {1} = ?"; - - public AlertingListH2PersistenceDAO(H2Client client) { - super(client); - } - - @Override public AlertingList get(String id) { - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_SQL, AlertingListTable.TABLE, AlertingListTable.COLUMN_ID); - Object[] params = new Object[] {id}; - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - AlertingList alertingList = new AlertingList(id); - alertingList.setLayer(rs.getInt(AlertingListTable.COLUMN_LAYER)); - alertingList.setLayerId(rs.getInt(AlertingListTable.COLUMN_LAYER_ID)); - alertingList.setFirstTimeBucket(rs.getLong(AlertingListTable.COLUMN_FIRST_TIME_BUCKET)); - alertingList.setLastTimeBucket(rs.getLong(AlertingListTable.COLUMN_LAST_TIME_BUCKET)); - alertingList.setExpected(rs.getInt(AlertingListTable.COLUMN_EXPECTED)); - alertingList.setActual(rs.getInt(AlertingListTable.COLUMN_ACTUAL)); - alertingList.setValid(rs.getBoolean(AlertingListTable.COLUMN_VALID)); - - return alertingList; - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return null; - } - - @Override public H2SqlEntity prepareBatchInsert(AlertingList data) { - Map source = new HashMap<>(); - H2SqlEntity entity = new H2SqlEntity(); - source.put(AlertingListTable.COLUMN_LAYER, data.getLayer()); - source.put(AlertingListTable.COLUMN_LAYER_ID, data.getLayerId()); - source.put(AlertingListTable.COLUMN_FIRST_TIME_BUCKET, data.getFirstTimeBucket()); - source.put(AlertingListTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); - source.put(AlertingListTable.COLUMN_EXPECTED, data.getExpected()); - source.put(AlertingListTable.COLUMN_ACTUAL, data.getActual()); - source.put(AlertingListTable.COLUMN_VALID, data.getValid()); - - String sql = SqlBuilder.buildBatchInsertSql(AlertingListTable.TABLE, source.keySet()); - entity.setSql(sql); - entity.setParams(source.values().toArray(new Object[0])); - return entity; - } - - @Override public H2SqlEntity prepareBatchUpdate(AlertingList data) { - Map source = new HashMap<>(); - H2SqlEntity entity = new H2SqlEntity(); - source.put(AlertingListTable.COLUMN_LAYER, data.getLayer()); - source.put(AlertingListTable.COLUMN_LAYER_ID, data.getLayerId()); - source.put(AlertingListTable.COLUMN_FIRST_TIME_BUCKET, data.getFirstTimeBucket()); - source.put(AlertingListTable.COLUMN_LAST_TIME_BUCKET, data.getLastTimeBucket()); - source.put(AlertingListTable.COLUMN_EXPECTED, data.getExpected()); - source.put(AlertingListTable.COLUMN_ACTUAL, data.getActual()); - source.put(AlertingListTable.COLUMN_VALID, data.getValid()); - String sql = SqlBuilder.buildBatchUpdateSql(AlertingListTable.TABLE, source.keySet(), AlertingListTable.COLUMN_ID); - entity.setSql(sql); - List values = new ArrayList<>(source.values()); - values.add(data.getId()); - entity.setParams(values.toArray(new Object[0])); - return entity; - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationAlarmH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationAlarmH2PersistenceDAO.java new file mode 100644 index 000000000..bd31913ca --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationAlarmH2PersistenceDAO.java @@ -0,0 +1,55 @@ +/* + * 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.storage.h2.dao; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmH2PersistenceDAO extends H2DAO implements IApplicationAlarmPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationAlarmH2PersistenceDAO.class); + + public ApplicationAlarmH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override public ApplicationAlarm get(String id) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(ApplicationAlarm data) { + return null; + } + + @Override public H2SqlEntity prepareBatchUpdate(ApplicationAlarm data) { + return null; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationAlarmListH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationAlarmListH2PersistenceDAO.java new file mode 100644 index 000000000..9d9a85045 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationAlarmListH2PersistenceDAO.java @@ -0,0 +1,55 @@ +/* + * 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.storage.h2.dao; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListH2PersistenceDAO extends H2DAO implements IApplicationAlarmListPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationAlarmListH2PersistenceDAO.class); + + public ApplicationAlarmListH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override public ApplicationAlarmList get(String id) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(ApplicationAlarmList data) { + return null; + } + + @Override public H2SqlEntity prepareBatchUpdate(ApplicationAlarmList data) { + return null; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2MinutePersistenceDAO.java similarity index 90% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2MinutePersistenceDAO.java index 4a9f154c5..a2dfc1c4d 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2MinutePersistenceDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import java.sql.ResultSet; @@ -26,24 +25,24 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author peng-yongsheng, clevertension */ -public class ApplicationComponentH2PersistenceDAO extends H2DAO implements IApplicationComponentPersistenceDAO { - private final Logger logger = LoggerFactory.getLogger(ApplicationComponentH2PersistenceDAO.class); +public class ApplicationComponentH2MinutePersistenceDAO extends H2DAO implements IApplicationComponentMinutePersistenceDAO { + private final Logger logger = LoggerFactory.getLogger(ApplicationComponentH2MinutePersistenceDAO.class); private static final String GET_SQL = "select * from {0} where {1} = ?"; - public ApplicationComponentH2PersistenceDAO(H2Client client) { + public ApplicationComponentH2MinutePersistenceDAO(H2Client client) { super(client); } @@ -54,7 +53,8 @@ public class ApplicationComponentH2PersistenceDAO extends H2DAO implements IAppl Object[] params = new Object[] {id}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { - ApplicationComponent applicationComponent = new ApplicationComponent(id); + ApplicationComponent applicationComponent = new ApplicationComponent(); + applicationComponent.setId(id); applicationComponent.setComponentId(rs.getInt(ApplicationComponentTable.COLUMN_COMPONENT_ID)); applicationComponent.setPeerId(rs.getInt(ApplicationComponentTable.COLUMN_PEER_ID)); applicationComponent.setTimeBucket(rs.getLong(ApplicationComponentTable.COLUMN_TIME_BUCKET)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationH2CacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationH2CacheDAO.java index 48ba3ab74..c94863ee8 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationH2CacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationH2CacheDAO.java @@ -16,18 +16,17 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import java.sql.ResultSet; import java.sql.SQLException; import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,19 +36,21 @@ import org.slf4j.LoggerFactory; public class ApplicationH2CacheDAO extends H2DAO implements IApplicationCacheDAO { private final Logger logger = LoggerFactory.getLogger(ApplicationH2CacheDAO.class); - private static final String GET_APPLICATION_ID_OR_CODE_SQL = "select {0} from {1} where {2} = ?"; + + private static final String GET_APPLICATION_ID_SQL = "select {0} from {1} where {2} = ? and {3} = ?"; + private static final String GET_APPLICATION_CODE_SQL = "select {0} from {1} where {2} = ?"; public ApplicationH2CacheDAO(H2Client client) { super(client); } @Override - public int getApplicationId(String applicationCode) { - logger.info("get the application getId with application code = {}", applicationCode); + public int getApplicationIdByCode(String applicationCode) { + logger.info("get the application id with application code = {}", applicationCode); H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_OR_CODE_SQL, ApplicationTable.COLUMN_APPLICATION_ID, ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_CODE); + String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_SQL, ApplicationTable.COLUMN_APPLICATION_ID, ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_CODE, ApplicationTable.COLUMN_IS_ADDRESS); - Object[] params = new Object[] {applicationCode}; + Object[] params = new Object[] {applicationCode, false}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { return rs.getInt(1); @@ -63,7 +64,7 @@ public class ApplicationH2CacheDAO extends H2DAO implements IApplicationCacheDAO @Override public String getApplicationCode(int applicationId) { logger.debug("get application code, applicationId: {}", applicationId); H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_OR_CODE_SQL, ApplicationTable.COLUMN_APPLICATION_CODE, ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_ID); + String sql = SqlBuilder.buildSql(GET_APPLICATION_CODE_SQL, ApplicationTable.COLUMN_APPLICATION_CODE, ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_ID); Object[] params = new Object[] {applicationId}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { @@ -74,4 +75,20 @@ public class ApplicationH2CacheDAO extends H2DAO implements IApplicationCacheDAO } return Const.EMPTY_STRING; } + + @Override public int getApplicationIdByAddressId(int addressId) { + logger.info("get the application id with address id = {}", addressId); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_SQL, ApplicationTable.COLUMN_APPLICATION_ID, ApplicationTable.TABLE, ApplicationTable.COLUMN_ADDRESS_ID, ApplicationTable.COLUMN_IS_ADDRESS); + + Object[] params = new Object[] {addressId, true}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getInt(1); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationH2RegisterDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationH2RegisterDAO.java index c8dbe95fd..266f53665 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationH2RegisterDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationH2RegisterDAO.java @@ -16,18 +16,17 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegisterDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.register.Application; import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,6 +58,8 @@ public class ApplicationH2RegisterDAO extends H2DAO implements IApplicationRegis source.put(ApplicationTable.COLUMN_ID, application.getId()); source.put(ApplicationTable.COLUMN_APPLICATION_CODE, application.getApplicationCode()); source.put(ApplicationTable.COLUMN_APPLICATION_ID, application.getApplicationId()); + source.put(ApplicationTable.COLUMN_ADDRESS_ID, application.getAddressId()); + source.put(ApplicationTable.COLUMN_IS_ADDRESS, application.getIsAddress()); String sql = SqlBuilder.buildBatchInsertSql(ApplicationTable.TABLE, source.keySet()); Object[] params = source.values().toArray(new Object[0]); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2MinutePersistenceDAO.java similarity index 91% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2MinutePersistenceDAO.java index 562f1df25..ec35a05a9 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2MinutePersistenceDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import java.sql.ResultSet; @@ -26,25 +25,25 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMinutePersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author peng-yongsheng, clevertension */ -public class ApplicationMappingH2PersistenceDAO extends H2DAO implements IApplicationMappingPersistenceDAO { +public class ApplicationMappingH2MinutePersistenceDAO extends H2DAO implements IApplicationMappingMinutePersistenceDAO { - private final Logger logger = LoggerFactory.getLogger(ApplicationMappingH2PersistenceDAO.class); + private final Logger logger = LoggerFactory.getLogger(ApplicationMappingH2MinutePersistenceDAO.class); private static final String GET_SQL = "select * from {0} where {1} = ?"; - public ApplicationMappingH2PersistenceDAO(H2Client client) { + public ApplicationMappingH2MinutePersistenceDAO(H2Client client) { super(client); } @@ -54,7 +53,8 @@ public class ApplicationMappingH2PersistenceDAO extends H2DAO implements IApplic Object[] params = new Object[] {id}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { - ApplicationMapping applicationMapping = new ApplicationMapping(id); + ApplicationMapping applicationMapping = new ApplicationMapping(); + applicationMapping.setId(id); applicationMapping.setApplicationId(rs.getInt(ApplicationMappingTable.COLUMN_APPLICATION_ID)); applicationMapping.setAddressId(rs.getInt(ApplicationMappingTable.COLUMN_ADDRESS_ID)); applicationMapping.setTimeBucket(rs.getLong(ApplicationMappingTable.COLUMN_TIME_BUCKET)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMinuteMetricH2PersistenceDAO.java similarity index 95% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMetricH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMinuteMetricH2PersistenceDAO.java index 7ac10e014..4eee8a0a5 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMetricH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMinuteMetricH2PersistenceDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import java.sql.ResultSet; @@ -26,25 +25,25 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.amp.IApplicationMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author peng-yongsheng, clevertension */ -public class ApplicationMetricH2PersistenceDAO extends H2DAO implements IApplicationMetricPersistenceDAO { +public class ApplicationMinuteMetricH2PersistenceDAO extends H2DAO implements IApplicationMinuteMetricPersistenceDAO { - private final Logger logger = LoggerFactory.getLogger(ApplicationMetricH2PersistenceDAO.class); + private final Logger logger = LoggerFactory.getLogger(ApplicationMinuteMetricH2PersistenceDAO.class); private static final String GET_SQL = "select * from {0} where {1} = ?"; - public ApplicationMetricH2PersistenceDAO(H2Client client) { + public ApplicationMinuteMetricH2PersistenceDAO(H2Client client) { super(client); } @@ -54,7 +53,8 @@ public class ApplicationMetricH2PersistenceDAO extends H2DAO implements IApplica Object[] params = new Object[] {id}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { - ApplicationMetric applicationMetric = new ApplicationMetric(id); + ApplicationMetric applicationMetric = new ApplicationMetric(); + applicationMetric.setId(id); applicationMetric.setApplicationId(rs.getInt(ApplicationMetricTable.COLUMN_APPLICATION_ID)); applicationMetric.setTransactionCalls(rs.getLong(ApplicationMetricTable.COLUMN_TRANSACTION_CALLS)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceAlarmH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceAlarmH2PersistenceDAO.java new file mode 100644 index 000000000..92bed74fa --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceAlarmH2PersistenceDAO.java @@ -0,0 +1,55 @@ +/* + * 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.storage.h2.dao; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarm; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceAlarmH2PersistenceDAO extends H2DAO implements IApplicationReferenceAlarmPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceAlarmH2PersistenceDAO.class); + + public ApplicationReferenceAlarmH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override public ApplicationReferenceAlarm get(String id) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(ApplicationReferenceAlarm data) { + return null; + } + + @Override public H2SqlEntity prepareBatchUpdate(ApplicationReferenceAlarm data) { + return null; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceAlarmListH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceAlarmListH2PersistenceDAO.java new file mode 100644 index 000000000..25c21724c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceAlarmListH2PersistenceDAO.java @@ -0,0 +1,55 @@ +/* + * 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.storage.h2.dao; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationReferenceAlarmList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceAlarmListH2PersistenceDAO extends H2DAO implements IApplicationReferenceAlarmListPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceAlarmListH2PersistenceDAO.class); + + public ApplicationReferenceAlarmListH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override public ApplicationReferenceAlarmList get(String id) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(ApplicationReferenceAlarmList data) { + return null; + } + + @Override public H2SqlEntity prepareBatchUpdate(ApplicationReferenceAlarmList data) { + return null; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMinuteMetricH2PersistenceDAO.java similarity index 95% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMinuteMetricH2PersistenceDAO.java index 09c8d17ff..d9e4ea4dc 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMinuteMetricH2PersistenceDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import java.sql.ResultSet; @@ -25,26 +24,26 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author peng-yongsheng, clevertension */ -public class ApplicationReferenceMetricH2PersistenceDAO extends H2DAO implements IApplicationReferenceMetricPersistenceDAO { +public class ApplicationReferenceMinuteMetricH2PersistenceDAO extends H2DAO implements IApplicationReferenceMinuteMetricPersistenceDAO { - private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceMetricH2PersistenceDAO.class); + private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceMinuteMetricH2PersistenceDAO.class); private static final String GET_SQL = "select * from {0} where {1} = ?"; - public ApplicationReferenceMetricH2PersistenceDAO(H2Client client) { + public ApplicationReferenceMinuteMetricH2PersistenceDAO(H2Client client) { super(client); } @@ -54,7 +53,8 @@ public class ApplicationReferenceMetricH2PersistenceDAO extends H2DAO implements Object[] params = new Object[] {id}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { - ApplicationReferenceMetric applicationReferenceMetric = new ApplicationReferenceMetric(id); + ApplicationReferenceMetric applicationReferenceMetric = new ApplicationReferenceMetric(); + applicationReferenceMetric.setId(id); applicationReferenceMetric.setFrontApplicationId(rs.getInt(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID)); applicationReferenceMetric.setBehindApplicationId(rs.getInt(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuSecondMetricH2PersistenceDAO.java similarity index 86% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuSecondMetricH2PersistenceDAO.java index a3b52f1c9..47cacb3b7 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuSecondMetricH2PersistenceDAO.java @@ -26,7 +26,7 @@ import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; import org.apache.skywalking.apm.collector.client.h2.H2Client; -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.h2.base.dao.H2DAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,11 +34,11 @@ import org.slf4j.LoggerFactory; /** * @author peng-yongsheng, clevertension */ -public class CpuMetricH2PersistenceDAO extends H2DAO implements ICpuMetricPersistenceDAO { +public class CpuSecondMetricH2PersistenceDAO extends H2DAO implements ICpuSecondMetricPersistenceDAO { - private final Logger logger = LoggerFactory.getLogger(CpuMetricH2PersistenceDAO.class); + private final Logger logger = LoggerFactory.getLogger(CpuSecondMetricH2PersistenceDAO.class); - public CpuMetricH2PersistenceDAO(H2Client client) { + public CpuSecondMetricH2PersistenceDAO(H2Client client) { super(client); } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCSecondMetricH2PersistenceDAO.java similarity index 88% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCSecondMetricH2PersistenceDAO.java index a83d83457..d6c9e3388 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCSecondMetricH2PersistenceDAO.java @@ -24,7 +24,7 @@ import java.util.Map; import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -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.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; @@ -32,9 +32,9 @@ import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetric; /** * @author peng-yongsheng, clevertension */ -public class GCMetricH2PersistenceDAO extends H2DAO implements IGCMetricPersistenceDAO { +public class GCSecondMetricH2PersistenceDAO extends H2DAO implements IGCSecondMetricPersistenceDAO { - public GCMetricH2PersistenceDAO(H2Client client) { + public GCSecondMetricH2PersistenceDAO(H2Client client) { super(client); } @@ -49,7 +49,6 @@ public class GCMetricH2PersistenceDAO extends H2DAO implements IGCMetricPersiste source.put(GCMetricTable.COLUMN_INSTANCE_ID, data.getInstanceId()); source.put(GCMetricTable.COLUMN_PHRASE, data.getPhrase()); source.put(GCMetricTable.COLUMN_COUNT, data.getCount()); - source.put(GCMetricTable.COLUMN_TIME, data.getTime()); source.put(GCMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); String sql = SqlBuilder.buildBatchInsertSql(GCMetricTable.TABLE, source.keySet()); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceAlarmH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceAlarmH2PersistenceDAO.java new file mode 100644 index 000000000..b807b76e7 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceAlarmH2PersistenceDAO.java @@ -0,0 +1,55 @@ +/* + * 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.storage.h2.dao; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmH2PersistenceDAO extends H2DAO implements IInstanceAlarmPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceAlarmH2PersistenceDAO.class); + + public InstanceAlarmH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override public InstanceAlarm get(String id) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(InstanceAlarm data) { + return null; + } + + @Override public H2SqlEntity prepareBatchUpdate(InstanceAlarm data) { + return null; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceAlarmListH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceAlarmListH2PersistenceDAO.java new file mode 100644 index 000000000..ccf739a47 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceAlarmListH2PersistenceDAO.java @@ -0,0 +1,55 @@ +/* + * 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.storage.h2.dao; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmListH2PersistenceDAO extends H2DAO implements IInstanceAlarmListPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceAlarmListH2PersistenceDAO.class); + + public InstanceAlarmListH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override public InstanceAlarmList get(String id) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(InstanceAlarmList data) { + return null; + } + + @Override public H2SqlEntity prepareBatchUpdate(InstanceAlarmList data) { + return null; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2CacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2CacheDAO.java index dc7425a11..e02b4f738 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2CacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2CacheDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import java.sql.ResultSet; @@ -24,7 +23,7 @@ import java.sql.SQLException; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IInstanceCacheDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; import org.slf4j.Logger; @@ -38,14 +37,14 @@ public class InstanceH2CacheDAO extends H2DAO implements IInstanceCacheDAO { private final Logger logger = LoggerFactory.getLogger(InstanceH2CacheDAO.class); private static final String GET_APPLICATION_ID_SQL = "select {0} from {1} where {2} = ?"; - private static final String GET_INSTANCE_ID_SQL = "select {0} from {1} where {2} = ? and {3} = ?"; + private static final String GET_INSTANCE_ID_SQL = "select {0} from {1} where {2} = ? and {3} = ? and {4} = ?"; public InstanceH2CacheDAO(H2Client client) { super(client); } @Override public int getApplicationId(int instanceId) { - logger.info("get the application getId with application getId = {}", instanceId); + logger.info("get the application id by instance id = {}", instanceId); H2Client client = getClient(); String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_SQL, InstanceTable.COLUMN_APPLICATION_ID, InstanceTable.TABLE, InstanceTable.COLUMN_INSTANCE_ID); Object[] params = new Object[] {instanceId}; @@ -59,12 +58,28 @@ public class InstanceH2CacheDAO extends H2DAO implements IInstanceCacheDAO { return 0; } - @Override public int getInstanceId(int applicationId, String agentUUID) { - logger.info("get the application getId with application getId = {}, agentUUID = {}", applicationId, agentUUID); + @Override public int getInstanceIdByAgentUUID(int applicationId, String agentUUID) { + logger.info("get the instance id by application id = {}, agentUUID = {}", applicationId, agentUUID); H2Client client = getClient(); String sql = SqlBuilder.buildSql(GET_INSTANCE_ID_SQL, InstanceTable.COLUMN_INSTANCE_ID, InstanceTable.TABLE, InstanceTable.COLUMN_APPLICATION_ID, - InstanceTable.COLUMN_AGENT_UUID); - Object[] params = new Object[] {applicationId, agentUUID}; + InstanceTable.COLUMN_AGENT_UUID, InstanceTable.COLUMN_IS_ADDRESS); + Object[] params = new Object[] {applicationId, agentUUID, false}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getInt(InstanceTable.COLUMN_INSTANCE_ID); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0; + } + + @Override public int getInstanceIdByAddressId(int applicationId, int addressId) { + logger.info("get the instance id by application id = {}, address id = {}", applicationId, addressId); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_INSTANCE_ID_SQL, InstanceTable.COLUMN_INSTANCE_ID, InstanceTable.TABLE, InstanceTable.COLUMN_APPLICATION_ID, + InstanceTable.COLUMN_AGENT_UUID, InstanceTable.COLUMN_IS_ADDRESS); + Object[] params = new Object[] {applicationId, addressId, true}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { return rs.getInt(InstanceTable.COLUMN_INSTANCE_ID); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2RegisterDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2RegisterDAO.java index f446370c9..1bb794b40 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2RegisterDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2RegisterDAO.java @@ -16,18 +16,17 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +34,7 @@ import org.slf4j.LoggerFactory; * @author peng-yongsheng, clevertension */ public class InstanceH2RegisterDAO extends H2DAO implements IInstanceRegisterDAO { - + private final Logger logger = LoggerFactory.getLogger(InstanceH2RegisterDAO.class); public InstanceH2RegisterDAO(H2Client client) { @@ -62,6 +61,9 @@ public class InstanceH2RegisterDAO extends H2DAO implements IInstanceRegisterDAO source.put(InstanceTable.COLUMN_REGISTER_TIME, instance.getRegisterTime()); source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, instance.getHeartBeatTime()); source.put(InstanceTable.COLUMN_OS_INFO, instance.getOsInfo()); + source.put(InstanceTable.COLUMN_ADDRESS_ID, instance.getAddressId()); + source.put(InstanceTable.COLUMN_IS_ADDRESS, instance.getIsAddress()); + String sql = SqlBuilder.buildBatchInsertSql(InstanceTable.TABLE, source.keySet()); Object[] params = source.values().toArray(new Object[0]); try { diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java index 2d92f6850..674cbee05 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import com.google.gson.JsonArray; @@ -25,14 +24,14 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.LinkedList; import java.util.List; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.table.register.Instance; -import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.register.Instance; +import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -117,7 +116,8 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO { Object[] params = new Object[] {instanceId}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { - Instance instance = new Instance(rs.getString(InstanceTable.COLUMN_ID)); + Instance instance = new Instance(); + instance.setId(rs.getString(InstanceTable.COLUMN_ID)); instance.setApplicationId(rs.getInt(InstanceTable.COLUMN_APPLICATION_ID)); instance.setAgentUUID(rs.getString(InstanceTable.COLUMN_AGENT_UUID)); instance.setRegisterTime(rs.getLong(InstanceTable.COLUMN_REGISTER_TIME)); @@ -140,7 +140,8 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO { Object[] params = new Object[] {applicationId, timeBucket}; try (ResultSet rs = client.executeQuery(sql, params)) { while (rs.next()) { - Instance instance = new Instance(rs.getString(InstanceTable.COLUMN_ID)); + Instance instance = new Instance(); + instance.setId(rs.getString(InstanceTable.COLUMN_ID)); instance.setApplicationId(rs.getInt(InstanceTable.COLUMN_APPLICATION_ID)); instance.setHeartBeatTime(rs.getLong(InstanceTable.COLUMN_HEARTBEAT_TIME)); instance.setInstanceId(rs.getInt(InstanceTable.COLUMN_INSTANCE_ID)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceHeartBeatH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceHeartBeatH2PersistenceDAO.java index c24b9f967..4034e899f 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceHeartBeatH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceHeartBeatH2PersistenceDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import java.sql.ResultSet; @@ -26,6 +25,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.core.UnexpectedException; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO; @@ -33,7 +33,6 @@ import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,7 +55,8 @@ public class InstanceHeartBeatH2PersistenceDAO extends H2DAO implements IInstanc Object[] params = new Object[] {id}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { - Instance instance = new Instance(id); + Instance instance = new Instance(); + instance.setId(id); instance.setInstanceId(rs.getInt(InstanceTable.COLUMN_INSTANCE_ID)); instance.setHeartBeatTime(rs.getLong(InstanceTable.COLUMN_HEARTBEAT_TIME)); return instance; diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMappingH2MinutePersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMappingH2MinutePersistenceDAO.java new file mode 100644 index 000000000..d5e0a57f3 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMappingH2MinutePersistenceDAO.java @@ -0,0 +1,102 @@ +/* + * 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.storage.h2.dao; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class InstanceMappingH2MinutePersistenceDAO extends H2DAO implements IInstanceMappingMinutePersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceMappingH2MinutePersistenceDAO.class); + private static final String GET_SQL = "select * from {0} where {1} = ?"; + + public InstanceMappingH2MinutePersistenceDAO(H2Client client) { + super(client); + } + + @Override public InstanceMapping get(String id) { + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_SQL, InstanceMappingTable.TABLE, InstanceMappingTable.COLUMN_ID); + Object[] params = new Object[] {id}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + InstanceMapping instanceMapping = new InstanceMapping(); + instanceMapping.setId(id); + instanceMapping.setApplicationId(rs.getInt(InstanceMappingTable.COLUMN_APPLICATION_ID)); + instanceMapping.setInstanceId(rs.getInt(InstanceMappingTable.COLUMN_INSTANCE_ID)); + instanceMapping.setAddressId(rs.getInt(InstanceMappingTable.COLUMN_ADDRESS_ID)); + instanceMapping.setTimeBucket(rs.getLong(InstanceMappingTable.COLUMN_TIME_BUCKET)); + return instanceMapping; + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(InstanceMapping instanceMapping) { + Map source = new HashMap<>(); + H2SqlEntity entity = new H2SqlEntity(); + source.put(InstanceMappingTable.COLUMN_ID, instanceMapping.getId()); + source.put(InstanceMappingTable.COLUMN_APPLICATION_ID, instanceMapping.getApplicationId()); + source.put(InstanceMappingTable.COLUMN_INSTANCE_ID, instanceMapping.getInstanceId()); + source.put(InstanceMappingTable.COLUMN_ADDRESS_ID, instanceMapping.getAddressId()); + source.put(InstanceMappingTable.COLUMN_TIME_BUCKET, instanceMapping.getTimeBucket()); + String sql = SqlBuilder.buildBatchInsertSql(InstanceMappingTable.TABLE, source.keySet()); + entity.setSql(sql); + + entity.setParams(source.values().toArray(new Object[0])); + return entity; + } + + @Override public H2SqlEntity prepareBatchUpdate(InstanceMapping instanceMapping) { + Map source = new HashMap<>(); + H2SqlEntity entity = new H2SqlEntity(); + source.put(InstanceMappingTable.COLUMN_APPLICATION_ID, instanceMapping.getApplicationId()); + source.put(InstanceMappingTable.COLUMN_INSTANCE_ID, instanceMapping.getInstanceId()); + source.put(InstanceMappingTable.COLUMN_ADDRESS_ID, instanceMapping.getAddressId()); + source.put(InstanceMappingTable.COLUMN_TIME_BUCKET, instanceMapping.getTimeBucket()); + String sql = SqlBuilder.buildBatchUpdateSql(InstanceMappingTable.TABLE, source.keySet(), InstanceMappingTable.COLUMN_ID); + entity.setSql(sql); + List values = new ArrayList<>(source.values()); + values.add(instanceMapping.getId()); + entity.setParams(values.toArray(new Object[0])); + return entity; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMinuteMetricH2PersistenceDAO.java similarity index 95% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMinuteMetricH2PersistenceDAO.java index 6b89183f6..657370990 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMinuteMetricH2PersistenceDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import java.sql.ResultSet; @@ -25,13 +24,13 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; -import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,12 +38,12 @@ import org.slf4j.LoggerFactory; /** * @author peng-yongsheng, clevertension */ -public class InstanceMetricH2PersistenceDAO extends H2DAO implements IInstanceMetricPersistenceDAO { +public class InstanceMinuteMetricH2PersistenceDAO extends H2DAO implements IInstanceMinuteMetricPersistenceDAO { - private final Logger logger = LoggerFactory.getLogger(InstanceMetricH2PersistenceDAO.class); + private final Logger logger = LoggerFactory.getLogger(InstanceMinuteMetricH2PersistenceDAO.class); private static final String GET_SQL = "select * from {0} where {1} = ?"; - public InstanceMetricH2PersistenceDAO(H2Client client) { + public InstanceMinuteMetricH2PersistenceDAO(H2Client client) { super(client); } @@ -54,7 +53,8 @@ public class InstanceMetricH2PersistenceDAO extends H2DAO implements IInstanceMe Object[] params = new Object[] {id}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { - InstanceMetric instanceMetric = new InstanceMetric(id); + InstanceMetric instanceMetric = new InstanceMetric(); + instanceMetric.setId(id); instanceMetric.setApplicationId(rs.getInt(InstanceMetricTable.COLUMN_APPLICATION_ID)); instanceMetric.setInstanceId(rs.getInt(InstanceMetricTable.COLUMN_INSTANCE_ID)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceReferenceAlarmH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceReferenceAlarmH2PersistenceDAO.java new file mode 100644 index 000000000..7e67a9aee --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceReferenceAlarmH2PersistenceDAO.java @@ -0,0 +1,55 @@ +/* + * 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.storage.h2.dao; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceReferenceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarm; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceAlarmH2PersistenceDAO extends H2DAO implements IInstanceReferenceAlarmPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceReferenceAlarmH2PersistenceDAO.class); + + public InstanceReferenceAlarmH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override public InstanceReferenceAlarm get(String id) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(InstanceReferenceAlarm data) { + return null; + } + + @Override public H2SqlEntity prepareBatchUpdate(InstanceReferenceAlarm data) { + return null; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceReferenceAlarmListH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceReferenceAlarmListH2PersistenceDAO.java new file mode 100644 index 000000000..1ea9c3227 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceReferenceAlarmListH2PersistenceDAO.java @@ -0,0 +1,55 @@ +/* + * 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.storage.h2.dao; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IInstanceReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceReferenceAlarmList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceReferenceAlarmListH2PersistenceDAO extends H2DAO implements IInstanceReferenceAlarmListPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceReferenceAlarmListH2PersistenceDAO.class); + + public InstanceReferenceAlarmListH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override public InstanceReferenceAlarmList get(String id) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(InstanceReferenceAlarmList data) { + return null; + } + + @Override public H2SqlEntity prepareBatchUpdate(InstanceReferenceAlarmList data) { + return null; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceReferenceMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceReferenceMetricH2PersistenceDAO.java index 39bc9616b..1c4cf1156 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceReferenceMetricH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceReferenceMetricH2PersistenceDAO.java @@ -27,7 +27,7 @@ import java.util.Map; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceReferenceMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.irmp.IInstanceReferenceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; @@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory; /** * @author peng-yongsheng, clevertension */ -public class InstanceReferenceMetricH2PersistenceDAO extends H2DAO implements IInstanceReferenceMetricPersistenceDAO { +public class InstanceReferenceMetricH2PersistenceDAO extends H2DAO implements IInstanceReferenceMinuteMetricPersistenceDAO { private final Logger logger = LoggerFactory.getLogger(InstanceReferenceMetricH2PersistenceDAO.class); private static final String GET_SQL = "select * from {0} where {1} = ?"; @@ -53,7 +53,8 @@ public class InstanceReferenceMetricH2PersistenceDAO extends H2DAO implements II Object[] params = new Object[] {id}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { - InstanceReferenceMetric instanceReferenceMetric = new InstanceReferenceMetric(id); + InstanceReferenceMetric instanceReferenceMetric = new InstanceReferenceMetric(); + instanceReferenceMetric.setId(id); instanceReferenceMetric.setFrontInstanceId(rs.getInt(InstanceReferenceMetricTable.COLUMN_FRONT_INSTANCE_ID)); instanceReferenceMetric.setBehindInstanceId(rs.getInt(InstanceReferenceMetricTable.COLUMN_BEHIND_INSTANCE_ID)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolSecondMetricH2PersistenceDAO.java similarity index 89% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolSecondMetricH2PersistenceDAO.java index f23f31b25..1d3aa6a23 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolSecondMetricH2PersistenceDAO.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.mpoolmp.IMemoryPoolSecondMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetric; @@ -32,9 +32,9 @@ import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTab /** * @author peng-yongsheng, clevertension */ -public class MemoryPoolMetricH2PersistenceDAO extends H2DAO implements IMemoryPoolMetricPersistenceDAO { +public class MemoryPoolSecondMetricH2PersistenceDAO extends H2DAO implements IMemoryPoolSecondMetricPersistenceDAO { - public MemoryPoolMetricH2PersistenceDAO(H2Client client) { + public MemoryPoolSecondMetricH2PersistenceDAO(H2Client client) { super(client); } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemorySecondMetricH2PersistenceDAO.java similarity index 89% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemorySecondMetricH2PersistenceDAO.java index a67a9597a..b5115d43a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemorySecondMetricH2PersistenceDAO.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemorySecondMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetric; @@ -32,9 +32,9 @@ import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; /** * @author peng-yongsheng, clevertension */ -public class MemoryMetricH2PersistenceDAO extends H2DAO implements IMemoryMetricPersistenceDAO { +public class MemorySecondMetricH2PersistenceDAO extends H2DAO implements IMemorySecondMetricPersistenceDAO { - public MemoryMetricH2PersistenceDAO(H2Client client) { + public MemorySecondMetricH2PersistenceDAO(H2Client client) { super(client); } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/NetworkAddressH2CacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/NetworkAddressH2CacheDAO.java new file mode 100644 index 000000000..336e191cd --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/NetworkAddressH2CacheDAO.java @@ -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.storage.h2.dao; + +import java.sql.ResultSet; +import java.sql.SQLException; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.cache.INetworkAddressCacheDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddressTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class NetworkAddressH2CacheDAO extends H2DAO implements INetworkAddressCacheDAO { + + private final Logger logger = LoggerFactory.getLogger(NetworkAddressH2CacheDAO.class); + + private static final String GET_ADDRESS_ID_OR_CODE_SQL = "select {0} from {1} where {2} = ?"; + + public NetworkAddressH2CacheDAO(H2Client client) { + super(client); + } + + @Override + public int getAddressId(String networkAddress) { + logger.info("get the address id with network address = {}", networkAddress); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_ADDRESS_ID_OR_CODE_SQL, NetworkAddressTable.COLUMN_ADDRESS_ID, NetworkAddressTable.TABLE, NetworkAddressTable.COLUMN_NETWORK_ADDRESS); + + Object[] params = new Object[] {networkAddress}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getInt(1); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0; + } + + @Override public String getAddress(int addressId) { + logger.debug("get network address, address id: {}", addressId); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_ADDRESS_ID_OR_CODE_SQL, NetworkAddressTable.COLUMN_NETWORK_ADDRESS, NetworkAddressTable.TABLE, NetworkAddressTable.COLUMN_ADDRESS_ID); + Object[] params = new Object[] {addressId}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getString(1); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return Const.EMPTY_STRING; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/NetworkAddressRegisterH2DAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/NetworkAddressRegisterH2DAO.java new file mode 100644 index 000000000..4068dd8d7 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/NetworkAddressRegisterH2DAO.java @@ -0,0 +1,71 @@ +/* + * 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.storage.h2.dao; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.register.INetworkAddressRegisterDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddress; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddressTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class NetworkAddressRegisterH2DAO extends H2DAO implements INetworkAddressRegisterDAO { + + private final Logger logger = LoggerFactory.getLogger(NetworkAddressRegisterH2DAO.class); + + public NetworkAddressRegisterH2DAO(H2Client client) { + super(client); + } + + @Override + public int getMaxNetworkAddressId() { + return getMaxId(NetworkAddressTable.TABLE, NetworkAddressTable.COLUMN_ADDRESS_ID); + } + + @Override + public int getMinNetworkAddressId() { + return getMinId(NetworkAddressTable.TABLE, NetworkAddressTable.COLUMN_ADDRESS_ID); + } + + @Override + public void save(NetworkAddress networkAddress) { + H2Client client = getClient(); + + Map source = new HashMap<>(); + source.put(NetworkAddressTable.COLUMN_ID, networkAddress.getId()); + source.put(NetworkAddressTable.COLUMN_NETWORK_ADDRESS, networkAddress.getNetworkAddress()); + source.put(NetworkAddressTable.COLUMN_ADDRESS_ID, networkAddress.getAddressId()); + + String sql = SqlBuilder.buildBatchInsertSql(NetworkAddressTable.TABLE, source.keySet()); + Object[] params = source.values().toArray(new Object[0]); + try { + client.execute(sql, params); + } catch (H2ClientException e) { + logger.error(e.getMessage(), e); + } + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceAlarmH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceAlarmH2PersistenceDAO.java new file mode 100644 index 000000000..05df9059e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceAlarmH2PersistenceDAO.java @@ -0,0 +1,55 @@ +/* + * 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.storage.h2.dao; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarm; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ServiceAlarmH2PersistenceDAO extends H2DAO implements IServiceAlarmPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ServiceAlarmH2PersistenceDAO.class); + + public ServiceAlarmH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override public ServiceAlarm get(String id) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(ServiceAlarm data) { + return null; + } + + @Override public H2SqlEntity prepareBatchUpdate(ServiceAlarm data) { + return null; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceAlarmListH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceAlarmListH2PersistenceDAO.java new file mode 100644 index 000000000..88b3d2a61 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceAlarmListH2PersistenceDAO.java @@ -0,0 +1,55 @@ +/* + * 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.storage.h2.dao; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarmList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ServiceAlarmListH2PersistenceDAO extends H2DAO implements IServiceAlarmListPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ServiceAlarmListH2PersistenceDAO.class); + + public ServiceAlarmListH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override public ServiceAlarmList get(String id) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(ServiceAlarmList data) { + return null; + } + + @Override public H2SqlEntity prepareBatchUpdate(ServiceAlarmList data) { + return null; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceEntryH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceEntryH2PersistenceDAO.java deleted file mode 100644 index 2c1d902de..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceEntryH2PersistenceDAO.java +++ /dev/null @@ -1,104 +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.storage.h2.dao; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntry; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class ServiceEntryH2PersistenceDAO extends H2DAO implements IServiceEntryPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(ServiceEntryH2PersistenceDAO.class); - private static final String GET_SERVICE_ENTRY_SQL = "select * from {0} where {1} = ?"; - - public ServiceEntryH2PersistenceDAO(H2Client client) { - super(client); - } - - @Override public ServiceEntry get(String id) { - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_SERVICE_ENTRY_SQL, ServiceEntryTable.TABLE, ServiceEntryTable.COLUMN_ID); - Object[] params = new Object[] {id}; - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - ServiceEntry serviceEntry = new ServiceEntry(id); - serviceEntry.setApplicationId(rs.getInt(ServiceEntryTable.COLUMN_APPLICATION_ID)); - serviceEntry.setEntryServiceId(rs.getInt(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID)); - serviceEntry.setEntryServiceName(rs.getString(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME)); - serviceEntry.setRegisterTime(rs.getLong(ServiceEntryTable.COLUMN_REGISTER_TIME)); - serviceEntry.setNewestTime(rs.getLong(ServiceEntryTable.COLUMN_NEWEST_TIME)); - return serviceEntry; - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return null; - } - - @Override public H2SqlEntity prepareBatchInsert(ServiceEntry data) { - H2SqlEntity entity = new H2SqlEntity(); - Map source = new HashMap<>(); - source.put(ServiceEntryTable.COLUMN_ID, data.getId()); - source.put(ServiceEntryTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, data.getEntryServiceId()); - source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, data.getEntryServiceName()); - source.put(ServiceEntryTable.COLUMN_REGISTER_TIME, data.getRegisterTime()); - source.put(ServiceEntryTable.COLUMN_NEWEST_TIME, data.getNewestTime()); - String sql = SqlBuilder.buildBatchInsertSql(ServiceEntryTable.TABLE, source.keySet()); - entity.setSql(sql); - entity.setParams(source.values().toArray(new Object[0])); - return entity; - } - - @Override public H2SqlEntity prepareBatchUpdate(ServiceEntry data) { - H2SqlEntity entity = new H2SqlEntity(); - Map source = new HashMap<>(); - source.put(ServiceEntryTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, data.getEntryServiceId()); - source.put(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, data.getEntryServiceName()); - source.put(ServiceEntryTable.COLUMN_REGISTER_TIME, data.getRegisterTime()); - source.put(ServiceEntryTable.COLUMN_NEWEST_TIME, data.getNewestTime()); - String sql = SqlBuilder.buildBatchUpdateSql(ServiceEntryTable.TABLE, source.keySet(), ServiceEntryTable.COLUMN_ID); - entity.setSql(sql); - List values = new ArrayList<>(source.values()); - values.add(data.getId()); - entity.setParams(values.toArray(new Object[0])); - return entity; - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceEntryH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceEntryH2UIDAO.java deleted file mode 100644 index 2f1f68643..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceEntryH2UIDAO.java +++ /dev/null @@ -1,102 +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.storage.h2.dao; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; -import org.apache.skywalking.apm.collector.core.util.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class ServiceEntryH2UIDAO extends H2DAO implements IServiceEntryUIDAO { - - private final Logger logger = LoggerFactory.getLogger(ServiceEntryH2UIDAO.class); - private static final String GET_SERVICE_ENTRY_SQL = "select * from {0} where {1} >= ? and {2} <= ?"; - - public ServiceEntryH2UIDAO(H2Client client) { - super(client); - } - - @Override public JsonObject load(int applicationId, String entryServiceName, long startTime, long endTime, int from, - int size) { - H2Client client = getClient(); - String sql = GET_SERVICE_ENTRY_SQL; - List params = new ArrayList<>(); - List columns = new ArrayList<>(); - columns.add(ServiceEntryTable.TABLE); - columns.add(ServiceEntryTable.COLUMN_NEWEST_TIME); - columns.add(ServiceEntryTable.COLUMN_REGISTER_TIME); - params.add(startTime); - params.add(endTime); - int paramIndex = 2; - if (applicationId != 0) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} = ?"; - params.add(applicationId); - columns.add(ServiceEntryTable.COLUMN_APPLICATION_ID); - } - if (StringUtils.isNotEmpty(entryServiceName)) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} = ?"; - params.add(entryServiceName); - columns.add(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME); - } - sql = sql + " limit " + from + "," + size; - sql = SqlBuilder.buildSql(sql, columns); - Object[] p = params.toArray(new Object[0]); - JsonArray serviceArray = new JsonArray(); - JsonObject response = new JsonObject(); - int index = 0; - try (ResultSet rs = client.executeQuery(sql, p)) { - while (rs.next()) { - int appId = rs.getInt(ServiceEntryTable.COLUMN_APPLICATION_ID); - int entryServiceId = rs.getInt(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID); - String entryServiceName1 = rs.getString(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME); - - JsonObject row = new JsonObject(); - row.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID), entryServiceId); - row.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME), entryServiceName1); - row.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_APPLICATION_ID), appId); - serviceArray.add(row); - index++; - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - response.addProperty("total", index); - response.add("array", serviceArray); - - return response; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceMinuteMetricH2PersistenceDAO.java similarity index 95% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceMetricH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceMinuteMetricH2PersistenceDAO.java index aae73ed23..d8973f6e7 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceMetricH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceMinuteMetricH2PersistenceDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import java.sql.ResultSet; @@ -25,26 +24,26 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.storage.dao.IServiceMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author peng-yongsheng, clevertension */ -public class ServiceMetricH2PersistenceDAO extends H2DAO implements IServiceMetricPersistenceDAO { +public class ServiceMinuteMetricH2PersistenceDAO extends H2DAO implements IServiceMinuteMetricPersistenceDAO { - private final Logger logger = LoggerFactory.getLogger(ServiceMetricH2PersistenceDAO.class); + private final Logger logger = LoggerFactory.getLogger(ServiceMinuteMetricH2PersistenceDAO.class); private static final String GET_SQL = "select * from {0} where {1} = ?"; - public ServiceMetricH2PersistenceDAO(H2Client client) { + public ServiceMinuteMetricH2PersistenceDAO(H2Client client) { super(client); } @@ -55,7 +54,8 @@ public class ServiceMetricH2PersistenceDAO extends H2DAO implements IServiceMetr Object[] params = new Object[] {id}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { - ServiceMetric serviceMetric = new ServiceMetric(id); + ServiceMetric serviceMetric = new ServiceMetric(); + serviceMetric.setId(id); serviceMetric.setServiceId(rs.getInt(ServiceMetricTable.COLUMN_SERVICE_ID)); serviceMetric.setTransactionCalls(rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceNameH2CacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceNameH2CacheDAO.java index 1520d2217..2db433d1e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceNameH2CacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceNameH2CacheDAO.java @@ -25,7 +25,7 @@ import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO; +import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable; import org.slf4j.Logger; diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceNameH2RegisterDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceNameH2RegisterDAO.java index 3376ca43a..a271ca11f 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceNameH2RegisterDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceNameH2RegisterDAO.java @@ -22,7 +22,7 @@ package org.apache.skywalking.apm.collector.storage.h2.dao; import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IServiceNameRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.register.IServiceNameRegisterDAO; import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceAlarmH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceAlarmH2PersistenceDAO.java new file mode 100644 index 000000000..0625a185b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceAlarmH2PersistenceDAO.java @@ -0,0 +1,55 @@ +/* + * 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.storage.h2.dao; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceReferenceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarm; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceAlarmH2PersistenceDAO extends H2DAO implements IServiceReferenceAlarmPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ServiceReferenceAlarmH2PersistenceDAO.class); + + public ServiceReferenceAlarmH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override public ServiceReferenceAlarm get(String id) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(ServiceReferenceAlarm data) { + return null; + } + + @Override public H2SqlEntity prepareBatchUpdate(ServiceReferenceAlarm data) { + return null; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceAlarmListH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceAlarmListH2PersistenceDAO.java new file mode 100644 index 000000000..6b0b329b5 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceAlarmListH2PersistenceDAO.java @@ -0,0 +1,55 @@ +/* + * 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.storage.h2.dao; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IServiceReferenceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceReferenceAlarmList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceAlarmListH2PersistenceDAO extends H2DAO implements IServiceReferenceAlarmListPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ServiceReferenceAlarmListH2PersistenceDAO.class); + + public ServiceReferenceAlarmListH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override public ServiceReferenceAlarmList get(String id) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(ServiceReferenceAlarmList data) { + return null; + } + + @Override public H2SqlEntity prepareBatchUpdate(ServiceReferenceAlarmList data) { + return null; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceH2UIDAO.java index d7bdb8fd9..c78ea2fee 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceH2UIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import com.google.gson.JsonObject; @@ -24,11 +23,11 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.LinkedHashMap; import java.util.Map; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; @@ -53,7 +52,7 @@ public class ServiceReferenceH2UIDAO extends H2DAO implements IServiceReferenceU public Map load(int entryServiceId, long startTime, long endTime) { H2Client client = getClient(); String sql = SqlBuilder.buildSql(GET_SRV_REF_LOAD1, ServiceReferenceMetricTable.TABLE, - ServiceReferenceMetricTable.COLUMN_TIME_BUCKET, ServiceReferenceMetricTable.COLUMN_ENTRY_SERVICE_ID, + ServiceReferenceMetricTable.COLUMN_TIME_BUCKET, ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS, ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceMetricH2PersistenceDAO.java index ff8cbdb25..a1cb5cfd5 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceMetricH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceMetricH2PersistenceDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import java.sql.ResultSet; @@ -26,20 +25,20 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author peng-yongsheng, clevertension */ -public class ServiceReferenceMetricH2PersistenceDAO extends H2DAO implements IServiceReferenceMetricPersistenceDAO { +public class ServiceReferenceMetricH2PersistenceDAO extends H2DAO implements IServiceReferenceMinuteMetricPersistenceDAO { private final Logger logger = LoggerFactory.getLogger(ServiceReferenceMetricH2PersistenceDAO.class); private static final String GET_SQL = "select * from {0} where {1} = ?"; @@ -55,8 +54,8 @@ public class ServiceReferenceMetricH2PersistenceDAO extends H2DAO implements ISe Object[] params = new Object[] {id}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { - ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(id); - serviceReferenceMetric.setEntryServiceId(rs.getInt(ServiceReferenceMetricTable.COLUMN_ENTRY_SERVICE_ID)); + ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(); + serviceReferenceMetric.setId(id); serviceReferenceMetric.setFrontServiceId(rs.getInt(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)); serviceReferenceMetric.setBehindServiceId(rs.getInt(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)); serviceReferenceMetric.setSourceValue(rs.getInt(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE)); @@ -90,7 +89,6 @@ public class ServiceReferenceMetricH2PersistenceDAO extends H2DAO implements ISe H2SqlEntity entity = new H2SqlEntity(); Map source = new HashMap<>(); source.put(ServiceReferenceMetricTable.COLUMN_ID, data.getId()); - source.put(ServiceReferenceMetricTable.COLUMN_ENTRY_SERVICE_ID, data.getEntryServiceId()); source.put(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, data.getFrontServiceId()); source.put(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, data.getBehindServiceId()); source.put(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); @@ -122,7 +120,6 @@ public class ServiceReferenceMetricH2PersistenceDAO extends H2DAO implements ISe public H2SqlEntity prepareBatchUpdate(ServiceReferenceMetric data) { H2SqlEntity entity = new H2SqlEntity(); Map source = new HashMap<>(); - source.put(ServiceReferenceMetricTable.COLUMN_ENTRY_SERVICE_ID, data.getEntryServiceId()); source.put(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, data.getFrontServiceId()); source.put(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, data.getBehindServiceId()); source.put(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/AlertingListH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/AlertingListH2TableDefine.java deleted file mode 100644 index 8a905602f..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/AlertingListH2TableDefine.java +++ /dev/null @@ -1,47 +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.storage.h2.define; - -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine; -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; -import org.apache.skywalking.apm.collector.storage.table.alerting.AlertingListTable; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; - -/** - * @author peng-yongsheng - */ -public class AlertingListH2TableDefine extends H2TableDefine { - - public AlertingListH2TableDefine() { - super(AlertingListTable.TABLE); - } - - @Override public void initialize() { - addColumn(new H2ColumnDefine(ApplicationComponentTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); - - addColumn(new H2ColumnDefine(AlertingListTable.COLUMN_LAYER, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(AlertingListTable.COLUMN_LAYER_ID, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(AlertingListTable.COLUMN_FIRST_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name())); - addColumn(new H2ColumnDefine(AlertingListTable.COLUMN_LAST_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name())); - addColumn(new H2ColumnDefine(AlertingListTable.COLUMN_EXPECTED, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(AlertingListTable.COLUMN_ACTUAL, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(AlertingListTable.COLUMN_VALID, H2ColumnDefine.Type.Boolean.name())); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/ApplicationH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/ApplicationH2TableDefine.java index f7122d763..4b1630d92 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/ApplicationH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/ApplicationH2TableDefine.java @@ -16,11 +16,10 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.define; -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable; /** @@ -36,5 +35,7 @@ public class ApplicationH2TableDefine extends H2TableDefine { addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_APPLICATION_CODE, H2ColumnDefine.Type.Varchar.name())); addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_ADDRESS_ID, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_IS_ADDRESS, H2ColumnDefine.Type.Boolean.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/GCMetricH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/GCMetricH2TableDefine.java index c6e3164b5..c62e38944 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/GCMetricH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/GCMetricH2TableDefine.java @@ -37,7 +37,7 @@ public class GCMetricH2TableDefine extends H2TableDefine { addColumn(new H2ColumnDefine(GCMetricTable.COLUMN_INSTANCE_ID, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(GCMetricTable.COLUMN_PHRASE, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(GCMetricTable.COLUMN_COUNT, H2ColumnDefine.Type.Bigint.name())); - addColumn(new H2ColumnDefine(GCMetricTable.COLUMN_TIME, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(GCMetricTable.COLUMN_TIMES, H2ColumnDefine.Type.Bigint.name())); addColumn(new H2ColumnDefine(GCMetricTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/InstanceH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/InstanceH2TableDefine.java index 7a7667c49..c9fbef734 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/InstanceH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/InstanceH2TableDefine.java @@ -16,12 +16,11 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.define; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine; /** * @author peng-yongsheng @@ -40,5 +39,7 @@ public class InstanceH2TableDefine extends H2TableDefine { addColumn(new H2ColumnDefine(InstanceTable.COLUMN_INSTANCE_ID, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(InstanceTable.COLUMN_HEARTBEAT_TIME, H2ColumnDefine.Type.Bigint.name())); addColumn(new H2ColumnDefine(InstanceTable.COLUMN_OS_INFO, H2ColumnDefine.Type.Varchar.name())); + addColumn(new H2ColumnDefine(InstanceTable.COLUMN_ADDRESS_ID, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(InstanceTable.COLUMN_IS_ADDRESS, H2ColumnDefine.Type.Boolean.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/InstanceMappingH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/InstanceMappingH2TableDefine.java new file mode 100644 index 000000000..422acf77f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/InstanceMappingH2TableDefine.java @@ -0,0 +1,41 @@ +/* + * 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.storage.h2.define; + +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable; + +/** + * @author peng-yongsheng + */ +public class InstanceMappingH2TableDefine extends H2TableDefine { + + public InstanceMappingH2TableDefine() { + super(InstanceMappingTable.TABLE); + } + + @Override public void initialize() { + addColumn(new H2ColumnDefine(InstanceMappingTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); + addColumn(new H2ColumnDefine(InstanceMappingTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(InstanceMappingTable.COLUMN_INSTANCE_ID, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(InstanceMappingTable.COLUMN_ADDRESS_ID, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(InstanceMappingTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/ServiceEntryH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/NetworkAddressH2TableDefine.java similarity index 55% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/ServiceEntryH2TableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/NetworkAddressH2TableDefine.java index e5281330e..4d2c3f9dd 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/ServiceEntryH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/NetworkAddressH2TableDefine.java @@ -16,28 +16,24 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.define; -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddressTable; /** * @author peng-yongsheng */ -public class ServiceEntryH2TableDefine extends H2TableDefine { +public class NetworkAddressH2TableDefine extends H2TableDefine { - public ServiceEntryH2TableDefine() { - super(ServiceEntryTable.TABLE); + public NetworkAddressH2TableDefine() { + super(NetworkAddressTable.TABLE); } @Override public void initialize() { - addColumn(new H2ColumnDefine(ServiceEntryTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); - addColumn(new H2ColumnDefine(ServiceEntryTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(ServiceEntryTable.COLUMN_ENTRY_SERVICE_ID, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(ServiceEntryTable.COLUMN_ENTRY_SERVICE_NAME, H2ColumnDefine.Type.Varchar.name())); - addColumn(new H2ColumnDefine(ServiceEntryTable.COLUMN_REGISTER_TIME, H2ColumnDefine.Type.Bigint.name())); - addColumn(new H2ColumnDefine(ServiceEntryTable.COLUMN_NEWEST_TIME, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(NetworkAddressTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); + addColumn(new H2ColumnDefine(NetworkAddressTable.COLUMN_NETWORK_ADDRESS, H2ColumnDefine.Type.Varchar.name())); + addColumn(new H2ColumnDefine(NetworkAddressTable.COLUMN_ADDRESS_ID, H2ColumnDefine.Type.Int.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/ServiceReferenceMetricH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/ServiceReferenceMetricH2TableDefine.java index 6a8bbeb62..68d96f215 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/ServiceReferenceMetricH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/ServiceReferenceMetricH2TableDefine.java @@ -34,7 +34,6 @@ public class ServiceReferenceMetricH2TableDefine extends H2TableDefine { @Override public void initialize() { addColumn(new H2ColumnDefine(ServiceReferenceMetricTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); - addColumn(new H2ColumnDefine(ServiceReferenceMetricTable.COLUMN_ENTRY_SERVICE_ID, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE, H2ColumnDefine.Type.Int.name())); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define index f511c32b7..47bebfaaf 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define @@ -1,3 +1,4 @@ +org.apache.skywalking.apm.collector.storage.h2.define.NetworkAddressH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.ApplicationH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.InstanceH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.ServiceNameH2TableDefine @@ -10,10 +11,9 @@ org.apache.skywalking.apm.collector.storage.h2.define.InstanceMetricH2TableDefin org.apache.skywalking.apm.collector.storage.h2.define.InstanceReferenceMetricH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.ApplicationComponentH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.ApplicationMappingH2TableDefine +org.apache.skywalking.apm.collector.storage.h2.define.InstanceMappingH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.ApplicationReferenceMetricH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.SegmentCostH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.SegmentH2TableDefine -org.apache.skywalking.apm.collector.storage.h2.define.ServiceEntryH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.ServiceMetricH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.ServiceReferenceMetricH2TableDefine -org.apache.skywalking.apm.collector.storage.h2.define.AlertingListH2TableDefine diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java index 2a0ec11bf..90bc5af2b 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java @@ -16,11 +16,9 @@ * */ - package org.apache.skywalking.apm.collector.ui.jetty; import java.util.Properties; -import org.apache.skywalking.apm.collector.ui.jetty.handler.time.OneInstanceLastTimeGetHandler; import org.apache.skywalking.apm.collector.cache.CacheModule; import org.apache.skywalking.apm.collector.cluster.ClusterModule; import org.apache.skywalking.apm.collector.cluster.service.ModuleListenerService; @@ -46,9 +44,9 @@ import org.apache.skywalking.apm.collector.ui.jetty.handler.instancemetric.Insta import org.apache.skywalking.apm.collector.ui.jetty.handler.instancemetric.InstanceOsInfoGetHandler; import org.apache.skywalking.apm.collector.ui.jetty.handler.naming.UIJettyNamingHandler; import org.apache.skywalking.apm.collector.ui.jetty.handler.naming.UIJettyNamingListener; -import org.apache.skywalking.apm.collector.ui.jetty.handler.servicetree.EntryServiceGetHandler; import org.apache.skywalking.apm.collector.ui.jetty.handler.servicetree.ServiceTreeGetByIdHandler; import org.apache.skywalking.apm.collector.ui.jetty.handler.time.AllInstanceLastTimeGetHandler; +import org.apache.skywalking.apm.collector.ui.jetty.handler.time.OneInstanceLastTimeGetHandler; /** * @author peng-yongsheng @@ -105,7 +103,6 @@ public class UIModuleJettyProvider extends ModuleProvider { jettyServer.addHandler(new InstanceMetricGetOneTimeBucketHandler(getManager())); jettyServer.addHandler(new InstanceMetricGetRangeTimeBucketHandler(getManager())); jettyServer.addHandler(new InstanceOsInfoGetHandler(getManager())); - jettyServer.addHandler(new EntryServiceGetHandler(getManager())); jettyServer.addHandler(new ServiceTreeGetByIdHandler(getManager())); jettyServer.addHandler(new AllInstanceLastTimeGetHandler(getManager())); jettyServer.addHandler(new OneInstanceLastTimeGetHandler(getManager())); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/application/ApplicationsGetHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/application/ApplicationsGetHandler.java index d86b1837d..51ddcc6ce 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/application/ApplicationsGetHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/application/ApplicationsGetHandler.java @@ -52,7 +52,7 @@ public class ApplicationsGetHandler extends JettyHandler { String startTimeStr = req.getParameter("startTime"); String endTimeStr = req.getParameter("endTime"); - logger.debug("applications get start time: {}, end time: {}", startTimeStr, endTimeStr); + logger.debug("applications getApplicationIdByCode start time: {}, end time: {}", startTimeStr, endTimeStr); long startTime; try { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancehealth/InstanceHealthGetHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancehealth/InstanceHealthGetHandler.java index 8bed92fe6..008f4e143 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancehealth/InstanceHealthGetHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancehealth/InstanceHealthGetHandler.java @@ -50,7 +50,7 @@ public class InstanceHealthGetHandler extends JettyHandler { @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { String timeBucketStr = req.getParameter("timeBucket"); String[] applicationIdsStr = req.getParameterValues("applicationIds"); - logger.debug("instance health get timeBucket: {}, applicationIdsStr: {}", timeBucketStr, applicationIdsStr); + logger.debug("instance health getApplicationIdByCode timeBucket: {}, applicationIdsStr: {}", timeBucketStr, applicationIdsStr); long timeBucket; try { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetOneTimeBucketHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetOneTimeBucketHandler.java index 1a3c722ea..15e73ce93 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetOneTimeBucketHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetOneTimeBucketHandler.java @@ -52,7 +52,7 @@ public class InstanceMetricGetOneTimeBucketHandler extends JettyHandler { String instanceIdStr = req.getParameter("instanceId"); String[] metricTypes = req.getParameterValues("metricTypes"); - logger.debug("instance jvm metric get timeBucket: {}, instance id: {}, metric types: {}", timeBucketStr, instanceIdStr, metricTypes); + logger.debug("instance jvm metric getApplicationIdByCode timeBucket: {}, instance id: {}, metric types: {}", timeBucketStr, instanceIdStr, metricTypes); long timeBucket; try { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetRangeTimeBucketHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetRangeTimeBucketHandler.java index 9e54789d0..a78c63dca 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetRangeTimeBucketHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetRangeTimeBucketHandler.java @@ -53,7 +53,7 @@ public class InstanceMetricGetRangeTimeBucketHandler extends JettyHandler { String instanceIdStr = req.getParameter("instanceId"); String[] metricTypes = req.getParameterValues("metricTypes"); - logger.debug("instance jvm metric get start timeBucket: {}, end timeBucket:{} , instance id: {}, metric types: {}", startTimeBucketStr, endTimeBucketStr, instanceIdStr, metricTypes); + logger.debug("instance jvm metric getApplicationIdByCode start timeBucket: {}, end timeBucket:{} , instance id: {}, metric types: {}", startTimeBucketStr, endTimeBucketStr, instanceIdStr, metricTypes); long startTimeBucket; try { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceOsInfoGetHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceOsInfoGetHandler.java index 790b3cf6f..3b035f8eb 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceOsInfoGetHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceOsInfoGetHandler.java @@ -47,7 +47,7 @@ public class InstanceOsInfoGetHandler extends JettyHandler { @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { String instanceIdStr = req.getParameter("instanceId"); - logger.debug("instance os info get, instance id: {}", instanceIdStr); + logger.debug("instance os info getApplicationIdByCode, instance id: {}", instanceIdStr); int instanceId; try { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/servicetree/EntryServiceGetHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/servicetree/EntryServiceGetHandler.java deleted file mode 100644 index 4cc635adf..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/servicetree/EntryServiceGetHandler.java +++ /dev/null @@ -1,104 +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.ui.jetty.handler.servicetree; - -import com.google.gson.JsonElement; -import javax.servlet.http.HttpServletRequest; -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.apache.skywalking.apm.collector.ui.service.ServiceTreeService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class EntryServiceGetHandler extends JettyHandler { - - private final Logger logger = LoggerFactory.getLogger(EntryServiceGetHandler.class); - - @Override public String pathSpec() { - return "/service/entry"; - } - - private final ServiceTreeService service; - - public EntryServiceGetHandler(ModuleManager moduleManager) { - this.service = new ServiceTreeService(moduleManager); - } - - @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - if (!req.getParameterMap().containsKey("applicationId") || !req.getParameterMap().containsKey("entryServiceName") - || !req.getParameterMap().containsKey("startTime") || !req.getParameterMap().containsKey("endTime") - || !req.getParameterMap().containsKey("from") || !req.getParameterMap().containsKey("size")) { - throw new ArgumentsParseException("must contains parameters: applicationId, entryServiceName, startTime, endTime, from, size"); - } - - String applicationIdStr = req.getParameter("applicationId"); - String entryServiceName = req.getParameter("entryServiceName"); - String startTimeStr = req.getParameter("startTime"); - String endTimeStr = req.getParameter("endTime"); - String fromStr = req.getParameter("from"); - String sizeStr = req.getParameter("size"); - logger.debug("service entry get applicationId: {}, entryServiceName: {}, startTime: {}, endTime: {}, from: {}, size: {}", applicationIdStr, entryServiceName, startTimeStr, endTimeStr, fromStr, sizeStr); - - int applicationId; - try { - applicationId = Integer.parseInt(applicationIdStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("application id must be integer"); - } - - long startTime; - try { - startTime = Long.parseLong(startTimeStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("start time must be long"); - } - - long endTime; - try { - endTime = Long.parseLong(endTimeStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("end time must be long"); - } - - int from; - try { - from = Integer.parseInt(fromStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("from must be integer"); - } - - int size; - try { - size = Integer.parseInt(sizeStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("size must be integer"); - } - - return service.loadEntryService(applicationId, entryServiceName, startTime, endTime, from, size); - } - - @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException { - throw new UnsupportedOperationException(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/servicetree/ServiceTreeGetByIdHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/servicetree/ServiceTreeGetByIdHandler.java index a871ef84f..27ea8149f 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/servicetree/ServiceTreeGetByIdHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/servicetree/ServiceTreeGetByIdHandler.java @@ -53,7 +53,7 @@ public class ServiceTreeGetByIdHandler extends JettyHandler { String entryServiceIdStr = req.getParameter("entryServiceId"); String startTimeStr = req.getParameter("startTime"); String endTimeStr = req.getParameter("endTime"); - logger.debug("service entry get entryServiceId: {}, startTime: {}, endTime: {}", entryServiceIdStr, startTimeStr, endTimeStr); + logger.debug("service entry getApplicationIdByCode entryServiceId: {}, startTime: {}, endTime: {}", entryServiceIdStr, startTimeStr, endTimeStr); int entryServiceId; try { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java index 1bb048725..1807fc321 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java @@ -46,7 +46,7 @@ public class ApplicationService { applications.forEach(jsonElement -> { JsonObject application = jsonElement.getAsJsonObject(); int applicationId = application.get("applicationId").getAsInt(); - String applicationCode = applicationCacheService.get(applicationId); + String applicationCode = applicationCacheService.getApplicationCodeById(applicationId); application.addProperty("applicationCode", applicationCode); }); return applications; diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java index f67ac6ff5..65492c8b1 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java @@ -64,7 +64,7 @@ public class InstanceHealthService { response.add("instances", instances); instanceList.forEach(instance -> { - response.addProperty("applicationCode", applicationCacheService.get(applicationId)); + response.addProperty("applicationCode", applicationCacheService.getApplicationCodeById(applicationId)); response.addProperty("applicationId", applicationId); IInstanceMetricUIDAO.InstanceMetric performance = instanceMetricUIDAO.get(timeBuckets, instance.getInstanceId()); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java index b31f7a0ad..085120e61 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java @@ -16,23 +16,19 @@ * */ - package org.apache.skywalking.apm.collector.ui.service; import com.google.gson.JsonArray; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import java.util.Iterator; import java.util.Map; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.core.util.ObjectUtils; -import org.apache.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceEntryTable; import org.apache.skywalking.apm.collector.cache.CacheModule; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; @@ -42,32 +38,16 @@ import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenc */ public class ServiceTreeService { - private final IServiceEntryUIDAO serviceEntryDAO; private final IServiceReferenceUIDAO serviceReferenceDAO; private final ApplicationCacheService applicationCacheService; private final ServiceNameCacheService serviceNameCacheService; public ServiceTreeService(ModuleManager moduleManager) { - this.serviceEntryDAO = moduleManager.find(StorageModule.NAME).getService(IServiceEntryUIDAO.class); this.serviceReferenceDAO = moduleManager.find(StorageModule.NAME).getService(IServiceReferenceUIDAO.class); this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class); } - public JsonObject loadEntryService(int applicationId, String entryServiceName, long startTime, long endTime, - int from, int size) { - JsonObject response = serviceEntryDAO.load(applicationId, entryServiceName, startTime, endTime, from, size); - JsonArray entryServices = response.get("array").getAsJsonArray(); - for (JsonElement element : entryServices) { - JsonObject entryService = element.getAsJsonObject(); - int respApplication = entryService.get(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_APPLICATION_ID)).getAsInt(); - String applicationCode = applicationCacheService.get(respApplication); - entryService.addProperty("applicationCode", applicationCode); - } - - return response; - } - public JsonArray loadServiceTree(int entryServiceId, long startTime, long endTime) { Map serviceReferenceMap = serviceReferenceDAO.load(entryServiceId, startTime, endTime); serviceReferenceMap.values().forEach(serviceReference -> { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java index 64180a74f..0e902fe34 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java @@ -108,7 +108,7 @@ public class SpanService { if (spanObject.getPeerId() == 0) { peerJson.addProperty("value", spanObject.getPeer()); } else { - peerJson.addProperty("value", applicationCacheService.get(spanObject.getPeerId())); + peerJson.addProperty("value", applicationCacheService.getApplicationCodeById(spanObject.getPeerId())); } tagsArray.add(peerJson); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java index b94e00279..297c43573 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java @@ -108,9 +108,9 @@ public class TraceDagDataBuilder { for (int i = 0; i < nodesMappingArray.size(); i++) { JsonObject nodesMappingJsonObj = nodesMappingArray.get(i).getAsJsonObject(); int applicationId = nodesMappingJsonObj.get(ApplicationMappingTable.COLUMN_APPLICATION_ID).getAsInt(); - String applicationCode = applicationCacheService.get(applicationId); + String applicationCode = applicationCacheService.getApplicationCodeById(applicationId); int addressId = nodesMappingJsonObj.get(ApplicationMappingTable.COLUMN_ADDRESS_ID).getAsInt(); - String address = applicationCacheService.get(addressId); + String address = applicationCacheService.getApplicationCodeById(addressId); mappingMap.put(address, applicationCode); } } @@ -122,7 +122,7 @@ public class TraceDagDataBuilder { int componentId = nodesJsonObj.get(ApplicationComponentTable.COLUMN_COMPONENT_ID).getAsInt(); String componentName = ComponentsDefine.getInstance().getComponentName(componentId); int peerId = nodesJsonObj.get(ApplicationComponentTable.COLUMN_PEER_ID).getAsInt(); - String peer = applicationCacheService.get(peerId); + String peer = applicationCacheService.getApplicationCodeById(peerId); nodeCompMap.put(peer, componentName); } } @@ -139,8 +139,8 @@ public class TraceDagDataBuilder { int frontApplicationId = nodeRefJsonObj.get(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID)).getAsInt(); int behindApplicationId = nodeRefJsonObj.get(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID)).getAsInt(); - String front = applicationCacheService.get(frontApplicationId); - String behind = applicationCacheService.get(behindApplicationId); + String front = applicationCacheService.getApplicationCodeById(frontApplicationId); + String behind = applicationCacheService.getApplicationCodeById(behindApplicationId); String id = front + Const.ID_SPLIT + behind; nodeRefJsonObj.addProperty("front", front); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java index 8f4c62499..16da98b37 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java @@ -134,7 +134,7 @@ public class TraceStackService { operationName = Const.EMPTY_STRING; } } - String applicationCode = applicationCacheService.get(segment.getApplicationId()); + String applicationCode = applicationCacheService.getApplicationCodeById(segment.getApplicationId()); long cost = spanObject.getEndTime() - spanObject.getStartTime(); if (cost == 0) { @@ -149,9 +149,9 @@ public class TraceStackService { // StringBuilder segmentIdBuilder = new StringBuilder(); // for (int i = 0; i < uniqueId.getIdPartsList().size(); i++) { // if (i == 0) { -// segmentIdBuilder.append(String.valueOf(uniqueId.getIdPartsList().get(i))); +// segmentIdBuilder.append(String.valueOf(uniqueId.getIdPartsList().getApplicationIdByCode(i))); // } else { -// segmentIdBuilder.append(".").append(String.valueOf(uniqueId.getIdPartsList().get(i))); +// segmentIdBuilder.append(".").append(String.valueOf(uniqueId.getIdPartsList().getApplicationIdByCode(i))); // } // } // diff --git a/apm-collector/apm-collector-core/src/test/java/org/apache/skywalking/apm/collector/core/data/AbstractHashMessageTest.java b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/BlockingDataCarrier.java similarity index 64% rename from apm-collector/apm-collector-core/src/test/java/org/apache/skywalking/apm/collector/core/data/AbstractHashMessageTest.java rename to apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/BlockingDataCarrier.java index 841e12716..8b970808d 100644 --- a/apm-collector/apm-collector-core/src/test/java/org/apache/skywalking/apm/collector/core/data/AbstractHashMessageTest.java +++ b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/BlockingDataCarrier.java @@ -16,25 +16,22 @@ * */ +package org.apache.skywalking.apm.commons.datacarrier; -package org.apache.skywalking.apm.collector.core.data; - -import org.junit.Assert; -import org.junit.Test; +import org.apache.skywalking.apm.commons.datacarrier.buffer.Channels; +import org.apache.skywalking.apm.commons.datacarrier.callback.QueueBlockingCallback; /** * @author wu-sheng */ -public class AbstractHashMessageTest { - public class NewMessage extends AbstractHashMessage { - public NewMessage() { - super("key"); - } +public class BlockingDataCarrier { + private Channels channels; + + BlockingDataCarrier(Channels channels) { + this.channels = channels; } - @Test - public void testHash() { - NewMessage message = new NewMessage(); - Assert.assertEquals("key".hashCode(), message.getHashCode()); + public void addCallback(QueueBlockingCallback callback) { + this.channels.addCallback(callback); } } diff --git a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/DataCarrier.java b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/DataCarrier.java index d40c1da82..081b25a6f 100644 --- a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/DataCarrier.java +++ b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/DataCarrier.java @@ -16,21 +16,17 @@ * */ - package org.apache.skywalking.apm.commons.datacarrier; -import org.apache.skywalking.apm.commons.datacarrier.buffer.Channels; -import org.apache.skywalking.apm.commons.datacarrier.partition.IDataPartitioner; import org.apache.skywalking.apm.commons.datacarrier.buffer.BufferStrategy; +import org.apache.skywalking.apm.commons.datacarrier.buffer.Channels; import org.apache.skywalking.apm.commons.datacarrier.consumer.ConsumerPool; import org.apache.skywalking.apm.commons.datacarrier.consumer.IConsumer; +import org.apache.skywalking.apm.commons.datacarrier.partition.IDataPartitioner; import org.apache.skywalking.apm.commons.datacarrier.partition.SimpleRollingPartitioner; /** - * DataCarrier main class. - * use this instance to set Producer/Consumer Model - *

- * Created by wusheng on 2016/10/25. + * DataCarrier main class. use this instance to set Producer/Consumer Model. */ public class DataCarrier { private final int bufferSize; @@ -45,8 +41,8 @@ public class DataCarrier { } /** - * set a new IDataPartitioner. - * It will cover the current one or default one.(Default is {@link SimpleRollingPartitioner)} + * set a new IDataPartitioner. It will cover the current one or default one.(Default is {@link + * SimpleRollingPartitioner)} * * @param dataPartitioner * @return @@ -57,8 +53,7 @@ public class DataCarrier { } /** - * override the strategy at runtime. - * Notice, {@link Channels} will override several channels one by one. + * override the strategy at runtime. Notice, {@link Channels} will override several channels one by one. * * @param strategy */ @@ -67,6 +62,11 @@ public class DataCarrier { return this; } + public BlockingDataCarrier toBlockingDataCarrier() { + this.channels.setStrategy(BufferStrategy.BLOCKING); + return new BlockingDataCarrier(this.channels); + } + /** * produce data to buffer, using the givven {@link BufferStrategy}. * @@ -84,36 +84,57 @@ public class DataCarrier { } /** - * set consumers to this Carrier. - * consumer begin to run when {@link DataCarrier#produce(T)} begin to work. + * set consumers to this Carrier. consumer begin to run when {@link DataCarrier#produce(T)} begin to work. * * @param consumerClass class of consumer * @param num number of consumer threads */ - public DataCarrier consume(Class> consumerClass, int num) { + public DataCarrier consume(Class> consumerClass, int num, long consumeCycle) { if (consumerPool != null) { consumerPool.close(); } - consumerPool = new ConsumerPool(this.channels, consumerClass, num); + consumerPool = new ConsumerPool(this.channels, consumerClass, num, consumeCycle); consumerPool.begin(); return this; } /** - * set consumers to this Carrier. - * consumer begin to run when {@link DataCarrier#produce(T)} begin to work. + * set consumers to this Carrier. consumer begin to run when {@link DataCarrier#produce(T)} begin to work with 20 + * millis consume cycle. + * + * @param consumerClass class of consumer + * @param num number of consumer threads + */ + public DataCarrier consume(Class> consumerClass, int num) { + return this.consume(consumerClass, num, 20); + } + + /** + * set consumers to this Carrier. consumer begin to run when {@link DataCarrier#produce(T)} begin to work. + * + * @param consumer single instance of consumer, all consumer threads will all use this instance. + * @param num number of consumer threads + * @return + */ + public DataCarrier consume(IConsumer consumer, int num, long consumeCycle) { + if (consumerPool != null) { + consumerPool.close(); + } + consumerPool = new ConsumerPool(this.channels, consumer, num, consumeCycle); + consumerPool.begin(); + return this; + } + + /** + * set consumers to this Carrier. consumer begin to run when {@link DataCarrier#produce(T)} begin to work with 20 + * millis consume cycle. * * @param consumer single instance of consumer, all consumer threads will all use this instance. * @param num number of consumer threads * @return */ public DataCarrier consume(IConsumer consumer, int num) { - if (consumerPool != null) { - consumerPool.close(); - } - consumerPool = new ConsumerPool(this.channels, consumer, num); - consumerPool.begin(); - return this; + return this.consume(consumer, num, 20); } /** diff --git a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Buffer.java b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Buffer.java index 6ac79c479..4fbb47869 100644 --- a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Buffer.java +++ b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Buffer.java @@ -16,10 +16,11 @@ * */ - package org.apache.skywalking.apm.commons.datacarrier.buffer; import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.commons.datacarrier.callback.QueueBlockingCallback; import org.apache.skywalking.apm.commons.datacarrier.common.AtomicRangeInteger; /** @@ -29,23 +30,36 @@ public class Buffer { private final Object[] buffer; private BufferStrategy strategy; private AtomicRangeInteger index; + private List> callbacks; Buffer(int bufferSize, BufferStrategy strategy) { buffer = new Object[bufferSize]; this.strategy = strategy; index = new AtomicRangeInteger(0, bufferSize); + callbacks = new LinkedList>(); } void setStrategy(BufferStrategy strategy) { this.strategy = strategy; } + void addCallback(QueueBlockingCallback callback) { + callbacks.add(callback); + } + boolean save(T data) { int i = index.getAndIncrement(); if (buffer[i] != null) { switch (strategy) { case BLOCKING: + boolean isFirstTimeBlocking = true; while (buffer[i] != null) { + if (isFirstTimeBlocking) { + isFirstTimeBlocking = false; + for (QueueBlockingCallback callback : callbacks) { + callback.notify(data); + } + } try { Thread.sleep(1L); } catch (InterruptedException e) { diff --git a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java index bf4c03fd7..4f7ee8754 100644 --- a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java +++ b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java @@ -16,17 +16,14 @@ * */ - package org.apache.skywalking.apm.commons.datacarrier.buffer; +import org.apache.skywalking.apm.commons.datacarrier.callback.QueueBlockingCallback; import org.apache.skywalking.apm.commons.datacarrier.partition.IDataPartitioner; /** - * Channels of Buffer - * It contais all buffer data which belongs to this channel. - * It supports several strategy when buffer is full. The Default is BLOCKING - *

- * Created by wusheng on 2016/10/25. + * Channels of Buffer It contais all buffer data which belongs to this channel. It supports several strategy when buffer + * is full. The Default is BLOCKING

Created by wusheng on 2016/10/25. */ public class Channels { private final Buffer[] bufferChannels; @@ -87,4 +84,10 @@ public class Channels { public Buffer getBuffer(int index) { return this.bufferChannels[index]; } + + public void addCallback(QueueBlockingCallback callback) { + for (Buffer channel : bufferChannels) { + channel.addCallback(callback); + } + } } diff --git a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/callback/QueueBlockingCallback.java b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/callback/QueueBlockingCallback.java new file mode 100644 index 000000000..c0a6c47c4 --- /dev/null +++ b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/callback/QueueBlockingCallback.java @@ -0,0 +1,28 @@ +/* + * 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.commons.datacarrier.callback; + +/** + * Notify when the queue, which is in blocking strategy, has be blocked. + * + * @author wu-sheng + */ +public interface QueueBlockingCallback { + void notify(T message); +} diff --git a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/consumer/ConsumerPool.java b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/consumer/ConsumerPool.java index 6d127cca7..814fdf8f8 100644 --- a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/consumer/ConsumerPool.java +++ b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/consumer/ConsumerPool.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.commons.datacarrier.consumer; import java.util.ArrayList; @@ -25,9 +24,7 @@ import org.apache.skywalking.apm.commons.datacarrier.buffer.Buffer; import org.apache.skywalking.apm.commons.datacarrier.buffer.Channels; /** - * Pool of consumers - *

- * Created by wusheng on 2016/10/25. + * Pool of consumers

Created by wusheng on 2016/10/25. */ public class ConsumerPool { private boolean running; @@ -35,19 +32,19 @@ public class ConsumerPool { private Channels channels; private ReentrantLock lock; - public ConsumerPool(Channels channels, Class> consumerClass, int num) { + public ConsumerPool(Channels channels, Class> consumerClass, int num, long consumeCycle) { this(channels, num); for (int i = 0; i < num; i++) { - consumerThreads[i] = new ConsumerThread("DataCarrier.Consumser." + i + ".Thread", getNewConsumerInstance(consumerClass)); + consumerThreads[i] = new ConsumerThread("DataCarrier.Consumser." + i + ".Thread", getNewConsumerInstance(consumerClass), consumeCycle); consumerThreads[i].setDaemon(true); } } - public ConsumerPool(Channels channels, IConsumer prototype, int num) { + public ConsumerPool(Channels channels, IConsumer prototype, int num, long consumeCycle) { this(channels, num); prototype.init(); for (int i = 0; i < num; i++) { - consumerThreads[i] = new ConsumerThread("DataCarrier.Consumser." + i + ".Thread", prototype); + consumerThreads[i] = new ConsumerThread("DataCarrier.Consumser." + i + ".Thread", prototype, consumeCycle); consumerThreads[i].setDaemon(true); } diff --git a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/consumer/ConsumerThread.java b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/consumer/ConsumerThread.java index 891aac465..1ba0223db 100644 --- a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/consumer/ConsumerThread.java +++ b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/consumer/ConsumerThread.java @@ -30,12 +30,14 @@ public class ConsumerThread extends Thread { private volatile boolean running; private IConsumer consumer; private List dataSources; + private long consumeCycle; - ConsumerThread(String threadName, IConsumer consumer) { + ConsumerThread(String threadName, IConsumer consumer, long consumeCycle) { super(threadName); this.consumer = consumer; running = false; dataSources = new LinkedList(); + this.consumeCycle = consumeCycle; } /** @@ -67,7 +69,7 @@ public class ConsumerThread extends Thread { if (!hasData) { try { - Thread.sleep(20); + Thread.sleep(consumeCycle); } catch (InterruptedException e) { } } diff --git a/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/DataCarrierTest.java b/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/DataCarrierTest.java index ca7096c05..85d767ed3 100644 --- a/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/DataCarrierTest.java +++ b/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/DataCarrierTest.java @@ -128,7 +128,7 @@ public class DataCarrierTest { @Override public void run() { try { - Thread.sleep(2000); + Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/consumer/ConsumerPoolTest.java b/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/consumer/ConsumerPoolTest.java index 4daa51e4f..18eab0eac 100644 --- a/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/consumer/ConsumerPoolTest.java +++ b/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/consumer/ConsumerPoolTest.java @@ -34,7 +34,7 @@ public class ConsumerPoolTest { @Test public void testBeginConsumerPool() throws IllegalAccessException { Channels channels = new Channels(2, 100, new SimpleRollingPartitioner(), BufferStrategy.BLOCKING); - ConsumerPool pool = new ConsumerPool(channels, new SampleConsumer(), 2); + ConsumerPool pool = new ConsumerPool(channels, new SampleConsumer(), 2, 20); pool.begin(); ConsumerThread[] threads = (ConsumerThread[])MemberModifier.field(ConsumerPool.class, "consumerThreads").get(pool); @@ -46,7 +46,7 @@ public class ConsumerPoolTest { @Test public void testCloseConsumerPool() throws InterruptedException, IllegalAccessException { Channels channels = new Channels(2, 100, new SimpleRollingPartitioner(), BufferStrategy.BLOCKING); - ConsumerPool pool = new ConsumerPool(channels, new SampleConsumer(), 2); + ConsumerPool pool = new ConsumerPool(channels, new SampleConsumer(), 2, 20); pool.begin(); Thread.sleep(5000); diff --git a/apm-commons/apm-util/src/main/java/org/apache/skywalking/apm/util/StringUtil.java b/apm-commons/apm-util/src/main/java/org/apache/skywalking/apm/util/StringUtil.java index 9e7aefe4e..e1ca37830 100644 --- a/apm-commons/apm-util/src/main/java/org/apache/skywalking/apm/util/StringUtil.java +++ b/apm-commons/apm-util/src/main/java/org/apache/skywalking/apm/util/StringUtil.java @@ -21,10 +21,7 @@ package org.apache.skywalking.apm.util; public final class StringUtil { public static boolean isEmpty(String str) { - if (str == null || "".equals(str) || str.length() == 0) { - return true; - } - return false; + return str == null || str.length() == 0; } public static String join(final char delimiter, final String... strings) { diff --git a/apm-network/pom.xml b/apm-protocol/apm-network/pom.xml similarity index 99% rename from apm-network/pom.xml rename to apm-protocol/apm-network/pom.xml index 7fbadf7bf..ceef97708 100644 --- a/apm-network/pom.xml +++ b/apm-protocol/apm-network/pom.xml @@ -21,7 +21,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - apm + apm-protocol org.apache.skywalking 5.0.0-alpha diff --git a/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/Component.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/Component.java similarity index 100% rename from apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/Component.java rename to apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/Component.java diff --git a/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java similarity index 100% rename from apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java rename to apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java diff --git a/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/OfficialComponent.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/OfficialComponent.java similarity index 100% rename from apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/OfficialComponent.java rename to apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/OfficialComponent.java diff --git a/apm-network/src/main/proto/ApplicationRegisterService.proto b/apm-protocol/apm-network/src/main/proto/ApplicationRegisterService.proto similarity index 57% rename from apm-network/src/main/proto/ApplicationRegisterService.proto rename to apm-protocol/apm-network/src/main/proto/ApplicationRegisterService.proto index 1852ee4ed..e5b4deee1 100644 --- a/apm-network/src/main/proto/ApplicationRegisterService.proto +++ b/apm-protocol/apm-network/src/main/proto/ApplicationRegisterService.proto @@ -7,14 +7,14 @@ import "KeyWithIntegerValue.proto"; //register service for ApplicationCode, this service is called when service starts. service ApplicationRegisterService { - rpc batchRegister (Applications) returns (ApplicationMappings) { + rpc applicationCodeRegister (Application) returns (ApplicationMapping) { } } -message Applications { - repeated string applicationCodes = 1; +message Application { + string applicationCode = 1; } -message ApplicationMappings { - repeated KeyWithIntegerValue applications = 1; +message ApplicationMapping { + KeyWithIntegerValue application = 1; } diff --git a/apm-network/src/main/proto/DiscoveryService.proto b/apm-protocol/apm-network/src/main/proto/DiscoveryService.proto similarity index 81% rename from apm-network/src/main/proto/DiscoveryService.proto rename to apm-protocol/apm-network/src/main/proto/DiscoveryService.proto index 5605c0d02..f2068f027 100644 --- a/apm-network/src/main/proto/DiscoveryService.proto +++ b/apm-protocol/apm-network/src/main/proto/DiscoveryService.proto @@ -5,17 +5,13 @@ option java_package = "org.apache.skywalking.apm.network.proto"; import "Downstream.proto"; -//discovery service for application instance, this service is called when application starts -//or http client connection switch to another collector server instance service InstanceDiscoveryService { - rpc register (ApplicationInstance) returns (ApplicationInstanceMapping) { + rpc registerInstance (ApplicationInstance) returns (ApplicationInstanceMapping) { } rpc heartbeat (ApplicationInstanceHeartbeat) returns (Downstream) { } - rpc registerRecover (ApplicationInstanceRecover) returns (Downstream) { - } } message ApplicationInstance { diff --git a/apm-network/src/main/proto/Downstream.proto b/apm-protocol/apm-network/src/main/proto/Downstream.proto similarity index 100% rename from apm-network/src/main/proto/Downstream.proto rename to apm-protocol/apm-network/src/main/proto/Downstream.proto diff --git a/apm-network/src/main/proto/JVMMetricsService.proto b/apm-protocol/apm-network/src/main/proto/JVMMetricsService.proto similarity index 100% rename from apm-network/src/main/proto/JVMMetricsService.proto rename to apm-protocol/apm-network/src/main/proto/JVMMetricsService.proto diff --git a/apm-network/src/main/proto/KeyWithIntegerValue.proto b/apm-protocol/apm-network/src/main/proto/KeyWithIntegerValue.proto similarity index 100% rename from apm-network/src/main/proto/KeyWithIntegerValue.proto rename to apm-protocol/apm-network/src/main/proto/KeyWithIntegerValue.proto diff --git a/apm-network/src/main/proto/KeyWithStringValue.proto b/apm-protocol/apm-network/src/main/proto/KeyWithStringValue.proto similarity index 100% rename from apm-network/src/main/proto/KeyWithStringValue.proto rename to apm-protocol/apm-network/src/main/proto/KeyWithStringValue.proto diff --git a/apm-protocol/apm-network/src/main/proto/NetworkAddressRegisterService.proto b/apm-protocol/apm-network/src/main/proto/NetworkAddressRegisterService.proto new file mode 100644 index 000000000..15a6b31b0 --- /dev/null +++ b/apm-protocol/apm-network/src/main/proto/NetworkAddressRegisterService.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "org.apache.skywalking.apm.network.proto"; + +import "KeyWithIntegerValue.proto"; + +service NetworkAddressRegisterService { + rpc batchRegister (NetworkAddresses) returns (NetworkAddressMappings) { + } +} + +message NetworkAddresses { + repeated string addresses = 1; +} + +message NetworkAddressMappings { + repeated KeyWithIntegerValue addressIds = 1; +} diff --git a/apm-network/src/main/proto/TraceSegmentService.proto b/apm-protocol/apm-network/src/main/proto/TraceSegmentService.proto similarity index 100% rename from apm-network/src/main/proto/TraceSegmentService.proto rename to apm-protocol/apm-network/src/main/proto/TraceSegmentService.proto diff --git a/apm-network/src/test/java/org/apache/skywalking/apm/network/trace/proto/GRPCNoServerTest.java b/apm-protocol/apm-network/src/test/java/org/apache/skywalking/apm/network/trace/proto/GRPCNoServerTest.java similarity index 100% rename from apm-network/src/test/java/org/apache/skywalking/apm/network/trace/proto/GRPCNoServerTest.java rename to apm-protocol/apm-network/src/test/java/org/apache/skywalking/apm/network/trace/proto/GRPCNoServerTest.java diff --git a/apm-protocol/apm-ui-protocol/pom.xml b/apm-protocol/apm-ui-protocol/pom.xml new file mode 100644 index 000000000..0e7e75784 --- /dev/null +++ b/apm-protocol/apm-ui-protocol/pom.xml @@ -0,0 +1,39 @@ + + + + + + apm-protocol + org.apache.skywalking + 5.0.0-alpha + + 4.0.0 + + apm-ui-protocol + + + + com.graphql-java + graphql-java + 6.0 + + + diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/README.md b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/README.md new file mode 100644 index 000000000..60ddb04aa --- /dev/null +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/README.md @@ -0,0 +1,41 @@ +# Abstract +**apm-ui-protocol** declares all services, using GraphQL API style, which provide by Collector UI module. + +## Services +### [Common](common.graphqls) + +Include common objects, which used in global + +### [Overview Layer Service](overview-layer.graphqls) + +Query data without specific application, server or service. It includes info for overview the whole cluster. + +### [Application Layer Service](application-layer.graphqls) + +Query application related data with specific application code. + +### [Server Layer Service](server-layer.graphqls) + +Query server related data with specific server id. + +### [Service Layer Service](service-layer.graphqls) + +Query service related data with specific service id + +### [Trace Service](trace.graphqls) + +Query trace by some conditions. + +### [Alarm Service](alarm.graphqls) + +Query alarm info. + +## Version +v1alpha1 + +### Versioning +Use URI Versioning, to follow the most straightforward approach, +though it does violate the principle that a URI should refer to a unique resource. + +e.g. +http://collector.host/graphql/v1alpha1 diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls new file mode 100644 index 000000000..b63946d8b --- /dev/null +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls @@ -0,0 +1,15 @@ +type AlarmItem { + content: String! + startTime: String! + alertType: AlarmType! +} + +enum AlarmType { + APPLICATION, + SERVER, + SERVICE +} + +extend type Query { + loadAlertList(keyword: String, alertType: AlarmType, duration:Duration!):[AlarmItem] +} \ No newline at end of file diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls new file mode 100644 index 000000000..f8ccf0eb9 --- /dev/null +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls @@ -0,0 +1,40 @@ +# ApplicationNode represents this node is under monitoring by agent. +type ApplicationNode implements Node { + id: ID! + name: String! + type: String + # Success rate of all incoming requests. + # Max value is 100. + # 2 Digits after floating point. + sla: Float! + # The number of incoming calls + calls: Long! + # ref: http://www.apdex.org/ + # Max value is 1 + # 2 Digits after floating point. + apdex: Float! + # The number of servers in the application code + numOfServer: Int! + # The number of servers alerting + numOfServerAlarm: Int! + # The number of services alerting + numOfServiceAlarm: Int! + # Incoming request node, means User or outside system access the cluster from this. + # Recommend the UI generate a User node for each incoming node + isIncomingNode: Boolean +} + +# The conjectural node generated by exit span +type ConjecturalNode implements Node { + id: ID! + name: String! + type: String +} + + +extend type Query { + getAllApplication(duration: Duration!): [ApplicationNode] + getApplicationTopology(applicationId: ID!, duration: Duration!): Topology + getSlowService(applicationId: ID!, duration: Duration!): [ServiceInfo!] + getServerThroughput(applicationId: ID!, duration: Duration!): [AppServerInfo!] +} diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls new file mode 100644 index 000000000..853f36258 --- /dev/null +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls @@ -0,0 +1,88 @@ +schema { + query: Query +} + +#Root node +type Query { + version: String +} + +# The Duration defines the start and end time for each query operation. +# Fields: `start` and `end` +# represents the time span. And each of them matches the step. +# ref https://www.ietf.org/rfc/rfc3339.txt +# The time formats are +# `SECOND` step: yyyy-MM-dd HHmmss +# `MINUTE` step: yyyy-MM-dd HHmm +# `HOUR` step: yyyy-MM-dd HH +# `DAY` step: yyyy-MM-dd +# `MONTH` step: yyyy-MM +# Field: `step` +# represents the accurate time point. +# e.g. +# if step==HOUR , start=2017-11-08 09, end=2017-11-08 19 +# then +# metrics from the following time points expected +# 2017-11-08 9:00 -> 2017-11-08 19:00 +# there are 11 time points (hours) in the time span. +input Duration { + start: String! + end: String! + step: Step! +} + +enum Step { + MONTH + DAY + HOUR + MINUTE + SECOND +} + +###################################### +# Common Metrics and Trends +###################################### +type ResponseTimeTrend { + trendList: [Int!] +} + +type ThroughputTrend { + trendList: [Int!] +} + +type SLATrend { + trendList: [Int!] +} + +# The overview topology of the whole application cluster or services, +type Topology { + nodes: [Node]! + calls: [Call] +} + +# The base Node of all node types in topology +interface Node { + # The global id of each node, + # 1. `Application ID` represents application under monitoring + # 2. `Peer ID` string represents the conjectural dependency. + id: ID! + # Application Code or literal Peer + name: String! + # The type name + # 1. The most important component in the application, from service provider perspective. + # 2. Conjectural dependent component, e.g. MySQL, Redis, Kafka + type: String +} + +# The Call represents a directed distributed call, +# from the `source` to the `target`. +type Call { + source: ID! + target: ID! + isAlert: Boolean + # The protocol and tech stack used in this distributed call + callType: String! + callsPerSec: Int! + # Unit: millisecond + responseTimePerSec: Int! +} diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls new file mode 100644 index 000000000..e7b0bc2d6 --- /dev/null +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls @@ -0,0 +1,37 @@ +# Query the cluster brief based on the given duration +type ClusterBrief { + numOfApplication: Int + numOfService: Int + numOfDatabase: Int + numOfCache: Int + numOfMQ: Int +} + +# Query the trend of alarm rate based on the given duration +type AlarmTrend { + numOfAlarmRate: [Int]! +} + +# Query all conjectural applications based on the given duration +# All applications here are not installed agent. +type ConjecturalAppBrief { + apps: [ConjecturalApp!] +} + +# The basic info of the conjectural application, +# includes the type and num of same type application +type ConjecturalApp { + # The display name of the application + # e.g. MySQL, RocketMQ, Kafka, Nginx + name: String! + num: Int! +} + +extend type Query { + getClusterTopology(duration: Duration!): Topology + getClusterBrief(duration: Duration!): ClusterBrief + getAlarmTrend(duration: Duration!): AlarmTrend + getConjecturalApps(duration: Duration!): ConjecturalAppBrief + getTopNSlowService(duration: Duration!, topN: Int!): [ServiceInfo!] + getTopNServerThroughput(duration: Duration!, topN: Int!): [AppServerInfo!] +} diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls new file mode 100644 index 000000000..eac33a7dc --- /dev/null +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls @@ -0,0 +1,42 @@ +# The server info. +# At here, `Server` represents a process in OS, +# e.g. +# 1. Spring boot application +# 2. A Tomcat server instance +type AppServerInfo { + id: ID! + name: String! + tps: Int! + os: String + host: String + pid: Int + IPv4: String + IPv6: String +} + +type CPUTrend { + cost: [Int!] +} + +# The gc trend represents the numbers of Garbage Collector execution +type GCTrend { + youngGC: [Int!] + oldGC: [Int!] +} + +# The memory used and max limit in heap and noheap space. +type MemoryTrend { + heap: [Int!] + maxHeap: [Int!] + noheap: [Int!] + maxNoheap: [Int!] +} + +extend type Query { + searchServer(keyword: String!, duration: Duration!): [AppServerInfo] + getServerResponseTimeTrend(serverId: ID!, duration: Duration!): ResponseTimeTrend + getServerTPSTrend(serverId: ID!, duration: Duration!): ThroughputTrend + getCPUTrend(serverId: ID!, duration: Duration!): CPUTrend + getGCTrend(serverId: ID!, duration: Duration!): GCTrend + getMemoryTrend(serverId: ID!, duration: Duration!): MemoryTrend +} \ No newline at end of file diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls new file mode 100644 index 000000000..3e33c8f9e --- /dev/null +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls @@ -0,0 +1,35 @@ +type ServiceNode implements Node { + id: ID! + name: String! + type: String + # Success rate of all incoming requests. + # Max value is 100. + # 2 Digits after floating point. + sla: Float! + # The number of incoming calls + calls: Long! + # The number of services alerting + numOfServiceAlarm: Int! +} + +type ServiceInfo { + id: ID! + name: String + # The unit is millisecond. + avgResponseTime: Int! + tps: Int! +} + +type TraceItem { + time: String! + entry: String! + duration: Int! +} + +extend type Query { + searchService(keyword: String!, duration: Duration!): [ServiceNode] + getServiceResponseTimeTrend(serviceId: ID!, duration: Duration!): ResponseTimeTrend + getServiceTPSTrend(serviceId: ID!, duration: Duration!): ThroughputTrend + getServiceSLATrend(serviceId: ID!, duration: Duration!): SLATrend + getServiceTopology(serviceId: ID!, duration: Duration!): Topology +} diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls new file mode 100644 index 000000000..4e2e1a0ec --- /dev/null +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls @@ -0,0 +1,89 @@ +# The list of traces +type TraceBrief { + traces: [BasicTrace!] +} + +# Trace basic info +type BasicTrace { + operationName: String! + duration: Int! + start: String! + isError: Boolean + traceId: String +} + +# Represent the conditions used for query TraceBrief +input TraceQueryCondition { + applicationCodes: [String!] + traceId: String + operationName: String + # The time range of traces started + queryDuration: Duration + # The mix time of trace + minTraceDuration: Int + # The max time of trace + maxTraceDuration: Int + topN: Boolean + needTotal: Int +} + +enum QueryOrder { + BY_START_TIME + BY_DURATION +} + +# The trace represents a distributed trace, includes all segments and spans. +type Trace { + traceId: ID! + segments: [Segment!] +} + +type Segment { + segmentId: ID! + appName: String! + isSizeLimited: Boolean! + spans: [Span!]! +} + +type Span { + refs: [Ref!] + spanId: Int! + parentSpanId: Int! + startTime: Long! + endTime: Long! + operationName: String + # There are three span types: Local, Entry and Exit + type: String! + # Peer network id, e.g. host+port, ip+port + peer: String + component: String + isError: Boolean + # There are 5 layers: Unknown, Database, RPCFramework, Http, MQ and Cache + layer: String + tags: [KeyValue!] + logs: [LogEntity!] +} + +# Ref represents the link between the segment and its parents. +type Ref { + parentSegmentId: ID! + parentSpanId: Int! + # Ref type represents why did the ref happen. + # Include: 1) CrossProcess 2) CrossThread + type: String! +} + +type KeyValue { + key: String! + value: String +} + +type LogEntity { + time: String + data: [KeyValue!] +} + +extend type Query { + queryBasicTraces(condition: TraceQueryCondition): TraceBrief + queryTrace(traceId: ID!): Trace +} \ No newline at end of file diff --git a/apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLScriptTest.java b/apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLScriptTest.java new file mode 100644 index 000000000..f017d6844 --- /dev/null +++ b/apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLScriptTest.java @@ -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.ui.protocol; + +import graphql.schema.idl.EchoingWiringFactory; +import graphql.schema.idl.RuntimeWiring; +import graphql.schema.idl.SchemaGenerator; +import graphql.schema.idl.SchemaParser; +import graphql.schema.idl.TypeDefinitionRegistry; +import java.io.File; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +public class GraphQLScriptTest { + + @Test + public void assertScriptFormat() { + SchemaParser schemaParser = new SchemaParser(); + SchemaGenerator schemaGenerator = new SchemaGenerator(); + + TypeDefinitionRegistry typeRegistry = new TypeDefinitionRegistry(); + typeRegistry.merge(schemaParser.parse(loadSchema("common.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("trace.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("overview-layer.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("application-layer.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("server-layer.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("service-layer.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("alarm.graphqls"))); + RuntimeWiring wiring = buildRuntimeWiring(); + assertTrue(schemaGenerator.makeExecutableSchema(typeRegistry, wiring).getAllTypesAsList().size() > 0); + } + + private File loadSchema(final String s) { + return new File(GraphQLScriptTest.class.getClassLoader().getResource("ui-graphql/" + s).getFile()); + } + + private RuntimeWiring buildRuntimeWiring() { + return RuntimeWiring.newRuntimeWiring().wiringFactory(new EchoingWiringFactory()).build(); + } +} diff --git a/apm-protocol/pom.xml b/apm-protocol/pom.xml new file mode 100644 index 000000000..fa5708532 --- /dev/null +++ b/apm-protocol/pom.xml @@ -0,0 +1,37 @@ + + + + + + apm + org.apache.skywalking + 5.0.0-alpha + + 4.0.0 + + apm-protocol + pom + + + apm-network + apm-ui-protocol + + \ No newline at end of file diff --git a/apm-sniffer/apm-agent-core/pom.xml b/apm-sniffer/apm-agent-core/pom.xml index 6e398be8a..9ea7e33d6 100644 --- a/apm-sniffer/apm-agent-core/pom.xml +++ b/apm-sniffer/apm-agent-core/pom.xml @@ -36,7 +36,7 @@ UTF-8 9.4.2.v20170220 1.8.0 - 1.7.6 + 1.7.9 org.apache.skywalking.apm.dependencies com.lmax.disruptor diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java index 5538a554c..2e674177f 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java @@ -19,13 +19,6 @@ package org.apache.skywalking.apm.agent.core.conf; -import org.apache.skywalking.apm.agent.core.boot.AgentPackageNotFoundException; -import org.apache.skywalking.apm.agent.core.boot.AgentPackagePath; -import org.apache.skywalking.apm.agent.core.logging.api.ILog; -import org.apache.skywalking.apm.agent.core.logging.api.LogManager; -import org.apache.skywalking.apm.util.ConfigInitializer; -import org.apache.skywalking.apm.util.StringUtil; - import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -33,6 +26,12 @@ import java.io.InputStream; import java.util.Iterator; import java.util.Map; import java.util.Properties; +import org.apache.skywalking.apm.agent.core.boot.AgentPackageNotFoundException; +import org.apache.skywalking.apm.agent.core.boot.AgentPackagePath; +import org.apache.skywalking.apm.agent.core.logging.api.ILog; +import org.apache.skywalking.apm.agent.core.logging.api.LogManager; +import org.apache.skywalking.apm.util.ConfigInitializer; +import org.apache.skywalking.apm.util.StringUtil; /** * The SnifferConfigInitializer initializes all configs in several way. @@ -44,6 +43,7 @@ public class SnifferConfigInitializer { private static final ILog logger = LogManager.getLogger(SnifferConfigInitializer.class); private static String CONFIG_FILE_NAME = "/config/agent.config"; private static String ENV_KEY_PREFIX = "skywalking."; + private static boolean IS_INIT_COMPLETED = false; /** * Try to locate `agent.config`, which should be in the /config dictionary of agent package. @@ -78,6 +78,12 @@ public class SnifferConfigInitializer { if (StringUtil.isEmpty(Config.Collector.SERVERS)) { throw new ExceptionInInitializerError("`collector.servers` is missing."); } + + IS_INIT_COMPLETED = true; + } + + public static boolean isInitCompleted() { + return IS_INIT_COMPLETED; } /** diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java index 63e257f42..03a1900a7 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java @@ -35,6 +35,8 @@ import org.apache.skywalking.apm.agent.core.context.trace.WithPeerInfo; import org.apache.skywalking.apm.agent.core.dictionary.DictionaryManager; import org.apache.skywalking.apm.agent.core.dictionary.DictionaryUtil; import org.apache.skywalking.apm.agent.core.dictionary.PossibleFound; +import org.apache.skywalking.apm.agent.core.logging.api.ILog; +import org.apache.skywalking.apm.agent.core.logging.api.LogManager; import org.apache.skywalking.apm.agent.core.sampling.SamplingService; /** @@ -52,6 +54,9 @@ import org.apache.skywalking.apm.agent.core.sampling.SamplingService; * @author zhang xin */ public class TracingContext implements AbstractTracerContext { + private static final ILog logger = LogManager.getLogger(TracingContext.class); + private long lastWarningTimestamp = 0; + /** * @see {@link SamplingService} */ @@ -323,7 +328,7 @@ public class TracingContext implements AbstractTracerContext { exitSpan = parentSpan; } else { final int parentSpanId = parentSpan == null ? -1 : parentSpan.getSpanId(); - exitSpan = (AbstractSpan)DictionaryManager.findApplicationCodeSection() + exitSpan = (AbstractSpan)DictionaryManager.findNetworkAddressSection() .find(remotePeer).doInCondition( new PossibleFound.FoundAndObtain() { @Override @@ -506,6 +511,16 @@ public class TracingContext implements AbstractTracerContext { } private boolean isLimitMechanismWorking() { - return spanIdGenerator >= Config.Agent.SPAN_LIMIT_PER_SEGMENT; + if (spanIdGenerator >= Config.Agent.SPAN_LIMIT_PER_SEGMENT) { + long currentTimeMillis = System.currentTimeMillis(); + if (currentTimeMillis - lastWarningTimestamp > 30 * 1000) { + logger.warn(new RuntimeException("Shadow tracing context. Thread dump"), "More than {} spans required to create", + Config.Agent.SPAN_LIMIT_PER_SEGMENT); + lastWarningTimestamp = currentTimeMillis; + } + return true; + } else { + return false; + } } } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryManager.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryManager.java index 3ce08c644..7d3543208 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryManager.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryManager.java @@ -24,10 +24,10 @@ package org.apache.skywalking.apm.agent.core.dictionary; */ public class DictionaryManager { /** - * @return {@link ApplicationDictionary} to find application id for application code and network address. + * @return {@link NetworkAddressDictionary} to find application id for application code and network address. */ - public static ApplicationDictionary findApplicationCodeSection() { - return ApplicationDictionary.INSTANCE; + public static NetworkAddressDictionary findNetworkAddressSection() { + return NetworkAddressDictionary.INSTANCE; } /** diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/ApplicationDictionary.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/NetworkAddressDictionary.java similarity index 65% rename from apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/ApplicationDictionary.java rename to apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/NetworkAddressDictionary.java index 28d934b0b..b48b02446 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/ApplicationDictionary.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/NetworkAddressDictionary.java @@ -23,42 +23,42 @@ import io.netty.util.internal.ConcurrentSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import org.apache.skywalking.apm.network.proto.ApplicationMappings; -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.apache.skywalking.apm.network.proto.NetworkAddressMappings; +import org.apache.skywalking.apm.network.proto.NetworkAddressRegisterServiceGrpc; +import org.apache.skywalking.apm.network.proto.NetworkAddresses; import static org.apache.skywalking.apm.agent.core.conf.Config.Dictionary.APPLICATION_CODE_BUFFER_SIZE; /** - * Map of application id to application code, which is from the collector side. + * Map of network address id to network literal address, which is from the collector side. * * @author wusheng */ -public enum ApplicationDictionary { +public enum NetworkAddressDictionary { INSTANCE; private Map applicationDictionary = new ConcurrentHashMap(); private Set unRegisterApplications = new ConcurrentSet(); - public PossibleFound find(String applicationCode) { - Integer applicationId = applicationDictionary.get(applicationCode); + public PossibleFound find(String networkAddress) { + Integer applicationId = applicationDictionary.get(networkAddress); if (applicationId != null) { return new Found(applicationId); } else { if (applicationDictionary.size() + unRegisterApplications.size() < APPLICATION_CODE_BUFFER_SIZE) { - unRegisterApplications.add(applicationCode); + unRegisterApplications.add(networkAddress); } return new NotFound(); } } public void syncRemoteDictionary( - ApplicationRegisterServiceGrpc.ApplicationRegisterServiceBlockingStub applicationRegisterServiceBlockingStub) { + NetworkAddressRegisterServiceGrpc.NetworkAddressRegisterServiceBlockingStub networkAddressRegisterServiceBlockingStub) { if (unRegisterApplications.size() > 0) { - ApplicationMappings applicationMapping = applicationRegisterServiceBlockingStub.batchRegister( - Applications.newBuilder().addAllApplicationCodes(unRegisterApplications).build()); - if (applicationMapping.getApplicationsCount() > 0) { - for (KeyWithIntegerValue keyWithIntegerValue : applicationMapping.getApplicationsList()) { + NetworkAddressMappings networkAddressMappings = networkAddressRegisterServiceBlockingStub.batchRegister( + NetworkAddresses.newBuilder().addAllAddresses(unRegisterApplications).build()); + if (networkAddressMappings.getAddressIdsCount() > 0) { + for (KeyWithIntegerValue keyWithIntegerValue : networkAddressMappings.getAddressIdsList()) { unRegisterApplications.remove(keyWithIntegerValue.getKey()); applicationDictionary.put(keyWithIntegerValue.getKey(), keyWithIntegerValue.getValue()); } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/api/ILog.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/api/ILog.java index 0589c2659..5c4d49608 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/api/ILog.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/api/ILog.java @@ -33,6 +33,8 @@ public interface ILog { void warn(String format, Object... arguments); + void warn(Throwable e, String format, Object... arguments); + void error(String format, Throwable e); void error(Throwable e, String format, Object... arguments); diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/api/NoopLogger.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/api/NoopLogger.java index 6aa243c7b..2ad720692 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/api/NoopLogger.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/api/NoopLogger.java @@ -26,9 +26,7 @@ package org.apache.skywalking.apm.agent.core.logging.api; * Created by xin on 2016/11/10. */ public enum NoopLogger implements ILog { - INSTANCE { - - }; + INSTANCE; @Override public void info(String message) { @@ -89,4 +87,10 @@ public enum NoopLogger implements ILog { public void error(Throwable e, String format, Object... arguments) { } + + + @Override + public void warn(Throwable e, String format, Object... arguments) { + + } } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/EasyLogger.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/EasyLogger.java index d7c423616..c8e5845ad 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/EasyLogger.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/EasyLogger.java @@ -105,6 +105,12 @@ public class EasyLogger implements ILog { logger(LogLevel.WARN, replaceParam(format, arguments), null); } + @Override + public void warn(Throwable e, String format, Object... arguments) { + if (isWarnEnable()) + logger(LogLevel.WARN, replaceParam(format, arguments), e); + } + @Override public void error(String format, Throwable e) { if (isErrorEnable()) diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/WriterFactory.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/WriterFactory.java index 9ee6ebf52..4bc357d2d 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/WriterFactory.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/WriterFactory.java @@ -22,11 +22,12 @@ package org.apache.skywalking.apm.agent.core.logging.core; import org.apache.skywalking.apm.agent.core.boot.AgentPackageNotFoundException; import org.apache.skywalking.apm.agent.core.boot.AgentPackagePath; import org.apache.skywalking.apm.agent.core.conf.Config; +import org.apache.skywalking.apm.agent.core.conf.SnifferConfigInitializer; import org.apache.skywalking.apm.util.StringUtil; public class WriterFactory { public static IWriter getLogWriter() { - if (AgentPackagePath.isPathFound()) { + if (SnifferConfigInitializer.isInitCompleted() && AgentPackagePath.isPathFound()) { if (StringUtil.isEmpty(Config.Logging.DIR)) { try { Config.Logging.DIR = AgentPackagePath.getPath() + "/logs"; diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/PluginFinder.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/PluginFinder.java index 09606c05e..99e49a50c 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/PluginFinder.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/PluginFinder.java @@ -30,6 +30,7 @@ import org.apache.skywalking.apm.agent.core.plugin.bytebuddy.AbstractJunction; import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.apache.skywalking.apm.agent.core.plugin.match.IndirectMatch; import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.ProtectiveShieldMatcher; import static net.bytebuddy.matcher.ElementMatchers.isInterface; import static net.bytebuddy.matcher.ElementMatchers.not; @@ -98,6 +99,6 @@ public class PluginFinder { judge = judge.or(((IndirectMatch)match).buildJunction()); } } - return judge; + return new ProtectiveShieldMatcher(judge); } } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/match/ProtectiveShieldMatcher.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/match/ProtectiveShieldMatcher.java new file mode 100644 index 000000000..a4c702765 --- /dev/null +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/match/ProtectiveShieldMatcher.java @@ -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.agent.core.plugin.match; + +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.logging.api.ILog; +import org.apache.skywalking.apm.agent.core.logging.api.LogManager; + +/** + * In some cases, some frameworks and libraries use some binary codes tech too. From the community feedback, some of + * them have compatible issues with byte-buddy core, which trigger "Can't resolve type description" exception. + * + * So I build this protective shield by a nested matcher. When the origin matcher(s) can't resolve the type, the + * SkyWalking agent ignores this types. + * + * Notice: this ignore mechanism may miss some instrumentations, but at most cases, it's same. If missing happens, + * please pay attention to the WARNING logs. + * + * @author wu-sheng + */ +public class ProtectiveShieldMatcher extends ElementMatcher.Junction.AbstractBase { + private static final ILog logger = LogManager.getLogger(ProtectiveShieldMatcher.class); + + private final ElementMatcher matcher; + + public ProtectiveShieldMatcher(ElementMatcher matcher) { + this.matcher = matcher; + } + + public boolean matches(T target) { + try { + return this.matcher.matches(target); + } catch (Throwable t) { + logger.warn(t, "Byte-buddy occurs exception when match type."); + return false; + } + } +} diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/AppAndServiceRegisterClient.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/AppAndServiceRegisterClient.java index 61cbd5172..db5b3d992 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/AppAndServiceRegisterClient.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/AppAndServiceRegisterClient.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.agent.core.remote; import io.grpc.ManagedChannel; @@ -24,28 +23,28 @@ import java.util.UUID; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import org.apache.skywalking.apm.agent.core.conf.RemoteDownstreamConfig; -import org.apache.skywalking.apm.agent.core.context.TracingContext; -import org.apache.skywalking.apm.agent.core.dictionary.ApplicationDictionary; -import org.apache.skywalking.apm.agent.core.os.OSUtil; import org.apache.skywalking.apm.agent.core.boot.BootService; import org.apache.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory; import org.apache.skywalking.apm.agent.core.boot.ServiceManager; import org.apache.skywalking.apm.agent.core.conf.Config; +import org.apache.skywalking.apm.agent.core.conf.RemoteDownstreamConfig; +import org.apache.skywalking.apm.agent.core.context.TracingContext; import org.apache.skywalking.apm.agent.core.context.TracingContextListener; import org.apache.skywalking.apm.agent.core.context.trace.TraceSegment; import org.apache.skywalking.apm.agent.core.dictionary.DictionaryUtil; +import org.apache.skywalking.apm.agent.core.dictionary.NetworkAddressDictionary; import org.apache.skywalking.apm.agent.core.dictionary.OperationNameDictionary; import org.apache.skywalking.apm.agent.core.logging.api.ILog; import org.apache.skywalking.apm.agent.core.logging.api.LogManager; +import org.apache.skywalking.apm.agent.core.os.OSUtil; +import org.apache.skywalking.apm.network.proto.Application; 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.ApplicationMappings; +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.InstanceDiscoveryServiceGrpc; +import org.apache.skywalking.apm.network.proto.NetworkAddressRegisterServiceGrpc; import org.apache.skywalking.apm.network.proto.ServiceNameDiscoveryServiceGrpc; /** @@ -59,8 +58,8 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList private volatile ApplicationRegisterServiceGrpc.ApplicationRegisterServiceBlockingStub applicationRegisterServiceBlockingStub; private volatile InstanceDiscoveryServiceGrpc.InstanceDiscoveryServiceBlockingStub instanceDiscoveryServiceBlockingStub; private volatile ServiceNameDiscoveryServiceGrpc.ServiceNameDiscoveryServiceBlockingStub serviceNameDiscoveryServiceBlockingStub; + private volatile NetworkAddressRegisterServiceGrpc.NetworkAddressRegisterServiceBlockingStub networkAddressRegisterServiceBlockingStub; private volatile ScheduledFuture applicationRegisterFuture; - private volatile boolean needRegisterRecover = false; private volatile long lastSegmentTime = -1; @Override @@ -69,10 +68,8 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList ManagedChannel channel = ServiceManager.INSTANCE.findService(GRPCChannelManager.class).getManagedChannel(); applicationRegisterServiceBlockingStub = ApplicationRegisterServiceGrpc.newBlockingStub(channel); instanceDiscoveryServiceBlockingStub = InstanceDiscoveryServiceGrpc.newBlockingStub(channel); - if (RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID != DictionaryUtil.nullValue()) { - needRegisterRecover = true; - } serviceNameDiscoveryServiceBlockingStub = ServiceNameDiscoveryServiceGrpc.newBlockingStub(channel); + networkAddressRegisterServiceBlockingStub = NetworkAddressRegisterServiceGrpc.newBlockingStub(channel); } else { applicationRegisterServiceBlockingStub = null; instanceDiscoveryServiceBlockingStub = null; @@ -105,17 +102,17 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList @Override public void run() { - logger.debug("AppAndServiceRegisterClient running, status:{}.",status); + logger.debug("AppAndServiceRegisterClient running, status:{}.", status); boolean shouldTry = true; while (GRPCChannelStatus.CONNECTED.equals(status) && shouldTry) { shouldTry = false; try { if (RemoteDownstreamConfig.Agent.APPLICATION_ID == DictionaryUtil.nullValue()) { if (applicationRegisterServiceBlockingStub != null) { - ApplicationMappings applicationMapping = applicationRegisterServiceBlockingStub.batchRegister( - Applications.newBuilder().addApplicationCodes(Config.Agent.APPLICATION_CODE).build()); - if (applicationMapping.getApplicationsCount() > 0) { - RemoteDownstreamConfig.Agent.APPLICATION_ID = applicationMapping.getApplications(0).getValue(); + ApplicationMapping applicationMapping = applicationRegisterServiceBlockingStub.applicationCodeRegister( + Application.newBuilder().setApplicationCode(Config.Agent.APPLICATION_CODE).build()); + if (applicationMapping != null) { + RemoteDownstreamConfig.Agent.APPLICATION_ID = applicationMapping.getApplication().getValue(); shouldTry = true; } } @@ -123,7 +120,7 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList if (instanceDiscoveryServiceBlockingStub != null) { if (RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID == DictionaryUtil.nullValue()) { - ApplicationInstanceMapping instanceMapping = instanceDiscoveryServiceBlockingStub.register(ApplicationInstance.newBuilder() + ApplicationInstanceMapping instanceMapping = instanceDiscoveryServiceBlockingStub.registerInstance(ApplicationInstance.newBuilder() .setApplicationId(RemoteDownstreamConfig.Agent.APPLICATION_ID) .setAgentUUID(PROCESS_UUID) .setRegisterTime(System.currentTimeMillis()) @@ -134,24 +131,14 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList = instanceMapping.getApplicationInstanceId(); } } else { - if (needRegisterRecover) { - instanceDiscoveryServiceBlockingStub.registerRecover(ApplicationInstanceRecover.newBuilder() - .setApplicationId(RemoteDownstreamConfig.Agent.APPLICATION_ID) + if (lastSegmentTime - System.currentTimeMillis() > 60 * 1000) { + instanceDiscoveryServiceBlockingStub.heartbeat(ApplicationInstanceHeartbeat.newBuilder() .setApplicationInstanceId(RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID) - .setRegisterTime(System.currentTimeMillis()) - .setOsinfo(OSUtil.buildOSInfo()) + .setHeartbeatTime(System.currentTimeMillis()) .build()); - needRegisterRecover = false; - } else { - if (lastSegmentTime - System.currentTimeMillis() > 60 * 1000) { - instanceDiscoveryServiceBlockingStub.heartbeat(ApplicationInstanceHeartbeat.newBuilder() - .setApplicationInstanceId(RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID) - .setHeartbeatTime(System.currentTimeMillis()) - .build()); - } } - ApplicationDictionary.INSTANCE.syncRemoteDictionary(applicationRegisterServiceBlockingStub); + NetworkAddressDictionary.INSTANCE.syncRemoteDictionary(networkAddressRegisterServiceBlockingStub); OperationNameDictionary.INSTANCE.syncRemoteDictionary(serviceNameDiscoveryServiceBlockingStub); } } diff --git a/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java b/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java index b49b1fd2c..eef05b7ef 100644 --- a/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.plugin.feign.http.v9; import feign.Request; @@ -52,9 +51,9 @@ public class DefaultHttpClientInterceptor implements InstanceMethodsAroundInterc private static final String COMPONENT_NAME = "FeignDefaultHttp"; /** - * Get the {@link feign.Request} from {@link EnhancedInstance}, then create {@link AbstractSpan} and set host, - * port, kind, component, url from {@link feign.Request}. - * Through the reflection of the way, set the http header of context data into {@link feign.Request#headers}. + * Get the {@link feign.Request} from {@link EnhancedInstance}, then create {@link AbstractSpan} and set host, port, + * kind, component, url from {@link feign.Request}. Through the reflection of the way, set the http header of + * context data into {@link feign.Request#headers}. * * @param method * @param result change this result, if you want to truncate the method. @@ -66,11 +65,16 @@ public class DefaultHttpClientInterceptor implements InstanceMethodsAroundInterc URL url = new URL(request.url()); ContextCarrier contextCarrier = new ContextCarrier(); - String remotePeer = url.getHost() + ":" + url.getPort(); - AbstractSpan span = ContextManager.createExitSpan(request.url(), contextCarrier, remotePeer); + int port = url.getPort() == -1 ? 80 : url.getPort(); + String remotePeer = url.getHost() + ":" + port; + String operationName = url.getPath(); + if (operationName == null || operationName.length() == 0) { + operationName = "/"; + } + AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, remotePeer); span.setComponent(ComponentsDefine.FEIGN); Tags.HTTP.METHOD.set(span, request.method()); - Tags.URL.set(span, url.getPath()); + Tags.URL.set(span, request.url()); SpanLayer.asHttp(span); Field headersField = Request.class.getDeclaredField("headers"); @@ -94,8 +98,7 @@ public class DefaultHttpClientInterceptor implements InstanceMethodsAroundInterc /** * Get the status code from {@link Response}, when status code greater than 400, it means there was some errors in - * the server. - * Finish the {@link AbstractSpan}. + * the server. Finish the {@link AbstractSpan}. * * @param method * @param ret the method's original return value. diff --git a/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptorTest.java index 1c5d30a1a..20f2ccfe9 100644 --- a/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptorTest.java @@ -87,7 +87,7 @@ public class DefaultHttpClientInterceptorTest { public void setUp() throws Exception { Map> headers = new LinkedHashMap>(); - request = Request.create("GET", "http://skywalking.org", headers, "Test".getBytes(), Charset.forName("UTF-8")); + request = Request.create("GET", "http://skywalking.org/", headers, "Test".getBytes(), Charset.forName("UTF-8")); Request.Options options = new Request.Options(); allArguments = new Object[] {request, options}; argumentTypes = new Class[] {request.getClass(), options.getClass()}; @@ -112,7 +112,7 @@ public class DefaultHttpClientInterceptorTest { List tags = SpanHelper.getTags(finishedSpan); assertThat(tags.size(), is(2)); assertThat(tags.get(0).getValue(), is("GET")); - assertThat(tags.get(1).getValue(), is("")); + assertThat(tags.get(1).getValue(), is("http://skywalking.org/")); Assert.assertEquals(false, SpanHelper.getErrorOccurred(finishedSpan)); } @@ -135,7 +135,7 @@ public class DefaultHttpClientInterceptorTest { List tags = SpanHelper.getTags(finishedSpan); assertThat(tags.size(), is(3)); assertThat(tags.get(0).getValue(), is("GET")); - assertThat(tags.get(1).getValue(), is("")); + assertThat(tags.get(1).getValue(), is("http://skywalking.org/")); assertThat(tags.get(2).getValue(), is("404")); Assert.assertEquals(true, SpanHelper.getErrorOccurred(finishedSpan)); @@ -166,7 +166,7 @@ public class DefaultHttpClientInterceptorTest { List tags = SpanHelper.getTags(finishedSpan); assertThat(tags.size(), is(2)); assertThat(tags.get(0).getValue(), is("GET")); - assertThat(tags.get(1).getValue(), is("")); + assertThat(tags.get(1).getValue(), is("http://skywalking.org/")); Assert.assertEquals(true, SpanHelper.getErrorOccurred(finishedSpan)); diff --git a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java index 024218c8f..f3892eb52 100644 --- a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.plugin.httpClient.v4; import java.lang.reflect.Method; @@ -25,13 +24,13 @@ import java.net.URL; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; +import org.apache.skywalking.apm.agent.core.context.CarrierItem; import org.apache.skywalking.apm.agent.core.context.ContextCarrier; +import org.apache.skywalking.apm.agent.core.context.ContextManager; import org.apache.skywalking.apm.agent.core.context.tag.Tags; import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; -import org.apache.skywalking.apm.agent.core.context.CarrierItem; -import org.apache.skywalking.apm.agent.core.context.ContextManager; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; @@ -48,7 +47,10 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc HttpRequest httpRequest = (HttpRequest)allArguments[1]; final ContextCarrier contextCarrier = new ContextCarrier(); AbstractSpan span = null; - String remotePeer = httpHost.getHostName() + ":" + httpHost.getPort(); + + String remotePeer = httpHost.getHostName() + ":" + (httpHost.getPort() > 0 ? httpHost.getPort() : + "https".equals(httpHost.getSchemeName().toLowerCase()) ? 443 : 80); + try { URL url = new URL(httpRequest.getRequestLine().getUri()); span = ContextManager.createExitSpan(url.getPath(), contextCarrier, remotePeer); diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/pom.xml new file mode 100644 index 000000000..bc51af148 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/pom.xml @@ -0,0 +1,42 @@ + + + + + jetty-plugins + org.apache.skywalking + 5.0.0-alpha + + 4.0.0 + + apm-jetty-client-9.0-plugin + jar + + jetty-client-9.0-plugin + http://maven.apache.org + + + + org.eclipse.jetty + jetty-client + 9.0.0.v20130308 + provided + + + diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/AsyncHttpRequestSendInterceptor.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v90/client/SyncHttpRequestSendInterceptor.java similarity index 79% rename from apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/AsyncHttpRequestSendInterceptor.java rename to apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v90/client/SyncHttpRequestSendInterceptor.java index 490be9d74..0313bf401 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/AsyncHttpRequestSendInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v90/client/SyncHttpRequestSendInterceptor.java @@ -16,24 +16,24 @@ * */ - -package org.apache.skywalking.apm.plugin.jetty.v9.client; +package org.apache.skywalking.apm.plugin.jetty.v90.client; import java.lang.reflect.Method; -import org.apache.skywalking.apm.agent.core.context.ContextCarrier; -import org.apache.skywalking.apm.agent.core.context.tag.Tags; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.http.HttpFields; import org.apache.skywalking.apm.agent.core.context.CarrierItem; +import org.apache.skywalking.apm.agent.core.context.ContextCarrier; import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.context.tag.Tags; import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; +import org.eclipse.jetty.client.HttpRequest; +import org.eclipse.jetty.http.HttpFields; +import org.eclipse.jetty.http.HttpMethod; -public class AsyncHttpRequestSendInterceptor implements InstanceMethodsAroundInterceptor { +public class SyncHttpRequestSendInterceptor implements InstanceMethodsAroundInterceptor { @Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, @@ -42,7 +42,8 @@ public class AsyncHttpRequestSendInterceptor implements InstanceMethodsAroundInt ContextCarrier contextCarrier = new ContextCarrier(); AbstractSpan span = ContextManager.createExitSpan(request.getURI().getPath(), contextCarrier, request.getHost() + ":" + request.getPort()); span.setComponent(ComponentsDefine.JETTY_CLIENT); - Tags.HTTP.METHOD.set(span, request.getMethod().asString()); + + Tags.HTTP.METHOD.set(span, getHttpMethod(request)); Tags.URL.set(span, request.getURI().toString()); SpanLayer.asHttp(span); @@ -52,9 +53,6 @@ public class AsyncHttpRequestSendInterceptor implements InstanceMethodsAroundInt next = next.next(); field.add(next.getHeadKey(), next.getHeadValue()); } - - EnhancedInstance callBackResult = (EnhancedInstance)allArguments[0]; - callBackResult.setSkyWalkingDynamicField(ContextManager.capture()); } @Override @@ -68,4 +66,20 @@ public class AsyncHttpRequestSendInterceptor implements InstanceMethodsAroundInt Class[] argumentsTypes, Throwable t) { ContextManager.activeSpan().errorOccurred().log(t); } + + public String getHttpMethod(HttpRequest request) { + HttpMethod httpMethod = HttpMethod.GET; + + /** + * The method is null if the client using GET method. + * + * @see org.eclipse.jetty.client.HttpRequest#GET(String uri) + * @see org.eclipse.jetty.client.HttpRequest( org.eclipse.jetty.client.HttpClient client, long conversation, java.net.URI uri) + */ + if (request.getMethod() != null) { + httpMethod = request.getMethod(); + } + + return httpMethod.name(); + } } diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v90/client/define/HttpRequestInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v90/client/define/HttpRequestInstrumentation.java new file mode 100644 index 000000000..62d5b87b5 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v90/client/define/HttpRequestInstrumentation.java @@ -0,0 +1,76 @@ +/* + * 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.plugin.jetty.v90.client.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.takesArguments; + +/** + * {@link HttpRequestInstrumentation} enhance the send method without argument in + * org.eclipse.jetty.client.HttpRequest by org.apache.skywalking.apm.plugin.jetty.client.SyncHttpRequestSendInterceptor + * and enhance the send with org.eclipse.jetty.client.api.Response$CompleteListener parameter + * by org.apache.skywalking.apm.plugin.jetty.client.AsyncHttpRequestSendInterceptor + * + * @author zhangxin + */ +public class HttpRequestInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "org.eclipse.jetty.client.HttpRequest"; + private static final String ENHANCE_CLASS_NAME = "send"; + public static final String SYNC_SEND_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jetty.v90.client.SyncHttpRequestSendV90Interceptor"; + + @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + //sync call interceptor point + @Override public ElementMatcher getMethodsMatcher() { + return named(ENHANCE_CLASS_NAME).and(takesArguments(0)); + } + + @Override public String getMethodsInterceptor() { + return SYNC_SEND_INTERCEPTOR; + } + + @Override public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override protected ClassMatch enhanceClass() { + return NameMatch.byName(ENHANCE_CLASS); + } + + @Override protected String[] witnessClasses() { + return new String[] {"org.eclipse.jetty.client.api.ProxyConfiguration"}; + } +} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/src/main/resources/skywalking-plugin.def new file mode 100644 index 000000000..05bc01091 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/src/main/resources/skywalking-plugin.def @@ -0,0 +1 @@ +jetty-client-9.0=org.apache.skywalking.apm.plugin.jetty.v90.client.define.HttpRequestInstrumentation diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jetty/v9/client/AsyncHttpRequestSendInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/src/test/java/org/apache/skywalking/apm/plugin/jetty/v90/client/SyncHttpRequestSendInterceptorTest.java similarity index 93% rename from apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jetty/v9/client/AsyncHttpRequestSendInterceptorTest.java rename to apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/src/test/java/org/apache/skywalking/apm/plugin/jetty/v90/client/SyncHttpRequestSendInterceptorTest.java index ca8f7f3ef..f666301cd 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jetty/v9/client/AsyncHttpRequestSendInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.0-plugin/src/test/java/org/apache/skywalking/apm/plugin/jetty/v90/client/SyncHttpRequestSendInterceptorTest.java @@ -17,7 +17,7 @@ */ -package org.apache.skywalking.apm.plugin.jetty.v9.client; +package org.apache.skywalking.apm.plugin.jetty.v90.client; import java.net.URI; import java.util.List; @@ -49,7 +49,7 @@ import static org.junit.Assert.assertThat; @RunWith(PowerMockRunner.class) @PowerMockRunnerDelegate(TracingSegmentRunner.class) -public class AsyncHttpRequestSendInterceptorTest { +public class SyncHttpRequestSendInterceptorTest { @SegmentStoragePoint private SegmentStorage segmentStorage; @@ -63,7 +63,7 @@ public class AsyncHttpRequestSendInterceptorTest { private Object[] allArguments; private Class[] argumentTypes; private MockHttpRequest enhancedInstance; - private AsyncHttpRequestSendInterceptor interceptor; + private SyncHttpRequestSendInterceptor interceptor; private URI uri = URI.create("http://localhost:8080/test"); @Before @@ -72,7 +72,7 @@ public class AsyncHttpRequestSendInterceptorTest { allArguments = new Object[] {"OperationKey", "OperationValue"}; argumentTypes = new Class[] {String.class, String.class}; - interceptor = new AsyncHttpRequestSendInterceptor(); + interceptor = new SyncHttpRequestSendInterceptor(); allArguments = new Object[] {callBackEnhanceInstance}; } @@ -89,7 +89,7 @@ public class AsyncHttpRequestSendInterceptorTest { List tags = SpanHelper.getTags(finishedSpan); assertThat(tags.size(), is(2)); - assertThat(tags.get(0).getValue(), is("POST")); + assertThat(tags.get(0).getValue(), is("GET")); assertThat(tags.get(1).getValue(), is(uri.toString())); Assert.assertEquals(false, SpanHelper.getErrorOccurred(finishedSpan)); @@ -109,7 +109,7 @@ public class AsyncHttpRequestSendInterceptorTest { List tags = SpanHelper.getTags(finishedSpan); assertThat(tags.size(), is(2)); - assertThat(tags.get(0).getValue(), is("POST")); + assertThat(tags.get(0).getValue(), is("GET")); assertThat(tags.get(1).getValue(), is(uri.toString())); Assert.assertEquals(true, SpanHelper.getErrorOccurred(finishedSpan)); @@ -131,7 +131,7 @@ public class AsyncHttpRequestSendInterceptorTest { } @Override public HttpMethod getMethod() { - return HttpMethod.POST; + return HttpMethod.GET; } @Override public URI getURI() { diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/pom.xml index 9730602da..3c13eddc6 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/pom.xml @@ -35,7 +35,7 @@ org.eclipse.jetty jetty-client - 9.0.0.v20130308 + 9.1.0.v20131115 provided diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/SyncHttpRequestSendInterceptor.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/SyncHttpRequestSendInterceptor.java index d595ae8d1..49ac74e9e 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/SyncHttpRequestSendInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/SyncHttpRequestSendInterceptor.java @@ -16,22 +16,21 @@ * */ - package org.apache.skywalking.apm.plugin.jetty.v9.client; import java.lang.reflect.Method; import org.apache.skywalking.apm.agent.core.context.CarrierItem; import org.apache.skywalking.apm.agent.core.context.ContextCarrier; +import org.apache.skywalking.apm.agent.core.context.ContextManager; import org.apache.skywalking.apm.agent.core.context.tag.Tags; import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; import org.eclipse.jetty.client.HttpRequest; import org.eclipse.jetty.http.HttpFields; -import org.apache.skywalking.apm.agent.core.context.ContextManager; -import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; -import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; public class SyncHttpRequestSendInterceptor implements InstanceMethodsAroundInterceptor { @@ -42,7 +41,8 @@ public class SyncHttpRequestSendInterceptor implements InstanceMethodsAroundInte ContextCarrier contextCarrier = new ContextCarrier(); AbstractSpan span = ContextManager.createExitSpan(request.getURI().getPath(), contextCarrier, request.getHost() + ":" + request.getPort()); span.setComponent(ComponentsDefine.JETTY_CLIENT); - Tags.HTTP.METHOD.set(span, "GET"); + + Tags.HTTP.METHOD.set(span, getHttpMethod(request)); Tags.URL.set(span, request.getURI().toString()); SpanLayer.asHttp(span); @@ -65,4 +65,14 @@ public class SyncHttpRequestSendInterceptor implements InstanceMethodsAroundInte Class[] argumentsTypes, Throwable t) { ContextManager.activeSpan().errorOccurred().log(t); } + + public String getHttpMethod(HttpRequest request) { + String method = request.getMethod(); + + if (method == null || method.length() == 0) { + method = "GET"; + } + + return method; + } } diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/define/HttpRequestInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/define/HttpRequestInstrumentation.java index 2946eac1f..53d454e8d 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/define/HttpRequestInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/define/HttpRequestInstrumentation.java @@ -21,15 +21,14 @@ package org.apache.skywalking.apm.plugin.jetty.v9.client.define; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; -import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.takesArguments; -import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; /** * {@link HttpRequestInstrumentation} enhance the send method without argument in @@ -43,8 +42,7 @@ public class HttpRequestInstrumentation extends ClassInstanceMethodsEnhancePlugi private static final String ENHANCE_CLASS = "org.eclipse.jetty.client.HttpRequest"; private static final String ENHANCE_CLASS_NAME = "send"; - public static final String ASYNC_SEND_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jetty.client.AsyncHttpRequestSendInterceptor"; - public static final String SYNC_SEND_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jetty.client.SyncHttpRequestSendInterceptor"; + public static final String SYNC_SEND_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jetty.v9.client.SyncHttpRequestSendInterceptor"; @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { return new ConstructorInterceptPoint[0]; @@ -62,20 +60,6 @@ public class HttpRequestInstrumentation extends ClassInstanceMethodsEnhancePlugi return SYNC_SEND_INTERCEPTOR; } - @Override public boolean isOverrideArgs() { - return false; - } - }, - new InstanceMethodsInterceptPoint() { - //async call interceptor point - @Override public ElementMatcher getMethodsMatcher() { - return named(ENHANCE_CLASS_NAME).and(takesArgumentWithType(0, "org.eclipse.jetty.client.api.Response$CompleteListener")); - } - - @Override public String getMethodsInterceptor() { - return ASYNC_SEND_INTERCEPTOR; - } - @Override public boolean isOverrideArgs() { return false; } @@ -86,4 +70,8 @@ public class HttpRequestInstrumentation extends ClassInstanceMethodsEnhancePlugi @Override protected ClassMatch enhanceClass() { return NameMatch.byName(ENHANCE_CLASS); } + + @Override protected String[] witnessClasses() { + return new String[] {"org.eclipse.jetty.client.AbstractHttpClientTransport"}; + } } diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/resources/skywalking-plugin.def index 2a8febe61..32e602e04 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/resources/skywalking-plugin.def +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/resources/skywalking-plugin.def @@ -1,2 +1 @@ -jetty-client-9.x=org.apache.skywalking.apm.plugin.jetty.v9.client.define.CompleteListenerInstrumentation jetty-client-9.x=org.apache.skywalking.apm.plugin.jetty.v9.client.define.HttpRequestInstrumentation diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jetty/v9/client/CompleteListenerInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jetty/v9/client/CompleteListenerInterceptorTest.java deleted file mode 100644 index bcea6c153..000000000 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jetty/v9/client/CompleteListenerInterceptorTest.java +++ /dev/null @@ -1,129 +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.plugin.jetty.v9.client; - -import java.net.URI; -import org.apache.skywalking.apm.agent.core.context.ContextSnapshot; -import org.apache.skywalking.apm.agent.core.context.ids.DistributedTraceId; -import org.apache.skywalking.apm.agent.core.context.ids.ID; -import org.apache.skywalking.apm.agent.core.context.trace.TraceSegment; -import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; -import org.apache.skywalking.apm.agent.test.tools.AgentServiceRule; -import org.apache.skywalking.apm.agent.test.tools.SegmentStorage; -import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint; -import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.http.HttpFields; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.modules.junit4.PowerMockRunnerDelegate; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.when; - -@RunWith(PowerMockRunner.class) -@PowerMockRunnerDelegate(TracingSegmentRunner.class) -public class CompleteListenerInterceptorTest { - - @SegmentStoragePoint - private SegmentStorage segmentStorage; - @Rule - public AgentServiceRule serviceRule = new AgentServiceRule(); - @Mock - private Result result; - @Mock - private HttpRequest httpRequest; - @Mock - private HttpResponse httpResponse; - private Object[] allArguments; - private Class[] argumentTypes; - private CompleteListenerInterceptor interceptor; - - @Mock - private ContextSnapshot contextSnapshot; - - private EnhancedInstance objectInstanceWithoutSnapshot = new EnhancedInstance() { - @Override - public Object getSkyWalkingDynamicField() { - return null; - } - - @Override - public void setSkyWalkingDynamicField(Object value) { - - } - }; - - private EnhancedInstance objectInstanceWithSnapshot = new EnhancedInstance() { - @Override - public Object getSkyWalkingDynamicField() { - return contextSnapshot; - } - - @Override - public void setSkyWalkingDynamicField(Object value) { - - } - }; - - @Before - public void setUp() { - interceptor = new CompleteListenerInterceptor(); - when(result.getResponse()).thenReturn(httpResponse); - when(httpRequest.getURI()).thenReturn(URI.create("http://localhost:8080/test")); - when(result.getRequest()).thenReturn(httpRequest); - allArguments = new Object[] {result}; - argumentTypes = new Class[] {result.getClass()}; - when(contextSnapshot.isValid()).thenReturn(true); - when(contextSnapshot.getEntryApplicationInstanceId()).thenReturn(1); - when(contextSnapshot.getSpanId()).thenReturn(2); - when(contextSnapshot.getTraceSegmentId()).thenReturn(mock(ID.class)); - when(contextSnapshot.getDistributedTraceId()).thenReturn(mock(DistributedTraceId.class)); - when(contextSnapshot.getEntryOperationName()).thenReturn("1"); - when(contextSnapshot.getParentOperationName()).thenReturn("2"); - } - - @Test - public void testMethodAroundWithoutSnapshot() throws Throwable { - interceptor.beforeMethod(objectInstanceWithoutSnapshot, null, allArguments, argumentTypes, null); - interceptor.afterMethod(objectInstanceWithoutSnapshot, null, allArguments, argumentTypes, null); - assertThat(segmentStorage.getTraceSegments().size(), is(0)); - } - - @Test - public void testMethodAroundWithSnapshot() throws Throwable { - HttpFields fields = new HttpFields(); - when(httpResponse.getHeaders()).thenReturn(fields); - interceptor.beforeMethod(objectInstanceWithSnapshot, null, allArguments, argumentTypes, null); - interceptor.afterMethod(objectInstanceWithSnapshot, null, allArguments, argumentTypes, null); - - assertThat(segmentStorage.getTraceSegments().size(), is(1)); - TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); - assertThat(traceSegment.getRefs().size(), is(1)); - } -} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jetty/v9/client/SyncHttpRequestSendInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jetty/v9/client/SyncHttpRequestSendInterceptorTest.java index cddb0b7a7..a084bb04f 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jetty/v9/client/SyncHttpRequestSendInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jetty/v9/client/SyncHttpRequestSendInterceptorTest.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.plugin.jetty.v9.client; import java.net.URI; @@ -31,9 +30,9 @@ import org.apache.skywalking.apm.agent.test.tools.AgentServiceRule; import org.apache.skywalking.apm.agent.test.tools.SegmentStorage; import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint; import org.apache.skywalking.apm.agent.test.tools.SpanAssert; +import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.http.HttpMethod; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -42,7 +41,6 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunnerDelegate; -import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; @@ -63,7 +61,7 @@ public class SyncHttpRequestSendInterceptorTest { private Object[] allArguments; private Class[] argumentTypes; private MockHttpRequest enhancedInstance; - private AsyncHttpRequestSendInterceptor interceptor; + private SyncHttpRequestSendInterceptor interceptor; private URI uri = URI.create("http://localhost:8080/test"); @Before @@ -72,7 +70,7 @@ public class SyncHttpRequestSendInterceptorTest { allArguments = new Object[] {"OperationKey", "OperationValue"}; argumentTypes = new Class[] {String.class, String.class}; - interceptor = new AsyncHttpRequestSendInterceptor(); + interceptor = new SyncHttpRequestSendInterceptor(); allArguments = new Object[] {callBackEnhanceInstance}; } @@ -130,8 +128,8 @@ public class SyncHttpRequestSendInterceptorTest { } - @Override public HttpMethod getMethod() { - return HttpMethod.GET; + @Override public String getMethod() { + return "GET"; } @Override public URI getURI() { diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/jetty-plugin/pom.xml index ec6914976..c80d1c488 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/pom.xml @@ -31,6 +31,7 @@ jetty-client-9.x-plugin jetty-server-9.x-plugin + jetty-client-9.0-plugin pom diff --git a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptor.java index ae40d5218..53a5bbf31 100644 --- a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptor.java @@ -173,7 +173,7 @@ public class MongoDBMethodInterceptor implements InstanceMethodsAroundIntercepto String executeMethod = arguments[0].getClass().getSimpleName(); String remotePeer = (String)objInst.getSkyWalkingDynamicField(); - AbstractSpan span = ContextManager.createExitSpan(MONGO_DB_OP_PREFIX + method.getName(), new ContextCarrier(), remotePeer); + AbstractSpan span = ContextManager.createExitSpan(MONGO_DB_OP_PREFIX + executeMethod, new ContextCarrier(), remotePeer); span.setComponent(ComponentsDefine.MONGODB); Tags.DB_TYPE.set(span, DB_TYPE); SpanLayer.asDB(span); diff --git a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptorTest.java index adc7798a1..8a88d79e3 100644 --- a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptorTest.java @@ -122,7 +122,7 @@ public class MongoDBMethodInterceptorTest { } private void assertRedisSpan(AbstractTracingSpan span) { - assertThat(span.getOperationName(), is("MongoDB/getUsedDatabases")); + assertThat(span.getOperationName(), is("MongoDB/FindOperation")); assertThat(SpanHelper.getComponentId(span), is(9)); List tags = SpanHelper.getTags(span); assertThat(tags.get(1).getValue(), is("FindOperation { \"name\" : \"by\" }")); diff --git a/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java index bea877b05..27b38e174 100644 --- a/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java @@ -32,6 +32,6 @@ import static org.apache.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameM public class DriverInstrumentation extends AbstractDriverInstrumentation { @Override protected ClassMatch enhanceClass() { - return byMultiClassMatch("com.mysql.jdbc.Driver", "com.mysql.cj.jdbc.Driver"); + return byMultiClassMatch("com.mysql.jdbc.Driver", "com.mysql.cj.jdbc.Driver", "com.mysql.jdbc.NonRegisteringDriver"); } } diff --git a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/AsyncCallInterceptor.java b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/AsyncCallInterceptor.java new file mode 100644 index 000000000..1ae84ef10 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/AsyncCallInterceptor.java @@ -0,0 +1,106 @@ +/* + * 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.plugin.okhttp.v3; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.Request; +import org.apache.skywalking.apm.agent.core.context.CarrierItem; +import org.apache.skywalking.apm.agent.core.context.ContextCarrier; +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.context.tag.Tags; +import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; + +/** + * {@link AsyncCallInterceptor} get the `EnhanceRequiredInfo` instance from `SkyWalkingDynamicField` and then put it + * into `AsyncCall` instance when the `AsyncCall` constructor called. + * + * {@link AsyncCallInterceptor} also create an exit span by using the `EnhanceRequiredInfo` when the `execute` method + * called. + * + * @author zhangxin + */ +public class AsyncCallInterceptor implements InstanceConstructorInterceptor, InstanceMethodsAroundInterceptor { + @Override + public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { + /** + * The first argument of constructor is not the `real` parameter when the enhance class is an inner class. This + * is the JDK compiler mechanism. + */ + EnhancedInstance realCallInstance = (EnhancedInstance)allArguments[1]; + Object enhanceRequireInfo = realCallInstance.getSkyWalkingDynamicField(); + + objInst.setSkyWalkingDynamicField(enhanceRequireInfo); + } + + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + EnhanceRequiredInfo enhanceRequiredInfo = (EnhanceRequiredInfo)objInst.getSkyWalkingDynamicField(); + Request request = (Request)enhanceRequiredInfo.getRealCallEnhance().getSkyWalkingDynamicField(); + + + HttpUrl requestUrl = request.url(); + AbstractSpan span = ContextManager.createExitSpan(requestUrl.uri().getPath(), requestUrl.host() + ":" + requestUrl.port()); + ContextManager.continued(enhanceRequiredInfo.getContextSnapshot()); + ContextCarrier contextCarrier = new ContextCarrier(); + ContextManager.inject(contextCarrier); + span.setComponent(ComponentsDefine.OKHTTP); + Tags.HTTP.METHOD.set(span, request.method()); + Tags.URL.set(span, requestUrl.uri().toString()); + SpanLayer.asHttp(span); + + Field headersField = Request.class.getDeclaredField("headers"); + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(headersField, headersField.getModifiers() & ~Modifier.FINAL); + + headersField.setAccessible(true); + Headers.Builder headerBuilder = request.headers().newBuilder(); + CarrierItem next = contextCarrier.items(); + while (next.hasNext()) { + next = next.next(); + headerBuilder.add(next.getHeadKey(), next.getHeadValue()); + } + headersField.set(request, headerBuilder.build()); + + + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable { + ContextManager.stopSpan(); + return ret; + } + + @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + ContextManager.activeSpan().log(t); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/EnhanceRequiredInfo.java b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/EnhanceRequiredInfo.java new file mode 100644 index 000000000..ff8a4664b --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/EnhanceRequiredInfo.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.okhttp.v3; + +import org.apache.skywalking.apm.agent.core.context.ContextSnapshot; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; + +/** + * {@link EnhanceRequiredInfo} storage the `ContextSnapshot` and `RealCall` instances for support the async function of + * okhttp client. + * + * @author zhangxin + */ +public class EnhanceRequiredInfo { + private ContextSnapshot contextSnapshot; + private EnhancedInstance realCallEnhance; + + public EnhanceRequiredInfo(EnhancedInstance realCallEnhance, + ContextSnapshot contextSnapshot) { + this.contextSnapshot = contextSnapshot; + this.realCallEnhance = realCallEnhance; + } + + public ContextSnapshot getContextSnapshot() { + return contextSnapshot; + } + + public EnhancedInstance getRealCallEnhance() { + return realCallEnhance; + } +} diff --git a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/EnqueueInterceptor.java b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/EnqueueInterceptor.java new file mode 100644 index 000000000..63884651f --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/EnqueueInterceptor.java @@ -0,0 +1,72 @@ +/* + * 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.plugin.okhttp.v3; + +import java.lang.reflect.Method; +import okhttp3.Request; +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; + +/** + * {@link EnqueueInterceptor} create a local span and the prefix of the span operation name is start with `Async` when + * the `enqueue` method called and also put the `ContextSnapshot` and `RealCall` instance into the + * `SkyWalkingDynamicField`. + * + * @author zhangxin + */ +public class EnqueueInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor { + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + EnhancedInstance callbackInstance = (EnhancedInstance)allArguments[0]; + Request request = (Request)objInst.getSkyWalkingDynamicField(); + ContextManager.createLocalSpan("Async" + request.url().uri().getPath()); + + /** + * Here is the process about how to trace the async function. + * + * 1. Storage `Request` object into `RealCall` instance when the constructor of `RealCall` called. + * 2. Put the `RealCall` instance to `CallBack` instance + * 3. Get the `RealCall` instance from `CallBack` and then Put the `RealCall` into `AsyncCall` instance + * since the constructor of `RealCall` called. + * 5. Create the exit span by using the `RealCall` instance when `AsyncCall` method called. + */ + + callbackInstance.setSkyWalkingDynamicField(new EnhanceRequiredInfo(objInst, ContextManager.capture())); + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable { + ContextManager.stopSpan(); + return ret; + } + + @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + ContextManager.activeSpan().errorOccurred().log(t); + } + + @Override public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { + objInst.setSkyWalkingDynamicField(allArguments[1]); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/OnFailureInterceptor.java b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/OnFailureInterceptor.java new file mode 100644 index 000000000..9b6d357a3 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/OnFailureInterceptor.java @@ -0,0 +1,44 @@ +/* + * 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.plugin.okhttp.v3; + +import java.lang.reflect.Method; +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; + +public class OnFailureInterceptor implements InstanceMethodsAroundInterceptor { + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + ContextManager.activeSpan().errorOccurred(); + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable { + return ret; + } + + @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + ContextManager.activeSpan().errorOccurred().log(t); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/CompleteListenerInterceptor.java b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/OnResponseInterceptor.java similarity index 55% rename from apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/CompleteListenerInterceptor.java rename to apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/OnResponseInterceptor.java index 677fbff99..c7c0f390c 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/CompleteListenerInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/OnResponseInterceptor.java @@ -16,48 +16,35 @@ * */ - -package org.apache.skywalking.apm.plugin.jetty.v9.client; +package org.apache.skywalking.apm.plugin.okhttp.v3; import java.lang.reflect.Method; -import org.apache.skywalking.apm.agent.core.context.tag.Tags; -import org.eclipse.jetty.client.api.Result; +import okhttp3.Response; import org.apache.skywalking.apm.agent.core.context.ContextManager; -import org.apache.skywalking.apm.agent.core.context.ContextSnapshot; -import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; -import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; -import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; -public class CompleteListenerInterceptor implements InstanceMethodsAroundInterceptor { +/** + * {@link OnResponseInterceptor} validate the response code if it is great equal than 400. if so. the transaction status + * chang to `error`, or do nothing. + * + * @author zhangxin + */ +public class OnResponseInterceptor implements InstanceMethodsAroundInterceptor { @Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, MethodInterceptResult result) throws Throwable { - ContextSnapshot contextSnapshot = (ContextSnapshot)objInst.getSkyWalkingDynamicField(); - if (contextSnapshot != null) { - Result callBackResult = (Result)allArguments[0]; + Response response = (Response)allArguments[1]; - AbstractSpan abstractSpan = ContextManager.createLocalSpan("CallBack/" + callBackResult.getRequest().getURI().getPath()); - ContextManager.continued(contextSnapshot); - - if (callBackResult.isFailed()) { - abstractSpan.errorOccurred().log(callBackResult.getFailure()); - Tags.STATUS_CODE.set(abstractSpan, Integer.toString(callBackResult.getResponse().getStatus())); - } - abstractSpan.setComponent(ComponentsDefine.JETTY_CLIENT); - abstractSpan.setLayer(SpanLayer.HTTP); + if (response.code() >= 400) { + ContextManager.activeSpan().errorOccurred(); } } @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, Object ret) throws Throwable { - ContextSnapshot contextSnapshot = (ContextSnapshot)objInst.getSkyWalkingDynamicField(); - if (contextSnapshot != null) { - ContextManager.stopSpan(); - } return ret; } diff --git a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/AsyncCallInstrumentation.java b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/AsyncCallInstrumentation.java new file mode 100644 index 000000000..9c802d8ac --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/AsyncCallInstrumentation.java @@ -0,0 +1,69 @@ +/* + * 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.plugin.okhttp.v3.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; + +import static net.bytebuddy.matcher.ElementMatchers.any; +import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +public class AsyncCallInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[] { + new ConstructorInterceptPoint() { + @Override public ElementMatcher getConstructorMatcher() { + return any(); + } + + @Override public String getConstructorInterceptor() { + return "org.apache.skywalking.apm.plugin.okhttp.v3.AsyncCallInterceptor"; + } + } + }; + } + + @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override public ElementMatcher getMethodsMatcher() { + return named("execute"); + } + + @Override public String getMethodsInterceptor() { + return "org.apache.skywalking.apm.plugin.okhttp.v3.AsyncCallInterceptor"; + } + + @Override public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override protected ClassMatch enhanceClass() { + return byName("okhttp3.RealCall$AsyncCall"); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/define/CompleteListenerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/CallbackInstrumentation.java similarity index 62% rename from apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/define/CompleteListenerInstrumentation.java rename to apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/CallbackInstrumentation.java index ee6347513..9c791ab47 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/define/CompleteListenerInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/CallbackInstrumentation.java @@ -16,31 +16,19 @@ * */ - -package org.apache.skywalking.apm.plugin.jetty.v9.client.define; +package org.apache.skywalking.apm.plugin.okhttp.v3.define; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; -import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; import static org.apache.skywalking.apm.agent.core.plugin.match.HierarchyMatch.byHierarchyMatch; -/** - * {@link CompleteListenerInstrumentation} enhance the onComplete method in all class of hierarchy - * org.eclipse.jetty.client.api.Response$CompleteListener by org.apache.skywalking.apm.plugin.jetty.client.CompleteListenerInterceptor - * - * @author zhangxin - */ -public class CompleteListenerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { - - private static final String ENHANCE_CLASS = "org.eclipse.jetty.client.api.Response$CompleteListener"; - private static final String ENHANCE_METHOD = "onComplete"; - public static final String SEND_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jetty.client.CompleteListenerInterceptor"; - +public class CallbackInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { return new ConstructorInterceptPoint[0]; } @@ -48,18 +36,28 @@ public class CompleteListenerInstrumentation extends ClassInstanceMethodsEnhance @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { return new InstanceMethodsInterceptPoint[] { new InstanceMethodsInterceptPoint() { - @Override - public ElementMatcher getMethodsMatcher() { - return named(ENHANCE_METHOD); + @Override public ElementMatcher getMethodsMatcher() { + return named("onFailure"); } - @Override - public String getMethodsInterceptor() { - return SEND_INTERCEPTOR; + @Override public String getMethodsInterceptor() { + return "org.apache.skywalking.apm.plugin.okhttp.v3.OnFailureInterceptor"; } - @Override - public boolean isOverrideArgs() { + @Override public boolean isOverrideArgs() { + return false; + } + }, + new InstanceMethodsInterceptPoint() { + @Override public ElementMatcher getMethodsMatcher() { + return named("onResponse"); + } + + @Override public String getMethodsInterceptor() { + return "org.apache.skywalking.apm.plugin.okhttp.v3.OnResponseInterceptor"; + } + + @Override public boolean isOverrideArgs() { return false; } } @@ -67,6 +65,6 @@ public class CompleteListenerInstrumentation extends ClassInstanceMethodsEnhance } @Override protected ClassMatch enhanceClass() { - return byHierarchyMatch(new String[] {ENHANCE_CLASS}); + return byHierarchyMatch(new String[] {"okhttp3.Callback"}); } } diff --git a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/RealCallInstrumentation.java b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/RealCallInstrumentation.java index 8d0bbd6c3..517b97d4d 100644 --- a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/RealCallInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/RealCallInstrumentation.java @@ -29,6 +29,7 @@ import org.apache.skywalking.apm.plugin.okhttp.v3.RealCallInterceptor; import static net.bytebuddy.matcher.ElementMatchers.any; import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.takesArguments; /** * {@link RealCallInstrumentation} presents that skywalking intercepts {@link okhttp3.RealCall#RealCall(OkHttpClient, @@ -77,6 +78,19 @@ public class RealCallInstrumentation extends ClassInstanceMethodsEnhancePluginDe return INTERCEPT_CLASS; } + @Override public boolean isOverrideArgs() { + return false; + } + }, + new InstanceMethodsInterceptPoint() { + @Override public ElementMatcher getMethodsMatcher() { + return named("enqueue").and(takesArguments(1)); + } + + @Override public String getMethodsInterceptor() { + return "org.apache.skywalking.apm.plugin.okhttp.v3.EnqueueInterceptor"; + } + @Override public boolean isOverrideArgs() { return false; } diff --git a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/resources/skywalking-plugin.def index dd2eec445..f9236da8f 100644 --- a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/resources/skywalking-plugin.def +++ b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/resources/skywalking-plugin.def @@ -1 +1,3 @@ okhttp-3.x=org.apache.skywalking.apm.plugin.okhttp.v3.define.RealCallInstrumentation +okhttp-3.x=org.apache.skywalking.apm.plugin.okhttp.v3.define.CallbackInstrumentation +okhttp-3.x=org.apache.skywalking.apm.plugin.okhttp.v3.define.AsyncCallInstrumentation diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/concurrent-util-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/concurrent/define/FailureCallbackInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/concurrent-util-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/concurrent/define/FailureCallbackInstrumentation.java index 45fbe6bd8..2c03cc13e 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/concurrent-util-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/concurrent/define/FailureCallbackInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/concurrent-util-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/concurrent/define/FailureCallbackInstrumentation.java @@ -38,7 +38,7 @@ import static org.apache.skywalking.apm.plugin.spring.concurrent.match.FailedCal */ public class FailureCallbackInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { - public static final String FAILURE_CALLBACK_INTERCEPTOR = "FailureCallbackInterceptor"; + public static final String FAILURE_CALLBACK_INTERCEPTOR = "org.apache.skywalking.apm.plugin.spring.concurrent.FailureCallbackInterceptor"; public static final String FAILURE_METHOD_NAME = "onFailure"; @Override diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/concurrent-util-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/concurrent/define/SuccessCallbackInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/concurrent-util-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/concurrent/define/SuccessCallbackInstrumentation.java index 5659c6277..a66ed1612 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/concurrent-util-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/concurrent/define/SuccessCallbackInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/concurrent-util-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/concurrent/define/SuccessCallbackInstrumentation.java @@ -38,7 +38,7 @@ import static org.apache.skywalking.apm.plugin.spring.concurrent.match.SuccessCa public class SuccessCallbackInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { public static final String SUCCESS_CALLBACK_INTERCEPTOR = - "SuccessCallbackInterceptor"; + "org.apache.skywalking.apm.plugin.spring.concurrent.SuccessCallbackInterceptor"; public static final String SUCCESS_METHOD_NAME = "onSuccess"; @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/EnhanceRequireObjectCache.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/EnhanceRequireObjectCache.java index 4b80c011a..914882eed 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/EnhanceRequireObjectCache.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/EnhanceRequireObjectCache.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.plugin.spring.mvc.commons; import java.lang.reflect.Method; @@ -26,13 +25,14 @@ import org.springframework.web.context.request.NativeWebRequest; public class EnhanceRequireObjectCache { private PathMappingCache pathMappingCache; private NativeWebRequest nativeWebRequest; + private HttpServletResponse httpResponse; public void setPathMappingCache(PathMappingCache pathMappingCache) { this.pathMappingCache = pathMappingCache; } public HttpServletResponse getHttpServletResponse() { - return (HttpServletResponse)nativeWebRequest.getNativeResponse(); + return httpResponse == null ? (HttpServletResponse)nativeWebRequest.getNativeResponse() : httpResponse; } public void setNativeWebRequest(NativeWebRequest nativeWebRequest) { @@ -50,4 +50,12 @@ public class EnhanceRequireObjectCache { public PathMappingCache getPathMappingCache() { return pathMappingCache; } + + public void setHttpResponse(HttpServletResponse httpResponse) { + this.httpResponse = httpResponse; + } + + public HttpServletResponse getHttpResponse() { + return httpResponse; + } } diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/define/AnnotationMethodHandlerAdapterInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/define/AnnotationMethodHandlerAdapterInstrumentation.java new file mode 100644 index 000000000..cfaba1b92 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/define/AnnotationMethodHandlerAdapterInstrumentation.java @@ -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.plugin.spring.mvc.commons.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +public class AnnotationMethodHandlerAdapterInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override public ElementMatcher getMethodsMatcher() { + return named("invokeHandlerMethod"); + } + + @Override public String getMethodsInterceptor() { + return "org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor.InvokeHandlerMethodInterceptor"; + } + + @Override public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override protected ClassMatch enhanceClass() { + return byName("org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/InvokeHandlerMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/InvokeHandlerMethodInterceptor.java new file mode 100644 index 000000000..7a502d21f --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/InvokeHandlerMethodInterceptor.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor; + +import java.lang.reflect.Method; +import javax.servlet.http.HttpServletResponse; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; +import org.apache.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache; + +public class InvokeHandlerMethodInterceptor implements InstanceMethodsAroundInterceptor { + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + if (allArguments[2] instanceof EnhancedInstance) { + ((EnhanceRequireObjectCache)((EnhancedInstance)allArguments[2]).getSkyWalkingDynamicField()).setHttpResponse((HttpServletResponse)allArguments[1]); + } + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable { + return ret; + } + + @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + + } +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/resources/skywalking-plugin.def new file mode 100644 index 000000000..6d6268840 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/resources/skywalking-plugin.def @@ -0,0 +1 @@ +spring-mvc-annotation=org.apache.skywalking.apm.plugin.spring.mvc.commons.define.AnnotationMethodHandlerAdapterInstrumentation diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestExecuteInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestExecuteInterceptor.java index ce3f7e5d4..f6148968c 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestExecuteInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestExecuteInterceptor.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.plugin.spring.resttemplate.async; import java.lang.reflect.Method; @@ -40,7 +39,8 @@ public class RestExecuteInterceptor implements InstanceMethodsAroundInterceptor final URI requestURL = (URI)allArguments[0]; final HttpMethod httpMethod = (HttpMethod)allArguments[1]; final ContextCarrier contextCarrier = new ContextCarrier(); - String remotePeer = requestURL.getHost() + ":" + requestURL.getPort(); + + String remotePeer = requestURL.getHost() + ":" + (requestURL.getPort() > 0 ? requestURL.getPort() : "https".equalsIgnoreCase(requestURL.getScheme()) ? 443 : 80); AbstractSpan span = ContextManager.createExitSpan(requestURL.getPath(), contextCarrier, remotePeer); span.setComponent(ComponentsDefine.SPRING_REST_TEMPLATE); diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestExecuteInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestExecuteInterceptor.java index 3d5088f3e..f634df071 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestExecuteInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestExecuteInterceptor.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.plugin.spring.resttemplate.sync; import java.lang.reflect.Method; @@ -40,7 +39,8 @@ public class RestExecuteInterceptor implements InstanceMethodsAroundInterceptor final URI requestURL = (URI)allArguments[0]; final HttpMethod httpMethod = (HttpMethod)allArguments[1]; final ContextCarrier contextCarrier = new ContextCarrier(); - String remotePeer = requestURL.getHost() + ":" + requestURL.getPort(); + + String remotePeer = requestURL.getHost() + ":" + (requestURL.getPort() > 0 ? requestURL.getPort() : "https".equalsIgnoreCase(requestURL.getScheme()) ? 443 : 80); AbstractSpan span = ContextManager.createExitSpan(requestURL.getPath(), contextCarrier, remotePeer); span.setComponent(ComponentsDefine.SPRING_REST_TEMPLATE); diff --git a/docs/README.md b/docs/README.md index 900c41c81..c38355652 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3,9 +3,6 @@ * Getting Started * [Quick start](en/Quick-start.md) - * [Deploy Standalone mode collector](en/Deploy-collector-in-standalone-mode.md) - * [Deploy Cluster mode collector](en/Deploy-collector-in-cluster-mode.md) - * [Deploy javaagent](en/Deploy-skywalking-agent.md) * [Deploy docker image](en/Deploy-docker-image.md) * [Supported middlewares, frameworks and libraries](Supported-list.md) * [How to disable plugins?](en/How-to-disable-plugin.md) @@ -21,6 +18,9 @@ * [Plugin Test](https://github.com/SkywalkingTest/agent-integration-test-report) * [Java Agent Performance Test](https://skywalkingtest.github.io/Agent-Benchmarks/) * Development Guides - * [Skywalking 3 Cross Process Propagation Headers Protocol, v1.0](en/Skywalking-3-Cross-Process-Propagation-Headers-Protocol.md) + * [How to build project](en/How-to-build.md) + * [Plugin development guide](en/Plugin-Development-Guide.md) + * Protocol + * [Cross Process Propagation Headers Protocol, v1.0](en/Skywalking-Cross-Process-Propagation-Headers-Protocol-v1.md) * FAQ diff --git a/docs/README_ZH.md b/docs/README_ZH.md index d09167189..1db771371 100644 --- a/docs/README_ZH.md +++ b/docs/README_ZH.md @@ -3,9 +3,6 @@ * [项目简介](/README_ZH.md) * [快速入门](cn/Quick-start-CN.md) - * [部署单机collector](cn/Deploy-collector-in-standalone-mode-CN.md) - * [部署集群collector](cn/Deploy-collector-in-cluster-mode-CN.md) - * [部署探针Agent](cn/Deploy-skywalking-agent-CN.md) * [部署Collector镜像](cn/Deploy-docker-image.CN.md) * [中间件,框架与类库支持列表](Supported-list.md) * [如何关闭特定插件](cn/How-to-disable-plugin-CN.md) @@ -25,8 +22,9 @@ * 开发指南 * [工程编译指南](cn/How-to-build-CN.md) * [插件开发指南](cn/Plugin-Development-Guide-CN.md) - * [跨进程追踪上下文传递协议](cn/Skywalking-3-Cross-Process-Propagation-Headers-Protocol-CN.md) - * [探针与Collector间网络协议,v3.2+](cn/How-to-communicate-with-the-collector-CN.md) + * 交互协议 + * [Cross Process Propagation Headers Protocol, v1.0 跨进程追踪上下文传递协议](cn/Skywalking-Cross-Process-Propagation-Headers-Protocol-CN-v1.md) + * [SkyWalking Trace Data Protocol 探针与Collector间网络协议](cn/Trace-Data-Protocol-CN.md) * FAQ * [Trace查询有数据,但是没有拓扑图和JVM数据?](cn/FAQ/Why-have-traces-no-others-CN.md) * [加载探针,Console被GRPC日志刷屏](cn/FAQ/Too-many-gRPC-logs-CN.md) diff --git a/docs/cn/Application-toolkit-log4j-1.x-CN.md b/docs/cn/Application-toolkit-log4j-1.x-CN.md index a1dcef005..bf4891f7d 100644 --- a/docs/cn/Application-toolkit-log4j-1.x-CN.md +++ b/docs/cn/Application-toolkit-log4j-1.x-CN.md @@ -6,7 +6,6 @@ {project.release.version} ``` -   [ ![Download](https://api.bintray.com/packages/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-log4j-1.x/images/download.svg) ](https://bintray.com/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-log4j-1.x/_latestVersion) * 配置layout ```properties diff --git a/docs/cn/Application-toolkit-log4j-2.x-CN.md b/docs/cn/Application-toolkit-log4j-2.x-CN.md index 33790310b..a9c4e5142 100644 --- a/docs/cn/Application-toolkit-log4j-2.x-CN.md +++ b/docs/cn/Application-toolkit-log4j-2.x-CN.md @@ -6,7 +6,6 @@ {project.release.version} ``` -   [ ![Download](https://api.bintray.com/packages/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-log4j-2.x/images/download.svg) ](https://bintray.com/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-log4j-2.x/_latestVersion) * 在log4j2.xml中的pattern 配置节,配置`[%traceId]` ```xml diff --git a/docs/cn/Application-toolkit-logback-1.x-CN.md b/docs/cn/Application-toolkit-logback-1.x-CN.md index 0182c28ee..a82ef1e25 100644 --- a/docs/cn/Application-toolkit-logback-1.x-CN.md +++ b/docs/cn/Application-toolkit-logback-1.x-CN.md @@ -6,7 +6,6 @@ {project.release.version} ``` -   [ ![Download](https://api.bintray.com/packages/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-log4j-2.x/images/download.svg) ](https://bintray.com/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-log4j-2.x/_latestVersion) * 在logback.xml中的`Pattern`配制节中,设置`%tid` ```xml diff --git a/docs/cn/Application-toolkit-trace-CN.md b/docs/cn/Application-toolkit-trace-CN.md index 840690909..dab3f7ea4 100644 --- a/docs/cn/Application-toolkit-trace-CN.md +++ b/docs/cn/Application-toolkit-trace-CN.md @@ -6,7 +6,6 @@ ${skywalking.version} ``` -   [ ![Download](https://api.bintray.com/packages/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-trace/images/download.svg) ](https://bintray.com/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-trace/_latestVersion) * 随时使用 `TraceContext.traceId()` API,在应用程序的任何地方获取traceId. ```java diff --git a/docs/cn/How-to-build-CN.md b/docs/cn/How-to-build-CN.md index df5fbb020..8159b1746 100644 --- a/docs/cn/How-to-build-CN.md +++ b/docs/cn/How-to-build-CN.md @@ -2,17 +2,17 @@ 本文档用于指导开发者,在本地开发环境中编译工程。 ### 前言 -因为工程结构和代码依赖会随版本变化,如果读者熟悉travis-ci,则可直接参考[.travis.yml](https://github.com/wu-sheng/sky-walking/blob/master/.travis.yml) +因为工程结构和代码依赖会随版本变化,如果读者熟悉travis-ci,则可直接参考[.travis.yml](../../.travis.yml) ### 编译步骤 1. 准备环境,jdk8,Maven 1. 执行`mvn clean package` +1. 生成包在`/packages`目录下,包括一个`skywalking-agent`的探针目录,以及两个collector包(.tar.gz是linux环境,.zip是windows环境) ### 在IntelliJ IDEA中编译工程 上述步骤在命令行中,能够很好的编译工程,但导入到编译器中的工程依然会有一些报错,我们需要进行几步简单的操作。 1. 在IntelliJ Terminal中,执行`mvn compile -Dmaven.test.skip=true`进行编译 1. 设置gRPC的自动生成代码目录,为源码目录 - - **apm-network/target/generated--sources/protobuf**目录下的`grpc-java`和`java`目录 + - **apm-protocol/apm-network/target/generated-sources/protobuf**目录下的`grpc-java`和`java`目录 - **apm-collector/apm-collector-remote/apm-remote-grpc-provider/target/protobuf**目录下的`grpc-java`和`java`目录 -注:从3.2开始,网络通讯协议引入GRPC,所以增加上述的步骤 diff --git a/docs/cn/How-to-communicate-with-the-collector-CN.md b/docs/cn/How-to-communicate-with-the-collector-CN.md deleted file mode 100644 index 115480d66..000000000 --- a/docs/cn/How-to-communicate-with-the-collector-CN.md +++ /dev/null @@ -1,352 +0,0 @@ -# 探针与Collector间通讯协议 -## 前言 -这篇文章主要介绍3.2版本的Collector对外提供的服务协议。一般情况下,使用者和开发者都无需了解此协议细节。但是在庞大的开源生态中,我们已经收到过多次有公司或个人的使用案例,使用自己的非Java探针(PHP,GO等)探针,接入我们的Collector进行数据分析和监控。 - -## 协议类型 -Collector从3.2开始,对外同时提供gRPC和HTTP RESTFul两种类型的协议。从效率上,我们推荐使用gRPC - -# gRPC服务 -本章节,描述官方java探针使用的网络协议 - -## Collector服务发现协议 -### 简介 -**Collector服务发现协议是探针启动时,第一个调用的服务。**通过服务,查找对应的gRPC服务地址与端口列表,并在由客户端选择其中任意一个作为服务端。此服务需周期性调用,确保探针本地的服务端口列表是准确有效的。 - -### 协议类型 -HTTP GET - -### 协议内容 -- 请求 -GET操作:http://collectorIp:port/agentstream/grpc 。 其中`/agentstream/grpc`是默认值,如需修改,需要参考collector相关配置。 - -- 返回 -JSON数组,数组的每个元素,为一个有效的gRPC服务地址。 -```json -["ip address1:port1","ip address2:port2","ip address3:port3"] -``` - -## 应用注册服务 -### 简介 -应用注册服务,是将手动设计的applicationCode,以及ip:port沟通的服务地址,转换成数字的服务。此服务会在后续的传输过程中,有效降低网络带宽需求。 - -### 协议类型 -gRPC服务 - -### 协议内容 -https://github.com/apache/incubator-skywalking/blob/master/apm-network/src/main/proto/ApplicationRegisterService.proto -```proto -syntax = "proto3"; - -option java_multiple_files = true; -option java_package = "org.apache.skywalking.apm.network.proto"; - -import "KeyWithIntegerValue.proto"; - -//register service for ApplicationCode, this service is called when service starts. -service ApplicationRegisterService { - rpc register (Application) returns (ApplicationMapping) { - } -} - -message Application { - repeated string applicationCode = 1; -} - -message ApplicationMapping { - repeated KeyWithIntegerValue application = 1; -} -``` -- 首次调用时,applicationCode为客户端设置的应用名(显示在拓扑图和应用列表上的名字)。之后随着追踪过程,会上报此应用相关的周边服务的`ip:port`地址列表 -- KeyWithIntegerValue 返回,key为上报的applicationCode和ip:port地址,value为对应的id。applicationCode对应的返回id,在后续协议中,被称为applicationId。 -- 此服务按需调用,本地无法找到ip:port对应的id时,可异步发起调用。 -- 获取applicationId的操作是必选。 -- 获取ip:port对应的id是可选,但是完成id设置,会有效提高collector处理效率,降低网络消耗。 - - -## 应用实例发现服务 -### 简介 -应用实例发现服务存在三个子服务,分别是实例注册服务,实例心跳服务,实例注册重连服务。这三个服务负责获取和保持应用实例在线的功能。 - -### 协议类型 -gRPC服务 - -### 实例注册服务 -https://github.com/apache/incubator-skywalking/blob/master/apm-network/src/main/proto/DiscoveryService.proto#L11-L12 -```proto -service InstanceDiscoveryService { - rpc register (ApplicationInstance) returns (ApplicationInstanceMapping) { - } -} - -message ApplicationInstance { - int32 applicationId = 1; - string agentUUID = 2; - int64 registerTime = 3; - OSInfo osinfo = 4; -} - -message OSInfo { - string osName = 1; - string hostname = 2; - int32 processNo = 3; - repeated string ipv4s = 4; -} - -message ApplicationInstanceMapping { - int32 applicationId = 1; - int32 applicationInstanceId = 2; -} -``` -- agentUUID 由探针生成,需保持唯一性,推荐使用UUID算法。并在应用重启前保持不变 -- applicationId 由**应用注册服务**获取。 -- 服务端返回应用实例id,applicationInstanceId 。后续上报服务使用实例id标识。 - -### 实例心跳服务 -https://github.com/apache/incubator-skywalking/blob/master/apm-network/src/main/proto/DiscoveryService.proto#L14-L15 -```proto -service InstanceDiscoveryService { - rpc heartbeat (ApplicationInstanceHeartbeat) returns (Downstream) { - } -} - -message ApplicationInstanceHeartbeat { - int32 applicationInstanceId = 1; - int64 heartbeatTime = 2; -} -``` -- 心跳服务每分钟上报一次。 -- 如一分钟内有segment数据上报,则可不必上报心跳。 - -### 实例注册重连服务 -https://github.com/apache/incubator-skywalking/blob/master/apm-network/src/main/proto/DiscoveryService.proto#L17-L18 -```proto -service InstanceDiscoveryService { - rpc registerRecover (ApplicationInstanceRecover) returns (Downstream) { - } -} - -message ApplicationInstanceRecover { - int32 applicationId = 1; - int32 applicationInstanceId = 2; - int64 registerTime = 3; - OSInfo osinfo = 4; -} -``` -- 应用重连服务于**应用注册服务**类似,在gRPC发生重连,并再次连接成功后发送。需包含通过**应用注册服务**获取的applicationInstanceId。 - -## 服务名注册发现服务 -### 简介 -服务名注册发现服务,是将应用内的服务名(operationName)替换为id的服务。 - -### 协议类型 -gRPC服务 - -### 协议内容 -https://github.com/apache/incubator-skywalking/blob/master/apm-network/src/main/proto/DiscoveryService.proto#L53-L74 -```proto -//discovery service for ServiceName by Network address or application code -service ServiceNameDiscoveryService { - rpc discovery (ServiceNameCollection) returns (ServiceNameMappingCollection) { - } -} - -message ServiceNameCollection { - repeated ServiceNameElement elements = 1; -} - -message ServiceNameMappingCollection { - repeated ServiceNameMappingElement elements = 1; -} - -message ServiceNameMappingElement { - int32 serviceId = 1; - ServiceNameElement element = 2; -} - -message ServiceNameElement { - string serviceName = 1; - int32 applicationId = 2; -} -``` -- 可选服务,可有效降低网络消耗,推荐实现。注意,由于部分应用存在URI中夹带参数的情况,请注意限制探针内的缓存容量,防止内存溢出。 -- ServiceNameElement中,applicationId为当前applicationCode对应的id。serviceName一般为对应span的operationName - -## JVM指标上报服务 -### 简介 -上报当前实例的JVM信息,每秒上报一次。 - -### 协议类型 -gRPC服务 - -### 协议内容 -https://github.com/apache/incubator-skywalking/blob/master/apm-network/src/main/proto/JVMMetricsService.proto -```proto -syntax = "proto3"; - -option java_multiple_files = true; -option java_package = "org.apache.skywalking.apm.network.proto"; - -import "Downstream.proto"; - -service JVMMetricsService { - rpc collect (JVMMetrics) returns (Downstream) { - } -} - -message JVMMetrics { - repeated JVMMetric metrics = 1; - int64 applicationInstanceId = 2; -} - -message JVMMetric { - int64 time = 1; - CPU cpu = 2; - repeated Memory memory = 3; - repeated MemoryPool memoryPool = 4; - repeated GC gc = 5; -} - -message CPU { - double usagePercent = 2; -} - -message Memory { - bool isHeap = 1; - int64 init = 2; - int64 max = 3; - int64 used = 4; - int64 committed = 5; -} - -message MemoryPool { - PoolType type = 1; - bool isHeap = 2; - int64 init = 3; - int64 max = 4; - int64 used = 5; - int64 commited = 6; -} - -enum PoolType { - CODE_CACHE_USAGE = 0; - NEWGEN_USAGE = 1; - OLDGEN_USAGE = 2; - SURVIVOR_USAGE = 3; - PERMGEN_USAGE = 4; - METASPACE_USAGE = 5; -} - -message GC { - GCPhrase phrase = 1; - int64 count = 2; - int64 time = 3; -} - -enum GCPhrase { - NEW = 0; - OLD = 1; -} -``` - -## TraceSegment上报服务 -### 简介 -上报调用链信息 - -### 协议类型 -gRPC服务 - -### 协议内容 -```proto -syntax = "proto3"; - -option java_multiple_files = true; -option java_package = "org.apache.skywalking.apm.network.proto"; - -import "Downstream.proto"; -import "KeyWithStringValue.proto"; - -service TraceSegmentService { - rpc collect (stream UpstreamSegment) returns (Downstream) { - } -} - -message UpstreamSegment { - repeated UniqueId globalTraceIds = 1; - bytes segment = 2; // the byte array of TraceSegmentObject -} - -message UniqueId { - repeated int64 idParts = 1; -} - -message TraceSegmentObject { - UniqueId traceSegmentId = 1; - repeated TraceSegmentReference refs = 2; - repeated SpanObject spans = 3; - int32 applicationId = 4; - int32 applicationInstanceId = 5; -} - -message TraceSegmentReference { - RefType refType = 1; - UniqueId parentTraceSegmentId = 2; - int32 parentSpanId = 3; - int32 parentApplicationInstanceId = 4; - string networkAddress = 5; - int32 networkAddressId = 6; - string entryServiceName = 7; - int32 entryServiceId = 8; - string parentServiceName = 9; - int32 parentServiceId = 10; -} - -message SpanObject { - int32 spanId = 1; - int32 parentSpanId = 2; - int64 startTime = 3; - int64 endTime = 4; - int32 operationNameId = 5; - string operationName = 6; - int32 peerId = 7; - string peer = 8; - SpanType spanType = 9; - SpanLayer spanLayer = 10; - int32 componentId = 11; - string component = 12; - bool isError = 13; - repeated KeyWithStringValue tags = 14; - repeated LogMessage logs = 15; -} - -enum RefType { - CrossProcess = 0; - CrossThread = 1; -} - -enum SpanType { - Entry = 0; - Exit = 1; - Local = 2; -} - -enum SpanLayer { - Database = 0; - RPCFramework = 1; - Http = 2; - MQ = 3; -} - -message LogMessage { - int64 time = 1; - repeated KeyWithStringValue data = 2; -} -``` -- UniqueId为segment或者globalTraceId的数字表示。由3个long组成,1)applicationInstanceId,2)当前线程id,3)当前时间戳*10000 + seq(0-10000自循环) -- Span的数据,请参考[插件开发规范](https://github.com/apache/incubator-skywalking/wiki/Plugin-Development-Guide) -- 以下id和名称根据注册返回结果,优先上报id,无法获取id时,再上传name。参考之前的应用和服务注册章节。 - - operationNameId/operationName - - networkAddress/networkAddressId - - entryServiceName/entryServiceId - - parentServiceName/parentServiceId - - peerId/peer -- componentId为默认支持的插件id,非官方支持,需传输名称或修改服务端源代码。[官方组件列表](../../apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java) diff --git a/docs/cn/Plugin-Development-Guide-CN.md b/docs/cn/Plugin-Development-Guide-CN.md index b0e306e68..83f19305e 100644 --- a/docs/cn/Plugin-Development-Guide-CN.md +++ b/docs/cn/Plugin-Development-Guide-CN.md @@ -1,10 +1,11 @@ ## 插件开发指南 -本文档描述 [v3.2+](https://github.com/OpenTracing/skywalking/releases) 插件开发方法、使用的API,以及注意事项。 +这边文档描述插件的开发和贡献方法 -### 核心概念 -#### 一. Span +## 核心概念 +### 一. Span Span是追踪系统中的通用概念(有时候被翻译成埋点),关于Span的定义,请参考[OpenTracing 中文版](https://github.com/opentracing-contrib/opentracing-specification-zh/blob/master/specification.md#opentracing数据模型)。 -sky-walking作为OpenTracing的支持者,在核心实现中,与标准有较高的相似度。 + +SkyWalking作为OpenTracing的支持者,在核心实现中,与标准有较高的相似度。当然,作为实际产品的需要,我们一会扩展相关概念。 我们将span分为三类: @@ -15,16 +16,19 @@ EntrySpan代表一个服务的提供方,即,服务端的入口点。它是 LocalSpan代表一个普通的Span,代表任意一个本地逻辑块(或方法) 1.3 ExitSpan -ExitSpan也可以称为LeafSpan(sky-walking的早期版本中的称呼),代表了一个远程服务的客户端调用。如:一次JDBC调用。 +ExitSpan也可以称为LeafSpan(SkyWalking的早期版本中的称呼),代表了一个远程服务的客户端调用。如:一次JDBC调用。 -#### 二. ContextCarrier -分布式追踪要解决的一个重要问题,就是跨进程的问题,ContextCarrier的概念就是为了解决这种场景。 +### 二. ContextCarrier +分布式追踪要解决的一个重要问题,就是跨进程调用链连接的问题,ContextCarrier的概念就是为了解决这种场景。 当发生一次**A->B**的网络调用时: -1. 需要在客户端生成(inject操作)ContextCarrier,并序列化成String -1. 将这个String加入RPC调用的正文(或HEAD)中,传递到服务端 +1. 创建一个空的ContextCarrier +1. 通过`ContextManager#createExitSpan`方法创建一个ExitSpan,或者使用`ContextManager#inject`,在过程中传入并初始化`ContextCarrier` +1. 将`ContextCarrier`中所有元素放入请求头(如:HTTP头)或消息正文(如 Kafka) +1. `ContextCarrier`随请求传输到服务端 1. 服务端收到后,转换为新的ContextCarrier -1. 通过提取操作(extract操作)建立关联 +1. 通过`ContestManager#createEntrySpan`方法创建EntrySpan,或者使用`ContextManager#extract`,建立分布式调用关联 + 以HTTPComponent调用Tomcat为例: 1. 客户端(HTTPComponent端) @@ -33,8 +37,7 @@ ExitSpan也可以称为LeafSpan(sky-walking的早期版本中的称呼),代表 CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); - //向HTTP或者其他RPC HEAD中设置上下文 - heads.put(next.getHeadKey(), next.getHeadValue()); + httpRequest.setHeader(next.getHeadKey(), next.getHeadValue()); } ``` @@ -44,23 +47,23 @@ ExitSpan也可以称为LeafSpan(sky-walking的早期版本中的称呼),代表 CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); - //从HTTP或者其他RPC HEAD中,根据指定的KEY,提取上下文 - next.setHeadValue(heads.get(next.getHeadKey())); + next.setHeadValue(request.getHeader(next.getHeadKey())); } span = ContextManager.createEntrySpan(“/span/operation/name”, contextCarrier); ``` -#### 三. ContextSnapshot -除了跨进程的RPC调用,另外一种追踪的常见场景是跨线程。跨线程和跨进程有很高的相似度,都是需要完成上下文的传递工作。所以ContextSnapshot具有和ContextCarrier十分类似的API风格。 +### 三. ContextSnapshot +除了跨进程的RPC调用,另外一种追踪的常见场景是跨线程保持链路连接。跨线程和跨进程有很高的相似度,都是需要完成上下文的传递工作。 +所以ContextSnapshot具有和ContextCarrier十分类似的API风格。 当发生一次**A->B**的跨线程调用时: 1. 需要在A线程中通过ContextManager#capture操作生成ContextSnapshot对象实例 1. 将这个ContextSnapshot对象传递到B线程中 1. B线程通过ContextManager#continued操作完成上下文传递 -### 核心API -#### 一. ContextManager +## 核心API +### 一. ContextManager ContextManager提供了追踪相关操作的主入口 1. 创建EntrySpan @@ -81,7 +84,7 @@ public static AbstractSpan createExitSpan(String operationName, ContextCarrier c ``` 根据服务名,跨进程传递的ContextCarrier(空容器)和远端服务地址(IP、主机名、域名 + 端口),创建ExitSpan -#### 二. AbstractSpan +### 二. AbstractSpan AbstractSpan提供了Span内部,进行操作的各项API ```java @@ -139,17 +142,21 @@ AbstractSpan提供了Span内部,进行操作的各项API ``` Span的操作语义和OpenTracing类似。 -SpanLayer为我们的特有概念,如果是远程调用类的服务,请设置此属性,包括4个属性值 +SpanLayer为我们的特有概念,如果是远程调用类的服务,请设置此属性,包括5个属性值 +1. UNKNOWN, 默认 1. DB 1. RPC_FRAMEWORK,非HTTP类型的RPC框架,如:原生的DUBBO,MOTAN 1. HTTP 1. MQ -### 开发插件 -#### 一. 简介 -因为所有的程序调用都是基于方法的,所以插件实际上就是基于方法的拦截,类似面向切面编程的AOP技术。sky-walking底层已经完成相关的技术封装,所以插件开发者只需要定位需要拦截的类、方法,然后结合上文中的追踪API,即可完成插件的开发。 +Component ID被SkyWalking项目组定义和保护。0到10000为保留值,如果你希望贡献新插件,可以在插件pull request通过,并提交的自动化 +测试用户被接收后,申请自己的组件ID。私有插件,请使用10000以上的ID,避免重复。 -#### 二. 拦截类型 +## 开发插件 +### 一. 简介 +因为所有的程序调用都是基于方法的,所以插件实际上就是基于方法的拦截,类似面向切面编程的AOP技术。SkyWalking底层已经完成相关的技术封装,所以插件开发者只需要定位需要拦截的类、方法,然后结合上文中的追踪API,即可完成插件的开发。 + +### 二. 拦截类型 根据Java方法,共有三种拦截类型 1. 拦截构造函数 1. 拦截实例方法 @@ -161,7 +168,7 @@ SpanLayer为我们的特有概念,如果是远程调用类的服务,请设 当然,也可以同时支持实例和静态方法,直接继承ClassEnhancePluginDefine。但是,这种情况很少。 -#### 三. 实现自己的插件定义 +### 三. 实现自己的插件定义 我们以继承ClassInstanceMethodsEnhancePluginDefine为例(ClassStaticMethodsEnhancePluginDefine十分类似,不再重复描述),描述定义插件的全过程 1. 定义目标类名称 @@ -169,7 +176,7 @@ SpanLayer为我们的特有概念,如果是远程调用类的服务,请设 protected abstract ClassMatch enhanceClass(); ``` -ClassMatch反应类的匹配方式,目前提供三种: +ClassMatch反应类的匹配方式,目前提供四种: * byName, 通过类名完整匹配 * byClassAnnotationMatch, 通过类标注进行匹配 @@ -190,7 +197,7 @@ protected ClassMatch enhanceClassName() { ``` -2. 定义构造函数拦截点 +2. 定义方法拦截点 ```java protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints(); @@ -221,7 +228,7 @@ tomcat-7.x/8.x=TomcatInstrumentation * 插件名称,要求全局唯一,命名规范:目标组件+版本号 * 插件定义类全名 -#### 四. 实现拦截器逻辑 +### 四. 实现拦截器逻辑 我们继续以实现实例方法拦截为例,拦截器需要实现org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor。 ```java /** @@ -262,15 +269,15 @@ public interface InstanceMethodsAroundInterceptor { 可以在方法执行前、执行后、执行异常三个点,进行拦截,设置修改方法参数(执行前),并调用核心API,设置追踪逻辑。 -### 贡献插件到主仓库 +## 贡献插件到主仓库 我们鼓励大家共同贡献支持各个类库的插件。 大家需支持以下步骤执行: 1. 在issue页面提出插件扩展需求,对应的版本。 -1. Fork wu-sheng/sky-walking到本地 +1. Fork apache/incubator-skywalking到本地 1. 在apm-sniffer/apm-sdk-plugin下新建自己的插件模块,模块名为:支持类库名称+版本号 1. 按照规范开发插件 1. 完善注释和测试用例 1. 在本地打包进行集成测试 -1. 提交Pull Request到 wu-sheng/sky-walking,提供插件追踪的截图(拓扑和Trace明细),可独立运行的被追踪程序、docker镜像或docker-compose。 -1. sky-walking PMC( Project Management Committee) 成员完成插件审核,确定发布版本,并合并到主仓库。 +1. 提交Pull Request到 apache/incubator-skywalking,根据评审团队要求,提供相关自动化测试用例 +1. SkyWalking Committer成员完成插件审核,确定发布版本,并合并到主仓库。 diff --git a/docs/cn/Skywalking-3-Cross-Process-Propagation-Headers-Protocol-CN.md b/docs/cn/Skywalking-Cross-Process-Propagation-Headers-Protocol-CN-v1.md similarity index 81% rename from docs/cn/Skywalking-3-Cross-Process-Propagation-Headers-Protocol-CN.md rename to docs/cn/Skywalking-Cross-Process-Propagation-Headers-Protocol-CN-v1.md index 7c1be7778..884553467 100644 --- a/docs/cn/Skywalking-3-Cross-Process-Propagation-Headers-Protocol-CN.md +++ b/docs/cn/Skywalking-Cross-Process-Propagation-Headers-Protocol-CN-v1.md @@ -1,13 +1,15 @@ -# Skywalking 3 Cross Process Propagation Headers Protocol +# Skywalking Cross Process Propagation Headers Protocol * Version 1.0 -这是Skywalking3跨进程传输头协议第一个公开版本。Skywalking是一个偏向APM的分布式追踪系统,所以,为了提供服务端处理性能。头信息会比其他的追踪系统要更复杂一些。你会发现,这个头信息,更像一个商业APM系统,并且,一些商业APM系统的头信息,比我们的要复杂的多。所以,如果你希望开发或者贡献其他语言探针、或者JAVA探针的其他市县模式,请耐心阅读,并理解此协议内容。 - +Skywalking是一个偏向APM的分布式追踪系统,所以,为了提供服务端处理性能。头信息会比其他的追踪系统要更复杂一些。 +你会发现,这个头信息,更像一个商业APM系统,并且,一些商业APM系统的头信息,比我们的要复杂的多。 # Header Item * Header Name: `sw3` * Header Value: 使用`|`分隔,包含以下内容 +_消息头使用sw3,因为此协议始于SkyWalking 3.x版本。_ + ## Values * Trace Segment Id diff --git a/docs/cn/Trace-Data-Protocol-CN.md b/docs/cn/Trace-Data-Protocol-CN.md new file mode 100644 index 000000000..51c9afec9 --- /dev/null +++ b/docs/cn/Trace-Data-Protocol-CN.md @@ -0,0 +1,101 @@ +# Trace Data Protocol 中文 +Trace Data Protocol协议,也就是探针与Collector间通讯协议 + +## 概述 +此协议包含了Agent上行/下行数据的格式,可用于定制开发,或者探针的多语言扩展 + +### 协议版本 +v1.1 + +### 协议类型 +* 服务发现使用http服务 +* 注册和数据上行服务同时支持gRPC和HTTP服务 + +#### gRPC协议定义文件 +[gRPC proto files](../../apm-protocol/apm-network/src/main/proto) + +## Collector服务发现协议 +### 简介 +**Collector服务发现协议是探针启动时,第一个调用的服务。** 通过服务,查找可用的gRPC服务地址列表,并在由客户端选择其中任意一个作为服务端。 +此服务建议周期性调用,确保探针本地的服务端口列表是准确有效的。 + +### 协议类型 +HTTP GET + +### 协议内容 +- 请求 +GET操作:http://collectorIp:port/agent/grpc 。 其中`/agent/grpc`是默认值,如需修改,需要参考collector相关配置。 + +- 返回 +JSON数组,数组的每个元素,为一个有效的gRPC服务地址。 +```json +["ip address1:port1","ip address2:port2","ip address3:port3"] +``` + +## 应用注册服务 +### 简介 +应用注册服务,是将applicationCode,以及ip:port构成的服务地址,转换成数字ID的服务。 +此服务会在后续的传输过程中,有效降低网络带宽需求。 + +### 协议内容 +[gRPC service define](../..apm-protocol/apm-network/src/main/proto/ApplicationRegisterService.proto) + +- 首次调用时,applicationCode为客户端设置的应用名(显示在拓扑图和应用列表上的名字)。之后随着追踪过程,会上报此应用相关的周边服务的`ip:port`地址列表 +- KeyWithIntegerValue 返回,key为上报的applicationCode或ip:port地址,value为对应的id。applicationCode对应的返回id,在后续协议中,被称为applicationId。 +- 此服务按需调用,本地无法找到ip:port对应的id时,可异步发起调用。 +- 获取applicationId的操作是必选。后续追踪数据依赖此id +- 获取ip:port对应的id是可选,使用id,会有效提高collector处理效率,降低网络消耗。 + +## 应用实例发现服务 +### 简介 +应用实例发现服务存在三个子服务,分别是实例注册服务,实例心跳服务,实例注册重连服务。这三个服务负责获取和保持应用实例在线的功能。 + +### 协议类型 +gRPC服务 + +### 实例注册服务 +[gRPC service define](../../apm-protocol/apm-network/src/main/proto/DiscoveryService.proto#L11-L12) + +- agentUUID 由探针生成,需保持唯一性,推荐使用UUID算法。并在应用重启前保持不变 +- applicationId 由**应用注册服务**获取。 +- 服务端返回应用实例id,applicationInstanceId 。后续上报服务使用实例id标识。 + +### 实例心跳服务 +[gRPC service define](../../apm-protocol/apm-network/src/main/proto/DiscoveryService.proto#L14-L15) + +- 心跳服务每分钟上报一次。 +- 如果一分钟内有segment数据上报,则可不必上报心跳。 + +## 服务名注册发现服务 +### 简介 +服务名注册发现服务,是将应用内的服务名(operationName)替换为id的服务。 + +### 协议内容 +[gRPC service define](../../apm-protocol/apm-network/src/main/proto/DiscoveryService.proto#L53-L74) + +- 可选服务,可有效降低网络消耗,推荐实现。注意,由于部分应用存在URI中夹带参数的情况,请注意限制探针内的缓存容量,防止内存溢出。 +- ServiceNameElement中,applicationId为当前applicationCode对应的id。serviceName一般为对应span的operationName + +## JVM指标上报服务 +### 简介 +上报当前实例的JVM信息,每秒上报一次。 + +### 协议内容 +[gRPC service define](../../apm-protocol/apm-network/src/main/proto/JVMMetricsService.proto) + +## TraceSegment上报服务 +### 简介 +上报调用链信息 + +### 协议内容 +[gRPC service define](../../apm-protocol/apm-network/src/main/proto/TraceSegmentService.proto) + +- UniqueId为segment或者globalTraceId的数字表示。由3个long组成,1)applicationInstanceId,2)当前线程id,3)当前时间戳*10000 + seq(0-10000自循环) +- Span的数据,请参考[插件开发规范](Plugin-Development-Guide-CN.md) +- 以下id和名称根据注册返回结果,优先上报id,无法获取id时,再上传name。参考之前的应用和服务注册章节。 + - operationNameId/operationName + - networkAddress/networkAddressId + - entryServiceName/entryServiceId + - parentServiceName/parentServiceId + - peerId/peer +- componentId为默认支持的插件id,非官方支持,需传输名称或修改服务端源代码。[官方组件列表](../../apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java) diff --git a/docs/en/Application-toolkit-log4j-1.x.md b/docs/en/Application-toolkit-log4j-1.x.md index 80a37d690..753bf4b89 100644 --- a/docs/en/Application-toolkit-log4j-1.x.md +++ b/docs/en/Application-toolkit-log4j-1.x.md @@ -6,7 +6,6 @@ {project.release.version} ``` -   [ ![Download](https://api.bintray.com/packages/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-log4j-1.x/images/download.svg) ](https://bintray.com/wu-sheng/skywalking/org.apache.skywalking.apmg-toolkit-log4j-1.x/_latestVersion) * Config a layout ```properties diff --git a/docs/en/Application-toolkit-log4j-2.x.md b/docs/en/Application-toolkit-log4j-2.x.md index 13fb77e25..19502f9ae 100644 --- a/docs/en/Application-toolkit-log4j-2.x.md +++ b/docs/en/Application-toolkit-log4j-2.x.md @@ -6,7 +6,6 @@ {project.release.version} ``` -   [ ![Download](https://api.bintray.com/packages/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-log4j-2.x/images/download.svg) ](https://bintray.com/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-log4j-2.x/_latestVersion) * Config the `[%traceId]` pattern in your log4j2.xml ```xml diff --git a/docs/en/Application-toolkit-logback-1.x.md b/docs/en/Application-toolkit-logback-1.x.md index 6a52091a2..4b60043a8 100644 --- a/docs/en/Application-toolkit-logback-1.x.md +++ b/docs/en/Application-toolkit-logback-1.x.md @@ -6,7 +6,6 @@ {project.release.version} ``` -   [ ![Download](https://api.bintray.com/packages/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-logback-1.x/images/download.svg) ](https://bintray.com/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-logback-1.x/_latestVersion) * set `%tid` in `Pattern` section of logback.xml ```xml diff --git a/docs/en/Application-toolkit-trace.md b/docs/en/Application-toolkit-trace.md index e6dfdae17..4f195de41 100644 --- a/docs/en/Application-toolkit-trace.md +++ b/docs/en/Application-toolkit-trace.md @@ -6,7 +6,6 @@ ${skywalking.version} ``` -   [ ![Download](https://api.bintray.com/packages/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-trace/images/download.svg) ](https://bintray.com/wu-sheng/skywalking/org.apache.skywalking.apm-toolkit-trace/_latestVersion) * Use `TraceContext.traceId()` API to obtain traceId. ```java diff --git a/docs/en/Deploy-skywalking-agent.md b/docs/en/Deploy-skywalking-agent.md index d208d8b4c..c42ee3b51 100644 --- a/docs/en/Deploy-skywalking-agent.md +++ b/docs/en/Deploy-skywalking-agent.md @@ -1,5 +1,5 @@ ## Download skywalking agent release version -- Go to [release page](https://github.com/wu-sheng/sky-walking/releases) +- Go to [release page](https://github.com/apache/incubator-skywalking/releases) ## Deploy skywalking javaagent 1. Copy the agent package to anywhere you like. The logs, plugins and config are all included in the package. @@ -42,5 +42,5 @@ CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/skywalking-agent/skywalking-ag - Tomcat 8 Change the first line of `tomcat/bin/catalina.sh`. ```shell -set "CATALINA_OPTS=... -javaagent:E:\apache-tomcat-8.5.20\skywalking-agent\skywalking-agent.jar -Dconfig=\skywalking\config\dir" +set "CATALINA_OPTS=-javaagent:E:\apache-tomcat-8.5.20\skywalking-agent\skywalking-agent.jar -Dconfig=\skywalking\config\dir" ``` \ No newline at end of file diff --git a/docs/en/How-to-build.md b/docs/en/How-to-build.md new file mode 100644 index 000000000..b21e504f8 --- /dev/null +++ b/docs/en/How-to-build.md @@ -0,0 +1,14 @@ +# How to build project +This document helps people to compile and build the project in your maven and IDE. + +## Build in maven +1. Prepare JDK8 and maven3 +1. Run `mvn clean package` +1. All packages are in `/packages`, which includes `skywalking-agent` folder, and two collector files(.tar.gz for Linux and .zip for Windows) + +## Setup your IntelliJ IDEA +1. Import the project as a maven project +1. Run `mvn compile -Dmaven.test.skip=true` to compile project and generate source codes. Because we use gRPC and protobuf. +1. Set **Generated Source Codes** folders. + * `grpc-java` and `java` folders in **apm-protocol/apm-network/target/generated-sources/protobuf** + * `grpc-java` and `java` folders in **apm-collector/apm-collector-remote/apm-remote-grpc-provider/target/protobuf** \ No newline at end of file diff --git a/docs/en/Plugin-Development-Guide.md b/docs/en/Plugin-Development-Guide.md new file mode 100644 index 000000000..2174c33d6 --- /dev/null +++ b/docs/en/Plugin-Development-Guide.md @@ -0,0 +1,290 @@ +# Plugin Development Guide +This document describe how to understand, develop and contribute plugin. + +## Concepts +### Span +Span is an important and common concept in distributed tracing system. Learn **Span** from +[Google Dapper Paper](https://research.google.com/pubs/pub36356.html) and +[OpenTracing](http://opentracing.io) + +SkyWalking supports OpenTracing and OpenTracing-Java API from 2017. Our Span concepts are similar with the paper and OpenTracing. +Also we extend the Span. + +There are three types of Span + +1.1 EntrySpan +EntrySpan represents a service provider, also the endpoint of server side. As an APM system, we are targeting the +application servers. So almost all the services and MQ-comsumer are EntrySpan(s). + +1.2 LocalSpan +LocalSpan represents a normal Java method, which don't relate with remote service, neither a MQ producer/comsumer +nor a service(e.g. HTTP service) provider/consumer. + +1.3 ExitSpan +ExitSpan represents a client of service or MQ-producer, as named as `LeafSpan` at early age of SkyWalking. +e.g. accessing DB by JDBC, reading Redis/Memcached are cataloged an ExitSpan. + +### ContextCarrier +In order to implement distributed tracing, the trace across process need to be bind, and the context should propagate +across the process. That is ContextCarrier's duty. + +Here are the steps about how to use **ContextCarrier** in a `A->B` distributed call. +1. Create a new and empty `ContextCarrier` at client side. +1. Create an ExitSpan by `ContextManager#createExitSpan` or use `ContextManager#inject` to init the `ContextCarrier`. +1. Put all items of `ContextCarrier` into heads(e.g. HTTP HEAD), attachments(e.g. Dubbo RPC framework) or messages(e.g. Kafka) +1. The `ContextCarrier` propagates to server side by the service call. +1. At server side, get all items from heads, attachments or messages. +1. Create an EntrySpan by `ContestManager#createEntrySpan` or use `ContextManager#extract` to bind the client and server. + + +Let's demonstrate the steps by Apache HTTPComponent client plugin and Tomcat 7 server plugin +1. Client side steps by Apache HTTPComponent client plugin +```java + span = ContextManager.createExitSpan("/span/operation/name", contextCarrier, "ip:port"); + CarrierItem next = contextCarrier.items(); + while (next.hasNext()) { + next = next.next(); + httpRequest.setHeader(next.getHeadKey(), next.getHeadValue()); + } +``` + +2. Server side steps by Tomcat 7 server plugin +```java + ContextCarrier contextCarrier = new ContextCarrier(); + CarrierItem next = contextCarrier.items(); + while (next.hasNext()) { + next = next.next(); + next.setHeadValue(request.getHeader(next.getHeadKey())); + } + + span = ContextManager.createEntrySpan(“/span/operation/name”, contextCarrier); +``` + +### ContextSnapshot +Besides across process, across thread but in a process need to be supported, because async process(In-memory MQ) +and batch process are common in Java. Across process and across thread are similar, because they are both about propagating +context. The only difference is that, don't need to serialize for across thread. + +Here are the three steps about across thread propagation: +1. Use `ContextManager#capture` to get the ContextSnapshot object. +1. Let the sub-thread access the ContextSnapshot by any way, through method arguments or carried by an existed arguments +1. Use `ContextManager#continued` in sub-thread. + +## Core APIs +### ContextManager +ContextManager provides all major and primary APIs. + +1. Create EntrySpan +```java +public static AbstractSpan createEntrySpan(String operationName, ContextCarrier carrier) +``` +Create EntrySpan by operation name(e.g. service name, uri) and **ContextCarrier**. + +2. Create LocalSpan +```java +public static AbstractSpan createLocalSpan(String operationName) +``` +Create LocalSpan by operation name(e.g. full method signature) + +3. Create ExitSpan +```java +public static AbstractSpan createExitSpan(String operationName, ContextCarrier carrier, String remotePeer) +``` +Create ExitSpan by operation name(e.g. service name, uri) and new **ContextCarrier** and peer address +(e.g. ip+port, hostname+port) + +### AbstractSpan +```java + /** + * Set the component id, which defines in {@link ComponentsDefine} + * + * @param component + * @return the span for chaining. + */ + AbstractSpan setComponent(Component component); + + /** + * Only use this method in explicit instrumentation, like opentracing-skywalking-bridge. + * It it higher recommend don't use this for performance consideration. + * + * @param componentName + * @return the span for chaining. + */ + AbstractSpan setComponent(String componentName); + + AbstractSpan setLayer(SpanLayer layer); + + /** + * Set a key:value tag on the Span. + * + * @return this Span instance, for chaining + */ + AbstractSpan tag(String key, String value); + + /** + * Record an exception event of the current walltime timestamp. + * + * @param t any subclass of {@link Throwable}, which occurs in this span. + * @return the Span, for chaining + */ + AbstractSpan log(Throwable t); + + AbstractSpan errorOccurred(); + + /** + * Record an event at a specific timestamp. + * + * @param timestamp The explicit timestamp for the log record. + * @param event the events + * @return the Span, for chaining + */ + AbstractSpan log(long timestamp, Map event); + + /** + * Sets the string name for the logical operation this span represents. + * + * @return this Span instance, for chaining + */ + AbstractSpan setOperationName(String operationName); +``` +Besides set operation name, tags and logs, two attributes shoule be set, which are component and layer, +especially for EntrySpan and ExitSpan + +SpanLayer is the catalog of span. Here are 5 values: +1. UNKNOWN (default) +1. DB +1. RPC_FRAMEWORK, for a RPC framework, not an ordinary HTTP +1. HTTP +1. MQ + +Component IDs are defined and protected by SkyWalking project, 0 -> 10000 IDs are reserved. If you want to contribute +a new plugin, you can ask for an official ID, after your pull request approved and automatic test cases accepted by PMC. +Please use > 10000 ID, if you are going to develop a private plugin or don't intend to contribute the plugin to community, +to avoid the ID conflict. + +## Develop a plugin +### Abstract +The basic method to trace is intercepting a Java method, by using byte code manipulation tech and AOP concept. +SkyWalking boxed the byte code manipulation tech and tracing context propagation, +so you just need to define the intercept point(a.k.a. aspect pointcut in Spring) + +### Intercept +SkyWalking provide two common defines to intercept Contructor, instance method and class method. +* Extend `ClassInstanceMethodsEnhancePluginDefine` defines `Contructor` intercept points and `instance method` intercept points. +* Extend `ClassStaticMethodsEnhancePluginDefine` definec `class method` intercept points. + +Of course, you can extend `ClassEnhancePluginDefine` to set all intercept points. But it is unusual. + +### Implement plugin +I will demonstrate about how to implement a plugin by extending `ClassInstanceMethodsEnhancePluginDefine` + +1. Define the target class name +```java +protected abstract ClassMatch enhanceClass(); +``` + +ClassMatch represents how to match the target classes, there are 4 ways: +* byName, through the full class name(package name + `.` + class name) +* byClassAnnotationMatch, through the class existed certain annotations. +* byMethodAnnotationMatch, through the class's method existed certain annotations. +* byHierarchyMatch, throught the class's parent classes or interfaces + +**Attentions**: +* Forbid to use `*.class.getName()` to get the class String name. Recommend you to use literal String. This is for +avoiding ClassLoader issues. +* `by*AnnotationMatch` doesn't support the inherited annotations. +* Don't recommend use `byHierarchyMatch`, unless it is really necessary. Because using it may trigger intercepting +many unexcepted methods, which causes performance issues and concerns. + +Example: +```java +@Override +protected ClassMatch enhanceClassName() { + return byName("org.apache.catalina.core.StandardEngineValve"); +} + +``` + +2. Define an instance method intercept point +```java +protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints(); + +public interface InstanceMethodsInterceptPoint { + /** + * class instance methods matcher. + * + * @return methods matcher + */ + ElementMatcher getMethodsMatcher(); + + /** + * @return represents a class name, the class instance must instanceof InstanceMethodsAroundInterceptor. + */ + String getMethodsInterceptor(); + + boolean isOverrideArgs(); +} +``` +Also use `Matcher` to set the target methods. Return **true** in `isOverrideArgs`, if you want to change the argument +ref in interceptor. + +The following sections will tell you how to implement the interceptor. + +3. Add plugin define into skywalking-plugin.def file +```properties +tomcat-7.x/8.x=TomcatInstrumentation +``` + + +### Implement an interceptor +As an interceptor for an instance method, the interceptor implements +`org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor` +```java +/** + * A interceptor, which intercept method's invocation. The target methods will be defined in {@link + * ClassEnhancePluginDefine}'s subclass, most likely in {@link ClassInstanceMethodsEnhancePluginDefine} + * + * @author wusheng + */ +public interface InstanceMethodsAroundInterceptor { + /** + * called before target method invocation. + * + * @param result change this result, if you want to truncate the method. + * @throws Throwable + */ + void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable; + + /** + * called after target method invocation. Even method's invocation triggers an exception. + * + * @param ret the method's original return value. + * @return the method's actual return value. + * @throws Throwable + */ + Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable; + + /** + * called when occur exception. + * + * @param t the exception occur. + */ + void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Throwable t); +} +``` +Use the core APIs in before, after and exception handle stages. + +### Contribute plugins into Apache SkyWalking repository +We are welcome everyone to contribute plugins. + +Please follow there steps: +1. Submit an issue about which plugins are you going to contribute, including supported version. +1. Create sub modules under `apm-sniffer/apm-sdk-plugin`, and the name should include supported library name and versions +1. Follow this guide to develop. Make sure comments and test cases are provided. +1. Develop and test. +1. Send the pull request and ask for review, and provide the automatic test cases by following PMC members guides. +1. The plugin committers approves your plugins after automatic test cases provided and the tests passed in our CI. +1. The plugin accepted by SkyWalking. diff --git a/docs/en/Skywalking-3-Cross-Process-Propagation-Headers-Protocol.md b/docs/en/Skywalking-Cross-Process-Propagation-Headers-Protocol-v1.md similarity index 84% rename from docs/en/Skywalking-3-Cross-Process-Propagation-Headers-Protocol.md rename to docs/en/Skywalking-Cross-Process-Propagation-Headers-Protocol-v1.md index 40e9b6291..6388f8994 100644 --- a/docs/en/Skywalking-3-Cross-Process-Propagation-Headers-Protocol.md +++ b/docs/en/Skywalking-Cross-Process-Propagation-Headers-Protocol-v1.md @@ -1,12 +1,16 @@ -# Skywalking 3 Cross Process Propagation Headers Protocol +# Skywalking Cross Process Propagation Headers Protocol * Version 1.0 -This is the first open edition about `Skywalking 3 Cross Process Propagation Headers Protocol`. The skywalking is more likely an APM system, rather than normal distributed tracing system. The Headers is much more complex than them in order to improving analysis performance of collector. You can find many similar mechanism in other commercial APM system.(Some even much more complex than us) +SkyWalking is more likely an APM system, rather than common distributed tracing system. +The Headers is much more complex than them in order to improving analysis performance of collector. +You can find many similar mechanism in other commercial APM system.(Some even much more complex than us) # Header Item * Header Name: `sw3` * Header Value: Split by `|`, the parts are following. +_The header protocol came from SkyWalking 3, back to 2017. So sw3 header name keeps now._ + ## Values * Trace Segment Id diff --git a/pom.xml b/pom.xml index 8f8d3a094..371a47c6b 100644 --- a/pom.xml +++ b/pom.xml @@ -55,8 +55,8 @@ apm-commons apm-sniffer apm-application-toolkit - apm-network apm-collector + apm-protocol pom @@ -68,11 +68,6 @@ https://github.com/apache/incubator-skywalking/issues - - travis - https://travis-ci.org/wu-sheng/sky-walking - - UTF-8 1.8 diff --git a/travis/push_image.sh b/travis/push_image.sh deleted file mode 100644 index 8c284cce9..000000000 --- a/travis/push_image.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -check_pull_is_tagged() { - if [ "${TRAVIS_TAG}" == "" ]; then - return 1 - else - echo "This build was started by the tag ${TRAVIS_TAG}, push image" - return 0 - fi -} - -check_release_tag() { - tag="${TRAVIS_TAG}" - if [[ "$tag" =~ ^v[0-9.]*-[0-9]{4}$ ]]; then - return 0; - else - echo "The provided tag ${tag} doesn't match that." - return 1; - fi -} - -push_image() { - IMAGE_VERSION=`echo ${TRAVIS_TAG:1}` - docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" - mvn clean package docker:build - docker push skywalking/skywalking-collector:latest - docker push skywalking/skywalking-collector:${IMAGE_VERSION} -} - - -if check_pull_is_tagged && check_release_tag; then - push_image - echo "Push is Done!" -fi \ No newline at end of file