Search in sources :

Example 1 with BrokerInfo

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo in project zeebe-process-test by camunda.

the class GrpcToLogStreamGateway method topology.

@Override
public void topology(final TopologyRequest request, final StreamObserver<TopologyResponse> responseObserver) {
    final Partition partition = GatewayOuterClass.Partition.newBuilder().setHealth(GatewayOuterClass.Partition.PartitionBrokerHealth.HEALTHY).setRole(GatewayOuterClass.Partition.PartitionBrokerRole.LEADER).setPartitionId(partitionId).build();
    final BrokerInfo brokerInfo = GatewayOuterClass.BrokerInfo.newBuilder().addPartitions(partition).setHost("0.0.0.0").setPort(port).setVersion(VersionUtil.getVersion()).build();
    final TopologyResponse topologyResponse = GatewayOuterClass.TopologyResponse.newBuilder().addBrokers(brokerInfo).setClusterSize(1).setPartitionsCount(partitionCount).setReplicationFactor(1).setGatewayVersion(VersionUtil.getVersion()).build();
    responseObserver.onNext(topologyResponse);
    responseObserver.onCompleted();
}
Also used : Partition(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) BrokerInfo(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)

Example 2 with BrokerInfo

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo in project zeebe by zeebe-io.

the class EndpointManager method topology.

public void topology(final ServerStreamObserver<TopologyResponse> responseObserver) {
    final TopologyResponse.Builder topologyResponseBuilder = TopologyResponse.newBuilder();
    final BrokerClusterState topology = topologyManager.getTopology();
    final String gatewayVersion = VersionUtil.getVersion();
    if (gatewayVersion != null && !gatewayVersion.isBlank()) {
        topologyResponseBuilder.setGatewayVersion(gatewayVersion);
    }
    final ArrayList<BrokerInfo> brokers = new ArrayList<>();
    if (topology != null) {
        topologyResponseBuilder.setClusterSize(topology.getClusterSize()).setPartitionsCount(topology.getPartitionsCount()).setReplicationFactor(topology.getReplicationFactor());
        topology.getBrokers().forEach(brokerId -> {
            final Builder brokerInfo = BrokerInfo.newBuilder();
            addBrokerInfo(brokerInfo, brokerId, topology);
            addPartitionInfoToBrokerInfo(brokerInfo, brokerId, topology);
            brokers.add(brokerInfo.build());
        });
    }
    topologyResponseBuilder.addAllBrokers(brokers);
    final TopologyResponse response = topologyResponseBuilder.build();
    responseObserver.onNext(response);
    responseObserver.onCompleted();
}
Also used : BrokerClusterState(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterState) Builder(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo.Builder) ArrayList(java.util.ArrayList) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) BrokerInfo(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)

Example 3 with BrokerInfo

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo in project zeebe by camunda-cloud.

the class EndpointManager method topology.

public void topology(final ServerStreamObserver<TopologyResponse> responseObserver) {
    final TopologyResponse.Builder topologyResponseBuilder = TopologyResponse.newBuilder();
    final BrokerClusterState topology = topologyManager.getTopology();
    final String gatewayVersion = VersionUtil.getVersion();
    if (gatewayVersion != null && !gatewayVersion.isBlank()) {
        topologyResponseBuilder.setGatewayVersion(gatewayVersion);
    }
    final ArrayList<BrokerInfo> brokers = new ArrayList<>();
    if (topology != null) {
        topologyResponseBuilder.setClusterSize(topology.getClusterSize()).setPartitionsCount(topology.getPartitionsCount()).setReplicationFactor(topology.getReplicationFactor());
        topology.getBrokers().forEach(brokerId -> {
            final Builder brokerInfo = BrokerInfo.newBuilder();
            addBrokerInfo(brokerInfo, brokerId, topology);
            addPartitionInfoToBrokerInfo(brokerInfo, brokerId, topology);
            brokers.add(brokerInfo.build());
        });
    }
    topologyResponseBuilder.addAllBrokers(brokers);
    final TopologyResponse response = topologyResponseBuilder.build();
    responseObserver.onNext(response);
    responseObserver.onCompleted();
}
Also used : BrokerClusterState(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterState) Builder(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo.Builder) ArrayList(java.util.ArrayList) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) BrokerInfo(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)

Example 4 with BrokerInfo

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo in project zeebe-process-test by camunda-cloud.

the class GrpcToLogStreamGateway method topology.

@Override
public void topology(final TopologyRequest request, final StreamObserver<TopologyResponse> responseObserver) {
    final Partition partition = GatewayOuterClass.Partition.newBuilder().setHealth(GatewayOuterClass.Partition.PartitionBrokerHealth.HEALTHY).setRole(GatewayOuterClass.Partition.PartitionBrokerRole.LEADER).setPartitionId(partitionId).build();
    final BrokerInfo brokerInfo = GatewayOuterClass.BrokerInfo.newBuilder().addPartitions(partition).setHost("0.0.0.0").setPort(port).setVersion(VersionUtil.getVersion()).build();
    final TopologyResponse topologyResponse = GatewayOuterClass.TopologyResponse.newBuilder().addBrokers(brokerInfo).setClusterSize(1).setPartitionsCount(partitionCount).setReplicationFactor(1).setGatewayVersion(VersionUtil.getVersion()).build();
    responseObserver.onNext(topologyResponse);
    responseObserver.onCompleted();
}
Also used : Partition(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) BrokerInfo(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)

Example 5 with BrokerInfo

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo in project zeebe by camunda.

the class EndpointManager method topology.

public void topology(final ServerStreamObserver<TopologyResponse> responseObserver) {
    final TopologyResponse.Builder topologyResponseBuilder = TopologyResponse.newBuilder();
    final BrokerClusterState topology = topologyManager.getTopology();
    if (topology == null) {
        final StatusRuntimeException error = Status.UNAVAILABLE.augmentDescription("No brokers available").asRuntimeException();
        responseObserver.onError(error);
        return;
    }
    topologyResponseBuilder.setClusterSize(topology.getClusterSize()).setPartitionsCount(topology.getPartitionsCount()).setReplicationFactor(topology.getReplicationFactor());
    final String gatewayVersion = VersionUtil.getVersion();
    if (gatewayVersion != null && !gatewayVersion.isBlank()) {
        topologyResponseBuilder.setGatewayVersion(gatewayVersion);
    }
    final ArrayList<BrokerInfo> brokers = new ArrayList<>();
    topology.getBrokers().forEach(brokerId -> {
        final Builder brokerInfo = BrokerInfo.newBuilder();
        addBrokerInfo(brokerInfo, brokerId, topology);
        addPartitionInfoToBrokerInfo(brokerInfo, brokerId, topology);
        brokers.add(brokerInfo.build());
    });
    topologyResponseBuilder.addAllBrokers(brokers);
    final TopologyResponse response = topologyResponseBuilder.build();
    responseObserver.onNext(response);
    responseObserver.onCompleted();
}
Also used : BrokerClusterState(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterState) Builder(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo.Builder) StatusRuntimeException(io.grpc.StatusRuntimeException) ArrayList(java.util.ArrayList) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) BrokerInfo(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)

Aggregations

BrokerInfo (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)5 TopologyResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse)5 BrokerClusterState (io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterState)3 Builder (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo.Builder)3 ArrayList (java.util.ArrayList)3 Partition (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition)2 StatusRuntimeException (io.grpc.StatusRuntimeException)1