Package com.mapr.cli.common
Class ListCommand
- java.lang.Object
-
- com.mapr.cliframework.base.CLIBaseClass
-
- com.mapr.cli.common.ListCommand
-
- All Implemented Interfaces:
ListIterator,com.mapr.cliframework.base.CLIInterface
- Direct Known Subclasses:
AlarmCommands,DiskCommands,EntityCommands,FileFilterCommands,GlobalNSCommands,Heatmap,OffloadRuleCommands,S3BucketCommands,S3DomainCommands,S3KeysCommands,S3UserCommands,SecurityPolicyCommands,ServerCommands,SnapshotCommands,TierCommands,VirtualIPCommands,VolumeCommands
public abstract class ListCommand extends com.mapr.cliframework.base.CLIBaseClass implements ListIterator
-
-
Constructor Summary
Constructors Constructor Description ListCommand(com.mapr.cliframework.base.ProcessedInput input, com.mapr.cliframework.base.CLICommand cliCommand)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract com.google.protobuf.MessageLitebuildNextRequest(com.google.protobuf.MessageLite prevReq, com.google.protobuf.MessageLite prevResp)Builds the next request object by inspecting the previous request and previous response.protected <T> java.util.List<com.mapr.fs.cli.proto.CLIProto.Filter>getFilters(java.util.Map<T,com.mapr.cliframework.util.FieldInfo> table, java.lang.String filterParam)Helper method for the sub classes to build a list of Filters from the input filter string.protected com.mapr.fs.cli.proto.CLIProto.LimitergetNextLimiter(int prevStart, int prevCount, int origStart, int origLimit, int numRecsPerRpc)Helper method to build limiter for next request.protected booleanhasMore(int origStart, int origLimit, int prevStart, int prevCount)A method that helps the sub classes to determine if there are more records to be processed.abstract booleanhasMore(com.google.protobuf.MessageLite prevReq, com.google.protobuf.MessageLite prevResp)Inspect the last request and last response to see if there are more records to be fetched.voidlist(com.mapr.cliframework.base.CommandOutput.OutputHierarchy out)Initiates the iteration process.abstract voidprocessResponse(com.mapr.cliframework.base.CommandOutput.OutputHierarchy out, com.google.protobuf.MessageLite resp)Parse the response and populate the output hierarchy.abstract com.google.protobuf.MessageLitesendRequest(com.google.protobuf.MessageLite req)Send the request using RPC and fetch the response.-
Methods inherited from class com.mapr.cliframework.base.CLIBaseClass
executeCommand, executeRealCommand, executeSimpleSHHCommand, executeSimpleSHHCommand, getCLICommand, getCommandUsage, getGIds, getInput, getKeyType, getParamBooleanValue, getParamDateValue, getParamIntValue, getParamLongValue, getParamObjectValue, getParamTextValue, getUserCredentials, getUserId, getUserLoginId, getVersion, isParamPresent, isParamValueEmpty, setServerCall, setUserCredentials, setVersion, validateInput
-
-
-
-
Method Detail
-
getNextLimiter
protected com.mapr.fs.cli.proto.CLIProto.Limiter getNextLimiter(int prevStart, int prevCount, int origStart, int origLimit, int numRecsPerRpc)Helper method to build limiter for next request.- Parameters:
prevStart- - start index of the limiter in prev requestprevCount- - number of records returned in prev responseorigStart- - starting index of the records originally requested (using the cli -start param)origLimit- - number of records originally requested (using the cli -limit param)numRecsPerRpc- - number of records an rpc response can carry- Returns:
- - Limiter object for the next request
-
getFilters
protected <T> java.util.List<com.mapr.fs.cli.proto.CLIProto.Filter> getFilters(java.util.Map<T,com.mapr.cliframework.util.FieldInfo> table, java.lang.String filterParam) throws com.mapr.cliframework.base.CLIProcessingExceptionHelper method for the sub classes to build a list of Filters from the input filter string.- Type Parameters:
T-- Parameters:
table-filterParam-- Returns:
- Throws:
com.mapr.cliframework.base.CLIProcessingException
-
hasMore
protected boolean hasMore(int origStart, int origLimit, int prevStart, int prevCount)A method that helps the sub classes to determine if there are more records to be processed.- Parameters:
origStart- - The original value for the -start parameterorigLimit- - The original value for the -limit parameterprevStart- - The value for the start parameter supplied during previous iteration.prevCount- - The number of records returned in the previous iteration.- Returns:
- - true, if there are more records. false otherwise.
-
list
public void list(com.mapr.cliframework.base.CommandOutput.OutputHierarchy out) throws com.mapr.cliframework.base.CLIProcessingExceptionDescription copied from interface:ListIteratorInitiates the iteration process. while (hasMore()) { buildNextRequest sendRequest processResponse }- Specified by:
listin interfaceListIterator- Parameters:
out- - The output of all the processed responses.- Throws:
com.mapr.cliframework.base.CLIProcessingException
-
hasMore
public abstract boolean hasMore(com.google.protobuf.MessageLite prevReq, com.google.protobuf.MessageLite prevResp) throws com.mapr.cliframework.base.CLIProcessingExceptionDescription copied from interface:ListIteratorInspect the last request and last response to see if there are more records to be fetched.- Specified by:
hasMorein interfaceListIterator- Returns:
- - true, if there are more records. false, if no more.
- Throws:
com.mapr.cliframework.base.CLIProcessingException
-
buildNextRequest
public abstract com.google.protobuf.MessageLite buildNextRequest(com.google.protobuf.MessageLite prevReq, com.google.protobuf.MessageLite prevResp) throws com.mapr.cliframework.base.CLIProcessingExceptionDescription copied from interface:ListIteratorBuilds the next request object by inspecting the previous request and previous response.- Specified by:
buildNextRequestin interfaceListIterator- Returns:
- - new request object
- Throws:
com.mapr.cliframework.base.CLIProcessingException
-
sendRequest
public abstract com.google.protobuf.MessageLite sendRequest(com.google.protobuf.MessageLite req) throws com.mapr.cliframework.base.CLIProcessingExceptionDescription copied from interface:ListIteratorSend the request using RPC and fetch the response.- Specified by:
sendRequestin interfaceListIterator- Parameters:
req- - request object.- Returns:
- - the response object.
- Throws:
com.mapr.cliframework.base.CLIProcessingException
-
processResponse
public abstract void processResponse(com.mapr.cliframework.base.CommandOutput.OutputHierarchy out, com.google.protobuf.MessageLite resp) throws com.mapr.cliframework.base.CLIProcessingExceptionDescription copied from interface:ListIteratorParse the response and populate the output hierarchy.- Specified by:
processResponsein interfaceListIterator- Parameters:
out- -CommandOutput.OutputHierarchyresp- - response object- Throws:
com.mapr.cliframework.base.CLIProcessingException
-
-