@Component @ConditionalOnProperty(value="genie.jobs.clusters.loadBalancers.script.enabled", havingValue="true") public class ScriptLoadBalancer extends java.lang.Object implements ClusterLoadBalancer
The contract between the script and the Java code is that the script will be supplied global variables
clusters
and jobRequest
which will be JSON strings representing the list (array) of clusters
matching the cluster criteria tags and the job request that kicked off this evaluation. The code expects the script
to either return the id of the cluster if one is selected or null if none was selected.
DEFAULT_ORDER
Constructor and Description |
---|
ScriptLoadBalancer(org.springframework.core.task.AsyncTaskExecutor asyncTaskExecutor,
org.springframework.scheduling.TaskScheduler taskScheduler,
GenieFileTransferService fileTransferService,
org.springframework.core.env.Environment environment,
com.fasterxml.jackson.databind.ObjectMapper mapper,
com.netflix.spectator.api.Registry registry)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getOrder() |
void |
refresh()
Check if the script file needs to be refreshed.
|
Cluster |
selectCluster(java.util.Set<Cluster> clusters,
JobRequest jobRequest)
Return best cluster to run job on.
|
@Autowired public ScriptLoadBalancer(@Qualifier(value="genieAsyncTaskExecutor") org.springframework.core.task.AsyncTaskExecutor asyncTaskExecutor, @Qualifier(value="genieTaskScheduler") org.springframework.scheduling.TaskScheduler taskScheduler, @Qualifier(value="cacheGenieFileTransferService") GenieFileTransferService fileTransferService, org.springframework.core.env.Environment environment, com.fasterxml.jackson.databind.ObjectMapper mapper, com.netflix.spectator.api.Registry registry)
asyncTaskExecutor
- The asynchronous task executor to use to run the load balancer script intaskScheduler
- The task scheduler to schedule the script refresh task withfileTransferService
- The file transfer service to use to download the scriptenvironment
- The program environment to get properties frommapper
- The object mapper to use to serialize objects to JSON for binding with scriptsregistry
- The metrics registry to use for collecting metricspublic Cluster selectCluster(@Nonnull @NonNull @NotEmpty java.util.Set<Cluster> clusters, @Nonnull @NonNull JobRequest jobRequest) throws GenieException
selectCluster
in interface ClusterLoadBalancer
clusters
- An immutable, non-empty list of available clusters to choose fromjobRequest
- The job request these clusters are being load balanced forGenieException
- if there is any errorpublic int getOrder()
getOrder
in interface ClusterLoadBalancer
getOrder
in interface org.springframework.core.Ordered
public void refresh()