private class JoinManager.ProxyRegTask extends RetryTask
Modifier and Type | Field and Description |
---|---|
protected int |
nRetries |
protected JoinManager.ProxyReg |
proxyReg |
protected int |
seqN |
private long[] |
sleepTime |
protected int |
tryIndx |
DAYS, HOURS, MINUTES, SECONDS
Constructor and Description |
---|
JoinManager.ProxyRegTask(JoinManager.ProxyReg proxyReg,
int seqN)
Basic constructor; simply stores the input parameters
|
Modifier and Type | Method and Description |
---|---|
JoinManager.ProxyReg |
getProxyReg()
Accessor method that returns the instance of
ProxyReg
(the lookup service) associated with the task represented by
the current instance of this class. |
int |
getSeqN()
Accessor method that returns the unique sequence number associated
with the task represented by the current instance of this class.
|
long |
retryTime()
Returns the next absolute time (in milliseconds) at which another
execution of this task should be made (after the previous
attempt has failed).
|
boolean |
runAfter(List tasks,
int size)
Returns true if the current instance of this task must be run
after any task already in the task manager queue.
|
protected boolean |
stopTrying(Exception e)
Convenience method called by the child tasks when they encounter
an exception.
|
boolean |
tryOnce()
Executes the current instance of this task once, queuing it
for retry at a later time and returning
false
upon failure. |
private final long[] sleepTime
protected int tryIndx
protected int nRetries
protected JoinManager.ProxyReg proxyReg
protected int seqN
JoinManager.ProxyRegTask(JoinManager.ProxyReg proxyReg, int seqN)
public boolean tryOnce()
false
upon failure. This method attempts to execute all of the tasks
associated with the lookup service referenced in this task's
proxyReg
field. Order of execution is important,
and this method executes the tasks in the proxyReg
's
taskList
in a FIFO order.
Note that tasks may be added to the taskList
of
the proxyReg
during the execution of this method.
Upon successfully executing all of the tasks in the
taskList
, this method returns true
and the current instance of this task is not executed again.
For each unsuccessful execution of a task in the
taskList
, this method returns false
,
which causes the task to be scheduled by the
WakeupManager
to be executed again at a later
time, as indicated by the value returned by retryTime
.public long retryTime()
public boolean runAfter(List tasks, int size)
null
service ID (where it is desired that
a unique service ID be generated on the service's behalf),
that only the first task in the task manager's queue be run; no
other tasks in the queue should be run while that first task
is running. This is because the first sub-task executed by
the first main task in the task manager's queue will always be
a RegisterTask
. And during the execution of that
first sub-task (if the service ID has not yet been set), the
service ID generated by the associated lookup service is retrieved
and stored for use in all future lookup service registration
tasks, Once the service ID is set by that first registration
sub-task, all future main tasks (and their associated registration
sub-tasks) can be run in parallel; each using the same service ID.
If this is not done, then the registration sub-tasks would be
run in parallel, each assigning a different ID to the service.
This method guarantees that until the service's ID is set,
only one registration sub-task is run; that is, one task
doesn't start until the currently running task has completed,
and a non-null
service ID is assigned to the service.
Executing the main tasks sequentially until the service ID is
retrieved and stored must also be guaranteed because the currently
running registration task may fail to register the service
(because of a RemoteException
), and thus may fail
to obtain an ID for the service. This method guarantees then
that each main task (and thus, each registration sub-task) will
run in sequence until one of those tasks completes successfully;
and from that point on, this method guarantees that all other
queued tasks will run in parallel.tasks
- the tasks with which to compare the current tasksize
- elements with index less than size are consideredpublic JoinManager.ProxyReg getProxyReg()
ProxyReg
(the lookup service) associated with the task represented by
the current instance of this class.public int getSeqN()
protected boolean stopTrying(Exception e)
true
(which stops the wakeup manager
from retrying this task
otherwise, this method returns false
, which indicates
that the wakeup manager should not stop trying to successfully
execute the task.Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.