Search in sources :

Example 1 with ServiceContainer

use of io.zeebe.servicecontainer.ServiceContainer in project zeebe by zeebe-io.

the class TransportComponent method init.

@Override
public void init(SystemContext context) {
    final TransportComponentCfg transportComponentCfg = context.getConfigurationManager().readEntry("network", TransportComponentCfg.class);
    final ServiceContainer serviceContainer = context.getServiceContainer();
    final ActorFuture<Void> replactionApiFuture = bindNonBufferingProtocolEndpoint(serviceContainer, REPLICATION_API_SERVER_NAME, transportComponentCfg.replicationApi, transportComponentCfg, REPLICATION_API_MESSAGE_HANDLER, REPLICATION_API_MESSAGE_HANDLER);
    final ActorFuture<Void> managementApiFuture = bindBufferingProtocolEndpoint(serviceContainer, MANAGEMENT_API_SERVER_NAME, transportComponentCfg.managementApi, transportComponentCfg);
    final ActorFuture<Void> clientApiFuture = bindNonBufferingProtocolEndpoint(serviceContainer, CLIENT_API_SERVER_NAME, transportComponentCfg.clientApi, transportComponentCfg, CLIENT_API_MESSAGE_HANDLER, CLIENT_API_MESSAGE_HANDLER);
    final SocketAddress managementEndpoint = transportComponentCfg.managementApi.toSocketAddress(transportComponentCfg.host);
    final ActorFuture<Void> managementClientFuture = createClientTransport(serviceContainer, MANAGEMENT_API_CLIENT_NAME, transportComponentCfg.managementApi.getReceiveBufferSize(transportComponentCfg.defaultReceiveBufferSize), MGMT_REQUEST_POOL_SIZE, true, Collections.singletonList(managementEndpoint));
    final ActorFuture<Void> replicationClientFuture = createClientTransport(serviceContainer, REPLICATION_API_CLIENT_NAME, transportComponentCfg.replicationApi.getReceiveBufferSize(transportComponentCfg.defaultReceiveBufferSize), MGMT_REQUEST_POOL_SIZE, false, null);
    final ServiceName<Dispatcher> controlMessageBufferService = createReceiveBuffer(serviceContainer, CLIENT_API_SERVER_NAME, transportComponentCfg.clientApi.getReceiveBufferSize(transportComponentCfg.defaultReceiveBufferSize));
    final ClientApiMessageHandlerService messageHandlerService = new ClientApiMessageHandlerService();
    serviceContainer.createService(CLIENT_API_MESSAGE_HANDLER, messageHandlerService).dependency(controlMessageBufferService, messageHandlerService.getControlMessageBufferInjector()).groupReference(LogStreamServiceNames.WORKFLOW_STREAM_GROUP, messageHandlerService.getLogStreamsGroupReference()).groupReference(LogStreamServiceNames.SYSTEM_STREAM_GROUP, messageHandlerService.getLogStreamsGroupReference()).install();
    final RaftApiMessageHandlerService raftApiMessageHandlerService = new RaftApiMessageHandlerService();
    serviceContainer.createService(REPLICATION_API_MESSAGE_HANDLER, raftApiMessageHandlerService).groupReference(ClusterServiceNames.RAFT_SERVICE_GROUP, raftApiMessageHandlerService.getRaftGroupReference()).install();
    final long controlMessageRequestTimeoutInMillis = transportComponentCfg.clientApi.getControlMessageRequestTimeoutInMillis(Long.MAX_VALUE);
    final ControlMessageHandlerManagerService controlMessageHandlerManagerService = new ControlMessageHandlerManagerService(controlMessageRequestTimeoutInMillis);
    final ActorFuture<Void> controlMessageServiceFuture = serviceContainer.createService(TransportServiceNames.CONTROL_MESSAGE_HANDLER_MANAGER, controlMessageHandlerManagerService).dependency(controlMessageBufferService, controlMessageHandlerManagerService.getControlMessageBufferInjector()).dependency(TransportServiceNames.serverTransport(CLIENT_API_SERVER_NAME), controlMessageHandlerManagerService.getTransportInjector()).dependency(TaskQueueServiceNames.TASK_QUEUE_SUBSCRIPTION_MANAGER, controlMessageHandlerManagerService.getTaskSubscriptionManagerInjector()).dependency(TopicSubscriptionServiceNames.TOPIC_SUBSCRIPTION_SERVICE, controlMessageHandlerManagerService.getTopicSubscriptionServiceInjector()).dependency(SystemServiceNames.SYSTEM_LOG_MANAGER, controlMessageHandlerManagerService.getSystemPartitionManagerInjector()).dependency(ClusterServiceNames.CLUSTER_MANAGER_SERVICE, controlMessageHandlerManagerService.getClusterManagerInjector()).install();
    context.addRequiredStartAction(replactionApiFuture);
    context.addRequiredStartAction(managementApiFuture);
    context.addRequiredStartAction(clientApiFuture);
    context.addRequiredStartAction(managementClientFuture);
    context.addRequiredStartAction(replicationClientFuture);
    context.addRequiredStartAction(controlMessageServiceFuture);
}
Also used : TransportComponentCfg(io.zeebe.broker.transport.cfg.TransportComponentCfg) ServiceContainer(io.zeebe.servicecontainer.ServiceContainer) RaftApiMessageHandlerService(io.zeebe.broker.clustering.raft.RaftApiMessageHandlerService) ControlMessageHandlerManagerService(io.zeebe.broker.transport.controlmessage.ControlMessageHandlerManagerService) InetSocketAddress(java.net.InetSocketAddress) ClientApiMessageHandlerService(io.zeebe.broker.transport.clientapi.ClientApiMessageHandlerService)

Example 2 with ServiceContainer

use of io.zeebe.servicecontainer.ServiceContainer in project zeebe by zeebe-io.

the class WorkflowComponent method init.

@Override
public void init(SystemContext context) {
    final ServiceContainer serviceContainer = context.getServiceContainer();
    final ConfigurationManager configurationManager = context.getConfigurationManager();
    final WorkflowQueueManagerService workflowQueueManagerService = new WorkflowQueueManagerService(configurationManager);
    serviceContainer.createService(WORKFLOW_QUEUE_MANAGER, workflowQueueManagerService).dependency(TransportServiceNames.serverTransport(TransportServiceNames.CLIENT_API_SERVER_NAME), workflowQueueManagerService.getClientApiTransportInjector()).dependency(TransportServiceNames.bufferingServerTransport(TransportServiceNames.MANAGEMENT_API_SERVER_NAME), workflowQueueManagerService.getManagementServerInjector()).groupReference(WORKFLOW_STREAM_GROUP, workflowQueueManagerService.getLogStreamsGroupReference()).install();
}
Also used : ServiceContainer(io.zeebe.servicecontainer.ServiceContainer)

Example 3 with ServiceContainer

use of io.zeebe.servicecontainer.ServiceContainer in project zeebe by zeebe-io.

the class SystemComponent method init.

@Override
public void init(SystemContext context) {
    final ServiceContainer serviceContainer = context.getServiceContainer();
    final MetricsFileWriterService metricsFileWriterService = new MetricsFileWriterService(context.getConfigurationManager().readEntry("metrics", MetricsCfg.class));
    serviceContainer.createService(METRICS_FILE_WRITER, metricsFileWriterService).install();
    final SystemConfiguration systemConfiguration = context.getConfigurationManager().readEntry("system", SystemConfiguration.class);
    final PartitionManagerService partitionManagerService = new PartitionManagerService();
    serviceContainer.createService(SystemServiceNames.PARTITION_MANAGER_SERVICE, partitionManagerService).dependency(ClusterServiceNames.MEMBER_LIST_SERVICE, partitionManagerService.getMemberListServiceInjector()).dependency(TransportServiceNames.clientTransport(TransportServiceNames.MANAGEMENT_API_CLIENT_NAME), partitionManagerService.getManagementClientInjector()).install();
    final SystemPartitionManager systemPartitionManager = new SystemPartitionManager(systemConfiguration);
    serviceContainer.createService(SystemServiceNames.SYSTEM_LOG_MANAGER, systemPartitionManager).dependency(TransportServiceNames.serverTransport(TransportServiceNames.CLIENT_API_SERVER_NAME), systemPartitionManager.getClientApiTransportInjector()).dependency(PARTITION_MANAGER_SERVICE, systemPartitionManager.getPartitionManagerInjector()).groupReference(LogStreamServiceNames.SYSTEM_STREAM_GROUP, systemPartitionManager.getLogStreamsGroupReference()).install();
    final DeploymentManager deploymentManagerService = new DeploymentManager(systemConfiguration);
    serviceContainer.createService(SystemServiceNames.DEPLOYMENT_MANAGER_SERVICE, deploymentManagerService).dependency(TransportServiceNames.clientTransport(TransportServiceNames.MANAGEMENT_API_CLIENT_NAME), deploymentManagerService.getManagementClientInjector()).dependency(TransportServiceNames.serverTransport(TransportServiceNames.CLIENT_API_SERVER_NAME), deploymentManagerService.getClientApiTransportInjector()).dependency(PARTITION_MANAGER_SERVICE, deploymentManagerService.getPartitionManagerInjector()).groupReference(LogStreamServiceNames.SYSTEM_STREAM_GROUP, deploymentManagerService.getSystemStreamGroupReference()).install();
    final WorkflowRequestMessageHandlerService workflowRequestHandlerService = new WorkflowRequestMessageHandlerService();
    serviceContainer.createService(WORKFLOW_REQUEST_MESSAGE_HANDLER_SERVICE, workflowRequestHandlerService).groupReference(LogStreamServiceNames.WORKFLOW_STREAM_GROUP, workflowRequestHandlerService.getLogStreamsGroupReference()).install();
}
Also used : ServiceContainer(io.zeebe.servicecontainer.ServiceContainer) WorkflowRequestMessageHandlerService(io.zeebe.broker.system.deployment.service.WorkflowRequestMessageHandlerService) DeploymentManager(io.zeebe.broker.system.deployment.service.DeploymentManager) PartitionManagerService(io.zeebe.broker.system.log.PartitionManagerService) SystemPartitionManager(io.zeebe.broker.system.log.SystemPartitionManager) MetricsCfg(io.zeebe.broker.system.metrics.cfg.MetricsCfg) MetricsFileWriterService(io.zeebe.broker.system.metrics.MetricsFileWriterService)

Example 4 with ServiceContainer

use of io.zeebe.servicecontainer.ServiceContainer 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 5 with ServiceContainer

use of io.zeebe.servicecontainer.ServiceContainer in project zeebe by zeebe-io.

the class TaskQueueComponent method init.

@Override
public void init(SystemContext context) {
    final ServiceContainer serviceContainer = context.getServiceContainer();
    final TaskSubscriptionManagerService taskSubscriptionManagerService = new TaskSubscriptionManagerService();
    serviceContainer.createService(TASK_QUEUE_SUBSCRIPTION_MANAGER, taskSubscriptionManagerService).dependency(TransportServiceNames.serverTransport(TransportServiceNames.CLIENT_API_SERVER_NAME), taskSubscriptionManagerService.getClientApiTransportInjector()).groupReference(WORKFLOW_STREAM_GROUP, taskSubscriptionManagerService.getLogStreamsGroupReference()).install();
    final TaskQueueManagerService taskQueueManagerService = new TaskQueueManagerService();
    serviceContainer.createService(TASK_QUEUE_MANAGER, taskQueueManagerService).dependency(TransportServiceNames.serverTransport(CLIENT_API_SERVER_NAME), taskQueueManagerService.getClientApiTransportInjector()).dependency(TASK_QUEUE_SUBSCRIPTION_MANAGER, taskQueueManagerService.getTaskSubscriptionManagerInjector()).groupReference(WORKFLOW_STREAM_GROUP, taskQueueManagerService.getLogStreamsGroupReference()).install();
}
Also used : ServiceContainer(io.zeebe.servicecontainer.ServiceContainer)

Aggregations

ServiceContainer (io.zeebe.servicecontainer.ServiceContainer)7 TransportComponentCfg (io.zeebe.broker.transport.cfg.TransportComponentCfg)2 Broker (io.zeebe.broker.Broker)1 RaftApiMessageHandlerService (io.zeebe.broker.clustering.raft.RaftApiMessageHandlerService)1 DeploymentManager (io.zeebe.broker.system.deployment.service.DeploymentManager)1 WorkflowRequestMessageHandlerService (io.zeebe.broker.system.deployment.service.WorkflowRequestMessageHandlerService)1 PartitionManagerService (io.zeebe.broker.system.log.PartitionManagerService)1 SystemPartitionManager (io.zeebe.broker.system.log.SystemPartitionManager)1 MetricsFileWriterService (io.zeebe.broker.system.metrics.MetricsFileWriterService)1 MetricsCfg (io.zeebe.broker.system.metrics.cfg.MetricsCfg)1 ClientApiMessageHandlerService (io.zeebe.broker.transport.clientapi.ClientApiMessageHandlerService)1 ControlMessageHandlerManagerService (io.zeebe.broker.transport.controlmessage.ControlMessageHandlerManagerService)1 StreamProcessorController (io.zeebe.logstreams.processor.StreamProcessorController)1 Raft (io.zeebe.raft.Raft)1 Injector (io.zeebe.servicecontainer.Injector)1 InetSocketAddress (java.net.InetSocketAddress)1 ExecutionException (java.util.concurrent.ExecutionException)1 Test (org.junit.Test)1