use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class ClusterStateManager method lockClusterStateOnAllMembers.
private void lockClusterStateOnAllMembers(ClusterStateChange stateChange, NodeEngineImpl nodeEngine, long leaseTime, UUID txnId, Collection<MemberImpl> members, int memberListVersion, long partitionStateStamp) {
Collection<Future> futures = new ArrayList<>(members.size());
final Address thisAddress = node.getThisAddress();
for (Member member : members) {
Operation op = new LockClusterStateOp(stateChange, thisAddress, txnId, leaseTime, memberListVersion, partitionStateStamp);
Future future = nodeEngine.getOperationService().invokeOnTarget(SERVICE_NAME, op, member.getAddress());
futures.add(future);
}
StateManagerExceptionHandler exceptionHandler = new StateManagerExceptionHandler(logger);
waitWithDeadline(futures, leaseTime, TimeUnit.MILLISECONDS, exceptionHandler);
exceptionHandler.rethrowIfFailed();
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class MigrationRequestOperation method createNonFragmentedReplicaFragmentMigrationState.
private ReplicaFragmentMigrationState createNonFragmentedReplicaFragmentMigrationState() {
PartitionReplicationEvent event = getPartitionReplicationEvent();
Collection<Operation> operations = createNonFragmentedReplicationOperations(event);
Collection<ServiceNamespace> namespaces = Collections.singleton(NonFragmentedServiceNamespace.INSTANCE);
return createReplicaFragmentMigrationState(namespaces, operations, emptyList(), maxTotalChunkedDataInBytes);
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class PartitionReplicaManager method sendSyncReplicaRequest.
/**
* Send the sync request to {@code target} if the max number of parallel sync requests has not been made and the target
* was not removed while the cluster was not active. Also cancel any currently scheduled sync requests for the given
* partition and schedule a new sync request that is to be run in the case of timeout
*/
private void sendSyncReplicaRequest(int partitionId, Collection<ServiceNamespace> requestedNamespaces, int replicaIndex, PartitionReplica target) {
if (node.clusterService.isMissingMember(target.address(), target.uuid())) {
return;
}
int permits = tryAcquireReplicaSyncPermits(requestedNamespaces.size());
if (permits == 0) {
if (logger.isFinestEnabled()) {
logger.finest("Cannot send sync replica request for partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + ", namespaces=" + requestedNamespaces + ". No permits available!");
}
return;
}
// Select only permitted number of namespaces
Collection<ServiceNamespace> namespaces = registerSyncInfoForNamespaces(partitionId, requestedNamespaces, replicaIndex, target, permits);
// release unused permits
if (namespaces.size() != permits) {
releaseReplicaSyncPermits(permits - namespaces.size());
}
if (namespaces.isEmpty()) {
return;
}
if (logger.isFinestEnabled()) {
logger.finest("Sending sync replica request for partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + ", namespaces=" + namespaces);
}
replicaSyncRequestsCounter.inc();
Operation syncRequest = ALLOW_OFFLOAD ? new PartitionReplicaSyncRequestOffloadable(namespaces, partitionId, replicaIndex) : new PartitionReplicaSyncRequest(namespaces, partitionId, replicaIndex);
nodeEngine.getOperationService().send(syncRequest, target.address());
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class PartitionReplicaSyncResponse method nodeNotOwnsBackup.
/**
* Fail all replication operations with the exception that this node is no longer the replica with the sent index
*/
private void nodeNotOwnsBackup(InternalPartitionImpl partition) {
int partitionId = getPartitionId();
int replicaIndex = getReplicaIndex();
NodeEngine nodeEngine = getNodeEngine();
ILogger logger = getLogger();
if (logger.isFinestEnabled()) {
int currentReplicaIndex = partition.getReplicaIndex(PartitionReplica.from(nodeEngine.getLocalMember()));
logger.finest("This node is not backup replica of partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + " anymore. current replicaIndex=" + currentReplicaIndex);
}
if (operations != null) {
PartitionReplica replica = partition.getReplica(replicaIndex);
Member targetMember = null;
if (replica != null) {
ClusterServiceImpl clusterService = (ClusterServiceImpl) nodeEngine.getClusterService();
targetMember = clusterService.getMember(replica.address(), replica.uuid());
}
Throwable throwable = new WrongTargetException(nodeEngine.getLocalMember(), targetMember, partitionId, replicaIndex, getClass().getName());
for (Operation op : operations) {
prepareOperation(op);
onOperationFailure(op, throwable);
}
}
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class MigrationRequestOperation method createAllReplicaFragmentsMigrationState.
private ReplicaFragmentMigrationState createAllReplicaFragmentsMigrationState() {
PartitionReplicationEvent event = getPartitionReplicationEvent();
Collection<Operation> operations = createAllReplicationOperations(event);
return createReplicaFragmentMigrationState(namespacesContext.allNamespaces, operations, emptyList(), maxTotalChunkedDataInBytes);
}
Aggregations