Class TaskRegistry

java.lang.Object
org.episteme.core.distributed.TaskRegistry

public final class TaskRegistry extends Object
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"));

  • Method Details

    • getInstance

      public static TaskRegistry getInstance()
      Returns the singleton TaskRegistry instance.
      Returns:
      the TaskRegistry instance
    • register

      public static void register(String taskType, Class<? extends DistributedTask<?,?>> taskClass)
      Registers a task class with the given type identifier.
      Parameters:
      taskType - the task type identifier (e.g., "MANDELBROT")
      taskClass - the task implementation class
    • registerProvider

      public static void registerProvider(String taskType, TaskProvider<?,?> provider)
      Registers a task provider for the given type identifier.

      Providers allow switching between Primitive and Real implementations.

      Parameters:
      taskType - the task type identifier
      provider - the task provider
    • get

      public Optional<DistributedTask<?,?>> get(String taskType)
      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

      public Optional<DistributedTask<?,?>> get(String taskType, TaskRegistry.PrecisionMode mode)
      Gets a task instance with specific precision mode.
      Parameters:
      taskType - the task type identifier
      mode - the precision mode (DOUBLE, FLOAT or REAL)
      Returns:
      Optional containing the task instance
    • isRegistered

      public boolean isRegistered(String taskType)
      Checks if a task type is registered.
      Parameters:
      taskType - the task type identifier
      Returns:
      true if the task is registered
    • getRegisteredTypes

      public Iterable<String> getRegisteredTypes()
      Returns all registered task types.
      Returns:
      iterable of task type identifiers