Package org.wso2.carbon.ntask.core.impl
Class RandomTaskLocationResolver
- java.lang.Object
-
- org.wso2.carbon.ntask.core.impl.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 Summary
Constructors Constructor Description RandomTaskLocationResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getLocation(TaskServiceContext ctx, TaskInfo taskInfo)
Returns the location the given task should be scheduled in.void
init(Map<String,String> properties)
Initializes the task location resolver with the given properties.
-
-
-
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 interfaceTaskLocationResolver
- 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 interfaceTaskLocationResolver
- 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
-
-