Search in sources :

Example 1 with PartitionEventManager

use of com.hazelcast.internal.partition.impl.PartitionEventManager in project hazelcast by hazelcast.

the class FinalizePromotionOperation method shiftUpReplicaVersions.

private void shiftUpReplicaVersions() {
    final int partitionId = getPartitionId();
    try {
        final InternalPartitionServiceImpl partitionService = getService();
        // returns the internal array itself, not the copy
        final long[] versions = partitionService.getPartitionReplicaVersions(partitionId);
        final int lostReplicaIndex = currentReplicaIndex - 1;
        if (currentReplicaIndex > 1) {
            final long[] versionsCopy = Arrays.copyOf(versions, versions.length);
            final long version = versions[lostReplicaIndex];
            Arrays.fill(versions, 0, lostReplicaIndex, version);
            if (logger.isFinestEnabled()) {
                logger.finest("Partition replica is lost! partitionId=" + partitionId + " lost replicaIndex=" + lostReplicaIndex + " replica versions before shift up=" + Arrays.toString(versionsCopy) + " replica versions after shift up=" + Arrays.toString(versions));
            }
        } else if (logger.isFinestEnabled()) {
            logger.finest("PROMOTE partitionId=" + getPartitionId() + " from currentReplicaIndex=" + currentReplicaIndex);
        }
        PartitionEventManager partitionEventManager = partitionService.getPartitionEventManager();
        partitionEventManager.sendPartitionLostEvent(partitionId, lostReplicaIndex);
    } catch (Throwable e) {
        logger.warning("Promotion failed. partitionId=" + partitionId + " replicaIndex=" + currentReplicaIndex, e);
    }
}
Also used : InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) PartitionEventManager(com.hazelcast.internal.partition.impl.PartitionEventManager)

Aggregations

InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)1 PartitionEventManager (com.hazelcast.internal.partition.impl.PartitionEventManager)1