Commit 13ca73a3 authored by chiaming2000's avatar chiaming2000
Browse files

Batch operation:

Added support to abort batch operation (support batch opeartion abort
API/protocol) 
parent b435ff5f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -85,4 +85,9 @@ public class DefaultBatchOperation implements BatchOperation {
        return batchIdSequence++;
    }

    @Override
    public void abort() throws KineticException {
        this.client.abortBatchOperation(batchId);
    }

}
+15 −0
Original line number Diff line number Diff line
@@ -1052,6 +1052,21 @@ public class DefaultKineticClient implements AdvancedKineticClient {
        MessageFactory.checkReply(request, response);
    }

    void abortBatchOperation(int batchId) throws KineticException {

        KineticMessage request = null;
        KineticMessage response = null;

        // create get request message
        request = MessageFactory.createAbortBatchRequestMessage(batchId);

        // send request
        response = this.client.request(request);

        // check response
        MessageFactory.checkReply(request, response);
    }

    /**
     * {@inheritDoc}
     */
+14 −0
Original line number Diff line number Diff line
@@ -446,6 +446,20 @@ public class MessageFactory {
        return kineticMessage;
    }

    public static KineticMessage createAbortBatchRequestMessage(int batchId)
            throws KineticException {

        KineticMessage kineticMessage = createKineticMessageWithBuilder();

        Command.Builder request = (Command.Builder) kineticMessage.getCommand();

        request.getHeaderBuilder().setMessageType(MessageType.ABORT_BATCH);

        request.getHeaderBuilder().setBatchID(batchId);

        return kineticMessage;
    }

    /**
     * create an internal message with empty builder message.
     *
+9 −1
Original line number Diff line number Diff line
@@ -110,7 +110,15 @@ public interface BatchOperation {

    /**
     * Abort the current batch operation.
     * <p>
     * When this call returned successfully, all the commands queued in the
     * current batch are aborted. Resources related to the current batch are
     * cleaned up and released.
     * <p>
     * 
     * @throws KineticException
     *             if any internal error occurred.
     * 
     */
    // public void abort();
    public void abort() throws KineticException;
}
+2 −1
Original line number Diff line number Diff line
@@ -468,7 +468,8 @@ public class SimulatorEngine implements MessageService {

            checkBatchMode(kmreq);

            if (mtype == MessageType.START_BATCH) {
            if (mtype == MessageType.START_BATCH
                    || mtype == MessageType.ABORT_BATCH) {
                // do nothing, simply send OK response
                ;
            } else if (kmreq.getIsBatchMessage()) {
Loading