From e7b72eb2f94b4979900df65ddb87e87b68808dc3 Mon Sep 17 00:00:00 2001 From: wusheng Date: Thu, 4 Jan 2018 21:50:43 +0800 Subject: [PATCH 1/5] catch up the TODO list. --- .../ApplicationRegisterServiceHandler.java | 19 ++++++++----------- .../InstanceDiscoveryServiceHandler.java | 2 +- .../proto/ApplicationRegisterService.proto | 7 +++---- .../src/main/proto/DiscoveryService.proto | 3 +-- .../remote/AppAndServiceRegisterClient.java | 9 ++++----- pom.xml | 5 ----- 6 files changed, 17 insertions(+), 28 deletions(-) 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 8fa4070b3..e04aa2255 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.Application; 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.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.getOrCreateForApplicationCode(applicationCode); + 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.addApplications(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 87a8ceca4..b8d271b51 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 @@ -47,7 +47,7 @@ public class InstanceDiscoveryServiceHandler extends InstanceDiscoveryServiceGrp } @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.getOrCreateByAgentUUID(request.getApplicationId(), request.getAgentUUID(), timeBucket, buildOsInfo(request.getOsinfo())); ApplicationInstanceMapping.Builder builder = ApplicationInstanceMapping.newBuilder(); diff --git a/apm-protocol/apm-network/src/main/proto/ApplicationRegisterService.proto b/apm-protocol/apm-network/src/main/proto/ApplicationRegisterService.proto index c612eb395..c47875e2e 100644 --- a/apm-protocol/apm-network/src/main/proto/ApplicationRegisterService.proto +++ b/apm-protocol/apm-network/src/main/proto/ApplicationRegisterService.proto @@ -7,13 +7,12 @@ import "KeyWithIntegerValue.proto"; //register service for ApplicationCode, this service is called when service starts. service ApplicationRegisterService { - //TODO: TODO: `batchRegister` should be replaces by applicationCodeRegister - rpc batchRegister (Applications) returns (ApplicationMappings) { + rpc applicationCodeRegister (Application) returns (ApplicationMappings) { } } -message Applications { - repeated string applicationCodes = 1; +message Application { + string applicationCode = 1; } message ApplicationMappings { diff --git a/apm-protocol/apm-network/src/main/proto/DiscoveryService.proto b/apm-protocol/apm-network/src/main/proto/DiscoveryService.proto index 640b6d2d5..f2068f027 100644 --- a/apm-protocol/apm-network/src/main/proto/DiscoveryService.proto +++ b/apm-protocol/apm-network/src/main/proto/DiscoveryService.proto @@ -6,8 +6,7 @@ option java_package = "org.apache.skywalking.apm.network.proto"; import "Downstream.proto"; service InstanceDiscoveryService { - //TODO: need rename, `register` is a key word. - rpc register (ApplicationInstance) returns (ApplicationInstanceMapping) { + rpc registerInstance (ApplicationInstance) returns (ApplicationInstanceMapping) { } rpc heartbeat (ApplicationInstanceHeartbeat) returns (Downstream) { 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 3ebe836ac..800f3d4d3 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 @@ -37,12 +37,12 @@ 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.ApplicationMappings; 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; @@ -109,9 +109,8 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList try { if (RemoteDownstreamConfig.Agent.APPLICATION_ID == DictionaryUtil.nullValue()) { if (applicationRegisterServiceBlockingStub != null) { - //TODO: `batchRegister` should be replaces by applicationCodeRegister - ApplicationMappings applicationMapping = applicationRegisterServiceBlockingStub.batchRegister( - Applications.newBuilder().addApplicationCodes(Config.Agent.APPLICATION_CODE).build()); + ApplicationMappings applicationMapping = applicationRegisterServiceBlockingStub.applicationCodeRegister( + Application.newBuilder().setApplicationCode(Config.Agent.APPLICATION_CODE).build()); if (applicationMapping.getApplicationsCount() > 0) { RemoteDownstreamConfig.Agent.APPLICATION_ID = applicationMapping.getApplications(0).getValue(); shouldTry = true; @@ -121,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()) diff --git a/pom.xml b/pom.xml index 0473ff504..371a47c6b 100644 --- a/pom.xml +++ b/pom.xml @@ -68,11 +68,6 @@ https://github.com/apache/incubator-skywalking/issues - - travis - https://travis-ci.org/wu-sheng/sky-walking - - UTF-8 1.8 From fd08a731a46ca588b8ba85e350dd568dcc2f3a35 Mon Sep 17 00:00:00 2001 From: wusheng Date: Thu, 4 Jan 2018 22:29:52 +0800 Subject: [PATCH 2/5] Fix compile --- .../handler/ApplicationRegisterServiceHandlerTestCase.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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/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 index 84cd1775b..b8920e633 100644 --- a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/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 @@ -20,9 +20,9 @@ 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.Application; 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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,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); + Application application = Application.newBuilder().setApplicationCode("test141").build(); + ApplicationMappings mapping = stub.applicationCodeRegister(application); logger.debug(mapping.getApplications(0).getKey() + ", " + mapping.getApplications(0).getValue()); } } From ef284dc6d504c2f5246ebd18588476cab97274c1 Mon Sep 17 00:00:00 2001 From: wusheng Date: Thu, 4 Jan 2018 23:07:49 +0800 Subject: [PATCH 3/5] Make the applicationCodeRegister only for single code. --- .../handler/ApplicationRegisterServiceHandler.java | 8 ++++---- .../src/main/proto/ApplicationRegisterService.proto | 6 +++--- .../agent/core/remote/AppAndServiceRegisterClient.java | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) 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 e04aa2255..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 @@ -24,7 +24,7 @@ import org.apache.skywalking.apm.collector.analysis.register.define.service.IApp 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.Application; -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.KeyWithIntegerValue; import org.slf4j.Logger; @@ -44,16 +44,16 @@ public class ApplicationRegisterServiceHandler extends ApplicationRegisterServic } @Override - public void applicationCodeRegister(Application request, StreamObserver responseObserver) { + public void applicationCodeRegister(Application request, StreamObserver responseObserver) { logger.debug("register application"); - ApplicationMappings.Builder builder = ApplicationMappings.newBuilder(); + 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); + builder.setApplication(value); } responseObserver.onNext(builder.build()); responseObserver.onCompleted(); diff --git a/apm-protocol/apm-network/src/main/proto/ApplicationRegisterService.proto b/apm-protocol/apm-network/src/main/proto/ApplicationRegisterService.proto index c47875e2e..e5b4deee1 100644 --- a/apm-protocol/apm-network/src/main/proto/ApplicationRegisterService.proto +++ b/apm-protocol/apm-network/src/main/proto/ApplicationRegisterService.proto @@ -7,7 +7,7 @@ import "KeyWithIntegerValue.proto"; //register service for ApplicationCode, this service is called when service starts. service ApplicationRegisterService { - rpc applicationCodeRegister (Application) returns (ApplicationMappings) { + rpc applicationCodeRegister (Application) returns (ApplicationMapping) { } } @@ -15,6 +15,6 @@ message Application { string applicationCode = 1; } -message ApplicationMappings { - repeated KeyWithIntegerValue applications = 1; +message ApplicationMapping { + KeyWithIntegerValue application = 1; } 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 800f3d4d3..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 @@ -41,7 +41,7 @@ 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.ApplicationMappings; +import org.apache.skywalking.apm.network.proto.ApplicationMapping; import org.apache.skywalking.apm.network.proto.ApplicationRegisterServiceGrpc; import org.apache.skywalking.apm.network.proto.InstanceDiscoveryServiceGrpc; import org.apache.skywalking.apm.network.proto.NetworkAddressRegisterServiceGrpc; @@ -109,10 +109,10 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList try { if (RemoteDownstreamConfig.Agent.APPLICATION_ID == DictionaryUtil.nullValue()) { if (applicationRegisterServiceBlockingStub != null) { - ApplicationMappings applicationMapping = applicationRegisterServiceBlockingStub.applicationCodeRegister( + ApplicationMapping applicationMapping = applicationRegisterServiceBlockingStub.applicationCodeRegister( Application.newBuilder().setApplicationCode(Config.Agent.APPLICATION_CODE).build()); - if (applicationMapping.getApplicationsCount() > 0) { - RemoteDownstreamConfig.Agent.APPLICATION_ID = applicationMapping.getApplications(0).getValue(); + if (applicationMapping != null) { + RemoteDownstreamConfig.Agent.APPLICATION_ID = applicationMapping.getApplication().getValue(); shouldTry = true; } } From d934ec53f2025262e98a20ae2e62c3f00f181261 Mon Sep 17 00:00:00 2001 From: wusheng Date: Thu, 4 Jan 2018 23:19:17 +0800 Subject: [PATCH 4/5] Fix test cases --- .../handler/ApplicationRegisterServiceHandlerTestCase.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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/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 index b8920e633..aa29ffb03 100644 --- a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/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 @@ -21,6 +21,7 @@ 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.Application; +import org.apache.skywalking.apm.network.proto.ApplicationMapping; import org.apache.skywalking.apm.network.proto.ApplicationMappings; import org.apache.skywalking.apm.network.proto.ApplicationRegisterServiceGrpc; import org.slf4j.Logger; @@ -40,7 +41,7 @@ public class ApplicationRegisterServiceHandlerTestCase { stub = ApplicationRegisterServiceGrpc.newBlockingStub(channel); Application application = Application.newBuilder().setApplicationCode("test141").build(); - ApplicationMappings mapping = stub.applicationCodeRegister(application); - logger.debug(mapping.getApplications(0).getKey() + ", " + mapping.getApplications(0).getValue()); + ApplicationMapping mapping = stub.applicationCodeRegister(application); + logger.debug(mapping.getApplication().getKey() + ", " + mapping.getApplication().getValue()); } } From c11f37ab9f358ed7c854f30ab58e18a40a9d39eb Mon Sep 17 00:00:00 2001 From: wusheng Date: Fri, 5 Jan 2018 07:54:32 +0800 Subject: [PATCH 5/5] Remove an unused import. --- .../handler/ApplicationRegisterServiceHandlerTestCase.java | 1 - 1 file changed, 1 deletion(-) 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/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 index aa29ffb03..50d9e82dc 100644 --- a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/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 @@ -22,7 +22,6 @@ import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; import org.apache.skywalking.apm.network.proto.Application; import org.apache.skywalking.apm.network.proto.ApplicationMapping; -import org.apache.skywalking.apm.network.proto.ApplicationMappings; import org.apache.skywalking.apm.network.proto.ApplicationRegisterServiceGrpc; import org.slf4j.Logger; import org.slf4j.LoggerFactory;