+
+ private static final class InstructionCallback implements FutureCallback<OperationResult> {
+
+ private final Instruction insn;
+
+ public InstructionCallback(final Instruction insn) {
+ this.insn = insn;
+ }
+
+ @Override
+ public void onSuccess(final OperationResult result) {
+ if (result.getFailure() != null) {
+ switch (result.getFailure()) {
+ case Failed:
+ case NoAck:
+ this.insn.executionCompleted(InstructionStatus.Failed, null);
+ break;
+ case Unsent:
+ this.insn.executionCompleted(InstructionStatus.Cancelled, null);
+ break;
+ default:
+ break;
+ }
+ } else {
+ this.insn.executionCompleted(InstructionStatus.Successful, null);
+ }
+ }
+
+ @Override
+ public void onFailure(final Throwable t) {
+ this.insn.executionCompleted(InstructionStatus.Failed, null);
+ }
+ }
+