forked from CorfuDB/CorfuDB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Orchestrator Service Implementation of a workflow execution service that runs in the management server. * Add New Node Workflow Implementation of a workflow that adds a new node to the cluster.
- Loading branch information
Showing
20 changed files
with
1,065 additions
and
4 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
65 changes: 65 additions & 0 deletions
65
infrastructure/src/main/java/org/corfudb/infrastructure/orchestrator/Action.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,65 @@ | ||
package org.corfudb.infrastructure.orchestrator; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.corfudb.runtime.CorfuRuntime; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* | ||
* A workflow action. All workflow actions must extend this class. | ||
* | ||
* Created by Maithem on 10/25/17. | ||
*/ | ||
|
||
@Slf4j | ||
public abstract class Action { | ||
|
||
ActionStatus status = ActionStatus.CREATED; | ||
|
||
/** | ||
* Returns the name of this action. | ||
* @return Name of action | ||
*/ | ||
@Nonnull | ||
public abstract String getName(); | ||
|
||
/** | ||
* The implementation of the action | ||
* @param runtime A runtime that the action will use to execute | ||
* @throws Exception | ||
*/ | ||
public abstract void impl(@Nonnull CorfuRuntime runtime) throws Exception; | ||
|
||
/** | ||
* Execute the action. | ||
*/ | ||
@Nonnull | ||
public void execute(@Nonnull CorfuRuntime runtime) { | ||
try { | ||
changeStatus(ActionStatus.STARTED); | ||
impl(runtime); | ||
changeStatus(ActionStatus.COMPLETED); | ||
} catch (Exception e) { | ||
log.error("execute: error executing action", e); | ||
changeStatus(ActionStatus.ERROR); | ||
} | ||
} | ||
|
||
/** | ||
* Get the status of this action. | ||
* @return ActionStatus | ||
*/ | ||
public ActionStatus getStatus() { | ||
return status; | ||
} | ||
|
||
/** | ||
* Changes the status of this action | ||
* @param newStatus the new status | ||
*/ | ||
void changeStatus(ActionStatus newStatus) { | ||
status = newStatus; | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
infrastructure/src/main/java/org/corfudb/infrastructure/orchestrator/ActionStatus.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,30 @@ | ||
package org.corfudb.infrastructure.orchestrator; | ||
|
||
/** | ||
* The possible states in which an action can be in. | ||
* | ||
* Created by Maithem on 10/25/17. | ||
*/ | ||
|
||
public enum ActionStatus { | ||
|
||
/** | ||
* The state of the action when it gets created | ||
*/ | ||
CREATED, | ||
|
||
/** | ||
* The state of the action once it is invoked | ||
*/ | ||
STARTED, | ||
|
||
/** | ||
* The state of the action once it completes successfully | ||
*/ | ||
COMPLETED, | ||
|
||
/** | ||
* The state of the action if it fails executing | ||
*/ | ||
ERROR | ||
} |
Oops, something went wrong.