Search in sources :

Example 1 with PendingDeployment

use of io.zeebe.broker.system.deployment.data.PendingDeployments.PendingDeployment in project zeebe by zeebe-io.

the class WorkflowDeleteProcessor method updateState.

@Override
public void updateState(TypedEvent<WorkflowEvent> event) {
    final long workflowKey = event.getKey();
    final WorkflowEvent workflowEvent = event.getValue();
    for (int partitionId : partitionIds) {
        pendingWorkflows.remove(workflowKey, partitionId);
    }
    final PendingDeployment pendingDeployment = pendingDeployments.get(workflowEvent.getDeploymentKey());
    // reset the workflow's version which is incremented on creation
    workflowVersions.setLatestVersion(pendingDeployment.getTopicName(), workflowEvent.getBpmnProcessId(), workflowEvent.getVersion() - 1);
}
Also used : PendingDeployment(io.zeebe.broker.system.deployment.data.PendingDeployments.PendingDeployment) WorkflowEvent(io.zeebe.broker.workflow.data.WorkflowEvent)

Example 2 with PendingDeployment

use of io.zeebe.broker.system.deployment.data.PendingDeployments.PendingDeployment in project zeebe by zeebe-io.

the class WorkflowCreateProcessor method processEvent.

@Override
public void processEvent(TypedEvent<WorkflowEvent> event) {
    partitionIds.clear();
    final WorkflowEvent workflowEvent = event.getValue();
    final PendingDeployment pendingDeployment = pendingDeployments.get(workflowEvent.getDeploymentKey());
    ensureNotNull("pending deployment", pendingDeployment);
    final DirectBuffer topicName = pendingDeployment.getTopicName();
    final TopicPartitionIterator iterator = topicPartitions.iterator();
    while (iterator.hasNext()) {
        final TopicPartition topicPartition = iterator.next();
        if (BufferUtil.equals(topicName, topicPartition.getTopicName())) {
            partitionIds.add(topicPartition.getPartitionId());
        }
    }
    ensureGreaterThan("partition ids", partitionIds.size(), 0);
}
Also used : DirectBuffer(org.agrona.DirectBuffer) PendingDeployment(io.zeebe.broker.system.deployment.data.PendingDeployments.PendingDeployment) TopicPartitionIterator(io.zeebe.broker.system.deployment.data.TopicPartitions.TopicPartitionIterator) TopicPartition(io.zeebe.broker.system.deployment.data.TopicPartitions.TopicPartition) WorkflowEvent(io.zeebe.broker.workflow.data.WorkflowEvent)

Example 3 with PendingDeployment

use of io.zeebe.broker.system.deployment.data.PendingDeployments.PendingDeployment 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 4 with PendingDeployment

use of io.zeebe.broker.system.deployment.data.PendingDeployments.PendingDeployment in project zeebe by zeebe-io.

the class DeploymentDistributedProcessor method processEvent.

@Override
public void processEvent(TypedEvent<DeploymentEvent> event) {
    final PendingDeployment pendingDeployment = pendingDeployments.get(event.getKey());
    if (pendingDeployment != null && !pendingDeployment.isResolved()) {
        event.getValue().setState(CREATED);
        Loggers.SYSTEM_LOGGER.debug("Deployment with key '{}' on topic '{}' successful.", pendingDeployment.getDeploymentKey(), BufferUtil.bufferAsString(pendingDeployment.getTopicName()));
    }
    if (!event.getMetadata().hasRequestMetadata()) {
        throw new RuntimeException("missing request metadata of deployment");
    }
}
Also used : PendingDeployment(io.zeebe.broker.system.deployment.data.PendingDeployments.PendingDeployment)

Example 5 with PendingDeployment

use of io.zeebe.broker.system.deployment.data.PendingDeployments.PendingDeployment in project zeebe by zeebe-io.

the class DeploymentTimedOutProcessor method processEvent.

@Override
public void processEvent(TypedEvent<DeploymentEvent> event) {
    final PendingDeployment pendingDeployment = pendingDeployments.get(event.getKey());
    if (pendingDeployment != null && !pendingDeployment.isResolved()) {
        event.getValue().setState(REJECT);
        workflowKeys.clear();
        collectWorkflowKeysForDeployment(event.getKey());
        LOG.info("Creation of deployment with key '{}' timed out. Delete containg workflows with keys: {}", event.getKey(), workflowKeys);
    }
    if (!event.getMetadata().hasRequestMetadata()) {
        throw new RuntimeException("missing request metadata of deployment");
    }
}
Also used : PendingDeployment(io.zeebe.broker.system.deployment.data.PendingDeployments.PendingDeployment)

Aggregations

PendingDeployment (io.zeebe.broker.system.deployment.data.PendingDeployments.PendingDeployment)5 WorkflowEvent (io.zeebe.broker.workflow.data.WorkflowEvent)2 DirectBuffer (org.agrona.DirectBuffer)2 PendingWorkflow (io.zeebe.broker.system.deployment.data.PendingWorkflows.PendingWorkflow)1 TopicPartition (io.zeebe.broker.system.deployment.data.TopicPartitions.TopicPartition)1 TopicPartitionIterator (io.zeebe.broker.system.deployment.data.TopicPartitions.TopicPartitionIterator)1