use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class ClusterJoinManager method checkClusterStateBeforeJoin.
private boolean checkClusterStateBeforeJoin(Address target, UUID uuid) {
ClusterState state = clusterStateManager.getState();
if (state == ClusterState.IN_TRANSITION) {
logger.warning("Cluster state is in transition process. Join is not allowed until " + "transaction is completed -> " + clusterStateManager.stateToString());
return true;
}
if (state.isJoinAllowed()) {
return checkRecentlyJoinedMemberUuidBeforeJoin(target, uuid);
}
if (clusterService.isMissingMember(target, uuid)) {
return false;
}
if (node.getNodeExtension().isStartCompleted()) {
String message = "Cluster state either is locked or doesn't allow new members to join -> " + clusterStateManager.stateToString();
logger.warning(message);
OperationService operationService = nodeEngine.getOperationService();
BeforeJoinCheckFailureOp op = new BeforeJoinCheckFailureOp(message);
operationService.send(op, target);
} else {
String message = "Cluster state either is locked or doesn't allow new members to join -> " + clusterStateManager.stateToString() + ". Silently ignored join request of " + target + " because start not completed.";
logger.warning(message);
}
return true;
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class ClusterServiceImpl method sendExplicitSuspicionTrigger.
void sendExplicitSuspicionTrigger(Address triggerTo, MembersViewMetadata endpointMembersViewMetadata) {
if (triggerTo.equals(node.getThisAddress())) {
logger.warning("Cannot send explicit suspicion trigger for " + endpointMembersViewMetadata + " to itself.");
return;
}
int memberListVersion = membershipManager.getMemberListVersion();
Operation op = new TriggerExplicitSuspicionOp(memberListVersion, endpointMembersViewMetadata);
OperationService operationService = nodeEngine.getOperationService();
operationService.send(op, triggerTo);
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class CRDTReplicationTask method replicate.
/**
* Performs replication of a {@link CRDTReplicationAwareService} to the
* given target. The service may optimise the returned operation based on
* the target member and the previous successful replication operations.
*
* @param service the service to replicate
* @param target the target to replicate to
* @see CRDTReplicationAwareService
*/
private void replicate(CRDTReplicationAwareService service, Member target) {
if (Thread.currentThread().isInterrupted()) {
return;
}
final int targetIndex = getDataMemberListIndex(target);
final Map<String, VectorClock> lastSuccessfullyReplicatedClocks = replicationMigrationService.getReplicatedVectorClocks(service.getName(), target.getUuid());
final OperationService operationService = nodeEngine.getOperationService();
final CRDTReplicationContainer replicationOperation = service.prepareReplicationOperation(lastSuccessfullyReplicatedClocks, targetIndex);
if (replicationOperation == null) {
logger.finest("Skipping replication of " + service.getName() + " for target " + target);
return;
}
try {
logger.finest("Replicating " + service.getName() + " to " + target);
operationService.invokeOnTarget(null, replicationOperation.getOperation(), target.getAddress()).joinInternal();
replicationMigrationService.setReplicatedVectorClocks(service.getName(), target.getUuid(), replicationOperation.getVectorClocks());
} catch (Exception e) {
if (logger.isFineEnabled()) {
logger.fine("Failed replication of " + service.getName() + " for target " + target, e);
} else {
logger.info("Failed replication of " + service.getName() + " for target " + target);
}
}
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class CRDTReplicationMigrationService method tryProcessOnOtherMembers.
/**
* Attempts to process the {@code operation} on at least one non-local
* member. The method will iterate through the member list and try once on
* each member.
* The method returns as soon as the first member successfully processes
* the operation or once there are no more members to try.
*
* @param serviceName the service name
* @return {@code true} if at least one member successfully processed the
* operation, {@code false} otherwise.
*/
private boolean tryProcessOnOtherMembers(Operation operation, String serviceName, long timeoutNanos) {
final OperationService operationService = nodeEngine.getOperationService();
final Collection<Member> targets = nodeEngine.getClusterService().getMembers(DATA_MEMBER_SELECTOR);
final Member localMember = nodeEngine.getLocalMember();
for (Member target : targets) {
if (target.equals(localMember)) {
continue;
}
long start = System.nanoTime();
try {
logger.fine("Replicating " + serviceName + " to " + target);
InternalCompletableFuture<Object> future = operationService.createInvocationBuilder(null, operation, target.getAddress()).setTryCount(1).invoke();
future.get(timeoutNanos, TimeUnit.NANOSECONDS);
return true;
} catch (Exception e) {
logger.fine("Failed replication of " + serviceName + " for target " + target, e);
}
timeoutNanos -= (System.nanoTime() - start);
if (timeoutNanos < 0) {
break;
}
}
return false;
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class CRDTMigrationTask method migrate.
/**
* Performs migration of a {@link CRDTReplicationAwareService} to the
* given target.
*
* @param service the service to migrate
* @param target the target to migrate to
* @param maxConfiguredReplicaCount the maximum configured replica count
* for the CRDTs to be migrated (excluding)
* @see CRDTReplicationAwareService
*/
private boolean migrate(CRDTReplicationAwareService service, Member target, int maxConfiguredReplicaCount) {
if (Thread.currentThread().isInterrupted()) {
return false;
}
final OperationService operationService = nodeEngine.getOperationService();
final CRDTReplicationContainer migrationOperation = service.prepareMigrationOperation(maxConfiguredReplicaCount);
if (migrationOperation == null) {
logger.finest("Skipping migration of " + service.getName() + " for target " + target);
return true;
}
try {
logger.finest("Migrating " + service.getName() + " to " + target);
operationService.invokeOnTarget(null, migrationOperation.getOperation(), target.getAddress()).joinInternal();
final boolean allMigrated = service.clearCRDTState(migrationOperation.getVectorClocks());
if (!allMigrated) {
logger.fine(service.getName() + " CRDTs have been mutated since migrated to target " + target + ". Rescheduling migration in " + MIGRATION_RETRY_DELAY_SECONDS + " second(s).");
}
return allMigrated;
} catch (Exception e) {
if (logger.isFineEnabled()) {
logger.fine("Failed migration of " + service.getName() + " for target " + target + ". Rescheduling migration in " + MIGRATION_RETRY_DELAY_SECONDS + " second(s).", e);
} else {
logger.info("Failed migration of " + service.getName() + " for target " + target + ". Rescheduling migration in " + MIGRATION_RETRY_DELAY_SECONDS + " second(s).");
}
return false;
}
}
Aggregations