Java Code Examples for org.apache.hadoop.service.CompositeService

The following examples show how to use org.apache.hadoop.service.CompositeService. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: tajo   Source File:    License: Apache License 2.0 5 votes vote down vote up
public void setup() {
  conf = new TajoConf();
  nodeResource = NodeResource.createResource(2000, 3);
  service = new CompositeService(TestSimpleScheduler.class.getSimpleName()) {

    protected void serviceInit(Configuration conf) throws Exception {
      dispatcher = new AsyncDispatcher();

      rmContext = new TajoRMContext(dispatcher);
          new TajoResourceManager.WorkerEventDispatcher(rmContext));

      barrier = new Semaphore(0);
      scheduler = new MySimpleScheduler(rmContext, barrier);
      rmContext.getDispatcher().register(SchedulerEventType.class, scheduler);

      for (int i = 0; i < workerNum; i++) {
        WorkerConnectionInfo conn = new WorkerConnectionInfo("host" + i, 28091 + i, 28092, 21000, 28093, 28080);
            new NodeStatus(rmContext, NodeResources.clone(nodeResource), conn));
        rmContext.getDispatcher().getEventHandler().handle(new NodeEvent(conn.getId(), NodeEventType.STARTED));

  assertEquals(workerNum, rmContext.getNodes().size());
  totalResource = NodeResources.createResource(0);
  for(NodeStatus nodeStatus : rmContext.getNodes().values()) {
    NodeResources.addTo(totalResource, nodeStatus.getTotalResourceCapability());
Example 2
public CompositeService getYarnCluster() {
    return yarnCluster;