public class StatusScheduler extends Object
Modifier and Type | Class and Description |
---|---|
private static class |
StatusScheduler.ThreadFactory
GlassFish status tasks scheduler
StatusScheduler.ThreadFactory . |
Modifier and Type | Field and Description |
---|---|
private static int |
CONNECT_TIMEOUT
Administration port connect timeout [ms].
|
private static int |
DEFAULT_INTERNAL_CORE_POOL_SIZE
The number of threads to keep in the pool, even if they are idle.
|
private static long |
DELAY
Tasks execution delay [ms].
|
private static long |
DELAY_STARTUP
Tasks execution delay in startup mode [ms].
|
private ScheduledThreadPoolExecutor |
executor
Executor to run server status checks.
|
private static long |
INITIAL_DELAY
Tasks execution initial delay [ms].
|
private static long |
INITIAL_DELAY_STARTUP
Tasks execution initial delay in startup mode [ms].
|
private static StatusScheduler |
instance
Singleton object instance.
|
private Map<GlassFishServer,StatusJob> |
jobs
Server status jobs.
|
private static Logger |
LOGGER
Logger instance for this class.
|
private static ScheduledThreadPoolExecutor |
scheduledExecutor
External executor instance.
|
Modifier | Constructor and Description |
---|---|
private |
StatusScheduler(ScheduledThreadPoolExecutor executor)
Creates an instance of server status checks scheduler.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(GlassFishStatusEntity status)
Register GlassFisg server instance into scheduler and launch server
status checking jobs.
|
boolean |
add(GlassFishStatusEntity status,
GlassFishStatusListener listener,
boolean currentState,
GlassFishStatus... newState)
Register GlassFisg server instance into scheduler, register server status
listener and launch server status checking jobs.
|
private boolean |
addJob(StatusJob job)
Add server status job into jobs
Map . |
(package private) void |
cancel(StatusJob.Task task)
Cancel execution of scheduled job task.
|
boolean |
exists(GlassFishServer srv)
Check if given GlassFisg server instance is registered.
|
GlassFishServerStatus |
get(GlassFishServer srv)
Get GlassFisg server instance status object from scheduler.
|
static StatusScheduler |
getInstance()
Return existing singleton instance of this class or create a new one
when no instance exists.
|
StatusJob |
getJob(GlassFishServer srv)
Get server status job from jobs
Map . |
static void |
init(ScheduledThreadPoolExecutor executor)
Allows to initialize this class to use external executor.
|
private void |
localChecksAtOnce(StatusJob job)
All checks at once when we need full result ASAP.
|
private void |
localChecksStepByStep(StatusJob job)
All checks step by step when server state is stable and we have to run
all checks.
|
private static ScheduledThreadPoolExecutor |
newScheduledExecutor()
Allows to initialize this class to use internal executor.
|
private void |
portCheckOnly(StatusJob job)
Administrator port only check for states where we do not expect server
to be fully responding.
|
private void |
remoteChecksAtOnce(StatusJob job)
Checks for remote server at once when we need full result ASAP.
|
private void |
remoteChecksStepByStep(StatusJob job)
Checks for remote server step by step when server state is stable and
we have to run all checks.
|
boolean |
remove(GlassFishServer srv)
Unregister GlassFisg server instance from scheduler and and stop server
status checking jobs.
|
(package private) void |
remove(StatusJob job)
Remove all scheduled tasks from executor.
|
private StatusJob |
removeJob(GlassFishServer srv)
Remove server status job from jobs
Map . |
(package private) void |
reschedule(StatusJob job)
Schedule server status job after internal state transition to follow
current strategy.
|
private ScheduledFuture |
scheduleAdminPortTask(StatusJob job)
Schedule periodic execution of port check asynchronous task.
|
private ScheduledFuture |
scheduleLocationsTask(StatusJob job)
Schedule periodic execution of
__locations
asynchronous task. |
private ScheduledFuture |
scheduleLocationsTask(StatusJob job,
long initialDelay)
Schedule periodic execution of
__locations
asynchronous task. |
(package private) ScheduledFuture |
scheduleNew(StatusJob job)
Schedule new server status job.
|
private ScheduledFuture |
scheduleVersionTask(StatusJob job)
Schedule periodic execution of
version asynchronous task. |
private ScheduledFuture |
scheduleVersionTask(StatusJob job,
long initialDelay)
Schedule periodic execution of
version asynchronous task. |
private static long |
selectDelay(StatusJobState state)
Select tasks execution delay depending on current job internal state.
|
private static long |
selectInitialDelay(StatusJobState state)
Select tasks execution initial delay depending on current job internal
state.
|
boolean |
start(GlassFishServer srv)
Switch GlassFisg server status monitoring into startup mode.
|
private static final Logger LOGGER
private static ScheduledThreadPoolExecutor scheduledExecutor
private static volatile StatusScheduler instance
private static final int DEFAULT_INTERNAL_CORE_POOL_SIZE
private static final long DELAY
private static final long INITIAL_DELAY
private static final long DELAY_STARTUP
private static final long INITIAL_DELAY_STARTUP
private static final int CONNECT_TIMEOUT
private ScheduledThreadPoolExecutor executor
private final Map<GlassFishServer,StatusJob> jobs
private StatusScheduler(ScheduledThreadPoolExecutor executor)
executor
- External executor.public static void init(ScheduledThreadPoolExecutor executor)
getInstance()
method.
executor
- External executor to be supplied.private static ScheduledThreadPoolExecutor newScheduledExecutor()
getInstance()
method. Caller should hold StatusScheduler.class
lock.
executor
- External executor to be supplied.public static StatusScheduler getInstance()
GlassFishAccountInstanceProvider
singleton instance.private static long selectDelay(StatusJobState state)
state
- Current job internal state.private static long selectInitialDelay(StatusJobState state)
state
- Current job internal state.public boolean exists(GlassFishServer srv)
srv
- GlassFisg server instance to be checked.true
when server instance is registered
in scheduler or false
otherwise.public GlassFishServerStatus get(GlassFishServer srv)
srv
- GlassFisg server instance to search for in jobs.GlassFishServerStatus
object.
Returns null
value for unregistered server instance.public boolean start(GlassFishServer srv)
srv
- GlassFisg server instance to be started.true
when server instance is being
monitored in startup mode or false
if switching
failed.public boolean add(GlassFishStatusEntity status, GlassFishStatusListener listener, boolean currentState, GlassFishStatus... newState)
status
- GlassFish server status entity.listener
- Server status listener to be registered.currentState
- Notify about current server status after every check
when true
.newState
- Notify about server status change for new states
provided as this argument.true
when server instance was successfully
added into scheduler and status checking job was started
or false
otherwise.public boolean add(GlassFishStatusEntity status)
status
- GlassFish server status entity.true
when server instance was successfully
added into scheduler and status checking job was started
or false
otherwise.public boolean remove(GlassFishServer srv)
srv
- GlassFisg server instance to unregister.true
when server instance was successfully
removed from scheduler and status checking job was stopped.
or false
when server instance was not registered.public StatusJob getJob(GlassFishServer srv)
Map
.
srv
- GlassFisg server instance to search for in jobs.null
when no such job exists.private boolean addJob(StatusJob job)
Map
.
Server status job will be added only if there is no other job for
GlassFisg server instance associated with this job.
true
when jow was added into jobs
Map
or false
otherwise.private StatusJob removeJob(GlassFishServer srv)
Map
.
srv
- GlassFisg server instance associated with job to be removed.private ScheduledFuture scheduleLocationsTask(StatusJob job, long initialDelay)
__locations
asynchronous task.
Caller must own job
lock.
job
- Server status check job internal data.initialDelay
- Task execution initial delay.private ScheduledFuture scheduleVersionTask(StatusJob job, long initialDelay)
version
asynchronous task.
Caller must own job
lock.
job
- Server status check job internal data.initialDelay
- Task execution initial delay.private ScheduledFuture scheduleLocationsTask(StatusJob job)
__locations
asynchronous task.
Caller must own job
lock.
job
- Server status check job internal data.private ScheduledFuture scheduleVersionTask(StatusJob job)
version
asynchronous task.
Caller must own job
lock.
job
- Server status check job internal data.private ScheduledFuture scheduleAdminPortTask(StatusJob job)
job
lock.
job
- Server status check job internal data.void cancel(StatusJob.Task task)
task
- Individual status check task data.private void portCheckOnly(StatusJob job)
job
lock.
job
- Server status check job internal data.private void localChecksAtOnce(StatusJob job)
job
lock.
job
- Server status check job internal data.private void localChecksStepByStep(StatusJob job)
job
lock.
job
- Server status check job internal data.private void remoteChecksAtOnce(StatusJob job)
job
lock.
job
- Server status check job internal data.private void remoteChecksStepByStep(StatusJob job)
job
lock.
job
- Server status check job internal data.void remove(StatusJob job)
job
lock.ScheduledFuture scheduleNew(StatusJob job)
UNKNOWN
state.
Caller must own job
lock.
job
- Server status job.void reschedule(StatusJob job)
UNKNOWN
.
Caller must own job
lock.
job
- Server status job.Copyright © 2013. All Rights Reserved.