Search in sources :

Example 1 with CheckReplicaVersionOperation

use of com.hazelcast.replicatedmap.impl.operation.CheckReplicaVersionOperation in project hazelcast by hazelcast.

the class ReplicatedMapService method triggerAntiEntropy.

/** Send an operation to all replicas to check their replica versions for all partitions for which this node is the owner */
public void triggerAntiEntropy() {
    if (clusterService.getSize(DATA_MEMBER_SELECTOR) == 1) {
        return;
    }
    Collection<Address> addresses = new ArrayList<Address>(getMemberAddresses(DATA_MEMBER_SELECTOR));
    addresses.remove(nodeEngine.getThisAddress());
    for (int i = 0; i < partitionContainers.length; i++) {
        Address thisAddress = nodeEngine.getThisAddress();
        InternalPartition partition = partitionService.getPartition(i, false);
        Address ownerAddress = partition.getOwnerOrNull();
        if (!thisAddress.equals(ownerAddress)) {
            continue;
        }
        PartitionContainer partitionContainer = partitionContainers[i];
        if (partitionContainer.isEmpty()) {
            continue;
        }
        for (Address address : addresses) {
            CheckReplicaVersionOperation checkReplicaVersionOperation = new CheckReplicaVersionOperation(partitionContainer);
            checkReplicaVersionOperation.setPartitionId(i);
            checkReplicaVersionOperation.setValidateTarget(false);
            operationService.createInvocationBuilder(SERVICE_NAME, checkReplicaVersionOperation, address).setTryCount(INVOCATION_TRY_COUNT).invoke();
        }
    }
}
Also used : Address(com.hazelcast.nio.Address) CheckReplicaVersionOperation(com.hazelcast.replicatedmap.impl.operation.CheckReplicaVersionOperation) ArrayList(java.util.ArrayList) InternalPartition(com.hazelcast.internal.partition.InternalPartition)

Aggregations

InternalPartition (com.hazelcast.internal.partition.InternalPartition)1 Address (com.hazelcast.nio.Address)1 CheckReplicaVersionOperation (com.hazelcast.replicatedmap.impl.operation.CheckReplicaVersionOperation)1 ArrayList (java.util.ArrayList)1