public abstract class AServicePing extends Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
autostart_enabled
This indicates whether the service's autostart flag is enabled or disabled.
|
protected org.apache.uima.ducc.common.utils.DuccLogger |
duccLogger
When the pinger is run as a thread inside the SM, this logger is used to
join the ping log with the SM log.
|
protected int |
failure_cursor |
protected int |
failure_max
This is the total number of instance failures allowed within the failure window.
|
protected int[] |
failure_window |
protected int |
failure_window_period
This is the time, in minutes, over which the failure window is implemented.
|
protected int |
failure_window_size |
protected Map<String,Object> |
initializationState
This is a map containing the initialization state for the service, passed in only
once, during pinger initialization.
|
protected long |
last_use
This is the time/date the service was last used.
|
protected boolean |
log_enabled
This specifies whether the service log is requested to be enabled.
|
protected int |
monitor_rate
This is the time between pings, in minutes.
|
protected long |
service_id
This is the unique DUCC_assigned ID of the service.
|
protected Map<String,Object> |
smState
This is a map containing current service state, passed in from the SM on every ping.
|
protected int |
total_failures
This is the total number of instance failures since the SM or pinger was last started.
|
Constructor and Description |
---|
AServicePing() |
Modifier and Type | Method and Description |
---|---|
void |
doLog(String methodName,
Object... msg)
This is a convenience method for logging which enforces the use of the calling
method name and permits use of commas to separate fields in the message.
|
int |
getAdditions()
Called by the service manager to query the number of additional needed service instances.
|
Long[] |
getDeletions()
Called by the service manager to retrieve the specific service instances
to stop.
|
long |
getLastUse()
Pingers may track when a service was last used.
|
Map<String,Object> |
getSmState()
Getter of the service state; Implementors may just access it directly if they want.
|
abstract IServiceStatistics |
getStatistics()
Returns the object with application-derived health and statistics.
|
abstract void |
init(String arguments,
String endpoint)
Called by the ping driver, to pass in useful things the pinger may want.
|
void |
init(String arguments,
String endpoint,
Map<String,Object> initState)
Called by the ping driver to initialize static information about the service and
pinger.
|
boolean |
isAutostart()
The SM queries the ping/monitors autostart on return from each ping.
|
boolean |
isExcessiveFailures()
This determines if there have been excessive service instance failures by tracking the
number of failures, not consecutive, but rather within a window of time.
|
void |
setLogger(org.apache.uima.ducc.common.utils.DuccLogger logger)
This is used by the SM for running pingers internally as SM threads, to direct
the ping log into the SM log.
|
void |
setSmState(Map<String,Object> props)
Current state of the monitored service is passed in here.
|
abstract void |
stop()
Stop is called by the ping wrapper when it is being killed.
|
protected int[] failure_window
protected int failure_cursor
protected int total_failures
protected int failure_max
protected int failure_window_period
protected int failure_window_size
protected int monitor_rate
protected boolean autostart_enabled
protected long last_use
protected boolean log_enabled
protected long service_id
protected Map<String,Object> smState
getSmState()
for details of the map.protected Map<String,Object> initializationState
protected org.apache.uima.ducc.common.utils.DuccLogger duccLogger
doLog(String, Object...)
method
writes to stdout which is directed to
the declared service log directory by the infrastructore.public abstract void init(String arguments, String endpoint) throws Exception
arguments
- This is passed in from the service specification's
service_ping_arguments string.endpoint
- This is the name of the service endpoint, as passed in
at service registration.Exception
public void init(String arguments, String endpoint, Map<String,Object> initState) throws Exception
Called by the ping driver to initialize static information about the service and pinger. This method calls the public init() method and is not intended for public consumption.
This method initializes the following state prior to invoking init(String, String):
arguments
- This is passed in from the service specification's
service_ping_arguments string.endpoint
- This is the name of the service endpoint, as passed in
at service registration.initState
- Properties file with static data about the service and
pinger.Exception
public abstract void stop()
public abstract IServiceStatistics getStatistics()
IServiceStatistics
containing the basic
service health information for use by SM and display in the Web Server.public void setSmState(Map<String,Object> props)
public Map<String,Object> getSmState()
Getter of the service state; Implementors may just access it directly if they want. Access the state passed to the ping/monitor from SM:
public int getAdditions()
Called by the service manager to query the number of additional needed service instances.
Implementing ping/monitors override this method to request additional instances.
public Long[] getDeletions()
Called by the service manager to retrieve the specific service instances to stop.
Implementing ping/monitors return the specific IDs of service processes to be terminated by DUCC. The IDs are a subset of the IDS found in the 'all-instances' map from getSmState();
public boolean isAutostart()
The SM queries the ping/monitors autostart on return from each ping. The default is to return the same value that came in on the ping.
Implementing ping/monitors may override this behaviour to dynanically enable or disable autostart.
It is useful to disable autostart if a pinger detects that a service has been idle for a long time and it wants to shrink the number of live instances below the autostart value. If autostart is not disabled it the number of instances will not be allowed to shrink to 0.
public long getLastUse()
Pingers may track when a service was last used. If set to non-zero this is the time and date of last use, converted to milliseconds, as returned by System.getTimeMillis(). Its value is always set into the meta file for the pinger on each ping.
Implementing ping/monitors may return a datestamp to indicate when the service was last used by a job.
public void setLogger(org.apache.uima.ducc.common.utils.DuccLogger logger)
This is used by the SM for running pingers internally as SM threads, to direct the ping log into the SM log.
External an custom pingers should generally not invoke this method unless the intention is to fully manage their own logs.
In all cases, the use of the doLog(String, Object...)
method is strongly encouraged as it insures messages are logged into a
well-known and managed location.
public void doLog(String methodName, Object... msg)
methodName
- This should be the named of the method calling doLog.msg
- This is a variable length parameter list which gets joined
on ' ' and emitted to the logger.public boolean isExcessiveFailures()
This determines if there have been excessive service instance failures by tracking the number of failures, not consecutive, but rather within a window of time. It may be overridden by extending monitors.
This default implementation uses a time window to determine if exessive failures have occurred in a short period of time. It operates off the two failure parameters from the service registration:
If more than 'instance_failure_limit' failures occure within the preceding 'time-in-minutes' this method returns 'true' and the SM disables automatic restart of instances. Restart may be resumed by manually issuing a CLI start to the service one the problem is resolved.
Implementing ping/monitors may override this with custom logic to determine if a service has had excessive failures.
Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.