|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.service.mapred.AbstractJobAndTaskService<M,T>
public abstract class AbstractJobAndTaskService<M extends IJobMetadata,T extends ITask>
Abstract base class for services implementing IJobAndTaskService.
Concrete subclasses must:
workers that will
execute the tasks. IJobAndTaskService.getServiceUUID().threadPoolSize and jobs, both
of which are used now by some unit tests.
| Nested Class Summary | |
|---|---|
static class |
AbstractJobAndTaskService.AbstractTaskWorker<M,T extends ITask>
Abstract base class for task workers running in the MapService or the
ReduceService. |
static class |
AbstractJobAndTaskService.Options
Options for AbstractJobAndTaskService(Properties) |
| Field Summary | |
|---|---|
protected ExecutorService |
cancelService
A service used by the HeartbeatMonitorTask to cancel jobs. |
static String |
ERR_JOB_EXISTS
Text of the error message used when the UUID of a job is already known to the service. |
static String |
ERR_NO_JOB_IDENTIFIER
Text of the error message used when the UUID of a job is not available from the IJobMetadata provided to
IJobAndTaskService.startJob(IJobMetadata). |
static String |
ERR_NO_SUCH_JOB
Text of the error message used when the UUID of a job is not know to this service. |
protected Timer |
heartbeatMonitor
Service that looks for heartbeat messages and cancels a job if it misses more than N heartbeats. |
protected long |
heartbeatPeriod
The heartbeat period (ms). |
protected long |
heartbeatTimeout
The heartbeat timeout (ms). |
Map<UUID,JobState<M>> |
jobs
Running jobs. |
static org.apache.log4j.Logger |
log
|
protected ExecutorService |
taskService
Queue of executing ITasks. |
int |
threadPoolSize
The size of the thread pool. |
protected ScheduledExecutorService |
timeoutService
Service that looks for task execution timeouts and cancels a task if it exceeds its timeout. |
| Constructor Summary | |
|---|---|
protected |
AbstractJobAndTaskService(Properties properties)
|
| Method Summary | |
|---|---|
boolean |
cancel(UUID job,
UUID task)
Cancel a task. |
void |
cancelJob(UUID job)
Terminate a job. |
void |
destroy()
|
Outcome[] |
drain(UUID job)
Drains the Outcomes for all completed tasks. |
abstract IBigdataClient |
getBigdataClient()
|
int |
heartbeat(UUID job)
The service will IJobAndTaskService.cancelJob(UUID) the job if it does not continue
to receive heartbeat for that job. |
boolean |
isOpen()
Return true iff the service is running. |
protected JobState<M> |
newJobState(UUID job,
M metadata,
IBigdataClient client)
Factory for job state. |
protected abstract AbstractJobAndTaskService.AbstractTaskWorker<M,T> |
newTaskWorker(JobState<M> jobState,
T task)
Factory for task workers. |
void |
shutdown()
The service will no longer accept new requests, but existing requests will be processed (sychronous). |
void |
shutdownNow()
The service will no longer accept new requests and will make a best effort attempt to terminate all existing requests and return ASAP. |
void |
startJob(M jobMetadata)
Declare a job. |
void |
submit(UUID job,
T task,
long timeout)
Submit a task to be executed as part of a job (asynchronous). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.bigdata.service.mapred.IJobAndTaskService |
|---|
getServiceUUID |
| Field Detail |
|---|
public static final transient org.apache.log4j.Logger log
public static final String ERR_NO_JOB_IDENTIFIER
IJobMetadata provided to
IJobAndTaskService.startJob(IJobMetadata).
public static final String ERR_JOB_EXISTS
public static final String ERR_NO_SUCH_JOB
public final int threadPoolSize
protected final ExecutorService taskService
ITasks.
AbstractJobAndTaskService.Options.THREAD_POOL_SIZEprotected final ScheduledExecutorService timeoutService
protected final Timer heartbeatMonitor
protected final long heartbeatTimeout
AbstractJobAndTaskService.Options.HEARTBEAT_TIMEOUT
protected final long heartbeatPeriod
HeartbeatMonitorTask will run every N
milliseconds, where N is the heartbeatPeriod.
See AbstractJobAndTaskService.Options.HEARTBEAT_PERIOD
protected final ExecutorService cancelService
HeartbeatMonitorTask to cancel jobs.
The use of this services keeps down the latency of the timer
task.
public final Map<UUID,JobState<M extends IJobMetadata>> jobs
| Constructor Detail |
|---|
protected AbstractJobAndTaskService(Properties properties)
properties - See AbstractJobAndTaskService.Options| Method Detail |
|---|
public boolean isOpen()
IServiceShutdowntrue iff the service is running.
isOpen in interface IServiceShutdownpublic void shutdown()
IServiceShutdownIServiceShutdown.Options.SHUTDOWN_TIMEOUT. Implementations SHOULD be
synchronized. If the service is aleady shutdown, then
this method should be a NOP.
shutdown in interface IServiceShutdownpublic void shutdownNow()
IServiceShutdown
shutdownNow in interface IServiceShutdownpublic void destroy()
public abstract IBigdataClient getBigdataClient()
IBigdataClient should be initialized from the
IJobMetadata a per job basis. This will let us: (a) reuse
these services across federations; and (b) avoid mishap when the
client is connected to one federation and it tries to discover
services connected to another federation. Of course, this does
not matter until we support multiple federations....
This approach requires a weak value hash map of the clients and a hard reference to the client in the job. Once no job references a client that client should be disconnected from its federation. Rather than always minting a client for a job, we could also first check the hash map for an existing client for the same federation. Will the client explicitly disconnect from federations or should that be automatic when there is no longer a hard reference to a given federation? plus a delay?
It also makes sense to allow a different client for input and output so that a map/reduce job can cross federations.
protected JobState<M> newJobState(UUID job,
M metadata,
IBigdataClient client)
job - The job identifier.metadata - The job metadata.client - Used to access the IBigdataFederation when reading or
writing data.
JobState object.
protected abstract AbstractJobAndTaskService.AbstractTaskWorker<M,T> newTaskWorker(JobState<M> jobState,
T task)
jobState - The job state maintained by this service.task - The task to be executed.
public void startJob(M jobMetadata)
IJobAndTaskServiceIJobAndTaskService.heartbeat(UUID) messages or the service will
cancel the job.
startJob in interface IJobAndTaskService<M extends IJobMetadata,T extends ITask>jobMetadata - The service specific job metadata.public void cancelJob(UUID job)
IJobAndTaskServiceIJobAndTaskService.heartbeat(UUID) messages for this job.
cancelJob in interface IJobAndTaskService<M extends IJobMetadata,T extends ITask>job - The job identifier.
public int heartbeat(UUID job)
throws IOException
IJobAndTaskServiceIJobAndTaskService.cancelJob(UUID) the job if it does not continue
to receive heartbeat for that job. The service timeout for a job is on
the order of a few seconds, but clients are encouraged to send heartbeats
ever 100ms.
Note: Clients may also use this message to monitor the progression of tasks for the specified job.
heartbeat in interface IJobAndTaskService<M extends IJobMetadata,T extends ITask>job - The job identifier.
IOExceptionpublic Outcome[] drain(UUID job)
IJobAndTaskServiceOutcomes for all completed tasks. The Outcome
for those tasks is no longer available from the service.
drain in interface IJobAndTaskService<M extends IJobMetadata,T extends ITask>job - The job identifier.
Outcomes.
public void submit(UUID job,
T task,
long timeout)
IJobAndTaskServiceStatus, it
will be reported by IJobAndTaskService.heartbeat(UUID) and its Outcome will
be made available by IJobAndTaskService.drain(UUID).
submit in interface IJobAndTaskService<M extends IJobMetadata,T extends ITask>job - The job identifier.task - The task to be executed.timeout - When non-zero, the timeout in milliseconds for this task once
it begins to execute on the service (this controls the actual
maximum run time of the task rather than the time since the
task was submitted or since the job was started).
public boolean cancel(UUID job,
UUID task)
IJobAndTaskService
cancel in interface IJobAndTaskService<M extends IJobMetadata,T extends ITask>job - The job identifier.task - The task identifier.
Future.cancel(boolean)).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||