public abstract class HookWorkerComputable<MASTER_RESULT extends Bytable,WORKER_RESULT extends Bytable> extends Object implements WorkerComputable<MASTER_RESULT,WORKER_RESULT>
MasterComputable abstraction to define setup(WorkerContext) and
cleanup(WorkerContext) hooks.
For classes who extends HookWorkerComputable, user can provide its own setup(WorkerContext) and
cleanup(WorkerContext). Guagua will make sure both will be called only once at the beginning and the end of
whole process.
| Constructor and Description |
|---|
HookWorkerComputable() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanup(WorkerContext<MASTER_RESULT,WORKER_RESULT> context)
Cleanup method for master computation.
|
WORKER_RESULT |
compute(WorkerContext<MASTER_RESULT,WORKER_RESULT> context)
Worker computation for each iteration.
|
abstract WORKER_RESULT |
doCompute(WorkerContext<MASTER_RESULT,WORKER_RESULT> context)
Real computation logic excluding some setup and cleanup hooks.
|
protected void |
setup(WorkerContext<MASTER_RESULT,WORKER_RESULT> context)
Setup method for master computation.
|
protected void setup(WorkerContext<MASTER_RESULT,WORKER_RESULT> context)
context - the worker context instance.public WORKER_RESULT compute(WorkerContext<MASTER_RESULT,WORKER_RESULT> context)
WorkerComputablecompute in interface WorkerComputable<MASTER_RESULT extends Bytable,WORKER_RESULT extends Bytable>context - the worker context instance which includes worker info, master result of last iteration or other
useful into for each iteration.public abstract WORKER_RESULT doCompute(WorkerContext<MASTER_RESULT,WORKER_RESULT> context)
context - the worker context instance.protected void cleanup(WorkerContext<MASTER_RESULT,WORKER_RESULT> context)
context - the worker context instance.for cleanup hookCopyright © 2019. All Rights Reserved.