Search in sources :

Example 81 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class CancellableDelegatingFuture method invokeCancelOperation.

private Future<Boolean> invokeCancelOperation(boolean mayInterruptIfRunning) {
    CancellationOperation op = new CancellationOperation(uuid, mayInterruptIfRunning);
    OperationService opService = nodeEngine.getOperationService();
    InvocationBuilder builder;
    if (partitionId > -1) {
        builder = opService.createInvocationBuilder(DistributedExecutorService.SERVICE_NAME, op, partitionId);
    } else {
        builder = opService.createInvocationBuilder(DistributedExecutorService.SERVICE_NAME, op, target);
    }
    builder.setTryCount(CANCEL_TRY_COUNT).setTryPauseMillis(CANCEL_TRY_PAUSE_MILLIS);
    return builder.invoke();
}
Also used : CancellationOperation(com.hazelcast.executor.impl.operations.CancellationOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) InvocationBuilder(com.hazelcast.spi.impl.operationservice.InvocationBuilder)

Example 82 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class AbstractJoiner method startClusterMerge.

protected void startClusterMerge(Address targetAddress, int expectedMemberListVersion) {
    ClusterServiceImpl clusterService = node.clusterService;
    if (!prepareClusterState(clusterService, expectedMemberListVersion)) {
        return;
    }
    OperationService operationService = node.nodeEngine.getOperationService();
    Collection<Member> memberList = clusterService.getMembers();
    Collection<Future> futures = new ArrayList<>(memberList.size());
    for (Member member : memberList) {
        if (!member.localMember()) {
            Operation op = new MergeClustersOp(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 op = new MergeClustersOp(targetAddress);
    op.setNodeEngine(node.nodeEngine).setService(clusterService).setOperationResponseHandler(createEmptyResponseHandler());
    operationService.run(op);
}
Also used : MergeClustersOp(com.hazelcast.internal.cluster.impl.operations.MergeClustersOp) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation) Member(com.hazelcast.cluster.Member)

Example 83 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class ClusterHeartbeatManager method sendHeartbeatComplaintToMaster.

private void sendHeartbeatComplaintToMaster(MembersViewMetadata senderMembersViewMetadata) {
    if (clusterService.isMaster()) {
        logger.warning("Cannot send heartbeat complaint for " + senderMembersViewMetadata + " to itself.");
        return;
    }
    Address masterAddress = clusterService.getMasterAddress();
    if (masterAddress == null) {
        logger.fine("Cannot send heartbeat complaint for " + senderMembersViewMetadata.getMemberAddress() + ", master address is not set.");
        return;
    }
    MembersViewMetadata localMembersViewMetadata = clusterService.getMembershipManager().createLocalMembersViewMetadata();
    Operation op = new HeartbeatComplaintOp(localMembersViewMetadata, senderMembersViewMetadata);
    OperationService operationService = nodeEngine.getOperationService();
    operationService.send(op, masterAddress);
}
Also used : HeartbeatComplaintOp(com.hazelcast.internal.cluster.impl.operations.HeartbeatComplaintOp) Address(com.hazelcast.cluster.Address) Operation(com.hazelcast.spi.impl.operationservice.Operation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 84 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class ClusterHeartbeatManager method handleHeartbeat.

public void handleHeartbeat(MembersViewMetadata senderMembersViewMetadata, UUID receiverUuid, long timestamp, Collection<MemberInfo> suspectedMembers) {
    Address senderAddress = senderMembersViewMetadata.getMemberAddress();
    try {
        long timeout = Math.min(TimeUnit.SECONDS.toMillis(1), heartbeatIntervalMillis / 2);
        if (!clusterServiceLock.tryLock(timeout, MILLISECONDS)) {
            logger.warning("Cannot handle heartbeat from " + senderAddress + ", could not acquire lock in time.");
            return;
        }
    } catch (InterruptedException e) {
        logger.warning("Cannot handle heartbeat from " + senderAddress + ", thread interrupted.");
        Thread.currentThread().interrupt();
        return;
    }
    try {
        if (!clusterService.isJoined()) {
            if (clusterService.getThisUuid().equals(receiverUuid)) {
                logger.fine("Ignoring heartbeat of sender: " + senderMembersViewMetadata + ", because node is not joined!");
            } else {
                // we know that sender version is 3.9 so we send explicit suspicion back even if we are not joined...
                logger.fine("Sending explicit suspicion to " + senderAddress + " for heartbeat " + senderMembersViewMetadata + ", because this node has received an invalid heartbeat before it joins to the cluster");
                OperationService operationService = nodeEngine.getOperationService();
                Operation op = new ExplicitSuspicionOp(senderMembersViewMetadata);
                operationService.send(op, senderAddress);
            }
            return;
        }
        MembershipManager membershipManager = clusterService.getMembershipManager();
        MemberImpl member = membershipManager.getMember(senderAddress, senderMembersViewMetadata.getMemberUuid());
        if (member != null) {
            if (clusterService.getThisUuid().equals(receiverUuid)) {
                if (onHeartbeat(member, timestamp)) {
                    // local timestamp is used on purpose here
                    membershipManager.handleReceivedSuspectedMembers(member, clusterClock.getClusterTime(), suspectedMembers);
                }
                return;
            }
            logger.warning("Local UUID mismatch on received heartbeat. local UUID: " + clusterService.getThisUuid() + " received UUID: " + receiverUuid + " with " + senderMembersViewMetadata);
        }
        onInvalidHeartbeat(senderMembersViewMetadata);
    } finally {
        clusterServiceLock.unlock();
    }
}
Also used : Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ExplicitSuspicionOp(com.hazelcast.internal.cluster.impl.operations.ExplicitSuspicionOp) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation)

Example 85 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class CacheProxy method containsKey.

@Override
public boolean containsKey(K key) {
    ensureOpen();
    validateNotNull(key);
    Data dataKey = serializationService.toData(key);
    Operation operation = operationProvider.createContainsKeyOperation(dataKey);
    OperationService operationService = getNodeEngine().getOperationService();
    int partitionId = getPartitionId(dataKey);
    InvocationFuture<Boolean> future = operationService.invokeOnPartition(getServiceName(), operation, partitionId);
    return future.joinInternal();
}
Also used : Data(com.hazelcast.internal.serialization.Data) CacheEventJournalReadOperation(com.hazelcast.cache.impl.journal.CacheEventJournalReadOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) CacheEventJournalSubscribeOperation(com.hazelcast.cache.impl.journal.CacheEventJournalSubscribeOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Aggregations

OperationService (com.hazelcast.spi.impl.operationservice.OperationService)140 Operation (com.hazelcast.spi.impl.operationservice.Operation)55 Test (org.junit.Test)54 HazelcastInstance (com.hazelcast.core.HazelcastInstance)46 QuickTest (com.hazelcast.test.annotation.QuickTest)41 Accessors.getOperationService (com.hazelcast.test.Accessors.getOperationService)40 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)40 Address (com.hazelcast.cluster.Address)31 NodeEngine (com.hazelcast.spi.impl.NodeEngine)31 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)24 Future (java.util.concurrent.Future)24 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)23 Config (com.hazelcast.config.Config)22 Member (com.hazelcast.cluster.Member)21 Data (com.hazelcast.internal.serialization.Data)12 SlowTest (com.hazelcast.test.annotation.SlowTest)12 ClusterService (com.hazelcast.internal.cluster.ClusterService)9 ILogger (com.hazelcast.logging.ILogger)7 ArrayList (java.util.ArrayList)7 IPartitionService (com.hazelcast.internal.partition.IPartitionService)6