Search in sources :

Example 1 with BrokerCfg

use of io.camunda.zeebe.broker.system.configuration.BrokerCfg in project zeebe by zeebe-io.

the class EmbeddedBrokerRule method configureBroker.

public void configureBroker(final BrokerCfg brokerCfg) {
    // build-in exporters
    final ExporterCfg exporterCfg = new ExporterCfg();
    exporterCfg.setClassName(RecordingExporter.class.getName());
    brokerCfg.getExporters().put(TEST_RECORD_EXPORTER_ID, exporterCfg);
    // custom configurators
    for (final Consumer<BrokerCfg> configurator : configurators) {
        configurator.accept(brokerCfg);
    }
    // set random port numbers
    assignSocketAddresses(brokerCfg);
}
Also used : ExporterCfg(io.camunda.zeebe.broker.system.configuration.ExporterCfg) BrokerCfg(io.camunda.zeebe.broker.system.configuration.BrokerCfg) RecordingExporter(io.camunda.zeebe.test.util.record.RecordingExporter)

Example 2 with BrokerCfg

use of io.camunda.zeebe.broker.system.configuration.BrokerCfg in project zeebe by camunda.

the class SnapshotDirectorPartitionTransitionStepTest method setup.

@BeforeEach
void setup() {
    transitionContext.setComponentHealthMonitor(mock(HealthMonitor.class));
    transitionContext.setStreamProcessor(mock(StreamProcessor.class));
    transitionContext.setBrokerCfg(new BrokerCfg());
    when(raftPartition.getServer()).thenReturn(raftServer);
    transitionContext.setRaftPartition(raftPartition);
    when(actorSchedulingService.submitActor(any())).thenReturn(TestActorFuture.completedFuture(null));
    transitionContext.setActorSchedulingService(actorSchedulingService);
    when(snapshotDirectorFromPrevRole.closeAsync()).thenReturn(TestActorFuture.completedFuture(null));
    step = new SnapshotDirectorPartitionTransitionStep();
}
Also used : StreamProcessor(io.camunda.zeebe.engine.processing.streamprocessor.StreamProcessor) BrokerCfg(io.camunda.zeebe.broker.system.configuration.BrokerCfg) HealthMonitor(io.camunda.zeebe.util.health.HealthMonitor) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with BrokerCfg

use of io.camunda.zeebe.broker.system.configuration.BrokerCfg in project zeebe by camunda.

the class EmbeddedBrokerRule method startBroker.

public void startBroker(final PartitionListener... listeners) {
    if (brokerCfg == null) {
        try (final InputStream configStream = configSupplier.get()) {
            if (configStream == null) {
                brokerCfg = new BrokerCfg();
            } else {
                brokerCfg = new TestConfigurationFactory().create(null, "zeebe.broker", configStream, BrokerCfg.class);
            }
            configureBroker(brokerCfg);
        } catch (final IOException e) {
            throw new RuntimeException("Unable to open configuration", e);
        }
    }
    systemContext = new SystemContext(brokerCfg, newTemporaryFolder.getAbsolutePath(), controlledActorClock);
    systemContext.getScheduler().start();
    final var additionalListeners = new ArrayList<>(Arrays.asList(listeners));
    final CountDownLatch latch = new CountDownLatch(brokerCfg.getCluster().getPartitionsCount());
    additionalListeners.add(new LeaderPartitionListener(latch));
    broker = new Broker(systemContext, springBrokerBridge, additionalListeners);
    broker.start().join();
    try {
        latch.await(INSTALL_TIMEOUT, INSTALL_TIMEOUT_UNIT);
    } catch (final InterruptedException e) {
        LOG.info("Broker was not started in 15 seconds", e);
        Thread.currentThread().interrupt();
    }
    final EmbeddedGatewayService embeddedGatewayService = broker.getBrokerContext().getEmbeddedGatewayService();
    if (embeddedGatewayService != null) {
        final BrokerClient brokerClient = embeddedGatewayService.get().getBrokerClient();
        waitUntil(() -> {
            final BrokerTopologyManager topologyManager = brokerClient.getTopologyManager();
            final BrokerClusterState topology = topologyManager.getTopology();
            return topology != null && topology.getLeaderForPartition(1) >= 0;
        });
    }
    dataDirectory = broker.getSystemContext().getBrokerConfiguration().getData().getDirectory();
}
Also used : Broker(io.camunda.zeebe.broker.Broker) TestConfigurationFactory(io.camunda.zeebe.test.util.TestConfigurationFactory) SystemContext(io.camunda.zeebe.broker.system.SystemContext) InputStream(java.io.InputStream) BrokerTopologyManager(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerTopologyManager) ArrayList(java.util.ArrayList) IOException(java.io.IOException) CountDownLatch(java.util.concurrent.CountDownLatch) BrokerClient(io.camunda.zeebe.gateway.impl.broker.BrokerClient) BrokerCfg(io.camunda.zeebe.broker.system.configuration.BrokerCfg) EmbeddedGatewayService(io.camunda.zeebe.broker.system.EmbeddedGatewayService) BrokerClusterState(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterState)

Example 4 with BrokerCfg

use of io.camunda.zeebe.broker.system.configuration.BrokerCfg in project zeebe by camunda.

the class Broker method internalStart.

private void internalStart() {
    try {
        brokerContext = brokerStartupActor.start().join();
        healthCheckService.setBrokerStarted();
        startFuture.complete(this);
    } catch (final Exception bootStrapException) {
        final BrokerCfg brokerCfg = getConfig();
        LOG.error("Failed to start broker {}!", brokerCfg.getCluster().getNodeId(), bootStrapException);
        final UncheckedExecutionException exception = new UncheckedExecutionException("Failed to start broker", bootStrapException);
        startFuture.completeExceptionally(exception);
        throw exception;
    }
}
Also used : BrokerCfg(io.camunda.zeebe.broker.system.configuration.BrokerCfg) UncheckedExecutionException(io.camunda.zeebe.util.exception.UncheckedExecutionException) UncheckedExecutionException(io.camunda.zeebe.util.exception.UncheckedExecutionException) ExporterLoadException(io.camunda.zeebe.broker.exporter.repo.ExporterLoadException) ExternalJarLoadException(io.camunda.zeebe.util.jar.ExternalJarLoadException)

Example 5 with BrokerCfg

use of io.camunda.zeebe.broker.system.configuration.BrokerCfg in project zeebe by camunda.

the class SystemContextTest method shouldThrowExceptionWithNetworkSecurityEnabledAndWrongCert.

@Test
void shouldThrowExceptionWithNetworkSecurityEnabledAndWrongCert() throws CertificateException {
    // given
    final var certificate = new SelfSignedCertificate();
    final var brokerCfg = new BrokerCfg();
    brokerCfg.getNetwork().getSecurity().setEnabled(true).setPrivateKeyPath(certificate.privateKey()).setCertificateChainPath(new File("/tmp/i-dont-exist.crt"));
    // when - then
    assertThatCode(() -> initSystemContext(brokerCfg)).isInstanceOf(IllegalArgumentException.class).hasMessage("Expected the configured network security certificate chain path " + "'/tmp/i-dont-exist.crt' to point to a readable file, but it does not");
}
Also used : SelfSignedCertificate(io.netty.handler.ssl.util.SelfSignedCertificate) BrokerCfg(io.camunda.zeebe.broker.system.configuration.BrokerCfg) File(java.io.File) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

BrokerCfg (io.camunda.zeebe.broker.system.configuration.BrokerCfg)87 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)60 Test (org.junit.jupiter.api.Test)54 FixedPartitionCfg (io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg)15 NodeCfg (io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg.NodeCfg)12 Broker (io.camunda.zeebe.broker.Broker)6 SystemContext (io.camunda.zeebe.broker.system.SystemContext)6 UncheckedExecutionException (io.camunda.zeebe.util.exception.UncheckedExecutionException)6 File (java.io.File)6 IOException (java.io.IOException)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 ValueSource (org.junit.jupiter.params.provider.ValueSource)6 ExporterLoadException (io.camunda.zeebe.broker.exporter.repo.ExporterLoadException)3 ExporterCfg (io.camunda.zeebe.broker.system.configuration.ExporterCfg)3 SocketBindingCfg (io.camunda.zeebe.broker.system.configuration.SocketBindingCfg)3 StreamProcessor (io.camunda.zeebe.engine.processing.streamprocessor.StreamProcessor)3 TestConfigurationFactory (io.camunda.zeebe.test.util.TestConfigurationFactory)3 RecordingExporter (io.camunda.zeebe.test.util.record.RecordingExporter)3 HealthMonitor (io.camunda.zeebe.util.health.HealthMonitor)3 ExternalJarLoadException (io.camunda.zeebe.util.jar.ExternalJarLoadException)3