private Map<Integer, Object> retryPartitions(Collection<Integer> partitions, OperationFactory operationFactory) { try { return operationService.invokeOnPartitions(SERVICE_NAME, operationFactory, partitions); } catch (Throwable t) { throw rethrow(t); } }
private Map<Integer, Object> retryPartitions(Collection<Integer> partitions, OperationFactory operationFactory) { try { return operationService.invokeOnPartitions(SERVICE_NAME, operationFactory, partitions); } catch (Throwable t) { throw rethrow(t); } }
protected void invokePutAllOperationFactory(long size, int[] partitions, MapEntries[] entries) throws Exception { OperationFactory factory = operationProvider.createPutAllOperationFactory(name, partitions, entries); long startTimeNanos = System.nanoTime(); operationService.invokeOnPartitions(SERVICE_NAME, factory, partitions); localMapStats.incrementPutLatencyNanos(size, System.nanoTime() - startTimeNanos); }
protected void invokePutAllOperationFactory(long size, int[] partitions, MapEntries[] entries) throws Exception { OperationFactory factory = operationProvider.createPutAllOperationFactory(name, partitions, entries); long startTimeNanos = System.nanoTime(); operationService.invokeOnPartitions(SERVICE_NAME, factory, partitions); localMapStats.incrementPutLatencyNanos(size, System.nanoTime() - startTimeNanos); }
protected void getAllInternal(Set<K> keys, List<Data> dataKeys, List<Object> resultingKeyValuePairs) { if (keys == null || keys.isEmpty()) { return; } if (dataKeys.isEmpty()) { toDataCollectionWithNonNullKeyValidation(keys, dataKeys); } Collection<Integer> partitions = getPartitionsForKeys(dataKeys); Map<Integer, Object> responses; try { OperationFactory operationFactory = operationProvider.createGetAllOperationFactory(name, dataKeys); long startTimeNanos = System.nanoTime(); responses = operationService.invokeOnPartitions(SERVICE_NAME, operationFactory, partitions); for (Object response : responses.values()) { MapEntries entries = toObject(response); for (int i = 0; i < entries.size(); i++) { resultingKeyValuePairs.add(entries.getKey(i)); resultingKeyValuePairs.add(entries.getValue(i)); } } localMapStats.incrementGetLatencyNanos(dataKeys.size(), System.nanoTime() - startTimeNanos); } catch (Exception e) { throw rethrow(e); } }
protected void getAllInternal(Set<K> keys, List<Data> dataKeys, List<Object> resultingKeyValuePairs) { if (keys == null || keys.isEmpty()) { return; } if (dataKeys.isEmpty()) { toDataCollectionWithNonNullKeyValidation(keys, dataKeys); } Collection<Integer> partitions = getPartitionsForKeys(dataKeys); Map<Integer, Object> responses; try { OperationFactory operationFactory = operationProvider.createGetAllOperationFactory(name, dataKeys); long startTimeNanos = System.nanoTime(); responses = operationService.invokeOnPartitions(SERVICE_NAME, operationFactory, partitions); for (Object response : responses.values()) { MapEntries entries = toObject(response); for (int i = 0; i < entries.size(); i++) { resultingKeyValuePairs.add(entries.getKey(i)); resultingKeyValuePairs.add(entries.getValue(i)); } } localMapStats.incrementGetLatencyNanos(dataKeys.size(), System.nanoTime() - startTimeNanos); } catch (Exception e) { throw rethrow(e); } }
/** * TODO This method can be replaced with {@code executeOnKeysInternalAsync(...).get()} in 3.12 */ public Map<K, Object> executeOnKeysInternal(Set<K> keys, Set<Data> dataKeys, EntryProcessor entryProcessor) { // TODO: why are we not forwarding to executeOnKeysInternal(keys, entryProcessor, null) or some other kind of fake // callback? now there is a lot of code duplication if (dataKeys.isEmpty()) { toDataCollectionWithNonNullKeyValidation(keys, dataKeys); } Collection<Integer> partitionsForKeys = getPartitionsForKeys(dataKeys); Map<K, Object> result = createHashMap(partitionsForKeys.size()); try { OperationFactory operationFactory = operationProvider.createMultipleEntryOperationFactory(name, dataKeys, entryProcessor); Map<Integer, Object> results = operationService.invokeOnPartitions(SERVICE_NAME, operationFactory, partitionsForKeys); for (Object object : results.values()) { if (object != null) { MapEntries mapEntries = (MapEntries) object; mapEntries.putAllToMap(serializationService, result); } } } catch (Throwable t) { throw rethrow(t); } return result; }
@Override public Map<K, V> getAll(Set<? extends K> keys, ExpiryPolicy expiryPolicy) { ensureOpen(); validateNotNull(keys); if (keys.isEmpty()) { return emptyMap(); } final int keyCount = keys.size(); final Set<Data> ks = createHashSet(keyCount); for (K key : keys) { validateNotNull(key); Data dataKey = serializationService.toData(key); ks.add(dataKey); } Map<K, V> result = createHashMap(keyCount); Collection<Integer> partitions = getPartitionsForKeys(ks); try { OperationFactory factory = operationProvider.createGetAllOperationFactory(ks, expiryPolicy); OperationService operationService = getNodeEngine().getOperationService(); Map<Integer, Object> responses = operationService.invokeOnPartitions(getServiceName(), factory, partitions); for (Object response : responses.values()) { MapEntries mapEntries = serializationService.toObject(response); mapEntries.putAllToMap(serializationService, result); } } catch (Throwable e) { throw rethrowAllowedTypeFirst(e, CacheException.class); } return result; }
@Override public Map<K, V> getAll(Set<? extends K> keys, ExpiryPolicy expiryPolicy) { ensureOpen(); validateNotNull(keys); if (keys.isEmpty()) { return emptyMap(); } final int keyCount = keys.size(); final Set<Data> ks = createHashSet(keyCount); for (K key : keys) { validateNotNull(key); Data dataKey = serializationService.toData(key); ks.add(dataKey); } Map<K, V> result = createHashMap(keyCount); Collection<Integer> partitions = getPartitionsForKeys(ks); try { OperationFactory factory = operationProvider.createGetAllOperationFactory(ks, expiryPolicy); OperationService operationService = getNodeEngine().getOperationService(); Map<Integer, Object> responses = operationService.invokeOnPartitions(getServiceName(), factory, partitions); for (Object response : responses.values()) { MapEntries mapEntries = serializationService.toObject(response); mapEntries.putAllToMap(serializationService, result); } } catch (Throwable e) { throw rethrowAllowedTypeFirst(e, CacheException.class); } return result; }
results = operationService.invokeOnPartitions(SERVICE_NAME, operation, singletonList(partitionId)); } else { OperationFactory operation = operationProvider.createPartitionWideEntryWithPredicateOperationFactory(
protected void removeAllInternal(Predicate predicate) { try { if (predicate instanceof PartitionPredicate) { PartitionPredicate partitionPredicate = (PartitionPredicate) predicate; OperationFactory operation = operationProvider .createPartitionWideEntryWithPredicateOperationFactory(name, ENTRY_REMOVING_PROCESSOR, partitionPredicate.getTarget()); Data partitionKey = toDataWithStrategy(partitionPredicate.getPartitionKey()); int partitionId = partitionService.getPartitionId(partitionKey); // invokeOnPartitions is used intentionally here, instead of invokeOnPartition, since // the later one doesn't support PartitionAwareOperationFactory, which we need to use // to speed up the removal operation using global indexes // (see PartitionWideEntryWithPredicateOperationFactory.createFactoryOnRunner). operationService.invokeOnPartitions(SERVICE_NAME, operation, singletonList(partitionId)); } else { OperationFactory operation = operationProvider .createPartitionWideEntryWithPredicateOperationFactory(name, ENTRY_REMOVING_PROCESSOR, predicate); operationService.invokeOnAllPartitions(SERVICE_NAME, operation); } } catch (Throwable t) { throw rethrow(t); } }
results = operationService.invokeOnPartitions(SERVICE_NAME, operation, Collections.singletonList(partitionId)); } else { OperationFactory operation = operationProvider.createPartitionWideEntryWithPredicateOperationFactory(