private void invokeOnAllPartitions() { for (Map.Entry<Address, List<Integer>> mp : memberPartitions.entrySet()) { Address address = mp.getKey(); List<Integer> partitions = mp.getValue(); PartitionIteratingOperation op = new PartitionIteratingOperation(operationFactory, toIntArray(partitions)); Future future = operationService.createInvocationBuilder(serviceName, op, address) .setTryCount(TRY_COUNT) .setTryPauseMillis(TRY_PAUSE_MILLIS) .invoke(); futures.put(address, future); } }
private void retryFailedPartitions() throws InterruptedException, ExecutionException { List<Integer> failedPartitions = new LinkedList<Integer>(); for (Map.Entry<Integer, Object> partitionResult : partitionResults.entrySet()) { int partitionId = partitionResult.getKey(); Object result = partitionResult.getValue(); if (result instanceof Throwable) { failedPartitions.add(partitionId); } } for (Integer failedPartition : failedPartitions) { Operation operation; PartitionAwareOperationFactory partitionAwareFactory = extractPartitionAware(operationFactory); if (partitionAwareFactory != null) { operation = partitionAwareFactory.createPartitionOperation(failedPartition); } else { operation = operationFactory.createOperation(); } Future future = operationService.createInvocationBuilder(serviceName, operation, failedPartition).invoke(); partitionResults.put(failedPartition, future); } for (Integer failedPartition : failedPartitions) { Future future = (Future) partitionResults.get(failedPartition); Object result = future.get(); partitionResults.put(failedPartition, result); } } }
private void invokeOnAllPartitions() { if (memberPartitions.isEmpty()) { future.setResult(Collections.EMPTY_MAP); return; } for (final Map.Entry<Address, List<Integer>> mp : memberPartitions.entrySet()) { final Address address = mp.getKey(); List<Integer> partitions = mp.getValue(); PartitionIteratingOperation op = new PartitionIteratingOperation(operationFactory, toIntArray(partitions)); operationService.createInvocationBuilder(serviceName, op, address) .setTryCount(TRY_COUNT) .setTryPauseMillis(TRY_PAUSE_MILLIS) .invoke() .andThen(new FirstAttemptExecutionCallback(partitions)); } }
private void invokeOnAllPartitions() { if (memberPartitions.isEmpty()) { future.setResult(Collections.EMPTY_MAP); if (callback != null) { callback.onResponse(Collections.EMPTY_MAP); } return; } for (final Map.Entry<Address, List<Integer>> mp : memberPartitions.entrySet()) { final Address address = mp.getKey(); List<Integer> partitions = mp.getValue(); PartitionIteratingOperation op = new PartitionIteratingOperation(operationFactory, toIntArray(partitions)); operationService.createInvocationBuilder(serviceName, op, address) .setTryCount(TRY_COUNT) .setTryPauseMillis(TRY_PAUSE_MILLIS) .invoke() .andThen(new FirstAttemptExecutionCallback(mp.getValue())); } }
private void retryPartition(final int partitionId) { Operation operation; PartitionAwareOperationFactory partitionAwareFactory = extractPartitionAware(operationFactory); if (partitionAwareFactory != null) { operation = partitionAwareFactory.createPartitionOperation(partitionId); } else { operation = operationFactory.createOperation(); } operationService.createInvocationBuilder(serviceName, operation, partitionId) .invoke() .andThen(new ExecutionCallback<Object>() { @Override public void onResponse(Object response) { setPartitionResult(partitionId, response); decrementLatchAndHandle(1); } @Override public void onFailure(Throwable t) { setPartitionResult(partitionId, t); decrementLatchAndHandle(1); } }); }
private void retryPartition(final int partitionId) { Operation operation; PartitionAwareOperationFactory partitionAwareFactory = extractPartitionAware(operationFactory); if (partitionAwareFactory != null) { operation = partitionAwareFactory.createPartitionOperation(partitionId); } else { operation = operationFactory.createOperation(); } operationService.createInvocationBuilder(serviceName, operation, partitionId) .invoke() .andThen(new ExecutionCallback<Object>() { @Override public void onResponse(Object response) { setPartitionResult(partitionId, response); decrementLatchAndHandle(1); } @Override public void onFailure(Throwable t) { setPartitionResult(partitionId, t); decrementLatchAndHandle(1); } }); }