Search in sources :

Example 1 with Broker

use of io.zeebe.broker.Broker in project zeebe by zeebe-io.

the class ClusteringRule method startBroker.

private Broker startBroker(String configFile) {
    final InputStream config = this.getClass().getClassLoader().getResourceAsStream(configFile);
    final Broker broker = new Broker(config);
    autoCloseableRule.manage(broker);
    return broker;
}
Also used : TopologyBroker(io.zeebe.client.clustering.impl.TopologyBroker) Broker(io.zeebe.broker.Broker) InputStream(java.io.InputStream)

Example 2 with Broker

use of io.zeebe.broker.Broker in project zeebe by zeebe-io.

the class ServicesLifecycleTest method shouldShutdownStreamProcessingBeforeLogStream.

@Test
public void shouldShutdownStreamProcessingBeforeLogStream() throws Exception {
    // given
    final Broker broker = brokerRule.getBroker();
    final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer();
    final String logStreamName = ClientApiRule.DEFAULT_TOPIC_NAME + "." + apiRule.getDefaultPartitionId();
    final ServiceName<StreamProcessorController> streamProcessorServiceName = WorkflowQueueServiceNames.workflowInstanceStreamProcessorServiceName(logStreamName);
    final ServiceName<Raft> raftServiceName = ClusterServiceNames.raftServiceName(logStreamName);
    final StreamProcessorController streamProcessorController = getService(serviceContainer, streamProcessorServiceName);
    // when
    serviceContainer.removeService(raftServiceName).get();
    // then
    assertThat(!streamProcessorController.isOpened()).isTrue();
    assertThat(streamProcessorController.isFailed()).isFalse();
}
Also used : Broker(io.zeebe.broker.Broker) ServiceContainer(io.zeebe.servicecontainer.ServiceContainer) StreamProcessorController(io.zeebe.logstreams.processor.StreamProcessorController) Raft(io.zeebe.raft.Raft) Test(org.junit.Test)

Example 3 with Broker

use of io.zeebe.broker.Broker in project zeebe by zeebe-io.

the class ClusteringRule method restartBroker.

/**
 * Restarts broker, if the broker is still running it will be closed before.
 *
 * Returns to the user if the broker is back in the cluster.
 *
 * @param socketAddress
 * @return
 */
public void restartBroker(SocketAddress socketAddress) {
    final Broker broker = brokers.get(socketAddress);
    if (broker != null) {
        stopBroker(socketAddress);
    }
    for (int i = 0; i < brokerAddresses.length; i++) {
        if (brokerAddresses[i].equals(socketAddress)) {
            brokers.put(socketAddress, startBroker(brokerConfigs[i]));
            waitForInternalSystemAndReplicationFactor(replicationFactor);
            break;
        }
    }
    waitUntilBrokerIsAddedToTopology(socketAddress);
}
Also used : TopologyBroker(io.zeebe.client.clustering.impl.TopologyBroker) Broker(io.zeebe.broker.Broker)

Aggregations

Broker (io.zeebe.broker.Broker)3 TopologyBroker (io.zeebe.client.clustering.impl.TopologyBroker)2 StreamProcessorController (io.zeebe.logstreams.processor.StreamProcessorController)1 Raft (io.zeebe.raft.Raft)1 ServiceContainer (io.zeebe.servicecontainer.ServiceContainer)1 InputStream (java.io.InputStream)1 Test (org.junit.Test)1