Search in sources :

Example 1 with ConfigurationResponse

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();
}
Also used : GroupConfigurationResponse(org.apache.skywalking.oap.server.configuration.service.GroupConfigurationResponse) ConfigurationResponse(org.apache.skywalking.oap.server.configuration.service.ConfigurationResponse)

Example 2 with ConfigurationResponse

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();
}
Also used : GroupConfigurationResponse(org.apache.skywalking.oap.server.configuration.service.GroupConfigurationResponse) ConfigurationResponse(org.apache.skywalking.oap.server.configuration.service.ConfigurationResponse)

Example 3 with ConfigurationResponse

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);
}
Also used : GroupConfigurationResponse(org.apache.skywalking.oap.server.configuration.service.GroupConfigurationResponse) ConfigurationResponse(org.apache.skywalking.oap.server.configuration.service.ConfigurationResponse) ConfigurationRequest(org.apache.skywalking.oap.server.configuration.service.ConfigurationRequest) ConfigTable(org.apache.skywalking.oap.server.configuration.api.ConfigTable) GroupConfigTable(org.apache.skywalking.oap.server.configuration.api.GroupConfigTable)

Example 4 with ConfigurationResponse

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);
}
Also used : GroupConfigurationResponse(org.apache.skywalking.oap.server.configuration.service.GroupConfigurationResponse) ConfigurationResponse(org.apache.skywalking.oap.server.configuration.service.ConfigurationResponse) ConfigurationRequest(org.apache.skywalking.oap.server.configuration.service.ConfigurationRequest) ConfigTable(org.apache.skywalking.oap.server.configuration.api.ConfigTable) GroupConfigTable(org.apache.skywalking.oap.server.configuration.api.GroupConfigTable)

Aggregations

ConfigurationResponse (org.apache.skywalking.oap.server.configuration.service.ConfigurationResponse)4 GroupConfigurationResponse (org.apache.skywalking.oap.server.configuration.service.GroupConfigurationResponse)4 ConfigTable (org.apache.skywalking.oap.server.configuration.api.ConfigTable)2 GroupConfigTable (org.apache.skywalking.oap.server.configuration.api.GroupConfigTable)2 ConfigurationRequest (org.apache.skywalking.oap.server.configuration.service.ConfigurationRequest)2