protected Set<Data> keySetInternal() { final NodeEngine nodeEngine = getNodeEngine(); try { Map<Integer, Object> results = nodeEngine .getOperationService() .invokeOnAllPartitions( CollectionService.SERVICE_NAME, new MultiMapOperationFactory(proxyId, OperationFactoryType.KEY_SET)); Set<Data> keySet = new HashSet<Data>(); for (Object result : results.values()) { if (result == null) { continue; } CollectionResponse response = nodeEngine.toObject(result); if (response.getCollection() != null) { keySet.addAll(response.getCollection()); } } return keySet; } catch (Throwable throwable) { throw ExceptionUtil.rethrow(throwable); } }
public void clear() { final NodeEngine nodeEngine = getNodeEngine(); try { nodeEngine .getOperationService() .invokeOnAllPartitions( CollectionService.SERVICE_NAME, new MultiMapOperationFactory(proxyId, OperationFactoryType.CLEAR)); } catch (Throwable throwable) { throw ExceptionUtil.rethrow(throwable); } }
protected Map entrySetInternal() { final NodeEngine nodeEngine = getNodeEngine(); try { Map<Integer, Object> results = nodeEngine .getOperationService() .invokeOnAllPartitions( CollectionService.SERVICE_NAME, new MultiMapOperationFactory(proxyId, OperationFactoryType.ENTRY_SET)); return results; } catch (Throwable throwable) { throw ExceptionUtil.rethrow(throwable); } }
private Object invokeData(CollectionOperation operation, Data dataKey) { final NodeEngine nodeEngine = getNodeEngine(); try { int partitionId = nodeEngine.getPartitionService().getPartitionId(dataKey); Invocation inv = nodeEngine .getOperationService() .createInvocationBuilder(CollectionService.SERVICE_NAME, operation, partitionId) .build(); Future f = inv.invoke(); return nodeEngine.toObject(f.get()); } catch (Throwable throwable) { throw ExceptionUtil.rethrow(throwable); } }
public int size() { final NodeEngine nodeEngine = getNodeEngine(); try { Map<Integer, Object> results = nodeEngine .getOperationService() .invokeOnAllPartitions( CollectionService.SERVICE_NAME, new MultiMapOperationFactory(proxyId, OperationFactoryType.SIZE)); int size = 0; for (Object obj : results.values()) { if (obj == null) { continue; } Integer result = nodeEngine.toObject(obj); size += result; } return size; } catch (Throwable throwable) { throw ExceptionUtil.rethrow(throwable); } }
private <T> T invoke(Operation operation, Data dataKey) { final NodeEngine nodeEngine = getNodeEngine(); try { int partitionId = nodeEngine.getPartitionService().getPartitionId(dataKey); Invocation invocation = nodeEngine .getOperationService() .createInvocationBuilder(CollectionService.SERVICE_NAME, operation, partitionId) .build(); Future f; Object o; if (config.isStatisticsEnabled()) { long time = System.currentTimeMillis(); f = invocation.invoke(); o = f.get(); if (operation instanceof PutOperation) { getService() .getLocalMultiMapStatsImpl(proxyId) .incrementPuts(System.currentTimeMillis() - time); } else if (operation instanceof RemoveOperation || operation instanceof RemoveAllOperation) { getService() .getLocalMultiMapStatsImpl(proxyId) .incrementRemoves(System.currentTimeMillis() - time); } else if (operation instanceof GetAllOperation) { getService() .getLocalMultiMapStatsImpl(proxyId) .incrementGets(System.currentTimeMillis() - time); } } else { f = invocation.invoke(); o = f.get(); } return (T) nodeEngine.toObject(o); } catch (Throwable throwable) { throw ExceptionUtil.rethrow(throwable); } }
protected boolean containsInternal(Data key, Data value) { final NodeEngine nodeEngine = getNodeEngine(); try { Map<Integer, Object> results = nodeEngine .getOperationService() .invokeOnAllPartitions( CollectionService.SERVICE_NAME, new MultiMapOperationFactory(proxyId, OperationFactoryType.CONTAINS, key, value)); for (Object obj : results.values()) { if (obj == null) { continue; } Boolean result = nodeEngine.toObject(obj); if (result) { return true; } } return false; } catch (Throwable throwable) { throw ExceptionUtil.rethrow(throwable); } }