@Override public void sendResponse(Operation op, Object response) { if (response instanceof NormalResponse) { response = ((NormalResponse) response).getValue(); } else if (response == null) { response = NULL; } // we try to set the response in the responseArray if (!responseArray.compareAndSet(op.getPartitionId(), null, response)) { // duplicate response; should not happen. We can only log it since this method is being executed on some // general purpose executor. getLogger().warning("Duplicate response for " + op + " second response [" + response + "]" + "first response [" + responseArray.get(op.getPartitionId()) + "]"); return; } // if it is the last response we are waiting for, we can send the final response to the caller. if (pendingOperations.decrementAndGet() == 0) { sendResponse(); } }
private void executeOperations(PartitionAwareOperationFactory givenFactory) { final NodeEngine nodeEngine = getNodeEngine(); final PartitionAwareOperationFactory factory = givenFactory.createFactoryOnRunner(nodeEngine, partitions); final OperationResponseHandler responseHandler = new OperationResponseHandlerImpl(partitions); final Object service = getServiceName() == null ? null : getService(); PartitionTaskFactory f = new PartitionTaskFactory() { @Override public Operation create(int partitionId) { Operation op = factory.createPartitionOperation(partitionId) .setNodeEngine(nodeEngine) .setPartitionId(partitionId) .setReplicaIndex(getReplicaIndex()) .setOperationResponseHandler(responseHandler) .setServiceName(getServiceName()) .setService(service) .setCallerUuid(extractCallerUuid()); OperationAccessor.setCallerAddress(op, getCallerAddress()); return op; } }; getOperationService().executeOnPartitions(f, toPartitionBitSet()); }
private void executeOperations() { PartitionTaskFactory f = new PartitionTaskFactory() { private final NodeEngine nodeEngine = getNodeEngine(); private final OperationResponseHandler responseHandler = new OperationResponseHandlerImpl(partitions); private final Object service = getServiceName() == null ? null : getService(); @Override public Operation create(int partitionId) { Operation op = operationFactory.createOperation() .setNodeEngine(nodeEngine) .setPartitionId(partitionId) .setReplicaIndex(getReplicaIndex()) .setOperationResponseHandler(responseHandler) .setServiceName(getServiceName()) .setService(service) .setCallerUuid(extractCallerUuid()); OperationAccessor.setCallerAddress(op, getCallerAddress()); return op; } }; getOperationService().executeOnPartitions(f, toPartitionBitSet()); }
private void executeOperations(PartitionAwareOperationFactory givenFactory) { final NodeEngine nodeEngine = getNodeEngine(); final PartitionAwareOperationFactory factory = givenFactory.createFactoryOnRunner(nodeEngine, partitions); final OperationResponseHandler responseHandler = new OperationResponseHandlerImpl(partitions); final Object service = getServiceName() == null ? null : getService(); PartitionTaskFactory f = new PartitionTaskFactory() { @Override public Operation create(int partitionId) { Operation op = factory.createPartitionOperation(partitionId) .setNodeEngine(nodeEngine) .setPartitionId(partitionId) .setReplicaIndex(getReplicaIndex()) .setOperationResponseHandler(responseHandler) .setServiceName(getServiceName()) .setService(service) .setCallerUuid(extractCallerUuid()); OperationAccessor.setCallerAddress(op, getCallerAddress()); return op; } }; getOperationService().executeOnPartitions(f, toPartitionBitSet()); }
private void executeOperations() { PartitionTaskFactory f = new PartitionTaskFactory() { private final NodeEngine nodeEngine = getNodeEngine(); private final OperationResponseHandler responseHandler = new OperationResponseHandlerImpl(partitions); private final Object service = getServiceName() == null ? null : getService(); @Override public Operation create(int partitionId) { Operation op = operationFactory.createOperation() .setNodeEngine(nodeEngine) .setPartitionId(partitionId) .setReplicaIndex(getReplicaIndex()) .setOperationResponseHandler(responseHandler) .setServiceName(getServiceName()) .setService(service) .setCallerUuid(extractCallerUuid()); OperationAccessor.setCallerAddress(op, getCallerAddress()); return op; } }; getOperationService().executeOnPartitions(f, toPartitionBitSet()); }
@Override public void sendResponse(Operation op, Object response) { if (response instanceof NormalResponse) { response = ((NormalResponse) response).getValue(); } else if (response == null) { response = NULL; } // we try to set the response in the responseArray if (!responseArray.compareAndSet(op.getPartitionId(), null, response)) { // duplicate response; should not happen. We can only log it since this method is being executed on some // general purpose executor. getLogger().warning("Duplicate response for " + op + " second response [" + response + "]" + "first response [" + responseArray.get(op.getPartitionId()) + "]"); return; } // if it is the last response we are waiting for, we can send the final response to the caller. if (pendingOperations.decrementAndGet() == 0) { sendResponse(); } }