public abstract class AbstractWorkerApplication extends Object
Punch plans however are lightweight apps that also schedule processes but with an additional templating capabilitiy. Having one dedicated process per plan is overkillm, they basically do nothing but schedule from time to time a spark job. These are represented by threads.
Modifier and Type | Field and Description |
---|---|
protected org.thales.punch.libraries.shiva.api.Application |
application
the application descriptor as read from Kafka
|
protected Path |
applicationFolder
where are stored the application command and arguments files.
|
protected String |
clusterName
The Shiva cluster name of this task
|
protected Path |
confDirFolder
The top level directory associasted to this application.
|
protected boolean |
ephemeral
True if the application must be executed only once.
|
protected com.cronutils.model.time.ExecutionTime |
executionTime
the cron execution time.
|
protected boolean |
hasStarted
true if the a start has been issued.
|
protected Instant |
lastExecutionStart
the last execution start time.
|
protected int |
numExecution
Keep track of the number of time this app has been executed.
|
protected ApplicationPlatformReporter |
platformReporter
Contains helpers for logging information
|
protected String |
workerId
our worker identifier, used to properly log task traces to elasticsearch
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractWorkerApplication(Path applicationFolder,
Path confDirFolder,
org.thales.punch.libraries.shiva.api.Application application,
String clusterName,
String workerId) |
Modifier and Type | Method and Description |
---|---|
abstract int |
exitValue() |
org.thales.punch.libraries.shiva.api.Application |
getApplication() |
String |
getClusterName() |
Path |
getFolder() |
String |
getName() |
String |
getWorkerId() |
abstract boolean |
isAlive() |
boolean |
isEphemeral() |
boolean |
isEverRunningTask() |
boolean |
isStarted() |
static org.thales.punch.libraries.forkexec.api.ProcessFuture |
launchChildApplication(String workerId,
org.thales.punch.libraries.shiva.api.Application application,
File home,
String confDir,
String[] args)
Create an environment for the new worker application and launch its subprocess
|
abstract boolean |
start()
Start a worker task, i.e.
|
protected boolean |
started()
Mark this application as running.
|
abstract void |
stop()
Stop a worker task, i.e.
|
boolean |
taskShouldRunNow()
An application must start only if :
it must run all the time, it must run once and has never be executed yet, or if it is periodic
and it's time to fire it.
|
String |
toString() |
protected final Path applicationFolder
protected final Path confDirFolder
For example : "/tmp/shiva-worker/tenants_mytenant_channels_mychannel_myapp"
protected final org.thales.punch.libraries.shiva.api.Application application
protected final String clusterName
protected final String workerId
protected final ApplicationPlatformReporter platformReporter
protected boolean hasStarted
protected boolean ephemeral
protected int numExecution
protected com.cronutils.model.time.ExecutionTime executionTime
protected Instant lastExecutionStart
public String getName()
public final org.thales.punch.libraries.shiva.api.Application getApplication()
public String getClusterName()
public String getWorkerId()
public Path getFolder()
public boolean isEverRunningTask()
public boolean isEphemeral()
public boolean isStarted()
public abstract boolean isAlive()
public abstract boolean start()
IOException
- in case of issue retrieving argumentsorg.thales.punch.exceptions.ConfigurationException
public abstract void stop()
public abstract int exitValue()
IllegalStateException
- if the process has not been started yet, or is still runningprotected boolean started()
public static org.thales.punch.libraries.forkexec.api.ProcessFuture launchChildApplication(String workerId, org.thales.punch.libraries.shiva.api.Application application, File home, String confDir, String[] args)
workerId
- the worker id launching the application subprocessapplication
- application the application launched by the workerhome
- The working directory of the applicationconfDir
- the punchplatform configuration dir on the shiva worker machineargs
- the arguments to launch the applicationpublic boolean taskShouldRunNow()
Copyright © 2022. All rights reserved.