提交 e7b72eb2 编写于 作者: wu-sheng's avatar wu-sheng

catch up the TODO list.

上级 1fbb28d2
......@@ -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<ApplicationMappings> responseObserver) {
@Override
public void applicationCodeRegister(Application request, StreamObserver<ApplicationMappings> 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();
......
......@@ -47,7 +47,7 @@ public class InstanceDiscoveryServiceHandler extends InstanceDiscoveryServiceGrp
}
@Override
public void register(ApplicationInstance request, StreamObserver<ApplicationInstanceMapping> responseObserver) {
public void registerInstance(ApplicationInstance request, StreamObserver<ApplicationInstanceMapping> responseObserver) {
long timeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(request.getRegisterTime());
int instanceId = instanceIDService.getOrCreateByAgentUUID(request.getApplicationId(), request.getAgentUUID(), timeBucket, buildOsInfo(request.getOsinfo()));
ApplicationInstanceMapping.Builder builder = ApplicationInstanceMapping.newBuilder();
......
......@@ -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 {
......
......@@ -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) {
......
......@@ -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())
......
......@@ -68,11 +68,6 @@
<url>https://github.com/apache/incubator-skywalking/issues</url>
</issueManagement>
<ciManagement>
<system>travis</system>
<url>https://travis-ci.org/wu-sheng/sky-walking</url>
</ciManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler.version>1.8</compiler.version>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册