Class RandomTaskLocationResolver

  • All Implemented Interfaces:
    TaskLocationResolver

    public class RandomTaskLocationResolver
    extends Object
    implements TaskLocationResolver
    This class represents a task location resolver, which randomly assigns tasks to the task cluster. This implementation is much more performant than the round robin based one, since the round robin resolver requires the full list of tasks for the tenant/task-type to be loaded.
    • Constructor Detail

      • RandomTaskLocationResolver

        public RandomTaskLocationResolver()
    • Method Detail

      • init

        public void init​(Map<String,​String> properties)
                  throws org.wso2.carbon.ntask.common.TaskException
        Description copied from interface: TaskLocationResolver
        Initializes the task location resolver with the given properties.
        Specified by:
        init in interface TaskLocationResolver
        Parameters:
        properties - The property map
        Throws:
        org.wso2.carbon.ntask.common.TaskException
      • getLocation

        public int getLocation​(TaskServiceContext ctx,
                               TaskInfo taskInfo)
                        throws org.wso2.carbon.ntask.common.TaskException
        Description copied from interface: TaskLocationResolver
        Returns the location the given task should be scheduled in.
        Specified by:
        getLocation in interface TaskLocationResolver
        Parameters:
        ctx - The task context, which contains environmental information on other tasks etc..
        taskInfo - The task information of the task to be scheduled
        Returns:
        The location of the task to be scheduled
        Throws:
        org.wso2.carbon.ntask.common.TaskException