Search in sources :

Example 1 with TopicPartition

use of io.zeebe.broker.system.deployment.data.TopicPartitions.TopicPartition 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 2 with TopicPartition

use of io.zeebe.broker.system.deployment.data.TopicPartitions.TopicPartition in project zeebe by zeebe-io.

the class DeploymentCreateProcessor method isTopicCreated.

private boolean isTopicCreated(final DirectBuffer topicName) {
    boolean hasPartition = false;
    boolean topicPartitionsCreated = true;
    final TopicPartitionIterator iterator = topicPartitions.iterator();
    while (iterator.hasNext()) {
        final TopicPartition partition = iterator.next();
        if (BufferUtil.equals(topicName, partition.getTopicName())) {
            hasPartition = true;
            topicPartitionsCreated &= partition.getState() == TopicPartitions.STATE_CREATED;
        }
    }
    return hasPartition && topicPartitionsCreated;
}
Also used : TopicPartitionIterator(io.zeebe.broker.system.deployment.data.TopicPartitions.TopicPartitionIterator) TopicPartition(io.zeebe.broker.system.deployment.data.TopicPartitions.TopicPartition)

Aggregations

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