Commit 3ea94f5a authored by chiaming2000's avatar chiaming2000
Browse files

Added Java API to support FLUSHALLDATA message type (protocol).

Please note that the simulator has no effective (no op) on this command
at this time. 

The 'flush' operation will be added to the simulator at a later time
after evaluated an appropriate solution to support this opeartion.
 
parent b1badd92
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ BASE_DIR=`cd "$BASE_DIR"; pwd`
PROTO_REPO_URL=https://github.com/Seagate/Kinetic-Protocol.git
PROTO_FILE=$BASE_DIR/kinetic-common/src/main/java/com/seagate/kinetic/proto/kinetic.proto
CLONE_DIR=$BASE_DIR/bin/Kinetic-Protocol
PROTO_RELEASE_VERSION=2.0.2
PROTO_RELEASE_VERSION=2.0.3

function syncFromProtoRepo(){
    if [ -d "$CLONE_DIR" ]; then
+26 −0
Original line number Diff line number Diff line
@@ -792,6 +792,32 @@ public class DefaultKineticClient implements AdvancedKineticClient {
        return time;
    }
    
    /**
     * {@inheritDoc}
     */
    @Override
    public void flush() throws KineticException {

        try {

            // create get request message
            KineticMessage request = MessageFactory.createFlushDataRequestMessage();

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

            // check response
            MessageFactory.checkFushDataReply(response);

        } catch (KineticException ke) {
            throw ke;
        } catch (Exception e) {
            KineticException lce = new KineticException(e.getMessage(), e);
            throw lce;
        }

    }

    /**
     * Set persist option flag to the protocol buffer message.
     *
+35 −0
Original line number Diff line number Diff line
@@ -470,6 +470,41 @@ public class MessageFactory {

    }
    
    public static KineticMessage createFlushDataRequestMessage()
            throws KineticException {

        KineticMessage im = createKineticMessageWithBuilder();

        Message.Builder request = (Builder) im.getMessage();

        request.getCommandBuilder().getHeaderBuilder()
        .setMessageType(MessageType.FLUSHALLDATA);

        return im;
    }
    
    public static void checkFushDataReply(KineticMessage reply)
            throws KineticException {

        if (StatusCode.SUCCESS != reply.getMessage().getCommand().getStatus()
                .getCode()) {
            throw new KineticException("Kinetic Command Exception: "
                    + reply.getMessage().getCommand().getStatus().getCode()
                    + ": "
                    + reply.getMessage().getCommand().getStatus()
                    .getStatusMessage());
        }

        if (reply.getMessage().getCommand().getHeader().getMessageType() != MessageType.FLUSHALLDATA_RESPONSE) {
            throw new KineticException(
                    "Received wrong message type., received="
                            + reply.getMessage().getCommand().getHeader()
                            .getMessageType()
                            + ", expected=" + MessageType.FLUSHALLDATA_RESPONSE);
        }

    }

    /**
     * create an internal message with empty builder message.
     *
+2 −2
Original line number Diff line number Diff line
@@ -47,12 +47,12 @@ public class ClientConfiguration extends Properties {
	 /**
     * current supported kinetic protocol version on kinetic-protocol repo.
     */
    public static final String PROTOCOL_VERSION = "2.0.2";
    public static final String PROTOCOL_VERSION = "2.0.3";
    
    /**
     * current supported protocol source commit hash on kinetic-protocol repo.
     */
    public static final String PROTOCOL_SOURCE_HASH = "f6e21e281272b46c620284781cdb3a36a6c7a564";
    public static final String PROTOCOL_SOURCE_HASH = "389e63f814cc0b5d699104c08854b5b9c1abab38";

	// kinetic server host
	private String host = "localhost";
+11 −0
Original line number Diff line number Diff line
@@ -66,6 +66,17 @@ public interface KineticClient extends GenericKineticClient {
	 */
	public long noop() throws KineticException;
	
	/**
	 * The flush operation flushes any outstanding PUTs or DELETEs on the device.
	 * <p>
	 * Currently only Kinetic drive supports this operation.  This command has no effect on the simulator. 
	 * 
	 * @throws KineticException 
	 *             if any internal error occurred.
	 *             
	 */
	 public void flush() throws KineticException;

	/**
	 * Put the specified <code>Entry</code> entry to the persistent store.
	 * Replace the version in the store with the new version. If the version in
Loading