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

Make the applicationCodeRegister only for single code.

上级 fd08a731
......@@ -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<ApplicationMappings> responseObserver) {
public void applicationCodeRegister(Application request, StreamObserver<ApplicationMapping> 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();
......
......@@ -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;
}
......@@ -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;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册