public class WorkerImpl extends Object implements IWorker
IWorker
implementation.
A worker is the class in charge of keeping track of the arrival and departure of task assignments. Upon a change, it recompute the assignments, and submit task for execution accordingly.
This class is very simple. In zookeeper a task is defined by a node:
"/zk_root/shiva/tasks/punchplatform/mytenant/services/myservice/mytask"
When assigned to a worker, the worker loads all the zookeeper data once, and put it under
"/data_dir/punchplatform/mytenant/services/myservice/mytask"
The task name used to uniquely identify a task is simply:
"/punchplatform/mytenant/services/myservice/mytask"
Constructor and Description |
---|
WorkerImpl(String clusterName,
Path dataFolder,
String myId,
List<String> tags,
boolean useKafkaStore)
Create a new worker.
|
Modifier and Type | Method and Description |
---|---|
void |
addConfiguration(long offset,
org.thales.punch.libraries.shiva.api.Command cmd)
Refresh the configuration folder known to this worker.
|
org.thales.punch.settings.api.ISettingsMap |
asSettingsMap() |
String |
getWorkerId() |
void |
removeApplication(String appName)
Remove the folder of a stopped application
|
void |
tick()
Let the worker check for all tasks.
|
void |
updateAssignement(org.thales.punch.settings.api.ISettingsMap map)
WATCHOUT this code is subtle.
|
public WorkerImpl(String clusterName, Path dataFolder, String myId, List<String> tags, boolean useKafkaStore)
clusterName
- shiva cluster name to joindataFolder
- folder to use for runtimemyId
- worker idtags
- worker tagsuseKafkaStore
- if true, use a dedicated working directory from data folder, else use conf dirpublic void updateAssignement(org.thales.punch.settings.api.ISettingsMap map)
updateAssignement
in interface IWorker
map
- the refreshed assignmentspublic void tick()
public String getWorkerId()
getWorkerId
in interface IWorker
public org.thales.punch.settings.api.ISettingsMap asSettingsMap()
asSettingsMap
in interface IWorker
public void addConfiguration(long offset, org.thales.punch.libraries.shiva.api.Command cmd)
IWorker
This allow each worker to store locally all the required application files and be ready to eventually execute it should the leader decide so.
addConfiguration
in interface IWorker
offset
- the corresponding kafka offsetcmd
- the start commandpublic void removeApplication(String appName)
IWorker
removeApplication
in interface IWorker
Copyright © 2022. All rights reserved.