Search in sources :

Example 1 with ZeebeDbState

use of io.camunda.zeebe.engine.state.ZeebeDbState in project zdb by Zelldon.

the class ZeebeTest method shouldOpenAndReadState.

@Test
public void shouldOpenAndReadState() {
    // given
    final ZeebeClient client = ZeebeClient.newClientBuilder().gatewayAddress(zeebeContainer.getExternalGatewayAddress()).usePlaintext().build();
    final BpmnModelInstance process = Bpmn.createExecutableProcess("process").startEvent().endEvent().done();
    final DeploymentEvent deploymentEvent = client.newDeployCommand().addProcessModel(process, "process.bpmn").send().join();
    // when
    final var readonlyTransactionDb = ReadonlyTransactionDb.Companion.openReadonlyDb(ZeebePaths.Companion.getRuntimePath(tempDir, "1"));
    var zeebeState = new ZeebeDbState(readonlyTransactionDb, readonlyTransactionDb.createContext());
    // then
    final var processState = zeebeState.getProcessState();
    final var processes = processState.getProcesses();
    assertThat(processes).hasSize(1);
    final var deployedProcesses = new ArrayList<DeployedProcess>(processes);
    final var deployedProcess = deployedProcesses.get(0);
    assertThat(deployedProcess.getVersion()).isEqualTo(1);
    assertThat(deployedProcess.getBpmnProcessId()).isEqualTo(BufferUtil.wrapString("process"));
    assertThat(deployedProcess.getResourceName()).isEqualTo(BufferUtil.wrapString("process.bpmn"));
    assertThat(deployedProcess.getKey()).isEqualTo(deploymentEvent.getProcesses().get(0).getProcessDefinitionKey());
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ArrayList(java.util.ArrayList) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) ZeebeDbState(io.camunda.zeebe.engine.state.ZeebeDbState) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) Test(org.junit.jupiter.api.Test)

Example 2 with ZeebeDbState

use of io.camunda.zeebe.engine.state.ZeebeDbState in project zeebe by camunda.

the class ZeebeStateRule method before.

@Override
protected void before() throws Throwable {
    tempFolder.create();
    db = createNewDb();
    zeebeState = new ZeebeDbState(partition, db, db.createContext());
}
Also used : ZeebeDbState(io.camunda.zeebe.engine.state.ZeebeDbState)

Example 3 with ZeebeDbState

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

the class ZeebeStateRule method before.

@Override
protected void before() throws Throwable {
    tempFolder.create();
    db = createNewDb();
    zeebeState = new ZeebeDbState(partition, db, db.createContext());
}
Also used : ZeebeDbState(io.camunda.zeebe.engine.state.ZeebeDbState)

Example 4 with ZeebeDbState

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

the class StreamProcessor method recoverState.

private ZeebeDbState recoverState() {
    final TransactionContext transactionContext = zeebeDb.createContext();
    final ZeebeDbState zeebeState = new ZeebeDbState(partitionId, zeebeDb, transactionContext);
    processingContext.transactionContext(transactionContext);
    processingContext.zeebeState(zeebeState);
    processingContext.eventApplier(eventApplierFactory.apply(zeebeState));
    return zeebeState;
}
Also used : TransactionContext(io.camunda.zeebe.db.TransactionContext) ZeebeDbState(io.camunda.zeebe.engine.state.ZeebeDbState)

Example 5 with ZeebeDbState

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

the class StreamProcessor method recoverState.

private ZeebeDbState recoverState() {
    final TransactionContext transactionContext = zeebeDb.createContext();
    final ZeebeDbState zeebeState = new ZeebeDbState(partitionId, zeebeDb, transactionContext);
    processingContext.transactionContext(transactionContext);
    processingContext.zeebeState(zeebeState);
    processingContext.eventApplier(eventApplierFactory.apply(zeebeState));
    return zeebeState;
}
Also used : TransactionContext(io.camunda.zeebe.db.TransactionContext) ZeebeDbState(io.camunda.zeebe.engine.state.ZeebeDbState)

Aggregations

ZeebeDbState (io.camunda.zeebe.engine.state.ZeebeDbState)7 TransactionContext (io.camunda.zeebe.db.TransactionContext)3 ZeebeClient (io.camunda.zeebe.client.ZeebeClient)1 DeploymentEvent (io.camunda.zeebe.client.api.response.DeploymentEvent)1 BpmnModelInstance (io.camunda.zeebe.model.bpmn.BpmnModelInstance)1 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1