ml.shifu.guagua
接口 GuaguaService

所有已知实现类:
GuaguaMasterService, GuaguaWorkerService

public interface GuaguaService

GuaguaService is a common service interface of both master and worker service implementations.

GuaguaService defines the process to launch a master or worker service in container. GuaguaService should be called like code in below:

 try {
          guaguaService.init(props); 
          guaguaService.start(); 
          guaguaService.run(null); 
      } finally { 
          guaguaService.stop(); 
      } 
 
 

init(Properties) is used to transfer all properties needed in one guagua application. For Hadoop MapReduce or YARN job, it includes all the properties copied from Hadoop Configuration instance. And these properties will be set to MasterContext and WorkerContext for user to use them.


方法摘要
 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 © 2015. All Rights Reserved.