Java 类org.apache.hadoop.yarn.api.protocolrecords.KillApplicationResponse 实例源码

项目:hadoop    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException, IOException {
  KillApplicationRequestProto requestProto =
      ((KillApplicationRequestPBImpl) request).getProto();
  try {
    return new KillApplicationResponsePBImpl(proxy.forceKillApplication(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop    文件:TestRMRestart.java   
@Test (timeout = 60000)
public void testClientRetryOnKillingApplication() throws Exception {
  MemoryRMStateStore memStore = new TestMemoryRMStateStore();
  memStore.init(conf);

  // start RM
  MockRM rm1 = createMockRM(conf, memStore);
  rm1.start();
  MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService());
  nm1.registerNode();

  RMApp app1 =
      rm1.submitApp(200, "name", "user", null, false, "default", 1, null,
        "myType");
  MockAM am1 = launchAM(app1, rm1, nm1);

  KillApplicationResponse response;
  int count = 0;
  while (true) {
    response = rm1.killApp(app1.getApplicationId());
    if (response.getIsKillCompleted()) {
      break;
    }
    Thread.sleep(100);
    count++;
  }
  // we expect at least 2 calls for killApp as the first killApp always return
  // false.
  Assert.assertTrue(count >= 1);

  rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.KILLED);
  rm1.waitForState(app1.getApplicationId(), RMAppState.KILLED);
  Assert.assertEquals(1, ((TestMemoryRMStateStore) memStore).updateAttempt);
  Assert.assertEquals(2, ((TestMemoryRMStateStore) memStore).updateApp);
}
项目:hadoop    文件:TestKillApplicationWithRMHA.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException {
  ApplicationId applicationId = request.getApplicationId();
  RMApp application = this.rmContext.getRMApps().get(applicationId);
  if (application.isAppFinalStateStored()) {
    return KillApplicationResponse.newInstance(true);
  } else {
    return KillApplicationResponse.newInstance(false);
  }
}
项目:hadoop    文件:TestKillApplicationWithRMHA.java   
private void killApplication(MockRM rm, ApplicationId appId,
    ApplicationAttemptId appAttemptId, RMAppState rmAppState)
    throws Exception {
  KillApplicationResponse response = rm.killApp(appId);
  Assert
      .assertTrue(response.getIsKillCompleted() == isFinalState(rmAppState));
  RMApp loadedApp0 =
      rm.getRMContext().getRMApps().get(appId);
  rm.waitForState(appId, RMAppState.KILLED);
  if (appAttemptId != null) {
    rm.waitForState(appAttemptId, RMAppAttemptState.KILLED);
  }
  // no new attempt is created.
  Assert.assertEquals(1, loadedApp0.getAppAttempts().size());
}
项目:hadoop    文件:YarnClientImpl.java   
@Override
public void killApplication(ApplicationId applicationId)
    throws YarnException, IOException {
  KillApplicationRequest request =
      Records.newRecord(KillApplicationRequest.class);
  request.setApplicationId(applicationId);

  try {
    int pollCount = 0;
    long startTime = System.currentTimeMillis();

    while (true) {
      KillApplicationResponse response =
          rmClient.forceKillApplication(request);
      if (response.getIsKillCompleted()) {
        LOG.info("Killed application " + applicationId);
        break;
      }

      long elapsedMillis = System.currentTimeMillis() - startTime;
      if (enforceAsyncAPITimeout() &&
          elapsedMillis >= this.asyncApiPollTimeoutMillis) {
        throw new YarnException("Timed out while waiting for application " +
          applicationId + " to be killed.");
      }

      if (++pollCount % 10 == 0) {
        LOG.info("Waiting for application " + applicationId + " to be killed.");
      }
      Thread.sleep(asyncApiPollIntervalMillis);
    }
  } catch (InterruptedException e) {
    LOG.error("Interrupted while waiting for application " + applicationId
        + " to be killed.");
  }
}
项目:hadoop    文件:ProtocolHATestBase.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  return KillApplicationResponse.newInstance(true);
}
项目:aliyun-oss-hadoop-fs    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException, IOException {
  KillApplicationRequestProto requestProto =
      ((KillApplicationRequestPBImpl) request).getProto();
  try {
    return new KillApplicationResponsePBImpl(proxy.forceKillApplication(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestRMRestart.java   
@Test (timeout = 60000)
public void testClientRetryOnKillingApplication() throws Exception {
  MemoryRMStateStore memStore = new TestMemoryRMStateStore();
  memStore.init(conf);

  // start RM
  MockRM rm1 = createMockRM(conf, memStore);
  rm1.start();
  MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService());
  nm1.registerNode();

  RMApp app1 =
      rm1.submitApp(200, "name", "user", null, false, "default", 1, null,
        "myType");
  MockAM am1 = launchAM(app1, rm1, nm1);

  KillApplicationResponse response;
  int count = 0;
  while (true) {
    response = rm1.killApp(app1.getApplicationId());
    if (response.getIsKillCompleted()) {
      break;
    }
    Thread.sleep(100);
    count++;
  }
  // we expect at least 2 calls for killApp as the first killApp always return
  // false.
  Assert.assertTrue(count >= 1);

  rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.KILLED);
  rm1.waitForState(app1.getApplicationId(), RMAppState.KILLED);
  Assert.assertEquals(1, ((TestMemoryRMStateStore) memStore).updateAttempt);
  Assert.assertEquals(2, ((TestMemoryRMStateStore) memStore).updateApp);
}
项目:aliyun-oss-hadoop-fs    文件:TestKillApplicationWithRMHA.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException {
  ApplicationId applicationId = request.getApplicationId();
  RMApp application = this.rmContext.getRMApps().get(applicationId);
  if (application.isAppFinalStateStored()) {
    return KillApplicationResponse.newInstance(true);
  } else {
    return KillApplicationResponse.newInstance(false);
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestKillApplicationWithRMHA.java   
private void killApplication(MockRM rm, ApplicationId appId,
    ApplicationAttemptId appAttemptId, RMAppState rmAppState)
    throws Exception {
  KillApplicationResponse response = rm.killApp(appId);
  Assert
      .assertTrue(response.getIsKillCompleted() == isFinalState(rmAppState));
  RMApp loadedApp0 =
      rm.getRMContext().getRMApps().get(appId);
  rm.waitForState(appId, RMAppState.KILLED);
  if (appAttemptId != null) {
    rm.waitForState(appAttemptId, RMAppAttemptState.KILLED);
  }
  // no new attempt is created.
  Assert.assertEquals(1, loadedApp0.getAppAttempts().size());
}
项目:aliyun-oss-hadoop-fs    文件:YarnClientImpl.java   
@Override
public void killApplication(ApplicationId applicationId)
    throws YarnException, IOException {
  KillApplicationRequest request =
      Records.newRecord(KillApplicationRequest.class);
  request.setApplicationId(applicationId);

  try {
    int pollCount = 0;
    long startTime = System.currentTimeMillis();

    while (true) {
      KillApplicationResponse response =
          rmClient.forceKillApplication(request);
      if (response.getIsKillCompleted()) {
        LOG.info("Killed application " + applicationId);
        break;
      }

      long elapsedMillis = System.currentTimeMillis() - startTime;
      if (enforceAsyncAPITimeout() &&
          elapsedMillis >= this.asyncApiPollTimeoutMillis) {
        throw new YarnException("Timed out while waiting for application " +
          applicationId + " to be killed.");
      }

      if (++pollCount % 10 == 0) {
        LOG.info("Waiting for application " + applicationId + " to be killed.");
      }
      Thread.sleep(asyncApiPollIntervalMillis);
    }
  } catch (InterruptedException e) {
    LOG.error("Interrupted while waiting for application " + applicationId
        + " to be killed.");
  }
}
项目:aliyun-oss-hadoop-fs    文件:ProtocolHATestBase.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  return KillApplicationResponse.newInstance(true);
}
项目:big-c    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException, IOException {
  KillApplicationRequestProto requestProto =
      ((KillApplicationRequestPBImpl) request).getProto();
  try {
    return new KillApplicationResponsePBImpl(proxy.forceKillApplication(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:big-c    文件:TestRMRestart.java   
@Test (timeout = 60000)
public void testClientRetryOnKillingApplication() throws Exception {
  MemoryRMStateStore memStore = new TestMemoryRMStateStore();
  memStore.init(conf);

  // start RM
  MockRM rm1 = createMockRM(conf, memStore);
  rm1.start();
  MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService());
  nm1.registerNode();

  RMApp app1 =
      rm1.submitApp(200, "name", "user", null, false, "default", 1, null,
        "myType");
  MockAM am1 = launchAM(app1, rm1, nm1);

  KillApplicationResponse response;
  int count = 0;
  while (true) {
    response = rm1.killApp(app1.getApplicationId());
    if (response.getIsKillCompleted()) {
      break;
    }
    Thread.sleep(100);
    count++;
  }
  // we expect at least 2 calls for killApp as the first killApp always return
  // false.
  Assert.assertTrue(count >= 1);

  rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.KILLED);
  rm1.waitForState(app1.getApplicationId(), RMAppState.KILLED);
  Assert.assertEquals(1, ((TestMemoryRMStateStore) memStore).updateAttempt);
  Assert.assertEquals(2, ((TestMemoryRMStateStore) memStore).updateApp);
}
项目:big-c    文件:TestKillApplicationWithRMHA.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException {
  ApplicationId applicationId = request.getApplicationId();
  RMApp application = this.rmContext.getRMApps().get(applicationId);
  if (application.isAppFinalStateStored()) {
    return KillApplicationResponse.newInstance(true);
  } else {
    return KillApplicationResponse.newInstance(false);
  }
}
项目:big-c    文件:TestKillApplicationWithRMHA.java   
private void killApplication(MockRM rm, ApplicationId appId,
    ApplicationAttemptId appAttemptId, RMAppState rmAppState)
    throws Exception {
  KillApplicationResponse response = rm.killApp(appId);
  Assert
      .assertTrue(response.getIsKillCompleted() == isFinalState(rmAppState));
  RMApp loadedApp0 =
      rm.getRMContext().getRMApps().get(appId);
  rm.waitForState(appId, RMAppState.KILLED);
  if (appAttemptId != null) {
    rm.waitForState(appAttemptId, RMAppAttemptState.KILLED);
  }
  // no new attempt is created.
  Assert.assertEquals(1, loadedApp0.getAppAttempts().size());
}
项目:big-c    文件:YarnClientImpl.java   
@Override
public void killApplication(ApplicationId applicationId)
    throws YarnException, IOException {
  KillApplicationRequest request =
      Records.newRecord(KillApplicationRequest.class);
  request.setApplicationId(applicationId);

  try {
    int pollCount = 0;
    long startTime = System.currentTimeMillis();

    while (true) {
      KillApplicationResponse response =
          rmClient.forceKillApplication(request);
      if (response.getIsKillCompleted()) {
        LOG.info("Killed application " + applicationId);
        break;
      }

      long elapsedMillis = System.currentTimeMillis() - startTime;
      if (enforceAsyncAPITimeout() &&
          elapsedMillis >= this.asyncApiPollTimeoutMillis) {
        throw new YarnException("Timed out while waiting for application " +
          applicationId + " to be killed.");
      }

      if (++pollCount % 10 == 0) {
        LOG.info("Waiting for application " + applicationId + " to be killed.");
      }
      Thread.sleep(asyncApiPollIntervalMillis);
    }
  } catch (InterruptedException e) {
    LOG.error("Interrupted while waiting for application " + applicationId
        + " to be killed.");
  }
}
项目:big-c    文件:ProtocolHATestBase.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  return KillApplicationResponse.newInstance(true);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException, IOException {
  KillApplicationRequestProto requestProto =
      ((KillApplicationRequestPBImpl) request).getProto();
  try {
    return new KillApplicationResponsePBImpl(proxy.forceKillApplication(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestRMRestart.java   
@Test (timeout = 60000)
public void testClientRetryOnKillingApplication() throws Exception {
  MemoryRMStateStore memStore = new TestMemoryRMStateStore();
  memStore.init(conf);

  // start RM
  MockRM rm1 = createMockRM(conf, memStore);
  rm1.start();
  MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService());
  nm1.registerNode();

  RMApp app1 =
      rm1.submitApp(200, "name", "user", null, false, "default", 1, null,
        "myType");
  MockAM am1 = launchAM(app1, rm1, nm1);

  KillApplicationResponse response;
  int count = 0;
  while (true) {
    response = rm1.killApp(app1.getApplicationId());
    if (response.getIsKillCompleted()) {
      break;
    }
    Thread.sleep(100);
    count++;
  }
  // we expect at least 2 calls for killApp as the first killApp always return
  // false.
  Assert.assertTrue(count >= 1);

  rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.KILLED);
  rm1.waitForState(app1.getApplicationId(), RMAppState.KILLED);
  Assert.assertEquals(1, ((TestMemoryRMStateStore) memStore).updateAttempt);
  Assert.assertEquals(2, ((TestMemoryRMStateStore) memStore).updateApp);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestKillApplicationWithRMHA.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException {
  ApplicationId applicationId = request.getApplicationId();
  RMApp application = this.rmContext.getRMApps().get(applicationId);
  if (application.isAppFinalStateStored()) {
    return KillApplicationResponse.newInstance(true);
  } else {
    return KillApplicationResponse.newInstance(false);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestKillApplicationWithRMHA.java   
private void killApplication(MockRM rm, ApplicationId appId,
    ApplicationAttemptId appAttemptId, RMAppState rmAppState)
    throws Exception {
  KillApplicationResponse response = rm.killApp(appId);
  Assert
      .assertTrue(response.getIsKillCompleted() == isFinalState(rmAppState));
  RMApp loadedApp0 =
      rm.getRMContext().getRMApps().get(appId);
  rm.waitForState(appId, RMAppState.KILLED);
  if (appAttemptId != null) {
    rm.waitForState(appAttemptId, RMAppAttemptState.KILLED);
  }
  // no new attempt is created.
  Assert.assertEquals(1, loadedApp0.getAppAttempts().size());
}
项目:hadoop-2.6.0-cdh5.4.3    文件:YarnClientImpl.java   
@Override
public void killApplication(ApplicationId applicationId)
    throws YarnException, IOException {
  KillApplicationRequest request =
      Records.newRecord(KillApplicationRequest.class);
  request.setApplicationId(applicationId);

  try {
    int pollCount = 0;
    long startTime = System.currentTimeMillis();

    while (true) {
      KillApplicationResponse response =
          rmClient.forceKillApplication(request);
      if (response.getIsKillCompleted()) {
        LOG.info("Killed application " + applicationId);
        break;
      }

      long elapsedMillis = System.currentTimeMillis() - startTime;
      if (enforceAsyncAPITimeout() &&
          elapsedMillis >= this.asyncApiPollTimeoutMillis) {
        throw new YarnException("Timed out while waiting for application " +
          applicationId + " to be killed.");
      }

      if (++pollCount % 10 == 0) {
        LOG.info("Waiting for application " + applicationId + " to be killed.");
      }
      Thread.sleep(asyncApiPollIntervalMillis);
    }
  } catch (InterruptedException e) {
    LOG.error("Interrupted while waiting for application " + applicationId
        + " to be killed.");
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ProtocolHATestBase.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  return KillApplicationResponse.newInstance(true);
}
项目:hadoop-plus    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException, IOException {
  KillApplicationRequestProto requestProto =
      ((KillApplicationRequestPBImpl) request).getProto();
  try {
    return new KillApplicationResponsePBImpl(proxy.forceKillApplication(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hops    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException, IOException {
  KillApplicationRequestProto requestProto =
      ((KillApplicationRequestPBImpl) request).getProto();
  try {
    return new KillApplicationResponsePBImpl(proxy.forceKillApplication(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hops    文件:TestKillApplicationWithRMHA.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException {
  ApplicationId applicationId = request.getApplicationId();
  RMApp application = this.rmContext.getRMApps().get(applicationId);
  if (application.isAppFinalStateStored()) {
    return KillApplicationResponse.newInstance(true);
  } else {
    return KillApplicationResponse.newInstance(false);
  }
}
项目:hops    文件:TestKillApplicationWithRMHA.java   
private void killApplication(MockRM rm, ApplicationId appId,
    ApplicationAttemptId appAttemptId, RMAppState rmAppState)
    throws Exception {
  KillApplicationResponse response = rm.killApp(appId);
  Assert
      .assertTrue(response.getIsKillCompleted() == isFinalState(rmAppState));
  RMApp loadedApp0 =
      rm.getRMContext().getRMApps().get(appId);
  rm.waitForState(appId, RMAppState.KILLED);
  if (appAttemptId != null) {
    rm.waitForState(appAttemptId, RMAppAttemptState.KILLED);
  }
  // no new attempt is created.
  Assert.assertEquals(1, loadedApp0.getAppAttempts().size());
}
项目:hops    文件:ProtocolHATestBase.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  return KillApplicationResponse.newInstance(true);
}
项目:hadoop-TCP    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException, IOException {
  KillApplicationRequestProto requestProto =
      ((KillApplicationRequestPBImpl) request).getProto();
  try {
    return new KillApplicationResponsePBImpl(proxy.forceKillApplication(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:incubator-slider    文件:SliderYarnClientImpl.java   
/**
 * Kill a running application
 * @param applicationId
 * @return the response
 * @throws YarnException YARN problems
 * @throws IOException IO problems
 */
public  KillApplicationResponse killRunningApplication(ApplicationId applicationId,
                                                       String reason) throws
                                                                      YarnException,
                                                                      IOException {
  log.info("Killing application {} - {}", applicationId.getClusterTimestamp(),
           reason);
  KillApplicationRequest request =
    Records.newRecord(KillApplicationRequest.class);
  request.setApplicationId(applicationId);
  return getRmClient().forceKillApplication(request);
}
项目:hardfs    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException, IOException {
  KillApplicationRequestProto requestProto =
      ((KillApplicationRequestPBImpl) request).getProto();
  try {
    return new KillApplicationResponsePBImpl(proxy.forceKillApplication(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop-on-lustre2    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException, IOException {
  KillApplicationRequestProto requestProto =
      ((KillApplicationRequestPBImpl) request).getProto();
  try {
    return new KillApplicationResponsePBImpl(proxy.forceKillApplication(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop-on-lustre2    文件:TestRMRestart.java   
@Test (timeout = 60000)
public void testClientRetryOnKillingApplication() throws Exception {
  MemoryRMStateStore memStore = new TestMemoryRMStateStore();
  memStore.init(conf);

  // start RM
  MockRM rm1 = new MockRM(conf, memStore);
  rm1.start();
  MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService());
  nm1.registerNode();

  RMApp app1 =
      rm1.submitApp(200, "name", "user", null, false, "default", 1, null,
        "myType");
  MockAM am1 = launchAM(app1, rm1, nm1);

  KillApplicationResponse response;
  int count = 0;
  while (true) {
    response = rm1.killApp(app1.getApplicationId());
    if (response.getIsKillCompleted()) {
      break;
    }
    Thread.sleep(100);
    count++;
  }
  // we expect at least 2 calls for killApp as the first killApp always return
  // false.
  Assert.assertTrue(count >= 1);

  rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.KILLED);
  rm1.waitForState(app1.getApplicationId(), RMAppState.KILLED);
  Assert.assertEquals(1, ((TestMemoryRMStateStore) memStore).updateAttempt);
  Assert.assertEquals(2, ((TestMemoryRMStateStore) memStore).updateApp);
}
项目:hadoop-on-lustre2    文件:TestKillApplicationWithRMHA.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException {
  ApplicationId applicationId = request.getApplicationId();
  RMApp application = this.rmContext.getRMApps().get(applicationId);
  if (application.isAppFinalStateStored()) {
    return KillApplicationResponse.newInstance(true);
  } else {
    return KillApplicationResponse.newInstance(false);
  }
}
项目:hadoop-on-lustre2    文件:TestKillApplicationWithRMHA.java   
private void killApplication(MockRM rm, ApplicationId appId,
    ApplicationAttemptId appAttemptId, RMAppState rmAppState)
    throws Exception {
  KillApplicationResponse response = rm.killApp(appId);
  Assert
      .assertTrue(response.getIsKillCompleted() == isFinalState(rmAppState));
  RMApp loadedApp0 =
      rm.getRMContext().getRMApps().get(appId);
  rm.waitForState(appId, RMAppState.KILLED);
  if (appAttemptId != null) {
    rm.waitForState(appAttemptId, RMAppAttemptState.KILLED);
  }
  // no new attempt is created.
  Assert.assertEquals(1, loadedApp0.getAppAttempts().size());
}
项目:hadoop-on-lustre2    文件:YarnClientImpl.java   
@Override
public void killApplication(ApplicationId applicationId)
    throws YarnException, IOException {
  KillApplicationRequest request =
      Records.newRecord(KillApplicationRequest.class);
  request.setApplicationId(applicationId);

  try {
    int pollCount = 0;
    long startTime = System.currentTimeMillis();

    while (true) {
      KillApplicationResponse response =
          rmClient.forceKillApplication(request);
      if (response.getIsKillCompleted()) {
        LOG.info("Killed application " + applicationId);
        break;
      }

      long elapsedMillis = System.currentTimeMillis() - startTime;
      if (enforceAsyncAPITimeout() &&
          elapsedMillis >= this.asyncApiPollTimeoutMillis) {
        throw new YarnException("Timed out while waiting for application " +
          applicationId + " to be killed.");
      }

      if (++pollCount % 10 == 0) {
        LOG.info("Waiting for application " + applicationId + " to be killed.");
      }
      Thread.sleep(asyncApiPollIntervalMillis);
    }
  } catch (InterruptedException e) {
    LOG.error("Interrupted while waiting for application " + applicationId
        + " to be killed.");
  }
}
项目:hadoop-on-lustre2    文件:ProtocolHATestBase.java   
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  return KillApplicationResponse.newInstance(true);
}
项目:hadoop    文件:RMWebServices.java   
protected Response killApp(RMApp app, UserGroupInformation callerUGI,
    HttpServletRequest hsr) throws IOException, InterruptedException {

  if (app == null) {
    throw new IllegalArgumentException("app cannot be null");
  }
  String userName = callerUGI.getUserName();
  final ApplicationId appid = app.getApplicationId();
  KillApplicationResponse resp = null;
  try {
    resp =
        callerUGI
          .doAs(new PrivilegedExceptionAction<KillApplicationResponse>() {
            @Override
            public KillApplicationResponse run() throws IOException,
                YarnException {
              KillApplicationRequest req =
                  KillApplicationRequest.newInstance(appid);
              return rm.getClientRMService().forceKillApplication(req);
            }
          });
  } catch (UndeclaredThrowableException ue) {
    // if the root cause is a permissions issue
    // bubble that up to the user
    if (ue.getCause() instanceof YarnException) {
      YarnException ye = (YarnException) ue.getCause();
      if (ye.getCause() instanceof AccessControlException) {
        String appId = app.getApplicationId().toString();
        String msg =
            "Unauthorized attempt to kill appid " + appId
                + " by remote user " + userName;
        return Response.status(Status.FORBIDDEN).entity(msg).build();
      } else {
        throw ue;
      }
    } else {
      throw ue;
    }
  }

  AppState ret = new AppState();
  ret.setState(app.getState().toString());

  if (resp.getIsKillCompleted()) {
    RMAuditLogger.logSuccess(userName, AuditConstants.KILL_APP_REQUEST,
      "RMWebService", app.getApplicationId());
  } else {
    return Response.status(Status.ACCEPTED).entity(ret)
      .header(HttpHeaders.LOCATION, hsr.getRequestURL()).build();
  }
  return Response.status(Status.OK).entity(ret).build();
}
项目:hadoop    文件:ClientRMService.java   
@SuppressWarnings("unchecked")
@Override
public KillApplicationResponse forceKillApplication(
    KillApplicationRequest request) throws YarnException {

  ApplicationId applicationId = request.getApplicationId();

  UserGroupInformation callerUGI;
  try {
    callerUGI = UserGroupInformation.getCurrentUser();
  } catch (IOException ie) {
    LOG.info("Error getting UGI ", ie);
    RMAuditLogger.logFailure("UNKNOWN", AuditConstants.KILL_APP_REQUEST,
        "UNKNOWN", "ClientRMService" , "Error getting UGI",
        applicationId);
    throw RPCUtil.getRemoteException(ie);
  }

  RMApp application = this.rmContext.getRMApps().get(applicationId);
  if (application == null) {
    RMAuditLogger.logFailure(callerUGI.getUserName(),
        AuditConstants.KILL_APP_REQUEST, "UNKNOWN", "ClientRMService",
        "Trying to kill an absent application", applicationId);
    throw new ApplicationNotFoundException("Trying to kill an absent"
        + " application " + applicationId);
  }

  if (!checkAccess(callerUGI, application.getUser(),
      ApplicationAccessType.MODIFY_APP, application)) {
    RMAuditLogger.logFailure(callerUGI.getShortUserName(),
        AuditConstants.KILL_APP_REQUEST,
        "User doesn't have permissions to "
            + ApplicationAccessType.MODIFY_APP.toString(), "ClientRMService",
        AuditConstants.UNAUTHORIZED_USER, applicationId);
    throw RPCUtil.getRemoteException(new AccessControlException("User "
        + callerUGI.getShortUserName() + " cannot perform operation "
        + ApplicationAccessType.MODIFY_APP.name() + " on " + applicationId));
  }

  if (application.isAppFinalStateStored()) {
    RMAuditLogger.logSuccess(callerUGI.getShortUserName(),
        AuditConstants.KILL_APP_REQUEST, "ClientRMService", applicationId);
    return KillApplicationResponse.newInstance(true);
  }

  this.rmContext.getDispatcher().getEventHandler()
      .handle(new RMAppEvent(applicationId, RMAppEventType.KILL));

  // For UnmanagedAMs, return true so they don't retry
  return KillApplicationResponse.newInstance(
      application.getApplicationSubmissionContext().getUnmanagedAM());
}