private static Broker startBrokerFromConfiguration(final String[] args) { String basePath = System.getProperty("basedir"); if (basePath == null) { basePath = Paths.get(".").toAbsolutePath().normalize().toString(); } return new Broker(args[0], basePath, null); }
@Override public void run() { try { if (broker != null) { broker.close(); } } finally { deleteTempDirectory(); } } });
public Broker(final SystemContext systemContext) { this.brokerContext = systemContext; LogUtil.doWithMDC(systemContext.getDiagnosticContext(), () -> start()); }
public void startBroker() { startTime = System.currentTimeMillis(); broker = new Broker(brokerCfg, newTemporaryFolder.getAbsolutePath(), controlledActorClock); final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); try { // Hack: block until the system stream processor is available // this is required in the broker-test suite, because the client rule does not perform request // retries // How to make it better: https://github.com/zeebe-io/zeebe/issues/196 final String partitionName = Partition.getPartitionName(Protocol.DEPLOYMENT_PARTITION); serviceContainer .createService(TestService.NAME, new TestService()) .dependency(ClusterBaseLayerServiceNames.leaderPartitionServiceName(partitionName)) .dependency( TransportServiceNames.serverTransport(TransportServiceNames.CLIENT_API_SERVER_NAME)) .dependency(WORKFLOW_REPOSITORY_SERVICE) .install() .get(timeout, TimeUnit.SECONDS); } catch (final InterruptedException | ExecutionException | TimeoutException e) { stopBroker(); throw new RuntimeException( String.format( "System partition not installed into the container withing %d seconds.", timeout), e); } dataDirectories = broker.getBrokerContext().getBrokerConfiguration().getData().getDirectories(); }
public <T> void removeService(final ServiceName<T> name) { try { broker.getBrokerContext().getServiceContainer().removeService(name).get(10, TimeUnit.SECONDS); } catch (final InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException("Could not remove service " + name.getName() + " in 10 seconds."); } }
protected void start() { LOG.info("Version: {}", VERSION); LOG.info("Starting broker with configuration {}", getConfig().toJson()); brokerContext.addComponent(new SystemComponent()); brokerContext.addComponent(new TransportComponent()); brokerContext.addComponent(new LogStreamsComponent()); brokerContext.addComponent(new SubscriptionComponent()); brokerContext.addComponent(new ClusterComponent()); brokerContext.addComponent(new GatewayComponent()); brokerContext.addComponent(new ExporterComponent()); brokerContext.init(); }
public void startBroker() { startTime = System.currentTimeMillis(); broker = new Broker(brokerCfg, newTemporaryFolder.getAbsolutePath(), controlledActorClock); final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); try { // Hack: block until the system stream processor is available // this is required in the broker-test suite, because the client rule does not perform request // retries // How to make it better: https://github.com/zeebe-io/zeebe/issues/196 final String partitionName = Partition.getPartitionName(Protocol.DEPLOYMENT_PARTITION); serviceContainer .createService(TestService.NAME, new TestService()) .dependency(ClusterBaseLayerServiceNames.leaderPartitionServiceName(partitionName)) .dependency( TransportServiceNames.serverTransport(TransportServiceNames.CLIENT_API_SERVER_NAME)) .dependency(WORKFLOW_REPOSITORY_SERVICE) .install() .get(timeout, TimeUnit.SECONDS); } catch (final InterruptedException | ExecutionException | TimeoutException e) { stopBroker(); throw new RuntimeException( String.format( "System partition not installed into the container withing %d seconds.", timeout), e); } dataDirectories = broker.getBrokerContext().getBrokerConfiguration().getData().getDirectories(); }
public <T> void removeService(final ServiceName<T> name) { try { broker.getBrokerContext().getServiceContainer().removeService(name).get(10, TimeUnit.SECONDS); } catch (final InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException("Could not remove service " + name.getName() + " in 10 seconds."); } }
protected void start() { LOG.info("Version: {}", VERSION); LOG.info("Starting broker with configuration {}", getConfig().toJson()); brokerContext.addComponent(new SystemComponent()); brokerContext.addComponent(new TransportComponent()); brokerContext.addComponent(new LogStreamsComponent()); brokerContext.addComponent(new SubscriptionComponent()); brokerContext.addComponent(new ClusterComponent()); brokerContext.addComponent(new GatewayComponent()); brokerContext.addComponent(new ExporterComponent()); brokerContext.init(); }
broker = new Broker(brokerCfg, newTemporaryFolder.getAbsolutePath(), controlledActorClock); final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); dataDirectories = broker.getBrokerContext().getBrokerConfiguration().getData().getDirectories();
@Test public void shouldPersistConfigurationAsJSON() throws IOException { final int partitionId = 0; final BrokerCfg brokerCfg = brokerRule.getBroker().getBrokerContext().getBrokerConfiguration(); final ObjectReader jsonReader = new ObjectMapper().readerFor(RaftConfigurationMetadata.class); final String dataDirectory = brokerCfg.getData().getDirectories().get(0); final File configFile = new File(String.format("%s/partition-%d/partition.json", dataDirectory, partitionId)); final RaftConfigurationMetadata persisted = jsonReader.readValue(configFile); assertThat(persisted.getPartitionId()).isEqualTo(partitionId); } }
public void stopBroker() { if (broker != null) { broker.close(); broker = null; System.gc(); } }
private static Broker startDefaultBrokerInTempDirectory() { Loggers.SYSTEM_LOGGER.info("No configuration file specified. Using default configuration."); try { tempFolder = Files.createTempDirectory("zeebe").toAbsolutePath().normalize().toString(); final BrokerCfg cfg = new BrokerCfg(); return new Broker(cfg, tempFolder, null); } catch (final IOException e) { throw new RuntimeException("Could not start broker", e); } }
public Broker(final SystemContext systemContext) { this.brokerContext = systemContext; LogUtil.doWithMDC(systemContext.getDiagnosticContext(), () -> start()); }
broker = new Broker(brokerCfg, newTemporaryFolder.getAbsolutePath(), controlledActorClock); final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); dataDirectories = broker.getBrokerContext().getBrokerConfiguration().getData().getDirectories();
@Test public void shouldPersistConfigurationAsJSON() throws IOException { final int partitionId = 0; final BrokerCfg brokerCfg = brokerRule.getBroker().getBrokerContext().getBrokerConfiguration(); final ObjectReader jsonReader = new ObjectMapper().readerFor(RaftConfigurationMetadata.class); final String dataDirectory = brokerCfg.getData().getDirectories().get(0); final File configFile = new File(String.format("%s/partition-%d/partition.json", dataDirectory, partitionId)); final RaftConfigurationMetadata persisted = jsonReader.readValue(configFile); assertThat(persisted.getPartitionId()).isEqualTo(partitionId); } }
public void stopBroker() { if (broker != null) { broker.close(); broker = null; System.gc(); } }
public <T> void installService( Function<ServiceContainer, ServiceBuilder<T>> serviceBuilderFactory) { final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); final ServiceBuilder<T> serviceBuilder = serviceBuilderFactory.apply(serviceContainer); try { serviceBuilder.install().get(10, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException("Could not install service: " + serviceBuilder.getName(), e); } }
public void stopBroker() { if (broker != null) { broker.close(); broker = null; System.gc(); } }
public <T> void installService( Function<ServiceContainer, ServiceBuilder<T>> serviceBuilderFactory) { final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); final ServiceBuilder<T> serviceBuilder = serviceBuilderFactory.apply(serviceContainer); try { serviceBuilder.install().get(10, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException("Could not install service: " + serviceBuilder.getName(), e); } }