Search in sources :

Example 1 with MutableZeebeState

use of io.camunda.zeebe.engine.state.mutable.MutableZeebeState in project zeebe by zeebe-io.

the class EngineProcessors method createEngineProcessors.

public static TypedRecordProcessors createEngineProcessors(final ProcessingContext processingContext, final int partitionsCount, final SubscriptionCommandSender subscriptionCommandSender, final DeploymentDistributor deploymentDistributor, final DeploymentResponder deploymentResponder, final Consumer<String> onJobsAvailableCallback) {
    final var actor = processingContext.getActor();
    final MutableZeebeState zeebeState = processingContext.getZeebeState();
    final var writers = processingContext.getWriters();
    final TypedRecordProcessors typedRecordProcessors = TypedRecordProcessors.processors(zeebeState.getKeyGenerator(), writers);
    // register listener that handles migrations immediately, so it is the first to be called
    typedRecordProcessors.withListener(new DbMigrationController());
    typedRecordProcessors.withListener(processingContext.getZeebeState());
    final LogStream stream = processingContext.getLogStream();
    final int partitionId = stream.getPartitionId();
    final var variablesState = zeebeState.getVariableState();
    final var expressionProcessor = new ExpressionProcessor(ExpressionLanguageFactory.createExpressionLanguage(), variablesState::getVariable);
    final DueDateTimerChecker timerChecker = new DueDateTimerChecker(zeebeState.getTimerState());
    final CatchEventBehavior catchEventBehavior = new CatchEventBehavior(zeebeState, expressionProcessor, subscriptionCommandSender, writers.state(), timerChecker, partitionsCount);
    final var eventTriggerBehavior = new EventTriggerBehavior(zeebeState.getKeyGenerator(), catchEventBehavior, writers, zeebeState);
    final var eventPublicationBehavior = new BpmnEventPublicationBehavior(zeebeState, zeebeState.getKeyGenerator(), eventTriggerBehavior, writers);
    addDeploymentRelatedProcessorAndServices(catchEventBehavior, partitionId, zeebeState, typedRecordProcessors, deploymentResponder, expressionProcessor, writers, partitionsCount, actor, deploymentDistributor, zeebeState.getKeyGenerator());
    addMessageProcessors(eventTriggerBehavior, subscriptionCommandSender, zeebeState, typedRecordProcessors, writers);
    final var jobMetrics = new JobMetrics(partitionId);
    final TypedRecordProcessor<ProcessInstanceRecord> bpmnStreamProcessor = addProcessProcessors(zeebeState, expressionProcessor, typedRecordProcessors, subscriptionCommandSender, catchEventBehavior, eventTriggerBehavior, writers, timerChecker, jobMetrics);
    JobEventProcessors.addJobProcessors(typedRecordProcessors, zeebeState, onJobsAvailableCallback, eventPublicationBehavior, writers, jobMetrics, eventTriggerBehavior);
    addIncidentProcessors(zeebeState, bpmnStreamProcessor, typedRecordProcessors, writers, zeebeState.getKeyGenerator());
    return typedRecordProcessors;
}
Also used : MutableZeebeState(io.camunda.zeebe.engine.state.mutable.MutableZeebeState) BpmnEventPublicationBehavior(io.camunda.zeebe.engine.processing.bpmn.behavior.BpmnEventPublicationBehavior) LogStream(io.camunda.zeebe.logstreams.log.LogStream) DueDateTimerChecker(io.camunda.zeebe.engine.processing.timer.DueDateTimerChecker) JobMetrics(io.camunda.zeebe.engine.metrics.JobMetrics) CatchEventBehavior(io.camunda.zeebe.engine.processing.common.CatchEventBehavior) TypedRecordProcessors(io.camunda.zeebe.engine.processing.streamprocessor.TypedRecordProcessors) ExpressionProcessor(io.camunda.zeebe.engine.processing.common.ExpressionProcessor) EventTriggerBehavior(io.camunda.zeebe.engine.processing.common.EventTriggerBehavior) ProcessInstanceRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord) DbMigrationController(io.camunda.zeebe.engine.state.migration.DbMigrationController)

Example 2 with MutableZeebeState

use of io.camunda.zeebe.engine.state.mutable.MutableZeebeState in project zeebe by camunda.

the class BlacklistInstanceTest method shouldBlacklist.

@Test
public void shouldBlacklist() {
    // given
    final RecordMetadata metadata = new RecordMetadata();
    metadata.intent(recordIntent);
    metadata.valueType(recordValueType);
    final TypedEventImpl typedEvent = new TypedEventImpl(1);
    final LoggedEvent loggedEvent = mock(LoggedEvent.class);
    when(loggedEvent.getPosition()).thenReturn(1024L);
    typedEvent.wrap(loggedEvent, metadata, new Value());
    // when
    final MutableZeebeState zeebeState = ZEEBE_STATE_RULE.getZeebeState();
    zeebeState.getBlackListState().tryToBlacklist(typedEvent, (processInstanceKey) -> {
    });
    // then
    metadata.intent(ProcessInstanceIntent.ELEMENT_ACTIVATING);
    metadata.valueType(ValueType.PROCESS_INSTANCE);
    typedEvent.wrap(null, metadata, new Value());
    assertThat(zeebeState.getBlackListState().isOnBlacklist(typedEvent)).isEqualTo(expectedToBlacklist);
}
Also used : RecordMetadata(io.camunda.zeebe.protocol.impl.record.RecordMetadata) MutableZeebeState(io.camunda.zeebe.engine.state.mutable.MutableZeebeState) LoggedEvent(io.camunda.zeebe.logstreams.log.LoggedEvent) UnifiedRecordValue(io.camunda.zeebe.protocol.impl.record.UnifiedRecordValue) Test(org.junit.Test)

Example 3 with MutableZeebeState

use of io.camunda.zeebe.engine.state.mutable.MutableZeebeState in project zeebe by camunda.

the class TimerInstanceStateTest method setUp.

@Before
public void setUp() {
    final MutableZeebeState zeebeState = stateRule.getZeebeState();
    state = zeebeState.getTimerState();
}
Also used : MutableZeebeState(io.camunda.zeebe.engine.state.mutable.MutableZeebeState) Before(org.junit.Before)

Example 4 with MutableZeebeState

use of io.camunda.zeebe.engine.state.mutable.MutableZeebeState in project zeebe by camunda.

the class MessageSubscriptionStateTest method setUp.

@Before
public void setUp() {
    final MutableZeebeState zeebeState = stateRule.getZeebeState();
    state = zeebeState.getMessageSubscriptionState();
}
Also used : MutableZeebeState(io.camunda.zeebe.engine.state.mutable.MutableZeebeState) Before(org.junit.Before)

Example 5 with MutableZeebeState

use of io.camunda.zeebe.engine.state.mutable.MutableZeebeState in project zeebe by camunda-cloud.

the class EngineProcessors method createEngineProcessors.

public static TypedRecordProcessors createEngineProcessors(final ProcessingContext processingContext, final int partitionsCount, final SubscriptionCommandSender subscriptionCommandSender, final DeploymentDistributor deploymentDistributor, final DeploymentResponder deploymentResponder, final Consumer<String> onJobsAvailableCallback) {
    final var actor = processingContext.getActor();
    final MutableZeebeState zeebeState = processingContext.getZeebeState();
    final var writers = processingContext.getWriters();
    final TypedRecordProcessors typedRecordProcessors = TypedRecordProcessors.processors(zeebeState.getKeyGenerator(), writers);
    // register listener that handles migrations immediately, so it is the first to be called
    typedRecordProcessors.withListener(new DbMigrationController());
    typedRecordProcessors.withListener(processingContext.getZeebeState());
    final LogStream stream = processingContext.getLogStream();
    final int partitionId = stream.getPartitionId();
    final var variablesState = zeebeState.getVariableState();
    final var expressionProcessor = new ExpressionProcessor(ExpressionLanguageFactory.createExpressionLanguage(), variablesState::getVariable);
    final DueDateTimerChecker timerChecker = new DueDateTimerChecker(zeebeState.getTimerState());
    final CatchEventBehavior catchEventBehavior = new CatchEventBehavior(zeebeState, expressionProcessor, subscriptionCommandSender, writers.state(), timerChecker, partitionsCount);
    final var eventTriggerBehavior = new EventTriggerBehavior(zeebeState.getKeyGenerator(), catchEventBehavior, writers, zeebeState);
    final var eventPublicationBehavior = new BpmnEventPublicationBehavior(zeebeState, zeebeState.getKeyGenerator(), eventTriggerBehavior, writers);
    addDeploymentRelatedProcessorAndServices(catchEventBehavior, partitionId, zeebeState, typedRecordProcessors, deploymentResponder, expressionProcessor, writers, partitionsCount, actor, deploymentDistributor, zeebeState.getKeyGenerator());
    addMessageProcessors(eventTriggerBehavior, subscriptionCommandSender, zeebeState, typedRecordProcessors, writers);
    final var jobMetrics = new JobMetrics(partitionId);
    final TypedRecordProcessor<ProcessInstanceRecord> bpmnStreamProcessor = addProcessProcessors(zeebeState, expressionProcessor, typedRecordProcessors, subscriptionCommandSender, catchEventBehavior, eventTriggerBehavior, writers, timerChecker, jobMetrics);
    JobEventProcessors.addJobProcessors(typedRecordProcessors, zeebeState, onJobsAvailableCallback, eventPublicationBehavior, writers, jobMetrics, eventTriggerBehavior);
    addIncidentProcessors(zeebeState, bpmnStreamProcessor, typedRecordProcessors, writers, zeebeState.getKeyGenerator());
    return typedRecordProcessors;
}
Also used : MutableZeebeState(io.camunda.zeebe.engine.state.mutable.MutableZeebeState) BpmnEventPublicationBehavior(io.camunda.zeebe.engine.processing.bpmn.behavior.BpmnEventPublicationBehavior) LogStream(io.camunda.zeebe.logstreams.log.LogStream) DueDateTimerChecker(io.camunda.zeebe.engine.processing.timer.DueDateTimerChecker) JobMetrics(io.camunda.zeebe.engine.metrics.JobMetrics) CatchEventBehavior(io.camunda.zeebe.engine.processing.common.CatchEventBehavior) TypedRecordProcessors(io.camunda.zeebe.engine.processing.streamprocessor.TypedRecordProcessors) ExpressionProcessor(io.camunda.zeebe.engine.processing.common.ExpressionProcessor) EventTriggerBehavior(io.camunda.zeebe.engine.processing.common.EventTriggerBehavior) ProcessInstanceRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord) DbMigrationController(io.camunda.zeebe.engine.state.migration.DbMigrationController)

Aggregations

MutableZeebeState (io.camunda.zeebe.engine.state.mutable.MutableZeebeState)32 Before (org.junit.Before)12 Test (org.junit.Test)12 UnifiedRecordValue (io.camunda.zeebe.protocol.impl.record.UnifiedRecordValue)9 SideEffectProducer (io.camunda.zeebe.engine.processing.streamprocessor.sideeffect.SideEffectProducer)6 TypedResponseWriter (io.camunda.zeebe.engine.processing.streamprocessor.writers.TypedResponseWriter)6 TypedStreamWriter (io.camunda.zeebe.engine.processing.streamprocessor.writers.TypedStreamWriter)6 JobMetrics (io.camunda.zeebe.engine.metrics.JobMetrics)5 BpmnEventPublicationBehavior (io.camunda.zeebe.engine.processing.bpmn.behavior.BpmnEventPublicationBehavior)5 CatchEventBehavior (io.camunda.zeebe.engine.processing.common.CatchEventBehavior)5 EventTriggerBehavior (io.camunda.zeebe.engine.processing.common.EventTriggerBehavior)5 ExpressionProcessor (io.camunda.zeebe.engine.processing.common.ExpressionProcessor)5 TypedRecordProcessors (io.camunda.zeebe.engine.processing.streamprocessor.TypedRecordProcessors)5 DueDateTimerChecker (io.camunda.zeebe.engine.processing.timer.DueDateTimerChecker)5 DbMigrationController (io.camunda.zeebe.engine.state.migration.DbMigrationController)5 LogStream (io.camunda.zeebe.logstreams.log.LogStream)5 ProcessInstanceRecord (io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord)5 LoggedEvent (io.camunda.zeebe.logstreams.log.LoggedEvent)3 RecordMetadata (io.camunda.zeebe.protocol.impl.record.RecordMetadata)3 BeforeClass (org.junit.BeforeClass)3