Search in sources :

Example 1 with StreamProcessorController

use of io.zeebe.logstreams.processor.StreamProcessorController in project zeebe by zeebe-io.

the class TaskSubscriptionManager method removeStreamProcessorService.

protected ActorFuture<Void> removeStreamProcessorService(final LockTaskStreamProcessor streamProcessor) {
    final LogStreamBucket logStreamBucket = logStreamBuckets.get(streamProcessor.getLogStreamPartitionId());
    logStreamBucket.removeStreamProcessor(streamProcessor);
    final String logName = logStreamBucket.getLogStream().getLogName();
    final String taskType = bufferAsString(streamProcessor.getSubscriptedTaskType());
    final ServiceName<StreamProcessorController> streamProcessorServiceName = taskQueueLockStreamProcessorServiceName(logName, taskType);
    return serviceContext.removeService(streamProcessorServiceName);
}
Also used : StreamProcessorController(io.zeebe.logstreams.processor.StreamProcessorController) BufferUtil.bufferAsString(io.zeebe.util.buffer.BufferUtil.bufferAsString)

Example 2 with StreamProcessorController

use of io.zeebe.logstreams.processor.StreamProcessorController in project zeebe by zeebe-io.

the class TaskSubscriptionManager method createStreamProcessorService.

protected ActorFuture<Void> createStreamProcessorService(final LockTaskStreamProcessor factory, DirectBuffer newTaskTypeBuffer, final LogStreamBucket logStreamBucket, final DirectBuffer taskType) {
    final TypedStreamEnvironment env = new TypedStreamEnvironment(logStreamBucket.getLogStream(), transport.getOutput());
    final TypedStreamProcessor streamProcessor = factory.createStreamProcessor(env);
    final ServiceName<LogStream> logStreamServiceName = logStreamBucket.getLogServiceName();
    final String logName = logStreamBucket.getLogStream().getLogName();
    final ServiceName<StreamProcessorController> streamProcessorServiceName = taskQueueLockStreamProcessorServiceName(logName, bufferAsString(taskType));
    final String streamProcessorName = streamProcessorServiceName.getName();
    final StreamProcessorService streamProcessorService = new StreamProcessorService(streamProcessorName, TASK_LOCK_STREAM_PROCESSOR_ID, streamProcessor).eventFilter(streamProcessor.buildTypeFilter());
    return serviceContext.createService(streamProcessorServiceName, streamProcessorService).dependency(logStreamServiceName, streamProcessorService.getLogStreamInjector()).dependency(SNAPSHOT_STORAGE_SERVICE, streamProcessorService.getSnapshotStorageInjector()).install();
}
Also used : StreamProcessorController(io.zeebe.logstreams.processor.StreamProcessorController) LogStream(io.zeebe.logstreams.log.LogStream) BufferUtil.bufferAsString(io.zeebe.util.buffer.BufferUtil.bufferAsString) TypedStreamEnvironment(io.zeebe.broker.logstreams.processor.TypedStreamEnvironment) TypedStreamProcessor(io.zeebe.broker.logstreams.processor.TypedStreamProcessor) StreamProcessorService(io.zeebe.broker.logstreams.processor.StreamProcessorService)

Example 3 with StreamProcessorController

use of io.zeebe.logstreams.processor.StreamProcessorController in project zeebe by zeebe-io.

the class TaskQueueManagerService method startTaskQueue.

@Override
public void startTaskQueue(ServiceName<LogStream> logStreamServiceName, final LogStream stream) {
    final ServiceName<StreamProcessorController> streamProcessorServiceName = taskQueueInstanceStreamProcessorServiceName(stream.getLogName());
    final String streamProcessorName = streamProcessorServiceName.getName();
    final ServerTransport serverTransport = clientApiTransportInjector.getValue();
    final TaskSubscriptionManager taskSubscriptionManager = taskSubscriptionManagerInjector.getValue();
    final TaskInstanceStreamProcessor taskInstanceStreamProcessor = new TaskInstanceStreamProcessor(taskSubscriptionManager);
    final TypedStreamEnvironment env = new TypedStreamEnvironment(stream, serverTransport.getOutput());
    final TypedStreamProcessor streamProcessor = taskInstanceStreamProcessor.createStreamProcessor(env);
    final StreamProcessorService taskInstanceStreamProcessorService = new StreamProcessorService(streamProcessorName, TASK_QUEUE_STREAM_PROCESSOR_ID, streamProcessor).eventFilter(streamProcessor.buildTypeFilter());
    serviceContext.createService(streamProcessorServiceName, taskInstanceStreamProcessorService).group(TASK_QUEUE_STREAM_PROCESSOR_SERVICE_GROUP_NAME).dependency(logStreamServiceName, taskInstanceStreamProcessorService.getLogStreamInjector()).dependency(SNAPSHOT_STORAGE_SERVICE, taskInstanceStreamProcessorService.getSnapshotStorageInjector()).install();
    startExpireLockService(logStreamServiceName, stream, env);
}
Also used : ServerTransport(io.zeebe.transport.ServerTransport) TaskInstanceStreamProcessor(io.zeebe.broker.task.processor.TaskInstanceStreamProcessor) StreamProcessorController(io.zeebe.logstreams.processor.StreamProcessorController) TypedStreamEnvironment(io.zeebe.broker.logstreams.processor.TypedStreamEnvironment) TypedStreamProcessor(io.zeebe.broker.logstreams.processor.TypedStreamProcessor) StreamProcessorService(io.zeebe.broker.logstreams.processor.StreamProcessorService)

Example 4 with StreamProcessorController

use of io.zeebe.logstreams.processor.StreamProcessorController in project zeebe by zeebe-io.

the class WorkflowQueueManagerService method installIncidentStreamProcessor.

private void installIncidentStreamProcessor(final LogStream logStream) {
    final ServiceName<StreamProcessorController> streamProcessorServiceName = incidentStreamProcessorServiceName(logStream.getLogName());
    final String streamProcessorName = streamProcessorServiceName.getName();
    final ServerTransport transport = clientApiTransportInjector.getValue();
    final ServiceName<LogStream> logStreamServiceName = logStreamServiceName(logStream.getLogName());
    final TypedStreamEnvironment env = new TypedStreamEnvironment(logStream, transport.getOutput());
    final IncidentStreamProcessor incidentProcessorFactory = new IncidentStreamProcessor();
    final TypedStreamProcessor streamProcessor = incidentProcessorFactory.createStreamProcessor(env);
    final StreamProcessorService incidentStreamProcessorService = new StreamProcessorService(streamProcessorName, INCIDENT_PROCESSOR_ID, streamProcessor).eventFilter(streamProcessor.buildTypeFilter());
    serviceContext.createService(streamProcessorServiceName, incidentStreamProcessorService).dependency(logStreamServiceName, incidentStreamProcessorService.getLogStreamInjector()).dependency(SNAPSHOT_STORAGE_SERVICE, incidentStreamProcessorService.getSnapshotStorageInjector()).install();
}
Also used : ServerTransport(io.zeebe.transport.ServerTransport) IncidentStreamProcessor(io.zeebe.broker.incident.processor.IncidentStreamProcessor) StreamProcessorController(io.zeebe.logstreams.processor.StreamProcessorController) LogStream(io.zeebe.logstreams.log.LogStream) TypedStreamEnvironment(io.zeebe.broker.logstreams.processor.TypedStreamEnvironment) TypedStreamProcessor(io.zeebe.broker.logstreams.processor.TypedStreamProcessor) StreamProcessorService(io.zeebe.broker.logstreams.processor.StreamProcessorService)

Example 5 with StreamProcessorController

use of io.zeebe.logstreams.processor.StreamProcessorController 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)

Aggregations

StreamProcessorController (io.zeebe.logstreams.processor.StreamProcessorController)7 StreamProcessorService (io.zeebe.broker.logstreams.processor.StreamProcessorService)5 TypedStreamProcessor (io.zeebe.broker.logstreams.processor.TypedStreamProcessor)4 TypedStreamEnvironment (io.zeebe.broker.logstreams.processor.TypedStreamEnvironment)3 LogStream (io.zeebe.logstreams.log.LogStream)3 ServerTransport (io.zeebe.transport.ServerTransport)3 BufferUtil.bufferAsString (io.zeebe.util.buffer.BufferUtil.bufferAsString)2 Broker (io.zeebe.broker.Broker)1 IncidentStreamProcessor (io.zeebe.broker.incident.processor.IncidentStreamProcessor)1 CreateWorkflowResponseSender (io.zeebe.broker.system.deployment.handler.CreateWorkflowResponseSender)1 TaskExpireLockStreamProcessor (io.zeebe.broker.task.processor.TaskExpireLockStreamProcessor)1 TaskInstanceStreamProcessor (io.zeebe.broker.task.processor.TaskInstanceStreamProcessor)1 CommandResponseWriter (io.zeebe.broker.transport.clientapi.CommandResponseWriter)1 WorkflowInstanceStreamProcessor (io.zeebe.broker.workflow.processor.WorkflowInstanceStreamProcessor)1 Raft (io.zeebe.raft.Raft)1 ServiceContainer (io.zeebe.servicecontainer.ServiceContainer)1 Test (org.junit.Test)1