Search in sources :

Example 1 with PendingPartition

use of io.zeebe.broker.system.log.PendingPartitionsIndex.PendingPartition in project zeebe by zeebe-io.

the class CompletePartitionProcessor method processEvent.

@Override
public void processEvent(TypedEvent<PartitionEvent> event) {
    final PartitionEvent value = event.getValue();
    final PendingPartition partition = partitions.get(value.getId());
    if (partition != null) {
        value.setState(PartitionState.CREATED);
    } else {
        value.setState(PartitionState.CREATE_COMPLETE_REJECTED);
    }
}
Also used : PendingPartition(io.zeebe.broker.system.log.PendingPartitionsIndex.PendingPartition)

Example 2 with PendingPartition

use of io.zeebe.broker.system.log.PendingPartitionsIndex.PendingPartition in project zeebe by zeebe-io.

the class ExpirePartitionCreationProcessor method processEvent.

@Override
public void processEvent(TypedEvent<PartitionEvent> event) {
    final PartitionEvent value = event.getValue();
    final PendingPartition partition = partitions.get(value.getId());
    if (partition != null) {
        value.setState(PartitionState.CREATE_EXPIRED);
    } else {
        value.setState(PartitionState.CREATE_EXPIRE_REJECTED);
    }
}
Also used : PendingPartition(io.zeebe.broker.system.log.PendingPartitionsIndex.PendingPartition)

Example 3 with PendingPartition

use of io.zeebe.broker.system.log.PendingPartitionsIndex.PendingPartition in project zeebe by zeebe-io.

the class ResolvePendingPartitionsCommand method checkExpiredCreation.

private void checkExpiredCreation() {
    final Iterator<PendingPartition> partitionIt = partitions.iterator();
    final long now = ActorClock.currentTimeMillis();
    while (partitionIt.hasNext()) {
        final PendingPartition partition = partitionIt.next();
        if (partition.getCreationTimeout() < now) {
            final TypedEvent<PartitionEvent> event = reader.readValue(partition.getPosition(), PartitionEvent.class);
            event.getValue().setState(PartitionState.CREATE_EXPIRE);
            // it is ok if writing fails,
            // we will then try it again with the next command execution (there are no other side effects of expiration)
            writer.writeFollowupEvent(event.getKey(), event.getValue());
        }
    }
}
Also used : PendingPartition(io.zeebe.broker.system.log.PendingPartitionsIndex.PendingPartition)

Example 4 with PendingPartition

use of io.zeebe.broker.system.log.PendingPartitionsIndex.PendingPartition in project zeebe by zeebe-io.

the class ResolvePendingPartitionsCommand method checkCompletedCreation.

private void checkCompletedCreation() {
    final Iterator<Member> currentMembers = partitionManager.getKnownMembers();
    while (currentMembers.hasNext()) {
        final Member currentMember = currentMembers.next();
        final IntIterator partitionsLeadByMember = currentMember.getLeadingPartitions();
        while (partitionsLeadByMember.hasNext()) {
            final int currentPartition = partitionsLeadByMember.nextInt();
            final PendingPartition partition = partitions.get(currentPartition);
            if (partition != null) {
                final TypedEvent<PartitionEvent> event = reader.readValue(partition.getPosition(), PartitionEvent.class);
                event.getValue().setState(PartitionState.CREATE_COMPLETE);
                // it is ok if writing fails,
                // we will then try it again with the next command execution (there are no other side effects of completion)
                writer.writeFollowupEvent(event.getKey(), event.getValue());
            }
        }
    }
}
Also used : IntIterator(io.zeebe.util.collection.IntIterator) PendingPartition(io.zeebe.broker.system.log.PendingPartitionsIndex.PendingPartition) Member(io.zeebe.broker.clustering.member.Member)

Aggregations

PendingPartition (io.zeebe.broker.system.log.PendingPartitionsIndex.PendingPartition)4 Member (io.zeebe.broker.clustering.member.Member)1 IntIterator (io.zeebe.util.collection.IntIterator)1