Progress is represented by two attributes:
Because {@code AdminCommand} can execute other {@code AdminCommand} and command execution on a cluster triggers the replication process the {@code ProgressStatus} can have child ProgressStatus objects. Any {@code ProgressStatus} can be used independently without knowledge of the parent's {@code ProgressStatus}.
Any child ProgressStatus objects can be named by its creator. The {@code name}is mainly used in connection with the {@code message} attribute to define its context.
Usage:
First inject a {@code ProgressStatus} into an {@code AdminCommand} implementation.
Optionally pass the total step count or name to provide context of the progress (if the name is not provided it defaults to the command's name).@Progress private ProgressStatus ps;
@Progress(totalStepCount=10, name="deploy")
Total step count can also be set via this method. This overrides the count if it was previously set (possibly via the @Progress annotation).
setTotalStepCount(int totalStepCount);
The primary use of {@code tatalStepCount} is as the denominator for computing the completion percentage as reported in the commands progress report:
percent complete = current step count / total step count * 100
The total step count can be changed after being set but may result in the completion percentage jumping (forward or backwards).
If the total step count is not set then a completion percentage will not be available.
The {@code progress()} methods are used to move progress forward (or backwards).The current step count will be incremented by the number of steps indicated.
progress(String message, int steps); progress(String message); progress(int steps);
The version of progress that only takes a message will cause a new message to be displayed but will not change the completion percentage.
It is possible to set the current step count to a specific value, for example when an error occurs and the command must repeat a set of operations.
setCurrentStepCount(int stepCount);
This will likely result in the overall completion percentage jumping when the next progress() message is generated.
Any ProgressStatus can be completed using methods
complete(String message); complete();
Indicates the command is complete and no further progress status will be delivered. Subsequent invocations of progress() will be ignored. This method also invokes {@code complete()} on all child ProgressStatus objects.
It is also possible to create a child ProgressStatus with independent logic used to determine progress. The parent {@code ProgressStatus} is not visible to thechild ProgressStatus object and the child can progress somewhat independently from the parent's progress. But generally the parent should not complete its progress before the children have completed.
createChild(String name, int allocatedSteps); createChild(int allocatedSteps);
The name allocated to the child is used in the progress status output to define context of the {@code message}.
. 80%: [parent name:[child name:[...]] message
The allocatedSteps parameter represents the subset of steps from the parent's allocation that will be given to the child to complete. @see org.glassfish.api.Progress @author mmares
|
|
|
|
|
|
|
|
|
|
|
|