use of org.apache.skywalking.oap.server.configuration.service.ConfigurationResponse in project incubator-skywalking by apache.
the class MockGRPCConfigService method call.
@Override
public void call(ConfigurationRequest request, StreamObserver<ConfigurationResponse> responseObserver) {
ConfigurationResponse response;
String uuid = request.getUuid();
switch(this.dataFlag.get()) {
case 1:
response = ConfigurationResponse.newBuilder().setUuid(UUID.randomUUID().toString()).addConfigTable(Config.newBuilder().setName("test-module.grpc.testKey").setValue("300").build()).build();
responseObserver.onNext(response);
break;
case 2:
response = ConfigurationResponse.newBuilder().setUuid(uuid).build();
responseObserver.onNext(response);
break;
case 3:
response = ConfigurationResponse.newBuilder().setUuid(UUID.randomUUID().toString()).addConfigTable(Config.newBuilder().setName("test-module.grpc.testKey").build()).build();
responseObserver.onNext(response);
break;
default:
response = ConfigurationResponse.newBuilder().setUuid(UUID.randomUUID().toString()).addConfigTable(Config.newBuilder().setName("test-module.grpc.testKey").setValue("100").build()).build();
responseObserver.onNext(response);
}
responseObserver.onCompleted();
}
use of org.apache.skywalking.oap.server.configuration.service.ConfigurationResponse in project skywalking by apache.
the class MockGRPCConfigService method call.
@Override
public void call(ConfigurationRequest request, StreamObserver<ConfigurationResponse> responseObserver) {
ConfigurationResponse response;
String uuid = request.getUuid();
switch(this.dataFlag.get()) {
case 1:
response = ConfigurationResponse.newBuilder().setUuid(UUID.randomUUID().toString()).addConfigTable(Config.newBuilder().setName("test-module.grpc.testKey").setValue("300").build()).build();
responseObserver.onNext(response);
break;
case 2:
response = ConfigurationResponse.newBuilder().setUuid(uuid).build();
responseObserver.onNext(response);
break;
case 3:
response = ConfigurationResponse.newBuilder().setUuid(UUID.randomUUID().toString()).addConfigTable(Config.newBuilder().setName("test-module.grpc.testKey").build()).build();
responseObserver.onNext(response);
break;
default:
response = ConfigurationResponse.newBuilder().setUuid(UUID.randomUUID().toString()).addConfigTable(Config.newBuilder().setName("test-module.grpc.testKey").setValue("100").build()).build();
responseObserver.onNext(response);
}
responseObserver.onCompleted();
}
use of org.apache.skywalking.oap.server.configuration.service.ConfigurationResponse in project skywalking by apache.
the class GRPCConfigWatcherRegister method readConfig.
@Override
public Optional<ConfigTable> readConfig(Set<String> keys) {
ConfigTable table = new ConfigTable();
try {
ConfigurationRequest.Builder builder = ConfigurationRequest.newBuilder().setClusterName(settings.getClusterName());
if (uuid != null) {
builder.setUuid(uuid);
}
ConfigurationResponse response = stub.call(builder.build());
String responseUuid = response.getUuid();
if (Objects.equals(uuid, responseUuid)) {
// If UUID matched, the config table is expected as empty.
return Optional.empty();
}
response.getConfigTableList().forEach(config -> {
final String name = config.getName();
if (keys.contains(name)) {
table.add(new ConfigTable.ConfigItem(name, config.getValue()));
}
});
this.uuid = responseUuid;
} catch (Exception e) {
log.error("Remote config center [{}] is not available.", settings, e);
}
return Optional.of(table);
}
use of org.apache.skywalking.oap.server.configuration.service.ConfigurationResponse in project incubator-skywalking by apache.
the class GRPCConfigWatcherRegister method readConfig.
@Override
public Optional<ConfigTable> readConfig(Set<String> keys) {
ConfigTable table = new ConfigTable();
try {
ConfigurationRequest.Builder builder = ConfigurationRequest.newBuilder().setClusterName(settings.getClusterName());
if (uuid != null) {
builder.setUuid(uuid);
}
ConfigurationResponse response = stub.call(builder.build());
String responseUuid = response.getUuid();
if (Objects.equals(uuid, responseUuid)) {
// If UUID matched, the config table is expected as empty.
return Optional.empty();
}
response.getConfigTableList().forEach(config -> {
final String name = config.getName();
if (keys.contains(name)) {
table.add(new ConfigTable.ConfigItem(name, config.getValue()));
}
});
this.uuid = responseUuid;
} catch (Exception e) {
log.error("Remote config center [{}] is not available.", settings, e);
}
return Optional.of(table);
}
Aggregations