コード例 #1
0
ファイル: DragonAppMaster.java プロジェクト: Brassrat/dragon
  /**
   * Initial DragonAppMaster Get and CheckOut necessary parameters from system environment eg:
   * container_Id,host,port,http_port,submitTime
   *
   * @param args
   */
  public static void main(String[] args) {
    try {
      String containerIdStr = System.getenv(ApplicationConstants.AM_CONTAINER_ID_ENV);
      String nodeHostString = System.getenv(ApplicationConstants.NM_HOST_ENV);
      String nodePortString = System.getenv(ApplicationConstants.NM_PORT_ENV);
      String nodeHttpPortString = System.getenv(ApplicationConstants.NM_HTTP_PORT_ENV);
      String appSubmitTimeStr = System.getenv(ApplicationConstants.APP_SUBMIT_TIME_ENV);

      validateInputParam(containerIdStr, ApplicationConstants.AM_CONTAINER_ID_ENV);
      validateInputParam(nodeHostString, ApplicationConstants.NM_HOST_ENV);
      validateInputParam(nodePortString, ApplicationConstants.NM_PORT_ENV);
      validateInputParam(nodeHttpPortString, ApplicationConstants.NM_HTTP_PORT_ENV);
      validateInputParam(appSubmitTimeStr, ApplicationConstants.APP_SUBMIT_TIME_ENV);
      ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);
      ApplicationAttemptId applicationAttemptId = containerId.getApplicationAttemptId();
      long appSubmitTime = Long.parseLong(appSubmitTimeStr);

      DragonAppMaster appMaster =
          new DragonAppMaster(
              applicationAttemptId,
              containerId,
              nodeHostString,
              Integer.parseInt(nodePortString),
              Integer.parseInt(nodeHttpPortString),
              appSubmitTime);
      Runtime.getRuntime().addShutdownHook(new CompositeServiceShutdownHook(appMaster));
      YarnConfiguration conf = new YarnConfiguration(new DragonConfiguration());
      conf.addResource(new Path(DragonJobConfig.JOB_CONF_FILE));
      String jobUserName = System.getenv(ApplicationConstants.Environment.USER.name());
      conf.set(DragonJobConfig.USER_NAME, jobUserName);

      // Do not automatically close FileSystem objects so that in case of
      // SIGTERM I have a chance to write out the job history. I'll be closing
      // the objects myself.
      conf.setBoolean("fs.automatic.close", false);
      initAndStartAppMaster(appMaster, conf, jobUserName);
    } catch (Throwable t) {
      LOG.fatal("Error starting MRAppMaster", t);
      System.exit(1);
    }
  }
コード例 #2
0
  @Before
  public void configure() throws IOException {
    admin = mock(ResourceManagerAdministrationProtocol.class);

    haadmin = mock(HAServiceProtocol.class);
    when(haadmin.getServiceStatus())
        .thenReturn(new HAServiceStatus(HAServiceProtocol.HAServiceState.INITIALIZING));

    final HAServiceTarget haServiceTarget = mock(HAServiceTarget.class);
    when(haServiceTarget.getProxy(any(Configuration.class), anyInt())).thenReturn(haadmin);
    rmAdminCLI =
        new RMAdminCLI(new Configuration()) {

          @Override
          protected ResourceManagerAdministrationProtocol createAdminProtocol() throws IOException {
            return admin;
          }

          @Override
          protected HAServiceTarget resolveTarget(String rmId) {
            return haServiceTarget;
          }
        };

    YarnConfiguration conf = new YarnConfiguration();
    conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
    rmAdminCLIWithHAEnabled =
        new RMAdminCLI(conf) {

          @Override
          protected ResourceManagerAdministrationProtocol createAdminProtocol() throws IOException {
            return admin;
          }

          @Override
          protected HAServiceTarget resolveTarget(String rmId) {
            return haServiceTarget;
          }
        };
  }
コード例 #3
0
  @Test
  public void testNonLeaderKeyReception()
      throws InterruptedException, StorageInitializtionException, Exception {
    // create a groupMembershipService that will be leader
    RMContextImpl rmContext = new RMContextImpl();
    rmContext.setDistributedEnabled(true);
    rmContext.setHAEnabled(true);
    GroupMembershipService groupMembershipService = new GroupMembershipService(null, rmContext);
    groupMembershipService.init(conf);
    NMTokenSecretManagerInRM nmTokenSecretManager = new NMTokenSecretManagerInRM(conf, rmContext);
    // create a resrouce tracker
    conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
    conf.setBoolean(YarnConfiguration.DISTRIBUTED_RM, true);
    MockRM mockRM = new MockRM(conf);
    mockRM.init(conf);

    try {
      groupMembershipService.start();
      rmContext.setRMGroupMembershipService(groupMembershipService);
      rmContext.setStateStore(new NDBRMStateStore());

      while (!rmContext.isLeader()) {
        Thread.sleep(1000);
      }

      mockRM.start();

      if (mockRM.getRMContext().isDistributedEnabled() && !mockRM.getRMContext().isLeader()) {
        conf.set(
            YarnConfiguration.EVENT_RT_CONFIG_PATH, "target/test-classes/RT_EventAPIConfig.ini");
        NdbRtStreamingProcessor rtStreamingProcessor =
            new NdbRtStreamingProcessor(mockRM.getRMContext());
        RMStorageFactory.kickTheNdbEventStreamingAPI(false, conf);
        new Thread(rtStreamingProcessor).start();
      }

      // this should be a resource tracker not a scheduler
      assertFalse(mockRM.getRMContext().isLeader());

      // simulate creation of a token on the sheduler
      nmTokenSecretManager.start();

      assertNotNull("did not roll master key", nmTokenSecretManager.getCurrentKey());
      Thread.sleep(1000);
      dummyUpdate();
      Thread.sleep(1000);
      RMStateStore.RMState state = rmContext.getStateStore().loadState(rmContext);
      assertEquals(
          "key not persisted to the database",
          state.getSecretTokenMamagerKey(RMStateStore.KeyType.CURRENTNMTOKENMASTERKEY),
          nmTokenSecretManager.getCurrentKey());

      assertEquals(
          nmTokenSecretManager.getCurrentKey(),
          mockRM.getRMContext().getNMTokenSecretManager().getCurrentKey());
      assertEquals(
          nmTokenSecretManager.getNextKey(),
          mockRM.getRMContext().getNMTokenSecretManager().getNextKey());
    } finally {
      groupMembershipService.stop();
      mockRM.stop();
      nmTokenSecretManager.stop();
      DefaultMetricsSystem.shutdown();
    }
  }