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();
}
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);
}
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);
}
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();
}
}
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();
}
Aggregations