ml.shifu.guagua
接口 GuaguaService

所有已知实现类:
GuaguaMasterService, GuaguaWorkerService

public interface GuaguaService

GuaguaService is a common service interface of both master and worker service implementations. TODO Define GuaguaServiceListener: 'onInit(Properties), onStart(), onStop()' to make three hooks for GuaguaMasterService and GuaguaWorkerService to scale. GuaguaServiceListener is a list can be configurated by using one parameter. And, we should also add setServiceListeners to set listeners on GuaguaService, which will be invoked at the end of init, start and stop. Example: Master as a RPC server, workers as RPC client, start and stop them here, which can be used to update progress or counter.


方法摘要
 void init(Properties props)
          Service initialization.
 void run(Progressable progress)
          Real logic implementation, for example, master and worker iteration logic.
 void setAppId(String appId)
          App id for whole application.
 void setContainerId(String containerId)
          Set the unique container id for master or worker.
 void setSplits(List<GuaguaFileSplit> splits)
          Assign splits to each worker to make them load that data.
 void start()
          Start point for the service.
 void stop()
          Stop service, resources cleaning should be added in this function.
 

方法详细信息

init

void init(Properties props)
Service initialization. For example, parameters setting.

The caller should make sure init(Properties) is called before start(), run(Progressable), stop() functions.

参数:
props - which contains different properties for master and workers to use.

start

void start()
Start point for the service. For example, setting up connection with zookeeper server.


run

void run(Progressable progress)
Real logic implementation, for example, master and worker iteration logic.

If progress is not null, it will be invoked by once per iteration.


stop

void stop()
Stop service, resources cleaning should be added in this function. Warning: this function should be included in finally segment to make sure resources are cleaning well.


setSplits

void setSplits(List<GuaguaFileSplit> splits)
Assign splits to each worker to make them load that data.


setAppId

void setAppId(String appId)
App id for whole application. For example: Job id in MapReduce(hadoop 1.0) or application id in Yarn.


setContainerId

void setContainerId(String containerId)
Set the unique container id for master or worker. For example: Task id in MapReduce or container id in Yarn.



Copyright © 2014. All Rights Reserved.