-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[LRO] Support blocking for intermediate states , OTHER [DRAFT][ #4010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
hemanttanwar
wants to merge
6
commits into
Azure:master
from
hemanttanwar:3930-long-running-operation-other-status
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
23913d7
Initial design for Other status, Test classes will fail since we are …
d13ad48
javadoc formatting changes
47b25f1
javadoc formatting changes
08b0569
javadoc formatting changes
6fb7458
java doc and comments
ed666f7
Merge remote-tracking branch 'upstream/master' into 3930-long-running…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
core/azure-core/src/main/java/com/azure/core/util/polling/OperationStatus.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| package com.azure.core.util.polling; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| public class OperationStatus { | ||
| /** | ||
| * An enum to represent all possible states that a long-running operation may find itself in. | ||
| * The poll operation is considered complete when the status is one of {@code SUCCESSFULLY_COMPLETED}, {@code USER_CANCELLED} or {@code FAILED}. | ||
| * The state {@code OTHER} does not represent long-running operation is complete. This is one of the custom intermediate state. | ||
| */ | ||
| public enum State { | ||
| /** | ||
| * Represents that polling has not yet started for this long-running operation. | ||
| */ | ||
| NOT_STARTED, | ||
|
|
||
| /** | ||
| * Represents that this long-running operation is in progress and not yet complete. | ||
| */ | ||
| IN_PROGRESS, | ||
|
|
||
| /** | ||
| * Represent that this long-running operation is completed successfully. | ||
| */ | ||
| SUCCESSFULLY_COMPLETED, | ||
|
|
||
| /** | ||
| * Represents that this long-running operation has failed to successfully complete, however this is still | ||
| * considered as complete long-running operation, meaning that the {@link Poller} instance will report that it is complete. | ||
| */ | ||
| FAILED, | ||
|
|
||
| /** | ||
| * Represents that this long-running operation is cancelled by user, however this is still | ||
| * considered as complete long-running operation. | ||
| */ | ||
| USER_CANCELLED, | ||
|
|
||
| /** | ||
| * When long-running operation state could not be represented by any state in {@link State}, this state represents | ||
| * a custom state Azure service could be in. This custom state is not considered as complete long-running operation. | ||
| * It must have valid value for {@code otherStatus} as {@link String}. | ||
| */ | ||
| OTHER | ||
| } | ||
| private State state; | ||
| private String otherStatus; | ||
|
|
||
| /** | ||
| * | ||
| * @param state in which the long-running operation find itself in. | ||
| */ | ||
| public OperationStatus(State state) { | ||
| this.state = state; | ||
| } | ||
|
|
||
| /** | ||
| * This is normally used for {@link State#OTHER}. | ||
| * @param state in which long-running operation find itself in. | ||
| * @param otherStatus The string representation of custom state the long-running operation find itself in. | ||
| */ | ||
| public OperationStatus(State state, String otherStatus) { | ||
| this(state); | ||
| if (state == State.OTHER ) { | ||
| if ( Objects.isNull(otherStatus) || otherStatus.trim().length() == 0 ) { | ||
| throw new IllegalArgumentException("otherStatus can not be empty or null for State.OTHER"); | ||
| }else { | ||
| this.otherStatus = otherStatus; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public State getState(){ | ||
| return this.state; | ||
| } | ||
|
|
||
| public String getOtherStatus(){ | ||
| return this.otherStatus; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving it into separate class since now, it will have its own POJO like structure as we are supporting OTHER state and must have String value for custom other state.