Search in sources :

Example 1 with PendingWorkflow

use of io.zeebe.broker.system.deployment.data.PendingWorkflows.PendingWorkflow in project zeebe by zeebe-io.

the class WorkflowDeleteProcessor method processEvent.

@Override
public void processEvent(TypedEvent<WorkflowEvent> event) {
    event.getValue().setState(WorkflowState.DELETED);
    final long workflowKey = event.getKey();
    partitionIds.clear();
    final PendingWorkflowIterator workflows = pendingWorkflows.iterator();
    while (workflows.hasNext()) {
        final PendingWorkflow workflow = workflows.next();
        if (workflow.getWorkflowKey() == workflowKey) {
            partitionIds.addInt(workflow.getPartitionId());
        }
    }
    ensureGreaterThan("partition ids", partitionIds.size(), 0);
}
Also used : PendingWorkflow(io.zeebe.broker.system.deployment.data.PendingWorkflows.PendingWorkflow) PendingWorkflowIterator(io.zeebe.broker.system.deployment.data.PendingWorkflows.PendingWorkflowIterator)

Example 2 with PendingWorkflow

use of io.zeebe.broker.system.deployment.data.PendingWorkflows.PendingWorkflow in project zeebe by zeebe-io.

the class RemoteWorkflowsManager method onRequestSuccessful.

private void onRequestSuccessful(ClientResponse request) {
    try {
        final DirectBuffer responseBuffer = request.getResponseBuffer();
        createResponse.wrap(responseBuffer, 0, responseBuffer.capacity());
        final long workflowKey = createResponse.getWorkflowKey();
        final int partitionId = createResponse.getPartitionId();
        final long deploymentKey = createResponse.getDeploymentKey();
        final PendingWorkflow pendingWorkflow = pendingWorkflows.get(workflowKey, partitionId);
        if (pendingWorkflow != null && pendingWorkflow.getState() == PendingWorkflows.STATE_CREATE) {
            // ignore response if pending workflow or deployment is already processed
            pendingWorkflows.put(workflowKey, partitionId, PendingWorkflows.STATE_CREATED, deploymentKey);
        }
        if (isDeploymentDistributed(deploymentKey)) {
            final PendingDeployment pendingDeployment = pendingDeployments.get(deploymentKey);
            writer.writeDeploymentEvent(pendingDeployment.getDeploymentEventPosition(), DeploymentState.DISTRIBUTED);
        }
    } finally {
        request.close();
    }
}
Also used : DirectBuffer(org.agrona.DirectBuffer) PendingDeployment(io.zeebe.broker.system.deployment.data.PendingDeployments.PendingDeployment) PendingWorkflow(io.zeebe.broker.system.deployment.data.PendingWorkflows.PendingWorkflow)

Example 3 with PendingWorkflow

use of io.zeebe.broker.system.deployment.data.PendingWorkflows.PendingWorkflow in project zeebe by zeebe-io.

the class DeploymentDistributedProcessor method removePendingWorkflowsOfDeployment.

private void removePendingWorkflowsOfDeployment(long deploymentKey) {
    int offset = 0;
    // cannot delete entries while iterating over it
    final PendingWorkflowIterator iterator = pendingWorkflows.iterator();
    while (iterator.hasNext()) {
        final PendingWorkflow pendingWorkflow = iterator.next();
        if (deploymentKey == pendingWorkflow.getDeploymentKey()) {
            buffer.putLong(offset, pendingWorkflow.getWorkflowKey());
            offset += SIZE_OF_LONG;
            buffer.putInt(offset, pendingWorkflow.getPartitionId());
            offset += SIZE_OF_INT;
        }
    }
    final int limit = offset;
    offset = 0;
    while (offset < limit) {
        final long workflowKey = buffer.getLong(offset);
        offset += SIZE_OF_LONG;
        final int partitionId = buffer.getInt(offset);
        offset += SIZE_OF_INT;
        pendingWorkflows.remove(workflowKey, partitionId);
    }
}
Also used : PendingWorkflow(io.zeebe.broker.system.deployment.data.PendingWorkflows.PendingWorkflow) PendingWorkflowIterator(io.zeebe.broker.system.deployment.data.PendingWorkflows.PendingWorkflowIterator)

Aggregations

PendingWorkflow (io.zeebe.broker.system.deployment.data.PendingWorkflows.PendingWorkflow)3 PendingWorkflowIterator (io.zeebe.broker.system.deployment.data.PendingWorkflows.PendingWorkflowIterator)2 PendingDeployment (io.zeebe.broker.system.deployment.data.PendingDeployments.PendingDeployment)1 DirectBuffer (org.agrona.DirectBuffer)1