use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class ClusterStateManager method lockClusterStateOnAllMembers.
private void lockClusterStateOnAllMembers(ClusterStateChange stateChange, NodeEngineImpl nodeEngine, long leaseTime, String txnId, Collection<Member> members, int partitionStateVersion) {
Collection<Future> futures = new ArrayList<Future>(members.size());
final Address thisAddress = node.getThisAddress();
for (Member member : members) {
Operation op = new LockClusterStateOperation(stateChange, thisAddress, txnId, leaseTime, partitionStateVersion);
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.Operation in project hazelcast by hazelcast.
the class PostJoinOperation method run.
@Override
public void run() throws Exception {
if (operations != null && operations.length > 0) {
for (final Operation op : operations) {
op.beforeRun();
op.run();
op.afterRun();
}
}
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class FinalizeJoinOperation method sendPostJoinOperations.
private void sendPostJoinOperations() {
final ClusterServiceImpl clusterService = getService();
final NodeEngineImpl nodeEngine = clusterService.getNodeEngine();
// Post join operations must be lock free; means no locks at all;
// no partition locks, no key-based locks, no service level locks!
final Operation[] postJoinOperations = nodeEngine.getPostJoinOperations();
final OperationService operationService = nodeEngine.getOperationService();
if (postJoinOperations != null && postJoinOperations.length > 0) {
final Collection<Member> members = clusterService.getMembers();
for (Member member : members) {
if (!member.localMember()) {
PostJoinOperation operation = new PostJoinOperation(postJoinOperations);
operationService.createInvocationBuilder(ClusterServiceImpl.SERVICE_NAME, operation, member.getAddress()).setTryCount(POST_JOIN_TRY_COUNT).invoke();
}
}
}
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class MemberMapMetaDataFetcher method scanMembers.
@Override
protected List<InternalCompletableFuture> scanMembers(List<String> names) {
Collection<Member> members = clusterService.getMembers(DATA_MEMBER_SELECTOR);
List<InternalCompletableFuture> futures = new ArrayList<InternalCompletableFuture>(members.size());
for (Member member : members) {
Operation operation = new MapGetInvalidationMetaDataOperation(names);
Address address = member.getAddress();
try {
futures.add(operationService.invokeOnTarget(SERVICE_NAME, operation, address));
} catch (Exception e) {
if (logger.isWarningEnabled()) {
logger.warning("Cant fetch invalidation meta-data from address + " + address + " + [" + e.getMessage() + "]");
}
}
}
return futures;
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class PartitionIteratingOperation method executePartitionAwareOperations.
private void executePartitionAwareOperations(PartitionAwareOperationFactory givenFactory) {
PartitionAwareOperationFactory factory = givenFactory.createFactoryOnRunner(getNodeEngine());
NodeEngine nodeEngine = getNodeEngine();
int[] operationFactoryPartitions = factory.getPartitions();
partitions = operationFactoryPartitions == null ? partitions : operationFactoryPartitions;
OperationResponseHandler responseHandler = new OperationResponseHandlerImpl(partitions);
OperationService operationService = nodeEngine.getOperationService();
Object service = getServiceName() == null ? null : getService();
for (int partitionId : partitions) {
Operation op = factory.createPartitionOperation(partitionId).setNodeEngine(nodeEngine).setPartitionId(partitionId).setReplicaIndex(getReplicaIndex()).setOperationResponseHandler(responseHandler).setServiceName(getServiceName()).setService(service).setCallerUuid(extractCallerUuid());
OperationAccessor.setCallerAddress(op, getCallerAddress());
operationService.execute(op);
}
}
Aggregations