org.apache.hadoop.service.Service.STATE Java Examples

The following examples show how to use org.apache.hadoop.service.Service.STATE. 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 File: TestNodeStatusUpdater.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testNodeDecommision() throws Exception {
  nm = getNodeManager(NodeAction.SHUTDOWN);
  YarnConfiguration conf = createNMConfig();
  nm.init(conf);
  Assert.assertEquals(STATE.INITED, nm.getServiceState());
  nm.start();

  int waitCount = 0;
  while (heartBeatID < 1 && waitCount++ != 200) {
    Thread.sleep(500);
  }
  Assert.assertFalse(heartBeatID < 1);
  Assert.assertTrue(nm.getNMContext().getDecommissioned());

  // NM takes a while to reach the STOPPED state.
  waitCount = 0;
  while (nm.getServiceState() != STATE.STOPPED && waitCount++ != 20) {
    LOG.info("Waiting for NM to stop..");
    Thread.sleep(1000);
  }

  Assert.assertEquals(STATE.STOPPED, nm.getServiceState());
}
 
Example #2
Source File: TestJobHistoryServer.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test (timeout= 50000 )
public void testStartStopServer() throws Exception {
  historyServer = new JobHistoryServer();
  Configuration config = new Configuration();
  historyServer.init(config);
  assertEquals(STATE.INITED, historyServer.getServiceState());
  assertEquals(6, historyServer.getServices().size());
  HistoryClientService historyService = historyServer.getClientService();
  assertNotNull(historyServer.getClientService());
  assertEquals(STATE.INITED, historyService.getServiceState());

  historyServer.start();
  assertEquals(STATE.STARTED, historyServer.getServiceState());
  assertEquals(STATE.STARTED, historyService.getServiceState());
  historyServer.stop();
  assertEquals(STATE.STOPPED, historyServer.getServiceState());
  assertNotNull(historyService.getClientHandler().getConnectAddress());
}
 
Example #3
Source File: TestRMAdminCLI.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testAccessLocalNodeLabelManager() throws Exception {
  assertFalse(dummyNodeLabelsManager.getServiceState() == STATE.STOPPED);
  
  String[] args =
      { "-addToClusterNodeLabels", "x,y", "-directlyAccessNodeLabelStore" };
  assertEquals(0, rmAdminCLI.run(args));
  assertTrue(dummyNodeLabelsManager.getClusterNodeLabels().containsAll(
      ImmutableSet.of("x", "y")));
  
  // reset localNodeLabelsManager
  dummyNodeLabelsManager.removeFromClusterNodeLabels(ImmutableSet.of("x", "y"));
  
  // change the sequence of "-directlyAccessNodeLabelStore" and labels,
  // should not matter
  args =
      new String[] { "-addToClusterNodeLabels",
          "-directlyAccessNodeLabelStore", "x,y" };
  assertEquals(0, rmAdminCLI.run(args));
  assertTrue(dummyNodeLabelsManager.getClusterNodeLabels().containsAll(
      ImmutableSet.of("x", "y")));
  
  // local node labels manager will be close after running
  assertTrue(dummyNodeLabelsManager.getServiceState() == STATE.STOPPED);
}
 
Example #4
Source File: TestRMAdminCLI.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testAccessLocalNodeLabelManager() throws Exception {
  assertFalse(dummyNodeLabelsManager.getServiceState() == STATE.STOPPED);
  
  String[] args =
      { "-addToClusterNodeLabels", "x,y", "-directlyAccessNodeLabelStore" };
  assertEquals(0, rmAdminCLI.run(args));
  assertTrue(dummyNodeLabelsManager.getClusterNodeLabels().containsAll(
      ImmutableSet.of("x", "y")));
  
  // reset localNodeLabelsManager
  dummyNodeLabelsManager.removeFromClusterNodeLabels(ImmutableSet.of("x", "y"));
  
  // change the sequence of "-directlyAccessNodeLabelStore" and labels,
  // should not matter
  args =
      new String[] { "-addToClusterNodeLabels",
          "-directlyAccessNodeLabelStore", "x,y" };
  assertEquals(0, rmAdminCLI.run(args));
  assertTrue(dummyNodeLabelsManager.getClusterNodeLabels().containsAll(
      ImmutableSet.of("x", "y")));
  
  // local node labels manager will be close after running
  assertTrue(dummyNodeLabelsManager.getServiceState() == STATE.STOPPED);
}
 
Example #5
Source File: TestRMRestart.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test (timeout = 10000)
public void testRMShutdown() throws Exception {
  MemoryRMStateStore memStore = new MemoryRMStateStore() {
    @Override
    public synchronized void checkVersion()
        throws Exception {
      throw new Exception("Invalid version.");
    }
  };
  // start RM
  memStore.init(conf);
  MockRM rm1 = null;
  try {
    rm1 = createMockRM(conf, memStore);
    rm1.start();
    Assert.fail();
  } catch (Exception e) {
    Assert.assertTrue(e.getMessage().contains("Invalid version."));
  }
  Assert.assertTrue(rm1.getServiceState() == STATE.STOPPED);
}
 
Example #6
Source File: TestJobHistoryServer.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test (timeout= 50000 )
public void testStartStopServer() throws Exception {
  historyServer = new JobHistoryServer();
  Configuration config = new Configuration();
  historyServer.init(config);
  assertEquals(STATE.INITED, historyServer.getServiceState());
  assertEquals(6, historyServer.getServices().size());
  HistoryClientService historyService = historyServer.getClientService();
  assertNotNull(historyServer.getClientService());
  assertEquals(STATE.INITED, historyService.getServiceState());

  historyServer.start();
  assertEquals(STATE.STARTED, historyServer.getServiceState());
  assertEquals(STATE.STARTED, historyService.getServiceState());
  historyServer.stop();
  assertEquals(STATE.STOPPED, historyServer.getServiceState());
  assertNotNull(historyService.getClientHandler().getConnectAddress());
}
 
Example #7
Source File: TestCompositeService.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Shut down from not-inited: expect nothing to have happened
 */
@Test
public void testServiceStopFromNotInited() {
  ServiceManager serviceManager = new ServiceManager("ServiceManager");

  // Add services
  for (int i = 0; i < NUM_OF_SERVICES; i++) {
    CompositeServiceImpl service = new CompositeServiceImpl(i);
    serviceManager.addTestService(service);
  }

  CompositeServiceImpl[] services = serviceManager.getServices().toArray(
    new CompositeServiceImpl[0]);
  serviceManager.stop();
  assertInState(STATE.NOTINITED, services);
}
 
Example #8
Source File: TestCompositeService.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Shut down from inited
 */
@Test
public void testServiceStopFromInited() {
  ServiceManager serviceManager = new ServiceManager("ServiceManager");

  // Add services
  for (int i = 0; i < NUM_OF_SERVICES; i++) {
    CompositeServiceImpl service = new CompositeServiceImpl(i);
    serviceManager.addTestService(service);
  }

  CompositeServiceImpl[] services = serviceManager.getServices().toArray(
    new CompositeServiceImpl[0]);
  serviceManager.init(new Configuration());
  serviceManager.stop();
  if (STOP_ONLY_STARTED_SERVICES) {
    //this policy => no services were stopped
    assertInState(STATE.INITED, services);
  } else {
    assertInState(STATE.STOPPED, services);
  }
}
 
Example #9
Source File: TestCompositeService.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Shut down from not-inited: expect nothing to have happened
 */
@Test
public void testServiceStopFromNotInited() {
  ServiceManager serviceManager = new ServiceManager("ServiceManager");

  // Add services
  for (int i = 0; i < NUM_OF_SERVICES; i++) {
    CompositeServiceImpl service = new CompositeServiceImpl(i);
    serviceManager.addTestService(service);
  }

  CompositeServiceImpl[] services = serviceManager.getServices().toArray(
    new CompositeServiceImpl[0]);
  serviceManager.stop();
  assertInState(STATE.NOTINITED, services);
}
 
Example #10
Source File: TestCompositeService.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Shut down from inited
 */
@Test
public void testServiceStopFromInited() {
  ServiceManager serviceManager = new ServiceManager("ServiceManager");

  // Add services
  for (int i = 0; i < NUM_OF_SERVICES; i++) {
    CompositeServiceImpl service = new CompositeServiceImpl(i);
    serviceManager.addTestService(service);
  }

  CompositeServiceImpl[] services = serviceManager.getServices().toArray(
    new CompositeServiceImpl[0]);
  serviceManager.init(new Configuration());
  serviceManager.stop();
  if (STOP_ONLY_STARTED_SERVICES) {
    //this policy => no services were stopped
    assertInState(STATE.INITED, services);
  } else {
    assertInState(STATE.STOPPED, services);
  }
}
 
Example #11
Source File: TestCompositeService.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 1000)
public void testAddUninitedSiblingInInit() throws Throwable {
  CompositeService parent = new CompositeService("parent");
  BreakableService sibling = new BreakableService();
  parent.addService(new AddSiblingService(parent,
                                          sibling,
                                          STATE.INITED));
  parent.init(new Configuration());
  try {
    parent.start();
    fail("Expected an exception, got " + parent);
  } catch (ServiceStateException e) {
    //expected
  }
  parent.stop();
  assertEquals("Incorrect number of services",
               2, parent.getServices().size());
}
 
Example #12
Source File: TestLocalDirsHandlerService.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testValidPathsDirHandlerService() throws Exception {
  Configuration conf = new YarnConfiguration();
  String localDir1 = new File("file:///" + testDir, "localDir1").getPath();
  String localDir2 = new File("hdfs:///" + testDir, "localDir2").getPath();
  conf.set(YarnConfiguration.NM_LOCAL_DIRS, localDir1 + "," + localDir2);
  String logDir1 = new File("file:///" + testDir, "logDir1").getPath();
  conf.set(YarnConfiguration.NM_LOG_DIRS, logDir1);
  LocalDirsHandlerService dirSvc = new LocalDirsHandlerService();
  try {
    dirSvc.init(conf);
    Assert.fail("Service should have thrown an exception due to wrong URI");
  } catch (YarnRuntimeException e) {
  }
  Assert.assertEquals("Service should not be inited",
                      STATE.STOPPED,
                      dirSvc.getServiceState());
  dirSvc.close();
}
 
Example #13
Source File: TestRMRestart.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test (timeout = 10000)
public void testRMShutdown() throws Exception {
  MemoryRMStateStore memStore = new MemoryRMStateStore() {
    @Override
    public synchronized void checkVersion()
        throws Exception {
      throw new Exception("Invalid version.");
    }
  };
  // start RM
  memStore.init(conf);
  MockRM rm1 = null;
  try {
    rm1 = createMockRM(conf, memStore);
    rm1.start();
    Assert.fail();
  } catch (Exception e) {
    Assert.assertTrue(e.getMessage().contains("Invalid version."));
  }
  Assert.assertTrue(rm1.getServiceState() == STATE.STOPPED);
}
 
Example #14
Source File: TestCompositeService.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 1000)
public void testAddUninitedSiblingInInit() throws Throwable {
  CompositeService parent = new CompositeService("parent");
  BreakableService sibling = new BreakableService();
  parent.addService(new AddSiblingService(parent,
                                          sibling,
                                          STATE.INITED));
  parent.init(new Configuration());
  try {
    parent.start();
    fail("Expected an exception, got " + parent);
  } catch (ServiceStateException e) {
    //expected
  }
  parent.stop();
  assertEquals("Incorrect number of services",
               2, parent.getServices().size());
}
 
Example #15
Source File: TestNodeStatusUpdater.java    From big-c with Apache License 2.0 6 votes vote down vote up
private void verifyNodeStartFailure(String errMessage) throws Exception {
  Assert.assertNotNull("nm is null", nm);
  YarnConfiguration conf = createNMConfig();
  nm.init(conf);
  try {
    nm.start();
    Assert.fail("NM should have failed to start. Didn't get exception!!");
  } catch (Exception e) {
    //the version in trunk looked in the cause for equality
    // and assumed failures were nested.
    //this version assumes that error strings propagate to the base and
    //use a contains() test only. It should be less brittle
    if(!e.getMessage().contains(errMessage)) {
      throw e;
    }
  }

  // the service should be stopped
  Assert.assertEquals("NM state is wrong!", STATE.STOPPED, nm
      .getServiceState());

  Assert.assertEquals("Number of registered nodes is wrong!", 0,
      this.registeredNodes.size());
}
 
Example #16
Source File: TestLocalDirsHandlerService.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testValidPathsDirHandlerService() throws Exception {
  Configuration conf = new YarnConfiguration();
  String localDir1 = new File("file:///" + testDir, "localDir1").getPath();
  String localDir2 = new File("hdfs:///" + testDir, "localDir2").getPath();
  conf.set(YarnConfiguration.NM_LOCAL_DIRS, localDir1 + "," + localDir2);
  String logDir1 = new File("file:///" + testDir, "logDir1").getPath();
  conf.set(YarnConfiguration.NM_LOG_DIRS, logDir1);
  LocalDirsHandlerService dirSvc = new LocalDirsHandlerService();
  try {
    dirSvc.init(conf);
    Assert.fail("Service should have thrown an exception due to wrong URI");
  } catch (YarnRuntimeException e) {
  }
  Assert.assertEquals("Service should not be inited",
                      STATE.STOPPED,
                      dirSvc.getServiceState());
  dirSvc.close();
}
 
Example #17
Source File: TestNodeStatusUpdater.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private void verifyNodeStartFailure(String errMessage) throws Exception {
  Assert.assertNotNull("nm is null", nm);
  YarnConfiguration conf = createNMConfig();
  nm.init(conf);
  try {
    nm.start();
    Assert.fail("NM should have failed to start. Didn't get exception!!");
  } catch (Exception e) {
    //the version in trunk looked in the cause for equality
    // and assumed failures were nested.
    //this version assumes that error strings propagate to the base and
    //use a contains() test only. It should be less brittle
    if(!e.getMessage().contains(errMessage)) {
      throw e;
    }
  }

  // the service should be stopped
  Assert.assertEquals("NM state is wrong!", STATE.STOPPED, nm
      .getServiceState());

  Assert.assertEquals("Number of registered nodes is wrong!", 0,
      this.registeredNodes.size());
}
 
Example #18
Source File: TestCompositeService.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 1000)
public void testAddStartedSiblingInInit() throws Throwable {
  CompositeService parent = new CompositeService("parent");
  BreakableService sibling = new BreakableService();
  sibling.init(new Configuration());
  sibling.start();
  parent.addService(new AddSiblingService(parent,
                                          sibling,
                                          STATE.INITED));
  parent.init(new Configuration());
  assertInState(STATE.STARTED, sibling);
  parent.start();
  assertInState(STATE.STARTED, sibling);
  parent.stop();
  assertEquals("Incorrect number of services",
               2, parent.getServices().size());
  assertInState(STATE.STOPPED, sibling);
}
 
Example #19
Source File: TestCompositeService.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 1000)
public void testAddStartedSiblingInInit() throws Throwable {
  CompositeService parent = new CompositeService("parent");
  BreakableService sibling = new BreakableService();
  sibling.init(new Configuration());
  sibling.start();
  parent.addService(new AddSiblingService(parent,
                                          sibling,
                                          STATE.INITED));
  parent.init(new Configuration());
  assertInState(STATE.STARTED, sibling);
  parent.start();
  assertInState(STATE.STARTED, sibling);
  parent.stop();
  assertEquals("Incorrect number of services",
               2, parent.getServices().size());
  assertInState(STATE.STOPPED, sibling);
}
 
Example #20
Source File: TestNodeStatusUpdater.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testNodeDecommision() throws Exception {
  nm = getNodeManager(NodeAction.SHUTDOWN);
  YarnConfiguration conf = createNMConfig();
  nm.init(conf);
  Assert.assertEquals(STATE.INITED, nm.getServiceState());
  nm.start();

  int waitCount = 0;
  while (heartBeatID < 1 && waitCount++ != 200) {
    Thread.sleep(500);
  }
  Assert.assertFalse(heartBeatID < 1);
  Assert.assertTrue(nm.getNMContext().getDecommissioned());

  // NM takes a while to reach the STOPPED state.
  waitCount = 0;
  while (nm.getServiceState() != STATE.STOPPED && waitCount++ != 20) {
    LOG.info("Waiting for NM to stop..");
    Thread.sleep(1000);
  }

  Assert.assertEquals(STATE.STOPPED, nm.getServiceState());
}
 
Example #21
Source File: TestCompositeService.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 1000)
public void testAddUninitedSiblingInStart() throws Throwable {
  CompositeService parent = new CompositeService("parent");
  BreakableService sibling = new BreakableService();
  parent.addService(new AddSiblingService(parent,
                                          sibling,
                                          STATE.STARTED));
  parent.init(new Configuration());
  assertInState(STATE.NOTINITED, sibling);
  parent.start();
  parent.stop();
  assertEquals("Incorrect number of services",
               2, parent.getServices().size());
}
 
Example #22
Source File: TestCompositeService.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 1000)
public void testAddStartedSiblingInStart() throws Throwable {
  CompositeService parent = new CompositeService("parent");
  BreakableService sibling = new BreakableService();
  sibling.init(new Configuration());
  sibling.start();
  parent.addService(new AddSiblingService(parent,
                                          sibling,
                                          STATE.STARTED));
  parent.init(new Configuration());
  parent.start();
  parent.stop();
  assertEquals("Incorrect number of services",
               2, parent.getServices().size());
}
 
Example #23
Source File: TestResourceManagerAdministrationProtocolPBClientImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Start resource manager server
 */

@BeforeClass
public static void setUpResourceManager() throws IOException,
        InterruptedException {
  Configuration.addDefaultResource("config-with-security.xml");
  Configuration configuration = new YarnConfiguration();
  resourceManager = new ResourceManager() {
    @Override
    protected void doSecureLogin() throws IOException {
    }
  };
  resourceManager.init(configuration);
  new Thread() {
    public void run() {
      resourceManager.start();
    }
  }.start();
  int waitCount = 0;
  while (resourceManager.getServiceState() == STATE.INITED
          && waitCount++ < 10) {
    LOG.info("Waiting for RM to start...");
    Thread.sleep(1000);
  }
  if (resourceManager.getServiceState() != STATE.STARTED) {
    throw new IOException("ResourceManager failed to start. Final state is "
            + resourceManager.getServiceState());
  }
  LOG.info("ResourceManager RMAdmin address: "
          + configuration.get(YarnConfiguration.RM_ADMIN_ADDRESS));

  client = new ResourceManagerAdministrationProtocolPBClientImpl(1L,
          getProtocolAddress(configuration), configuration);

}
 
Example #24
Source File: TestCompositeService.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddServiceInInit() throws Throwable {
  BreakableService child = new BreakableService();
  assertInState(STATE.NOTINITED, child);
  CompositeServiceAddingAChild composite =
    new CompositeServiceAddingAChild(child);
  composite.init(new Configuration());
  assertInState(STATE.INITED, child);
}
 
Example #25
Source File: TestCompositeService.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 1000)
public void testAddInitedSiblingInInit() throws Throwable {
  CompositeService parent = new CompositeService("parent");
  BreakableService sibling = new BreakableService();
  sibling.init(new Configuration());
  parent.addService(new AddSiblingService(parent,
                                          sibling,
                                          STATE.INITED));
  parent.init(new Configuration());
  parent.start();
  parent.stop();
  assertEquals("Incorrect number of services",
               2, parent.getServices().size());
}
 
Example #26
Source File: MyriadFileSystemRMStateStoreTest.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartStop() throws Exception {
  MyriadFileSystemRMStateStore store = getInitializedStore();
  store.start();    
  assertTrue(store.isInState(STATE.STARTED));
  store.stop();
  assertTrue(store.isInState(STATE.STOPPED));
  store.close();
}
 
Example #27
Source File: TestApplicationHistoryServer.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 60000)
public void testStartStopServer() throws Exception {
  ApplicationHistoryServer historyServer = new ApplicationHistoryServer();
  Configuration config = new YarnConfiguration();
  config.setClass(YarnConfiguration.TIMELINE_SERVICE_STORE,
      MemoryTimelineStore.class, TimelineStore.class);
  config.setClass(YarnConfiguration.TIMELINE_SERVICE_STATE_STORE_CLASS,
      MemoryTimelineStateStore.class, TimelineStateStore.class);
  config.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, "localhost:0");
  try {
    try {
      historyServer.init(config);
      config.setInt(YarnConfiguration.TIMELINE_SERVICE_HANDLER_THREAD_COUNT,
          0);
      historyServer.start();
      fail();
    } catch (IllegalArgumentException e) {
      Assert.assertTrue(e.getMessage().contains(
          YarnConfiguration.TIMELINE_SERVICE_HANDLER_THREAD_COUNT));
    }
    config.setInt(YarnConfiguration.TIMELINE_SERVICE_HANDLER_THREAD_COUNT,
        YarnConfiguration.DEFAULT_TIMELINE_SERVICE_CLIENT_THREAD_COUNT);
    historyServer = new ApplicationHistoryServer();
    historyServer.init(config);
    assertEquals(STATE.INITED, historyServer.getServiceState());
    assertEquals(5, historyServer.getServices().size());
    ApplicationHistoryClientService historyService =
        historyServer.getClientService();
    assertNotNull(historyServer.getClientService());
    assertEquals(STATE.INITED, historyService.getServiceState());

    historyServer.start();
    assertEquals(STATE.STARTED, historyServer.getServiceState());
    assertEquals(STATE.STARTED, historyService.getServiceState());
    historyServer.stop();
    assertEquals(STATE.STOPPED, historyServer.getServiceState());
  } finally {
    historyServer.stop();
  }
}
 
Example #28
Source File: TestRMWebServices.java    From big-c with Apache License 2.0 5 votes vote down vote up
public void verifyClusterGeneric(long clusterid, long startedon,
    String state, String haState, String hadoopVersionBuiltOn,
    String hadoopBuildVersion, String hadoopVersion,
    String resourceManagerVersionBuiltOn, String resourceManagerBuildVersion,
    String resourceManagerVersion) {

  assertEquals("clusterId doesn't match: ",
      ResourceManager.getClusterTimeStamp(), clusterid);
  assertEquals("startedOn doesn't match: ",
      ResourceManager.getClusterTimeStamp(), startedon);
  assertTrue("stated doesn't match: " + state,
      state.matches(STATE.INITED.toString()));
  assertTrue("HA state doesn't match: " + haState,
      haState.matches("INITIALIZING"));

  WebServicesTestUtils.checkStringMatch("hadoopVersionBuiltOn",
      VersionInfo.getDate(), hadoopVersionBuiltOn);
  WebServicesTestUtils.checkStringEqual("hadoopBuildVersion",
      VersionInfo.getBuildVersion(), hadoopBuildVersion);
  WebServicesTestUtils.checkStringMatch("hadoopVersion",
      VersionInfo.getVersion(), hadoopVersion);

  WebServicesTestUtils.checkStringMatch("resourceManagerVersionBuiltOn",
      YarnVersionInfo.getDate(), resourceManagerVersionBuiltOn);
  WebServicesTestUtils.checkStringEqual("resourceManagerBuildVersion",
      YarnVersionInfo.getBuildVersion(), resourceManagerBuildVersion);
  WebServicesTestUtils.checkStringMatch("resourceManagerVersion",
      YarnVersionInfo.getVersion(), resourceManagerVersion);
}
 
Example #29
Source File: QueueACLsTestBase.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws InterruptedException, IOException {
  conf = createConfiguration();
  rpc = YarnRPC.create(conf);
  rmAddress = conf.getSocketAddr(
    YarnConfiguration.RM_ADDRESS, YarnConfiguration.DEFAULT_RM_ADDRESS,
    YarnConfiguration.DEFAULT_RM_PORT);
  
  AccessControlList adminACL = new AccessControlList("");
  conf.set(YarnConfiguration.YARN_ADMIN_ACL, adminACL.getAclString());

  resourceManager = new MockRM(conf) {
    protected ClientRMService createClientRMService() {
      return new ClientRMService(getRMContext(), this.scheduler,
        this.rmAppManager, this.applicationACLsManager,
        this.queueACLsManager, getRMContext().getRMDelegationTokenSecretManager());
    };

    @Override
    protected void doSecureLogin() throws IOException {
    }
  };
  new Thread() {
    public void run() {
      resourceManager.start();
    };
  }.start();
  int waitCount = 0;
  while (resourceManager.getServiceState() == STATE.INITED
      && waitCount++ < 60) {
    LOG.info("Waiting for RM to start...");
    Thread.sleep(1500);
  }
  if (resourceManager.getServiceState() != STATE.STARTED) {
    // RM could have failed.
    throw new IOException("ResourceManager failed to start. Final state is "
        + resourceManager.getServiceState());
  }
}
 
Example #30
Source File: TestNodeStatusUpdater.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testApplicationKeepAlive() throws Exception {
  MyNodeManager nm = new MyNodeManager();
  try {
    YarnConfiguration conf = createNMConfig();
    conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
    conf.setLong(YarnConfiguration.RM_NM_EXPIRY_INTERVAL_MS,
        4000l);
    nm.init(conf);
    nm.start();
    // HB 2 -> app cancelled by RM.
    while (heartBeatID < 12) {
      Thread.sleep(1000l);
    }
    MyResourceTracker3 rt =
        (MyResourceTracker3) nm.getNodeStatusUpdater().getRMClient();
    rt.context.getApplications().remove(rt.appId);
    Assert.assertEquals(1, rt.keepAliveRequests.size());
    int numKeepAliveRequests = rt.keepAliveRequests.get(rt.appId).size();
    LOG.info("Number of Keep Alive Requests: [" + numKeepAliveRequests + "]");
    Assert.assertTrue(numKeepAliveRequests == 2 || numKeepAliveRequests == 3);
    while (heartBeatID < 20) {
      Thread.sleep(1000l);
    }
    int numKeepAliveRequests2 = rt.keepAliveRequests.get(rt.appId).size();
    Assert.assertEquals(numKeepAliveRequests, numKeepAliveRequests2);
  } finally {
    if (nm.getServiceState() == STATE.STARTED)
      nm.stop();
  }
}