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);
}
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();
}
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();
}
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;
}
}
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");
}
Aggregations