Class TaskRegistry
java.lang.Object
org.episteme.core.distributed.TaskRegistry
Registry for distributed task implementations.
The TaskRegistry provides dynamic task discovery and instantiation, eliminating the need for hardcoded task handlers in WorkerNode. Tasks can be registered programmatically or discovered via ServiceLoader.
Example usage:
// Register a task
TaskRegistry.register("MANDELBROT", MandelbrotTask.class);
// Get a task instance
DistributedTask<?, ?> task = TaskRegistry.getInstance().get("MANDELBROT")
.orElseThrow(() -> new IllegalArgumentException("Unknown task"));
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumPrecision mode for task execution. -
Method Summary
Modifier and TypeMethodDescriptionOptional<DistributedTask<?, ?>> Gets a task instance for the given type.Optional<DistributedTask<?, ?>> get(String taskType, TaskRegistry.PrecisionMode mode) Gets a task instance with specific precision mode.static TaskRegistryReturns the singleton TaskRegistry instance.Returns all registered task types.booleanisRegistered(String taskType) Checks if a task type is registered.static voidregister(String taskType, Class<? extends DistributedTask<?, ?>> taskClass) Registers a task class with the given type identifier.static voidregisterProvider(String taskType, TaskProvider<?, ?> provider) Registers a task provider for the given type identifier.
-
Method Details
-
getInstance
Returns the singleton TaskRegistry instance.- Returns:
- the TaskRegistry instance
-
register
Registers a task class with the given type identifier.- Parameters:
taskType- the task type identifier (e.g., "MANDELBROT")taskClass- the task implementation class
-
registerProvider
Registers a task provider for the given type identifier.Providers allow switching between Primitive and Real implementations.
- Parameters:
taskType- the task type identifierprovider- the task provider
-
get
Gets a task instance for the given type.- Parameters:
taskType- the task type identifier- Returns:
- Optional containing the task instance, or empty if not found
-
get
Gets a task instance with specific precision mode.- Parameters:
taskType- the task type identifiermode- the precision mode (DOUBLE, FLOAT or REAL)- Returns:
- Optional containing the task instance
-
isRegistered
Checks if a task type is registered.- Parameters:
taskType- the task type identifier- Returns:
- true if the task is registered
-
getRegisteredTypes
-