The command response format

Overview

Most FlexRAID commands execute asynchronously.

When the execution of a command is successful (CommandResponse.success == true), the CommandStatus will be set and CommandStatus.referenceCode can be used to query for the status of the running task (See the status command). Additionally, CommandResponse.commandMessages will contain information about the successful operation.
If the execution was unsuccessful, the CommandStatus will be null and either or both of the CommandResponse.commandMessages and/or CommandResponse.serverMessages will have details on the reason for the failure.

For commands that execute synchronously, CommandStatus will always be null.

public class CommandResponse implements Serializable {
	private static final long serialVersionUID = -3950611043492884625L;

	private boolean success; //whether the command execution was successful or not
	private CommandStatus status; //null or the command's status when applicable
	private List<CommandMessage> commandMessages;
	private List<String> serverMessages;
}

 

public class InfoRequestCommandResponse<T> extends CommandResponse {
	private static final long serialVersionUID = -5122259168559136386L;

        //Each command using InfoRequestCommandResponse will describe what T is
	private final List<T> infos = new LinkedList<T>();// Can be any list implementation
}

 

public class CommandStatus implements Serializable {
	private static final long serialVersionUID = -1359324969972657518L;
	public static enum STATUS {STATUS_STARTED, STATUS_PROCESSING, STATUS_COMPLETED, 
		STATUS_ABORTED, STATUS_ABORTING, 
		STATUS_PAUSED, STATUS_PAUSING, 
		STATUS_RESUMED, STATUS_RESUMING};
	
	private String referenceCode; //A unique code identifying this operation
	private String task; //The name of a FlexRAID task
	private STATUS status;
	
	private ProgressSnapshot progress; //null or the progress if the operation is asynchronuous
	private ValidationReport report;
	
	private int processes;
	private int processesRequested;
}

 

public class CommandMessage implements Serializable {
	private static final long serialVersionUID = 7653982825854826281L;
	
	private String messageCode; //The resource bundle key for constructing the command message
	private List<String> messageData = new ArrayList<String>(); //A list of string to use as replacement values for the command message (0 or more)
}

 

public class ProgressSnapshot implements Serializable {
	private static final long serialVersionUID = -8165836709194695854L;
	
	private final List<ProgressInfo> infos = new ArrayList<ProgressInfo>();
	private long startTime; //time in millisecond since Epoch - 0 if not yet started
	private long endTime; //time in millisecond since Epoch - 0 if not yet ended
}

 

public final class ProgressInfo implements Serializable {
	private static final long serialVersionUID = -197743983667971791L;
	
	private String name; //The name of the operation segment
	private long totalCount; //The total process count
	private boolean ioProgress; //Whether this segment involves reading/writting data to/from disks
	
	private long startTime; //Time in millisecond sinde Epoch - 0 if not yet started
	private long pausedTime; //Duration in millisecond - 0 if never paused
	private long refTime; //Time in millisecond sinde Epoch - when this progress snapshot was taken
	private long remainingCount; //The remaining count to process
	private boolean ended; //Whether this segment has completed
	
	private List<ProgressInfo> subProgresses; //Operation segments can have sub-segments
			//For instance, the copyData command for instance tracks the number of files and folders being processed
			//along with the throughput information for the data being copied.
	
}

 

Be Sociable, Share!

No comments yet.

Leave a Reply

9 + 5 =