ml.shifu.guagua.master
接口 MasterInterceptor<MASTER_RESULT extends Bytable,WORKER_RESULT extends Bytable>

类型参数:
MASTER_RESULT - master computation result in each iteration.
WORKER_RESULT - worker computation result in each iteration.
所有已知实现类:
AbstractMasterCoordinator, AsyncMasterCoordinator, BasicMasterInterceptor, LocalMasterCoordinator, MasterComputableTimer, MasterTimer, MemoryStatsMasterInterceptor, NettyMasterCoordinator, SyncMasterCoordinator, TraceMasterInterceptor

public interface MasterInterceptor<MASTER_RESULT extends Bytable,WORKER_RESULT extends Bytable>

MasterInterceptor defines hook points for each guagua application. Four hooks are defined like hooks before and after application and hooks after and before each iteration.

Almost all services in guagua like coordination, fail-over, profiler are implemented as interceptors. These are system interceptors can be configured by using command line '-D' parameter.

After system interceptors, user defined interceptors are also supported for user to define his/her own interceptors. Check SumOutput in examples project to see how interceper is used to save global result at the end of one guagua application.

For a list of interceptors, the order to call preXXX methods and postXXX methods is different. For example, a and b two interceptors. The order is a.preApplication->b.preApplication->a.preIteration->b.preIteration->computation->b.postIteration ->a.postIteration->b.postApplication->a.postApplication. This is like call stack to make sure each interceptor to intercept the whole other interceptors and master computation.

BasicMasterInterceptor is a empty implementation for user to choose the hooks to override.

另请参见:
BasicMasterInterceptor

方法摘要
 void postApplication(MasterContext<MASTER_RESULT,WORKER_RESULT> context)
          The hook point after any computation logic.
 void postIteration(MasterContext<MASTER_RESULT,WORKER_RESULT> context)
          The hook point after computation of each iteration.
 void preApplication(MasterContext<MASTER_RESULT,WORKER_RESULT> context)
          The hook point before any computation logic.
 void preIteration(MasterContext<MASTER_RESULT,WORKER_RESULT> context)
          The hook point before computation of each iteration.
 

方法详细信息

preApplication

void preApplication(MasterContext<MASTER_RESULT,WORKER_RESULT> context)
The hook point before any computation logic.

参数:
context - the master context instance which includes worker results and other useful parameters.

preIteration

void preIteration(MasterContext<MASTER_RESULT,WORKER_RESULT> context)
The hook point before computation of each iteration.

参数:
context - the master context instance which includes worker results and other useful parameters.

postIteration

void postIteration(MasterContext<MASTER_RESULT,WORKER_RESULT> context)
The hook point after computation of each iteration.

参数:
context - the master context instance which includes worker results and other useful parameters.

postApplication

void postApplication(MasterContext<MASTER_RESULT,WORKER_RESULT> context)
The hook point after any computation logic.

参数:
context - the master context instance which includes worker results and other useful parameters.


Copyright © 2015. All Rights Reserved.