-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from ydb-platform/operation_manager
Updated implementation of the long operations
- Loading branch information
Showing
39 changed files
with
1,615 additions
and
1,096 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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
11 changes: 11 additions & 0 deletions
11
core/src/main/java/tech/ydb/core/operation/AsyncOperation.java
This file contains 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,11 @@ | ||
package tech.ydb.core.operation; | ||
|
||
import java.util.concurrent.ScheduledExecutorService; | ||
|
||
/** | ||
* | ||
* @author Aleksandr Gorshenin | ||
*/ | ||
interface AsyncOperation<T> extends Operation<T> { | ||
ScheduledExecutorService getScheduler(); | ||
} |
61 changes: 61 additions & 0 deletions
61
core/src/main/java/tech/ydb/core/operation/FailedOperation.java
This file contains 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,61 @@ | ||
package tech.ydb.core.operation; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.function.Function; | ||
|
||
import tech.ydb.core.Result; | ||
import tech.ydb.core.Status; | ||
|
||
/** | ||
* | ||
* @author Aleksandr Gorshenin | ||
*/ | ||
class FailedOperation<T> implements Operation<T> { | ||
private final T value; | ||
private final Status status; | ||
|
||
FailedOperation(T value, Status status) { | ||
this.value = value; | ||
this.status = status; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isReady() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public T getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Status> cancel() { | ||
return CompletableFuture.completedFuture(status); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Status> forget() { | ||
return CompletableFuture.completedFuture(status); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Result<Boolean>> fetch() { | ||
return CompletableFuture.completedFuture(Result.fail(status)); | ||
} | ||
|
||
@Override | ||
public <R> Operation<R> transform(Function<T, R> func) { | ||
return new FailedOperation<>(func.apply(value), status); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "FailedOperation{status=" + status + "}"; | ||
} | ||
} |
This file contains 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.