Skip to content
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

Replace references to WorkflowDefinition with AbstractWorkflowDefinition #312

Merged
merged 1 commit into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## 5.5.1-SNAPSHOT (future release)
## 5.6.0-SNAPSHOT (future release)

**Highlights**
- Support non-enum WorkflowStates to enable, for example, Kotlin workflow definitions by extending AbstractWorkflowDefinition.

**Details**
- Dependency and plugin updates:
Expand All @@ -8,8 +11,10 @@
- `nflow-engine`
- Retry workflow state processing until all steps in nFlow-side are executed successfully. This will prevent workflow instances from being locked in `executing` status, if e.g. database connection fails after locking the instance and before querying the full workflow instance information (`WorkflowStateProcessor`).
- Fix #306: create empty ArrayList with default initial size
- Log more executor details on startup

- Log more executor details on startup
- Fix #311: Replace references to WorkflowDefinition with AbstractWorkflowDefinition to support non-enum WorkflowStates
- Use name() instead of toString() when getting workflow instance initial state name

## 5.5.0 (2019-04-04)

**Highlights**
Expand Down
2 changes: 1 addition & 1 deletion nflow-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<artifactId>nflow-root</artifactId>
<groupId>io.nflow</groupId>
<version>5.5.1-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public WorkflowInstance process(WorkflowInstance instance) {
}
WorkflowInstance.Builder builder = new WorkflowInstance.Builder(instance);
jsyrjala marked this conversation as resolved.
Show resolved Hide resolved
if (instance.state == null) {
builder.setState(def.getInitialState().toString());
builder.setState(def.getInitialState().name());
} else {
if (!def.isStartState(instance.state)) {
throw new RuntimeException("Specified state [" + instance.state + "] is not a start state.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import io.nflow.engine.config.NFlow;
import io.nflow.engine.internal.dao.WorkflowDefinitionDao;
import io.nflow.engine.workflow.definition.AbstractWorkflowDefinition;
import io.nflow.engine.workflow.definition.WorkflowDefinition;
import io.nflow.engine.workflow.definition.WorkflowState;

/**
Expand All @@ -35,7 +34,7 @@ public class WorkflowDefinitionService {
private static final Logger logger = getLogger(WorkflowDefinitionService.class);

private AbstractResource nonSpringWorkflowsListing;
private final Map<String, AbstractWorkflowDefinition<? extends WorkflowState>> workflowDefitions = new LinkedHashMap<>();
private final Map<String, AbstractWorkflowDefinition<? extends WorkflowState>> workflowDefinitions = new LinkedHashMap<>();
private final WorkflowDefinitionDao workflowDefinitionDao;
private final boolean persistWorkflowDefinitions;

Expand All @@ -50,7 +49,7 @@ public WorkflowDefinitionService(WorkflowDefinitionDao workflowDefinitionDao, En
* @param workflowDefinitions The workflow definitions to be added.
*/
@Autowired(required = false)
public void setWorkflowDefinitions(Collection<WorkflowDefinition<? extends WorkflowState>> workflowDefinitions) {
public void setWorkflowDefinitions(Collection<AbstractWorkflowDefinition<? extends WorkflowState>> workflowDefinitions) {
for (AbstractWorkflowDefinition<? extends WorkflowState> wd : workflowDefinitions) {
addWorkflowDefinition(wd);
}
Expand All @@ -67,15 +66,15 @@ public void setWorkflowDefinitions(@NFlow AbstractResource nflowNonSpringWorkflo
* @return The workflow definition or null if not found.
*/
public AbstractWorkflowDefinition<?> getWorkflowDefinition(String type) {
return workflowDefitions.get(type);
return workflowDefinitions.get(type);
}

/**
* Return all managed workflow definitions.
* @return List of workflow definitions.
*/
public List<AbstractWorkflowDefinition<? extends WorkflowState>> getWorkflowDefinitions() {
return new ArrayList<>(workflowDefitions.values());
return new ArrayList<>(workflowDefinitions.values());
}

/**
Expand All @@ -91,7 +90,7 @@ public void postProcessWorkflowDefinitions() throws IOException, ReflectiveOpera
initNonSpringWorkflowDefinitions();
}
if (persistWorkflowDefinitions) {
for (AbstractWorkflowDefinition<?> definition : workflowDefitions.values()) {
for (AbstractWorkflowDefinition<?> definition : workflowDefinitions.values()) {
workflowDefinitionDao.storeWorkflowDefinition(definition);
}
}
Expand All @@ -103,14 +102,14 @@ private void initNonSpringWorkflowDefinitions() throws IOException, ReflectiveOp
while ((row = br.readLine()) != null) {
logger.info("Preparing workflow {}", row);
@SuppressWarnings("unchecked")
Class<WorkflowDefinition<? extends WorkflowState>> clazz = (Class<WorkflowDefinition<? extends WorkflowState>>) Class.forName(row);
Class<AbstractWorkflowDefinition<? extends WorkflowState>> clazz = (Class<AbstractWorkflowDefinition<? extends WorkflowState>>) Class.forName(row);
addWorkflowDefinition(clazz.getDeclaredConstructor().newInstance());
}
}
}

public void addWorkflowDefinition(AbstractWorkflowDefinition<? extends WorkflowState> wd) {
AbstractWorkflowDefinition<? extends WorkflowState> conflict = workflowDefitions.put(wd.getType(), wd);
AbstractWorkflowDefinition<? extends WorkflowState> conflict = workflowDefinitions.put(wd.getType(), wd);
if (conflict != null) {
throw new IllegalStateException("Both " + wd.getClass().getName() + " and " + conflict.getClass().getName() +
" define same workflow type: " + wd.getType());
Expand Down
2 changes: 1 addition & 1 deletion nflow-explorer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<artifactId>nflow-root</artifactId>
<groupId>io.nflow</groupId>
<version>5.5.1-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<properties>
Expand Down
2 changes: 1 addition & 1 deletion nflow-jetty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<artifactId>nflow-root</artifactId>
<groupId>io.nflow</groupId>
<version>5.5.1-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
2 changes: 1 addition & 1 deletion nflow-metrics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>io.nflow</groupId>
<artifactId>nflow-root</artifactId>
<version>5.5.1-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion nflow-netty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<artifactId>nflow-root</artifactId>
<groupId>io.nflow</groupId>
<version>5.5.1-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
2 changes: 1 addition & 1 deletion nflow-perf-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>io.nflow</groupId>
<artifactId>nflow-root</artifactId>
<version>5.5.1-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<build>
<plugins>
Expand Down
2 changes: 1 addition & 1 deletion nflow-rest-api-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<artifactId>nflow-root</artifactId>
<groupId>io.nflow</groupId>
<version>5.5.1-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<properties>
<EMPTY></EMPTY>
Expand Down
2 changes: 1 addition & 1 deletion nflow-rest-api-jax-rs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<artifactId>nflow-root</artifactId>
<groupId>io.nflow</groupId>
<version>5.5.1-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<properties>
<EMPTY></EMPTY>
Expand Down
2 changes: 1 addition & 1 deletion nflow-rest-api-spring-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<artifactId>nflow-root</artifactId>
<groupId>io.nflow</groupId>
<version>5.5.1-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<properties>
<EMPTY></EMPTY>
Expand Down
2 changes: 1 addition & 1 deletion nflow-server-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<artifactId>nflow-root</artifactId>
<groupId>io.nflow</groupId>
<version>5.5.1-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
2 changes: 1 addition & 1 deletion nflow-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>io.nflow</groupId>
<artifactId>nflow-root</artifactId>
<version>5.5.1-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>nflow-root</artifactId>
<packaging>pom</packaging>
<description>nFlow Root</description>
<version>5.5.1-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
<url>http://nflow.io</url>
<licenses>
<license>
Expand Down