use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class AbstractInternalCacheProxy method clearInternal.
void clearInternal() {
try {
OperationService operationService = getNodeEngine().getOperationService();
OperationFactory operationFactory = operationProvider.createClearOperationFactory();
Map<Integer, Object> results = operationService.invokeOnAllPartitions(getServiceName(), operationFactory);
for (Object result : results.values()) {
if (result != null && result instanceof CacheClearResponse) {
Object response = ((CacheClearResponse) result).getResponse();
if (response instanceof Throwable) {
throw (Throwable) response;
}
}
}
} catch (Throwable t) {
throw rethrowAllowedTypeFirst(t, CacheException.class);
}
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class ClusterWideIterator method fetch.
protected List fetch() {
final OperationService operationService = cacheProxy.getNodeEngine().getOperationService();
if (prefetchValues) {
Operation operation = cacheProxy.operationProvider.createEntryIteratorOperation(lastTableIndex, fetchSize);
final InternalCompletableFuture<CacheEntryIterationResult> f = operationService.invokeOnPartition(CacheService.SERVICE_NAME, operation, partitionIndex);
CacheEntryIterationResult iteratorResult = f.join();
if (iteratorResult != null) {
setLastTableIndex(iteratorResult.getEntries(), iteratorResult.getTableIndex());
return iteratorResult.getEntries();
}
} else {
Operation operation = cacheProxy.operationProvider.createKeyIteratorOperation(lastTableIndex, fetchSize);
final InternalCompletableFuture<CacheKeyIterationResult> f = operationService.invokeOnPartition(CacheService.SERVICE_NAME, operation, partitionIndex);
CacheKeyIterationResult iteratorResult = f.join();
if (iteratorResult != null) {
setLastTableIndex(iteratorResult.getKeys(), iteratorResult.getTableIndex());
return iteratorResult.getKeys();
}
}
return null;
}
use of com.hazelcast.spi.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);
InternalCompletableFuture<Boolean> future = operationService.invokeOnPartition(getServiceName(), operation, partitionId);
return future.join();
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class CacheProxy method updateCacheListenerConfigOnOtherNodes.
private void updateCacheListenerConfigOnOtherNodes(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration, boolean isRegister) {
OperationService operationService = getNodeEngine().getOperationService();
Collection<Member> members = getNodeEngine().getClusterService().getMembers();
for (Member member : members) {
if (!member.localMember()) {
Operation op = new CacheListenerRegistrationOperation(getDistributedObjectName(), cacheEntryListenerConfiguration, isRegister);
operationService.invokeOnTarget(CacheService.SERVICE_NAME, op, member.getAddress());
}
}
}
use of com.hazelcast.spi.OperationService 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();
}
}
}
}
Aggregations