Interface TaskGlobalObject

All Superinterfaces:
AutoCloseable, Closeable, RamaSerializable, Serializable
All Known Subinterfaces:
ExternalDepot, TaskGlobalObjectWithTick

public interface TaskGlobalObject extends RamaSerializable, Closeable
Objects implementing this interface that are provided to RamaModule.Setup.declareObject(String, Object) can specialize their implementation per task. References to the declared var will see the specific instance of this object built for that task.

This object is serialized with Java serialization and then deserialized on every task before being built with prepareForTask(int, com.rpl.rama.integration.TaskGlobalContext).

This functionality can be used to integrate external queues, databases, or other tools with Rama.

Closeable.close() should be implemented to clean up any resources opened during preparation, such as connections to other processes. This is especially important for unit tests using InProcessCluster.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    This function is called on this object whenever the task on which it lives gains leadership.
    void
    prepareForTask(int taskId, TaskGlobalContext context)
    Specializes this object for this particular task ID.

    Methods inherited from interface java.io.Closeable

    close
  • Method Details

    • prepareForTask

      void prepareForTask(int taskId, TaskGlobalContext context)
      Specializes this object for this particular task ID. This is called one time during worker launch. Each task has a separate instance of this object by using serialization/deserialization.
      Parameters:
      taskId - Task ID on which this object will live
      context - Contextual information
      See Also:
    • gainedLeadership

      default void gainedLeadership()
      This function is called on this object whenever the task on which it lives gains leadership.