Commit e2dd06fa authored by Jay Jay Billings's avatar Jay Jay Billings
Browse files

First cut at Task interfaces.


Signed-off-by: default avatarJay Jay Billings <billingsjj@ornl.gov>
parent dd3d5f82
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.ice.tasks</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.ice</groupId>
<artifactId>org.eclipse.ice.tasks</artifactId>
<version>3.0.0-SNAPSHOT</version>
<name>Eclipse ICE Tasks</name>
<description>This package defines the interfaces and associated artifacts for tasks in Eclipse ICE</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.ice</groupId>
<artifactId>org.eclipse.ice.data</artifactId>
<version>3.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2020- UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings
*****************************************************************************/
package org.eclipse.ice.tasks;
/**
* Actions can be executed by Tasks and represent fundamental functional
* units.
*
* Actions have distinct types described by the {@link ActionType} enumeration.
*
* Actions store state data externally and do not control their own storage.
* Thus the must be configured when built to store state to the proper
* location. State controllers should be provided by Tasks executing an action,
* but Actions will attempt to store state locally by default if no controller
* is provided. State storage is separate from data storage, which is tracked by
* individual data models.
*
* @author Jay Jay Billings
*
*/
public interface Action<T> {
/**
* This operation returns the type of the Action.
* @return the type of the Action
*/
public ActionType getType();
/**
* This operation executes the Action on the provided input data.
* @param data the input data used by the action
* @return true if the Action executes successfully, false otherwise.
*/
public boolean run(T data);
}
/******************************************************************************
* Copyright (c) 2020- UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings
*****************************************************************************/
package org.eclipse.ice.tasks;
/**
* This enumeration is the master list of ActionTypes supported by Eclipse ICE
* and defines the type of the action that will be executed. It distinguishes
* among types of actions such as shell functions, conditionals, languages,
* etc.
*
* This is a hierarchical enumeration of action types that are organized
* according to the ontology produced by the author as part of the work
* "Ontological Considerations for Interoperability in Scientific Workflows."
* As hierarchical enumerations in Java are not natively supported, this
* enumeration engages in some trickery.
*
* @author Jay Jay Billings
*
*/
public interface ActionType {
/**
* The basic action type is the base class for basic actions that are
* typically considered native actions of workflow engines. This includes
* actions such as moving files or doing simple reductions.
* @author Jay Jay Billings
*
*/
public enum BASIC implements ActionType {
/**
* Actions of this type move files
*/
MOVE_FILE
}
/**
* The executable action type describes types of executables that are
* launched by actions.
* @author Jay Jay Billings
*
*/
public enum EXECUTABLE implements ActionType {
/**
* Actions of this type are systems calls to local executables.
*/
LOCAL,
/**
* Actions of this type launch remotely running executables.
*/
REMOTE
}
/**
* The function action type describes functions that can be executed by the
* Action.
* @author Jay Jay Billings
*
*/
public enum FUNCTION implements ActionType {
/**
* Actions of this type call Java function.
*/
JAVA
}
/**
* This enumeration describes the the hooks supported by tasks, including
* preprocessing, postprocessing, error, and conditional hooks.
*
* @author Jay Jay Billings
*
*/
public enum HOOK implements ActionType {
/**
* Pre-hook type. Preprocessors for the main Action. These hooks run
* before all other tasks except conditional tasks if their execution is
* triggered.
*/
PRE,
/**
* Post-hook type. Postprocessors for the main Action. These hooks run
* last.
*/
POST,
/**
* Error hook type. Error processors for unexpected faults, conditions, and
* exceptions. These hooks only run when errors are encountered.
*/
ERROR,
/**
* Conditional hook type. These hooks run when certain conditions are
* satisfied and they directly influence the execution of the main action,
* up to and including pre-empting and replacing it. These hooks are
* executed before other hooks if their condition for execution is
* satisfied.
*/
CONDITIONAL
}
}
/******************************************************************************
* Copyright (c) 2020- UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings
*****************************************************************************/
package org.eclipse.ice.tasks;
/**
* Hooks are special types of Actions that execute before or after other
* Actions and conditionally in place of other Actions.
*
* At the moment, this is simply a Marker interface.
*
* @author Jay Jay Billings
*
*/
public interface Hook<T> extends Action<T> {
}
/******************************************************************************
* Copyright (c) 2020- UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings
*****************************************************************************/
package org.eclipse.ice.tasks;
import org.eclipse.ice.data.IDataElement;
/**
*
* Tasks are executed by workflows, either fully automated workflows (such as
* ICE workflows) or workflows controlled by intelligent agents without full
* automation.
*
* Tasks combine Actions and data (templated on
* {@link org.eclipse.ice.data.IDataElement} classes). They also include
* properties and other metadata that may influence the way the task is
* executed.
*
* In addition to actions, tasks use Hooks, a special type of Action that
* executes either before or after another Action to support the execution of
* that main Action. The list of supported hook types is provided below.
*
* When directed to execute, tasks will execute all hooks and the action
* according to the execution order provided in the hook type table (see
* {@link TaskHookType}). Tasks support multiple hooks of each type since many
* different things may be required to support the execution of the main
* action. Hooks of the same type are executed as a queue (first-in-first-out).
*
* Tasks execute in one of several Task States (see {@link TaskState}) that are
* roughly correlated to hooks and action. Tasks start their life cycle with
* initialization and end with the execution of the action and any
* postprocessing hooks.
*
* Tasks store state data externally and do not control their own storage. Thus
* the must be configured when built to store state to the proper location. If
* no state controller is provided, tasks will attempt to store state locally
* by default. State storage is separate from data storage, which is tracked by
* individual data models.
*
* Tasks can be observed by listeners (see {@link ITaskListener}). Events are
* dispatched asynchronously and listeners are not consulted for command and
* control.
*
* Data is injected into tasks using a setter instead of including it directly
* in the run() operation. This supports option-operand separation and a
* specific case of its use is in the execution of multiple tasks
* simultaneously without the caller knowing anything about the data
* configuration.
*
* Thoughts on provenance tracking? ICE 2.0 used a log file.
*
* They are modeled as the combination of an
* action and properties defining the way that action should be executed. Tasks
* may also be assigned conditional actions that evaluate when a certain
* condition has been met based on the execution of the primary action with its
* properties.
*
* @author Jay Jay Billings
*
*/
public interface ITask<T extends IDataElement<T>> {
/**
* This operation sets the data on which the task should execute.
* @param taskData The data for the task
*/
public void setData(T taskData);
/**
* This operation gets the data on which the task is working.
* @return the data
*/
public T getData();
/**
* This function sets the Action that the task executes.
* @param taskAction the task's action.
*/
public void setAction(final Action<T> taskAction);
/**
* This operation adds a hook to the task that will be executed in support
* of the action.
* @param hook a hook to execute before, after, or conditionally in place of
* the action.
*/
public void addHook(final Hook<T> hook);
/**
* This operation executes the action.
* @return the state of the task after exection.
*/
public TaskState execute();
/**
* This operation returns the current state of the Task
* @return the state
*/
public TaskState getState();
}
/******************************************************************************
* Copyright (c) 2020- UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings
*****************************************************************************/
package org.eclipse.ice.tasks;
/**
* This enumeration describes the set of states for ITasks.
*
* @author Jay Jay Billings
*
*/
public enum TaskState {
/**
* This pseudostate indicates that the state machine has fully been
* initialized. This is a short-lived state that while notable primarily
* only exists in transition to READY.
*/
INITIALIZED,
/**
* This state indicates that the task can be executed and that all
* initialization has completed. It is ready to be executed.
*
* Idempotent tasks may re-enter the ready state when complete, using the
* FINISHED state as a transition back to readiness.
*/
READY,
/**
* The state is entered when a task needs to spend a large amount
* of time to review information received for pre-, post-, or in situ
* processing that is required to execute the task. Once the review is
* complete, the task will transition into the EXECUTING state in the ideal
* primary flow, or wait or fail in alternative flows. The difference
* between this state and the waiting states is that this state indicates
* actual work is being performed, i.e. - a review is in progress.
*/
REVIEWING,
/**
* This state indicates that the task is presently executing the work
* assigned to it.
*/
EXECUTING,
/**
* This state indicates that the task is waiting on internal resources or
* events, such as the allocation of compute or data resources or the
* completion of other tasks.
*/
WAITING,
/**
* Tasks in the WaitingForInfo state are waiting on information from an
* external agent. External agents are defined as actors that exist outside
* the workflow system, such as humans, file systems that generate events,
* or automated systems that provide information to the task.
*/
WAITINGFORAGENT,
/**
* This is the ideal terminal state for the task and indicates that all
* work has completed successfully. It may be possible to re-execute
* finished tasks and some idempotent tasks may use FINISHED as a
* transitional pseudostate pending a reset to READY.
*/
FINISHED,
/**
* This state indicates that an unexpected failure happened while executing
* the task.
*/
FAILED
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment