Search in sources :

Example 21 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class DurableExecutorServiceProxy method retrieveAndDisposeResult.

@Override
public <T> Future<T> retrieveAndDisposeResult(long uniqueId) {
    int partitionId = Bits.extractInt(uniqueId, false);
    int sequence = Bits.extractInt(uniqueId, true);
    Operation op = new RetrieveAndDisposeResultOperation(name, sequence).setPartitionId(partitionId);
    return invokeOnPartition(op);
}
Also used : ShutdownOperation(com.hazelcast.durableexecutor.impl.operations.ShutdownOperation) TaskOperation(com.hazelcast.durableexecutor.impl.operations.TaskOperation) Operation(com.hazelcast.spi.Operation) DisposeResultOperation(com.hazelcast.durableexecutor.impl.operations.DisposeResultOperation) RetrieveAndDisposeResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveAndDisposeResultOperation) RetrieveResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveResultOperation) RetrieveAndDisposeResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveAndDisposeResultOperation)

Example 22 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class AbstractJoiner method startClusterMerge.

protected void startClusterMerge(final Address targetAddress) {
    ClusterServiceImpl clusterService = node.clusterService;
    if (!prepareClusterState(clusterService)) {
        return;
    }
    OperationService operationService = node.nodeEngine.getOperationService();
    Collection<Member> memberList = clusterService.getMembers();
    Collection<Future> futures = new ArrayList<Future>(memberList.size());
    for (Member member : memberList) {
        if (!member.localMember()) {
            Operation op = new MergeClustersOperation(targetAddress);
            Future<Object> future = operationService.invokeOnTarget(ClusterServiceImpl.SERVICE_NAME, op, member.getAddress());
            futures.add(future);
        }
    }
    waitWithDeadline(futures, SPLIT_BRAIN_MERGE_TIMEOUT_SECONDS, TimeUnit.SECONDS, splitBrainMergeExceptionHandler);
    Operation mergeClustersOperation = new MergeClustersOperation(targetAddress);
    mergeClustersOperation.setNodeEngine(node.nodeEngine).setService(clusterService).setOperationResponseHandler(createEmptyResponseHandler());
    operationService.run(mergeClustersOperation);
}
Also used : ArrayList(java.util.ArrayList) MergeClustersOperation(com.hazelcast.internal.cluster.impl.operations.MergeClustersOperation) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.OperationService) SplitBrainMergeValidationOperation(com.hazelcast.internal.cluster.impl.operations.SplitBrainMergeValidationOperation) MemberRemoveOperation(com.hazelcast.internal.cluster.impl.operations.MemberRemoveOperation) MergeClustersOperation(com.hazelcast.internal.cluster.impl.operations.MergeClustersOperation) Operation(com.hazelcast.spi.Operation) Member(com.hazelcast.core.Member)

Example 23 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class ClusterJoinManager method checkIfJoinRequestFromAnExistingMember.

private boolean checkIfJoinRequestFromAnExistingMember(JoinMessage joinMessage, Connection connection) {
    Address target = joinMessage.getAddress();
    MemberImpl member = clusterService.getMember(target);
    if (member == null) {
        return checkIfUsingAnExistingMemberUuid(joinMessage);
    }
    if (joinMessage.getUuid().equals(member.getUuid())) {
        sendMasterAnswer(target);
        if (node.isMaster()) {
            if (logger.isFineEnabled()) {
                logger.fine(format("Ignoring join request, member already exists: %s", joinMessage));
            }
            // send members update back to node trying to join again...
            Operation[] postJoinOps = nodeEngine.getPostJoinOperations();
            boolean isPostJoinOperation = postJoinOps != null && postJoinOps.length > 0;
            PostJoinOperation postJoinOp = isPostJoinOperation ? new PostJoinOperation(postJoinOps) : null;
            PartitionRuntimeState partitionRuntimeState = node.getPartitionService().createPartitionState();
            List<MemberInfo> memberInfos = createMemberInfoList(clusterService.getMemberImpls());
            Operation operation = new FinalizeJoinOperation(member.getUuid(), memberInfos, postJoinOp, clusterClock.getClusterTime(), clusterService.getClusterId(), clusterClock.getClusterStartTime(), clusterStateManager.getState(), clusterService.getClusterVersion(), partitionRuntimeState, false);
            nodeEngine.getOperationService().send(operation, target);
        }
        return true;
    }
    //   and wants to join back, so drop old member and process join request if this node becomes master
    if (node.isMaster() || target.equals(node.getMasterAddress())) {
        String msg = format("New join request has been received from an existing endpoint %s." + " Removing old member and processing join request...", member);
        logger.warning(msg);
        clusterService.doRemoveAddress(target, msg, false);
        Connection existing = node.connectionManager.getConnection(target);
        if (existing != connection) {
            if (existing != null) {
                existing.close(msg, null);
            }
            node.connectionManager.registerConnection(target, connection);
        }
        return false;
    }
    return true;
}
Also used : FinalizeJoinOperation(com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOperation) Address(com.hazelcast.nio.Address) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) MemberImpl(com.hazelcast.instance.MemberImpl) PartitionRuntimeState(com.hazelcast.internal.partition.PartitionRuntimeState) Connection(com.hazelcast.nio.Connection) PostJoinOperation(com.hazelcast.internal.cluster.impl.operations.PostJoinOperation) FinalizeJoinOperation(com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOperation) MemberInfoUpdateOperation(com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation) ConfigMismatchOperation(com.hazelcast.internal.cluster.impl.operations.ConfigMismatchOperation) Operation(com.hazelcast.spi.Operation) BeforeJoinCheckFailureOperation(com.hazelcast.internal.cluster.impl.operations.BeforeJoinCheckFailureOperation) SetMasterOperation(com.hazelcast.internal.cluster.impl.operations.SetMasterOperation) GroupMismatchOperation(com.hazelcast.internal.cluster.impl.operations.GroupMismatchOperation) PostJoinOperation(com.hazelcast.internal.cluster.impl.operations.PostJoinOperation) MasterDiscoveryOperation(com.hazelcast.internal.cluster.impl.operations.MasterDiscoveryOperation) JoinRequestOperation(com.hazelcast.internal.cluster.impl.operations.JoinRequestOperation) AuthenticationFailureOperation(com.hazelcast.internal.cluster.impl.operations.AuthenticationFailureOperation)

Example 24 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class ClusterServiceImpl method shutdownNodes.

private void shutdownNodes() {
    final Operation op = new ShutdownNodeOperation();
    logger.info("Sending shutting down operations to all members...");
    Collection<Member> members = getMembers(NON_LOCAL_MEMBER_SELECTOR);
    final long timeout = node.getProperties().getNanos(GroupProperty.CLUSTER_SHUTDOWN_TIMEOUT_SECONDS);
    final long startTime = System.nanoTime();
    while ((System.nanoTime() - startTime) < timeout && !members.isEmpty()) {
        for (Member member : members) {
            nodeEngine.getOperationService().send(op, member.getAddress());
        }
        try {
            Thread.sleep(CLUSTER_SHUTDOWN_SLEEP_DURATION_IN_MILLIS);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            logger.warning("Shutdown sleep interrupted. ", e);
            break;
        }
        members = getMembers(NON_LOCAL_MEMBER_SELECTOR);
    }
    logger.info("Number of other nodes remaining: " + getSize(NON_LOCAL_MEMBER_SELECTOR) + ". Shutting down itself.");
    final HazelcastInstanceImpl hazelcastInstance = node.hazelcastInstance;
    hazelcastInstance.getLifecycleService().shutdown();
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.HazelcastInstanceImpl) ShutdownNodeOperation(com.hazelcast.internal.cluster.impl.operations.ShutdownNodeOperation) MemberInfoUpdateOperation(com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation) Operation(com.hazelcast.spi.Operation) TriggerMemberListPublishOperation(com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOperation) MemberRemoveOperation(com.hazelcast.internal.cluster.impl.operations.MemberRemoveOperation) ShutdownNodeOperation(com.hazelcast.internal.cluster.impl.operations.ShutdownNodeOperation) Member(com.hazelcast.core.Member)

Example 25 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class OperationDescriptors method toOperationDesc.

public static String toOperationDesc(Operation op) {
    Class<? extends Operation> operationClass = op.getClass();
    if (PartitionIteratingOperation.class.isAssignableFrom(operationClass)) {
        PartitionIteratingOperation partitionIteratingOperation = (PartitionIteratingOperation) op;
        OperationFactory operationFactory = partitionIteratingOperation.getOperationFactory();
        String desc = DESCRIPTORS.get(operationFactory.getClass().getName());
        if (desc == null) {
            desc = PartitionIteratingOperation.class.getSimpleName() + "(" + operationFactory.getClass().getName() + ")";
            DESCRIPTORS.put(operationFactory.getClass().getName(), desc);
        }
        return desc;
    } else if (Backup.class.isAssignableFrom(operationClass)) {
        Backup backup = (Backup) op;
        Operation backupOperation = backup.getBackupOp();
        String desc = DESCRIPTORS.get(backupOperation.getClass().getName());
        if (desc == null) {
            desc = Backup.class.getSimpleName() + "(" + backup.getBackupOp().getClass().getName() + ")";
            DESCRIPTORS.put(backupOperation.getClass().getName(), desc);
        }
        return desc;
    } else {
        return operationClass.getName();
    }
}
Also used : PartitionIteratingOperation(com.hazelcast.spi.impl.operationservice.impl.operations.PartitionIteratingOperation) Backup(com.hazelcast.spi.impl.operationservice.impl.operations.Backup) PartitionIteratingOperation(com.hazelcast.spi.impl.operationservice.impl.operations.PartitionIteratingOperation) Operation(com.hazelcast.spi.Operation) OperationFactory(com.hazelcast.spi.OperationFactory)

Aggregations

Operation (com.hazelcast.spi.Operation)216 QuickTest (com.hazelcast.test.annotation.QuickTest)60 Test (org.junit.Test)60 OperationService (com.hazelcast.spi.OperationService)39 ParallelTest (com.hazelcast.test.annotation.ParallelTest)39 Future (java.util.concurrent.Future)19 Member (com.hazelcast.core.Member)18 Address (com.hazelcast.nio.Address)18 Data (com.hazelcast.nio.serialization.Data)18 HazelcastInstance (com.hazelcast.core.HazelcastInstance)17 AssertTask (com.hazelcast.test.AssertTask)17 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)15 ArrayList (java.util.ArrayList)15 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)14 NodeEngine (com.hazelcast.spi.NodeEngine)14 BackupAwareOperation (com.hazelcast.spi.BackupAwareOperation)13 BlockingOperation (com.hazelcast.spi.BlockingOperation)13 MapOperation (com.hazelcast.map.impl.operation.MapOperation)12 AtomicReference (java.util.concurrent.atomic.AtomicReference)11 Config (com.hazelcast.config.Config)10