public BrokerCfg getConfig() { return brokerContext.getBrokerConfiguration(); } }
public BrokerCfg getConfig() { return brokerContext.getBrokerConfiguration(); } }
@Override public void init(final SystemContext context) { final EmbeddedGatewayCfg config = context.getBrokerConfiguration().getGateway(); if (config.isEnable()) { try { final Gateway gateway = new Gateway(config); gateway.start(); context.setGatewayResourceReleasingDelegate(gateway::stop); } catch (final IOException e) { throw new RuntimeException("Gateway was not able to start", e); } } } }
@Override public void init(final SystemContext context) { final EmbeddedGatewayCfg config = context.getBrokerConfiguration().getGateway(); if (config.isEnable()) { try { final Gateway gateway = new Gateway(config); gateway.start(); context.setGatewayResourceReleasingDelegate(gateway::stop); } catch (final IOException e) { throw new RuntimeException("Gateway was not able to start", e); } } } }
private void initPartitions( final CompositeServiceBuilder baseLayerInstall, final SystemContext context) { final RaftPersistentConfigurationManagerService raftConfigurationManagerService = new RaftPersistentConfigurationManagerService(context.getBrokerConfiguration()); baseLayerInstall .createService(RAFT_CONFIGURATION_MANAGER, raftConfigurationManagerService) .install(); final BootstrapPartitions raftBootstrapService = new BootstrapPartitions(context.getBrokerConfiguration()); baseLayerInstall .createService(RAFT_BOOTSTRAP_SERVICE, raftBootstrapService) .dependency( RAFT_CONFIGURATION_MANAGER, raftBootstrapService.getConfigurationManagerInjector()) .install(); } }
private void initPartitions( final CompositeServiceBuilder baseLayerInstall, final SystemContext context) { final RaftPersistentConfigurationManagerService raftConfigurationManagerService = new RaftPersistentConfigurationManagerService(context.getBrokerConfiguration()); baseLayerInstall .createService(RAFT_CONFIGURATION_MANAGER, raftConfigurationManagerService) .install(); final BootstrapPartitions raftBootstrapService = new BootstrapPartitions(context.getBrokerConfiguration()); baseLayerInstall .createService(RAFT_BOOTSTRAP_SERVICE, raftBootstrapService) .dependency( RAFT_CONFIGURATION_MANAGER, raftBootstrapService.getConfigurationManagerInjector()) .install(); } }
@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); } }
@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); } }
@Override public void init(SystemContext context) { final ServiceContainer serviceContainer = context.getServiceContainer(); final List<ExporterCfg> exporters = context.getBrokerConfiguration().getExporters(); if (!exporters.isEmpty()) { final ExporterManagerService exporterManagerService = new ExporterManagerService(exporters); serviceContainer .createService(EXPORTER_MANAGER, exporterManagerService) .dependency( STREAM_PROCESSOR_SERVICE_FACTORY, exporterManagerService.getStreamProcessorServiceFactoryInjector()) .groupReference( LEADER_PARTITION_GROUP_NAME, exporterManagerService.getPartitionsGroupReference()) .install(); } } }
@Override public void init(SystemContext context) { final ServiceContainer serviceContainer = context.getServiceContainer(); final List<ExporterCfg> exporters = context.getBrokerConfiguration().getExporters(); if (!exporters.isEmpty()) { final ExporterManagerService exporterManagerService = new ExporterManagerService(exporters); serviceContainer .createService(EXPORTER_MANAGER, exporterManagerService) .dependency( STREAM_PROCESSOR_SERVICE_FACTORY, exporterManagerService.getStreamProcessorServiceFactoryInjector()) .groupReference( LEADER_PARTITION_GROUP_NAME, exporterManagerService.getPartitionsGroupReference()) .install(); } } }
private void initGossip( final CompositeServiceBuilder baseLayerInstall, final SystemContext context, final NodeInfo localMember) { final GossipService gossipService = new GossipService(context.getBrokerConfiguration()); baseLayerInstall .createService(GOSSIP_SERVICE, gossipService) .dependency( TransportServiceNames.clientTransport(TransportServiceNames.MANAGEMENT_API_CLIENT_NAME), gossipService.getClientTransportInjector()) .dependency( TransportServiceNames.bufferingServerTransport( TransportServiceNames.MANAGEMENT_API_SERVER_NAME), gossipService.getBufferingServerTransportInjector()) .install(); // TODO: decide whether failure to join gossip cluster should result in broker startup fail final GossipJoinService gossipJoinService = new GossipJoinService(context.getBrokerConfiguration().getCluster(), localMember); baseLayerInstall .createService(GOSSIP_JOIN_SERVICE, gossipJoinService) .dependency(GOSSIP_SERVICE, gossipJoinService.getGossipInjector()) .install(); final AtomixService atomixService = new AtomixService(context.getBrokerConfiguration()); baseLayerInstall.createService(ATOMIX_SERVICE, atomixService).install(); }
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 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(); }
private void initGossip( final CompositeServiceBuilder baseLayerInstall, final SystemContext context, final NodeInfo localMember) { final GossipService gossipService = new GossipService(context.getBrokerConfiguration()); baseLayerInstall .createService(GOSSIP_SERVICE, gossipService) .dependency( TransportServiceNames.clientTransport(TransportServiceNames.MANAGEMENT_API_CLIENT_NAME), gossipService.getClientTransportInjector()) .dependency( TransportServiceNames.bufferingServerTransport( TransportServiceNames.MANAGEMENT_API_SERVER_NAME), gossipService.getBufferingServerTransportInjector()) .install(); // TODO: decide whether failure to join gossip cluster should result in broker startup fail final GossipJoinService gossipJoinService = new GossipJoinService(context.getBrokerConfiguration().getCluster(), localMember); baseLayerInstall .createService(GOSSIP_JOIN_SERVICE, gossipJoinService) .dependency(GOSSIP_SERVICE, gossipJoinService.getGossipInjector()) .install(); }
@Override public void init(final SystemContext context) { final ServiceContainer serviceContainer = context.getServiceContainer(); final MetricsFileWriterService metricsFileWriterService = new MetricsFileWriterService(context.getBrokerConfiguration().getMetrics()); serviceContainer.createService(METRICS_FILE_WRITER, metricsFileWriterService).install(); final LeaderManagementRequestHandler requestHandlerService = new LeaderManagementRequestHandler(); serviceContainer .createService(LEADER_MANAGEMENT_REQUEST_HANDLER, requestHandlerService) .dependency( bufferingServerTransport(MANAGEMENT_API_SERVER_NAME), requestHandlerService.getManagementApiServerTransportInjector()) .groupReference( LEADER_PARTITION_GROUP_NAME, requestHandlerService.getLeaderPartitionsGroupReference()) .install(); } }
private void createClientTransports(final SystemContext context) { final ServiceContainer serviceContainer = context.getServiceContainer(); final BrokerCfg brokerCfg = context.getBrokerConfiguration(); final NetworkCfg networkCfg = brokerCfg.getNetwork(); final int nodeId = brokerCfg.getCluster().getNodeId(); final SocketAddress managementEndpoint = networkCfg.getManagement().toSocketAddress(); final SocketAddress subscriptionEndpoint = networkCfg.getSubscription().toSocketAddress(); final ActorFuture<ClientTransport> managementClientFuture = createClientTransport( serviceContainer, MANAGEMENT_API_CLIENT_NAME, new ByteValue(networkCfg.getDefaultSendBufferSize()), Collections.singletonList(new IntTuple<>(nodeId, managementEndpoint))); context.addRequiredStartAction(managementClientFuture); final ActorFuture<ClientTransport> replicationClientFuture = createClientTransport( serviceContainer, REPLICATION_API_CLIENT_NAME, new ByteValue(networkCfg.getDefaultSendBufferSize()), null); context.addRequiredStartAction(replicationClientFuture); final ActorFuture<ClientTransport> subscriptionClientFuture = createClientTransport( serviceContainer, SUBSCRIPTION_API_CLIENT_NAME, new ByteValue(networkCfg.getDefaultSendBufferSize()), Collections.singletonList(new IntTuple<>(nodeId, subscriptionEndpoint))); context.addRequiredStartAction(subscriptionClientFuture); }
@Override public void init(final SystemContext context) { final ServiceContainer serviceContainer = context.getServiceContainer(); final MetricsFileWriterService metricsFileWriterService = new MetricsFileWriterService(context.getBrokerConfiguration().getMetrics()); serviceContainer.createService(METRICS_FILE_WRITER, metricsFileWriterService).install(); final LeaderManagementRequestHandler requestHandlerService = new LeaderManagementRequestHandler(); serviceContainer .createService(LEADER_MANAGEMENT_REQUEST_HANDLER, requestHandlerService) .dependency( bufferingServerTransport(MANAGEMENT_API_SERVER_NAME), requestHandlerService.getManagementApiServerTransportInjector()) .groupReference( LEADER_PARTITION_GROUP_NAME, requestHandlerService.getLeaderPartitionsGroupReference()) .install(); } }
private void createClientTransports(final SystemContext context) { final ServiceContainer serviceContainer = context.getServiceContainer(); final BrokerCfg brokerCfg = context.getBrokerConfiguration(); final NetworkCfg networkCfg = brokerCfg.getNetwork(); final int nodeId = brokerCfg.getCluster().getNodeId(); final SocketAddress managementEndpoint = networkCfg.getManagement().toSocketAddress(); final SocketAddress subscriptionEndpoint = networkCfg.getSubscription().toSocketAddress(); final ActorFuture<ClientTransport> managementClientFuture = createClientTransport( serviceContainer, MANAGEMENT_API_CLIENT_NAME, new ByteValue(networkCfg.getDefaultSendBufferSize()), Collections.singletonList(new IntTuple<>(nodeId, managementEndpoint))); context.addRequiredStartAction(managementClientFuture); final ActorFuture<ClientTransport> replicationClientFuture = createClientTransport( serviceContainer, REPLICATION_API_CLIENT_NAME, new ByteValue(networkCfg.getDefaultSendBufferSize()), null); context.addRequiredStartAction(replicationClientFuture); final ActorFuture<ClientTransport> subscriptionClientFuture = createClientTransport( serviceContainer, SUBSCRIPTION_API_CLIENT_NAME, new ByteValue(networkCfg.getDefaultSendBufferSize()), Collections.singletonList(new IntTuple<>(nodeId, subscriptionEndpoint))); context.addRequiredStartAction(subscriptionClientFuture); }
@Override public void init(SystemContext context) { final ServiceContainer serviceContainer = context.getServiceContainer(); final BrokerCfg brokerConfiguration = context.getBrokerConfiguration();
private void initClusterBaseLayer( final SystemContext context, final ServiceContainer serviceContainer) { final BrokerCfg brokerConfig = context.getBrokerConfiguration(); final NetworkCfg networkCfg = brokerConfig.getNetwork(); final CompositeServiceBuilder baseLayerInstall =