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