Java 类org.apache.hadoop.yarn.api.records.SerializedException 实例源码

项目:hadoop    文件:StopContainersResponsePBImpl.java   
private void addFailedRequestsToProto() {
  maybeInitBuilder();
  builder.clearFailedRequests();
  if (this.failedRequests == null)
    return;
  List<ContainerExceptionMapProto> protoList =
      new ArrayList<ContainerExceptionMapProto>();

  for (Map.Entry<ContainerId, SerializedException> entry : this.failedRequests
    .entrySet()) {
    protoList.add(ContainerExceptionMapProto.newBuilder()
      .setContainerId(convertToProtoFormat(entry.getKey()))
      .setException(convertToProtoFormat(entry.getValue())).build());
  }
  builder.addAllFailedRequests(protoList);
}
项目:hadoop    文件:StartContainersResponsePBImpl.java   
private void addFailedContainersToProto() {
  maybeInitBuilder();
  builder.clearFailedRequests();
  if (this.failedContainers == null)
    return;
  List<ContainerExceptionMapProto> protoList =
      new ArrayList<ContainerExceptionMapProto>();

  for (Map.Entry<ContainerId, SerializedException> entry : this.failedContainers
    .entrySet()) {
    protoList.add(ContainerExceptionMapProto.newBuilder()
      .setContainerId(convertToProtoFormat(entry.getKey()))
      .setException(convertToProtoFormat(entry.getValue())).build());
  }
  builder.addAllFailedRequests(protoList);
}
项目:hadoop    文件:SerializedExceptionPBImpl.java   
@SuppressWarnings("unchecked")
@Override
public Throwable deSerialize() {

  SerializedException cause = getCause();
  SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder;
  Class<?> realClass = null;
  try {
    realClass = Class.forName(p.getClassName());
  } catch (ClassNotFoundException e) {
    throw new YarnRuntimeException(e);
  }
  Class classType = null;
  if (YarnException.class.isAssignableFrom(realClass)) {
    classType = YarnException.class;
  } else if (IOException.class.isAssignableFrom(realClass)) {
    classType = IOException.class;
  } else if (RuntimeException.class.isAssignableFrom(realClass)) {
    classType = RuntimeException.class;
  } else {
    classType = Exception.class;
  }
  return instantiateException(realClass.asSubclass(classType), getMessage(),
    cause == null ? null : cause.deSerialize());
}
项目:hadoop    文件:TestContainerManagerSecurity.java   
private void startContainer(final YarnRPC rpc,
    org.apache.hadoop.yarn.api.records.Token nmToken,
    org.apache.hadoop.yarn.api.records.Token containerToken,
    NodeId nodeId, String user) throws Exception {

  ContainerLaunchContext context =
      Records.newRecord(ContainerLaunchContext.class);
  StartContainerRequest scRequest =
      StartContainerRequest.newInstance(context,containerToken);
  List<StartContainerRequest> list = new ArrayList<StartContainerRequest>();
  list.add(scRequest);
  StartContainersRequest allRequests =
      StartContainersRequest.newInstance(list);
  ContainerManagementProtocol proxy = null;
  try {
    proxy = getContainerManagementProtocolProxy(rpc, nmToken, nodeId, user);
    StartContainersResponse response = proxy.startContainers(allRequests);
    for(SerializedException ex : response.getFailedRequests().values()){
      parseAndThrowException(ex.deSerialize());
    }
  } finally {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
项目:hadoop    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:hadoop    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:hadoop    文件:TestPBRecordImpl.java   
static LocalResourceStatus createLocalResourceStatus() {
  LocalResourceStatus ret =
    recordFactory.newRecordInstance(LocalResourceStatus.class);
  assertTrue(ret instanceof LocalResourceStatusPBImpl);
  ret.setResource(createResource());
  ret.setLocalPath(
      ConverterUtils.getYarnUrlFromPath(
        new Path("file:///local/foo/bar")));
  ret.setStatus(ResourceStatusType.FETCH_SUCCESS);
  ret.setLocalSize(4443L);
  Exception e = new Exception("Dingos.");
  e.setStackTrace(new StackTraceElement[] {
      new StackTraceElement("foo", "bar", "baz", 10),
      new StackTraceElement("sbb", "one", "onm", 10) });
  ret.setException(SerializedException.newInstance(e));
  return ret;
}
项目:aliyun-oss-hadoop-fs    文件:StopContainersResponsePBImpl.java   
private void addFailedRequestsToProto() {
  maybeInitBuilder();
  builder.clearFailedRequests();
  if (this.failedRequests == null)
    return;
  List<ContainerExceptionMapProto> protoList =
      new ArrayList<ContainerExceptionMapProto>();

  for (Map.Entry<ContainerId, SerializedException> entry : this.failedRequests
    .entrySet()) {
    protoList.add(ContainerExceptionMapProto.newBuilder()
      .setContainerId(convertToProtoFormat(entry.getKey()))
      .setException(convertToProtoFormat(entry.getValue())).build());
  }
  builder.addAllFailedRequests(protoList);
}
项目:aliyun-oss-hadoop-fs    文件:IncreaseContainersResourceResponsePBImpl.java   
private void addFailedRequestsToProto() {
  maybeInitBuilder();
  builder.clearFailedRequests();
  if (this.failedRequests == null) {
    return;
  }
  List<ContainerExceptionMapProto> protoList =
      new ArrayList<ContainerExceptionMapProto>();

  for (Map.Entry<ContainerId, SerializedException> entry : this.failedRequests
      .entrySet()) {
    protoList.add(ContainerExceptionMapProto.newBuilder()
        .setContainerId(convertToProtoFormat(entry.getKey()))
        .setException(convertToProtoFormat(entry.getValue())).build());
  }
  builder.addAllFailedRequests(protoList);
}
项目:aliyun-oss-hadoop-fs    文件:StartContainersResponsePBImpl.java   
private void addFailedContainersToProto() {
  maybeInitBuilder();
  builder.clearFailedRequests();
  if (this.failedContainers == null)
    return;
  List<ContainerExceptionMapProto> protoList =
      new ArrayList<ContainerExceptionMapProto>();

  for (Map.Entry<ContainerId, SerializedException> entry : this.failedContainers
    .entrySet()) {
    protoList.add(ContainerExceptionMapProto.newBuilder()
      .setContainerId(convertToProtoFormat(entry.getKey()))
      .setException(convertToProtoFormat(entry.getValue())).build());
  }
  builder.addAllFailedRequests(protoList);
}
项目:aliyun-oss-hadoop-fs    文件:SerializedExceptionPBImpl.java   
@SuppressWarnings("unchecked")
@Override
public Throwable deSerialize() {

  SerializedException cause = getCause();
  SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder;
  Class<?> realClass = null;
  try {
    realClass = Class.forName(p.getClassName());
  } catch (ClassNotFoundException e) {
    throw new YarnRuntimeException(e);
  }
  Class classType = null;
  if (YarnException.class.isAssignableFrom(realClass)) {
    classType = YarnException.class;
  } else if (IOException.class.isAssignableFrom(realClass)) {
    classType = IOException.class;
  } else if (RuntimeException.class.isAssignableFrom(realClass)) {
    classType = RuntimeException.class;
  } else {
    classType = Throwable.class;
  }
  return instantiateException(realClass.asSubclass(classType), getMessage(),
    cause == null ? null : cause.deSerialize());
}
项目:aliyun-oss-hadoop-fs    文件:TestContainerManagerSecurity.java   
private void startContainer(final YarnRPC rpc,
    org.apache.hadoop.yarn.api.records.Token nmToken,
    org.apache.hadoop.yarn.api.records.Token containerToken,
    NodeId nodeId, String user) throws Exception {

  ContainerLaunchContext context =
      Records.newRecord(ContainerLaunchContext.class);
  StartContainerRequest scRequest =
      StartContainerRequest.newInstance(context,containerToken);
  List<StartContainerRequest> list = new ArrayList<StartContainerRequest>();
  list.add(scRequest);
  StartContainersRequest allRequests =
      StartContainersRequest.newInstance(list);
  ContainerManagementProtocol proxy = null;
  try {
    proxy = getContainerManagementProtocolProxy(rpc, nmToken, nodeId, user);
    StartContainersResponse response = proxy.startContainers(allRequests);
    for(SerializedException ex : response.getFailedRequests().values()){
      parseAndThrowException(ex.deSerialize());
    }
  } finally {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  if (identifier == null) {
    throw RPCUtil.getRemoteException(INVALID_NMTOKEN_MSG);
  }
  for (ContainerId id : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:aliyun-oss-hadoop-fs    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  if (identifier == null) {
    throw RPCUtil.getRemoteException(INVALID_NMTOKEN_MSG);
  }
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:aliyun-oss-hadoop-fs    文件:TestPBRecordImpl.java   
static LocalResourceStatus createLocalResourceStatus() {
  LocalResourceStatus ret =
    recordFactory.newRecordInstance(LocalResourceStatus.class);
  assertTrue(ret instanceof LocalResourceStatusPBImpl);
  ret.setResource(createResource());
  ret.setLocalPath(
      ConverterUtils.getYarnUrlFromPath(
        new Path("file:///local/foo/bar")));
  ret.setStatus(ResourceStatusType.FETCH_SUCCESS);
  ret.setLocalSize(4443L);
  Exception e = new Exception("Dingos.");
  e.setStackTrace(new StackTraceElement[] {
      new StackTraceElement("foo", "bar", "baz", 10),
      new StackTraceElement("sbb", "one", "onm", 10) });
  ret.setException(SerializedException.newInstance(e));
  return ret;
}
项目:big-c    文件:StopContainersResponsePBImpl.java   
private void addFailedRequestsToProto() {
  maybeInitBuilder();
  builder.clearFailedRequests();
  if (this.failedRequests == null)
    return;
  List<ContainerExceptionMapProto> protoList =
      new ArrayList<ContainerExceptionMapProto>();

  for (Map.Entry<ContainerId, SerializedException> entry : this.failedRequests
    .entrySet()) {
    protoList.add(ContainerExceptionMapProto.newBuilder()
      .setContainerId(convertToProtoFormat(entry.getKey()))
      .setException(convertToProtoFormat(entry.getValue())).build());
  }
  builder.addAllFailedRequests(protoList);
}
项目:big-c    文件:StartContainersResponsePBImpl.java   
private void addFailedContainersToProto() {
  maybeInitBuilder();
  builder.clearFailedRequests();
  if (this.failedContainers == null)
    return;
  List<ContainerExceptionMapProto> protoList =
      new ArrayList<ContainerExceptionMapProto>();

  for (Map.Entry<ContainerId, SerializedException> entry : this.failedContainers
    .entrySet()) {
    protoList.add(ContainerExceptionMapProto.newBuilder()
      .setContainerId(convertToProtoFormat(entry.getKey()))
      .setException(convertToProtoFormat(entry.getValue())).build());
  }
  builder.addAllFailedRequests(protoList);
}
项目:big-c    文件:SerializedExceptionPBImpl.java   
@SuppressWarnings("unchecked")
@Override
public Throwable deSerialize() {

  SerializedException cause = getCause();
  SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder;
  Class<?> realClass = null;
  try {
    realClass = Class.forName(p.getClassName());
  } catch (ClassNotFoundException e) {
    throw new YarnRuntimeException(e);
  }
  Class classType = null;
  if (YarnException.class.isAssignableFrom(realClass)) {
    classType = YarnException.class;
  } else if (IOException.class.isAssignableFrom(realClass)) {
    classType = IOException.class;
  } else if (RuntimeException.class.isAssignableFrom(realClass)) {
    classType = RuntimeException.class;
  } else {
    classType = Exception.class;
  }
  return instantiateException(realClass.asSubclass(classType), getMessage(),
    cause == null ? null : cause.deSerialize());
}
项目:big-c    文件:TestContainerManagerSecurity.java   
private void startContainer(final YarnRPC rpc,
    org.apache.hadoop.yarn.api.records.Token nmToken,
    org.apache.hadoop.yarn.api.records.Token containerToken,
    NodeId nodeId, String user) throws Exception {

  ContainerLaunchContext context =
      Records.newRecord(ContainerLaunchContext.class);
  StartContainerRequest scRequest =
      StartContainerRequest.newInstance(context,containerToken);
  List<StartContainerRequest> list = new ArrayList<StartContainerRequest>();
  list.add(scRequest);
  StartContainersRequest allRequests =
      StartContainersRequest.newInstance(list);
  ContainerManagementProtocol proxy = null;
  try {
    proxy = getContainerManagementProtocolProxy(rpc, nmToken, nodeId, user);
    StartContainersResponse response = proxy.startContainers(allRequests);
    for(SerializedException ex : response.getFailedRequests().values()){
      parseAndThrowException(ex.deSerialize());
    }
  } finally {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
项目:big-c    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:big-c    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:big-c    文件:TestPBRecordImpl.java   
static LocalResourceStatus createLocalResourceStatus() {
  LocalResourceStatus ret =
    recordFactory.newRecordInstance(LocalResourceStatus.class);
  assertTrue(ret instanceof LocalResourceStatusPBImpl);
  ret.setResource(createResource());
  ret.setLocalPath(
      ConverterUtils.getYarnUrlFromPath(
        new Path("file:///local/foo/bar")));
  ret.setStatus(ResourceStatusType.FETCH_SUCCESS);
  ret.setLocalSize(4443L);
  Exception e = new Exception("Dingos.");
  e.setStackTrace(new StackTraceElement[] {
      new StackTraceElement("foo", "bar", "baz", 10),
      new StackTraceElement("sbb", "one", "onm", 10) });
  ret.setException(SerializedException.newInstance(e));
  return ret;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:StopContainersResponsePBImpl.java   
private void addFailedRequestsToProto() {
  maybeInitBuilder();
  builder.clearFailedRequests();
  if (this.failedRequests == null)
    return;
  List<ContainerExceptionMapProto> protoList =
      new ArrayList<ContainerExceptionMapProto>();

  for (Map.Entry<ContainerId, SerializedException> entry : this.failedRequests
    .entrySet()) {
    protoList.add(ContainerExceptionMapProto.newBuilder()
      .setContainerId(convertToProtoFormat(entry.getKey()))
      .setException(convertToProtoFormat(entry.getValue())).build());
  }
  builder.addAllFailedRequests(protoList);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:StartContainersResponsePBImpl.java   
private void addFailedContainersToProto() {
  maybeInitBuilder();
  builder.clearFailedRequests();
  if (this.failedContainers == null)
    return;
  List<ContainerExceptionMapProto> protoList =
      new ArrayList<ContainerExceptionMapProto>();

  for (Map.Entry<ContainerId, SerializedException> entry : this.failedContainers
    .entrySet()) {
    protoList.add(ContainerExceptionMapProto.newBuilder()
      .setContainerId(convertToProtoFormat(entry.getKey()))
      .setException(convertToProtoFormat(entry.getValue())).build());
  }
  builder.addAllFailedRequests(protoList);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:SerializedExceptionPBImpl.java   
@SuppressWarnings("unchecked")
@Override
public Throwable deSerialize() {

  SerializedException cause = getCause();
  SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder;
  Class<?> realClass = null;
  try {
    realClass = Class.forName(p.getClassName());
  } catch (ClassNotFoundException e) {
    throw new YarnRuntimeException(e);
  }
  Class classType = null;
  if (YarnException.class.isAssignableFrom(realClass)) {
    classType = YarnException.class;
  } else if (IOException.class.isAssignableFrom(realClass)) {
    classType = IOException.class;
  } else if (RuntimeException.class.isAssignableFrom(realClass)) {
    classType = RuntimeException.class;
  } else {
    classType = Exception.class;
  }
  return instantiateException(realClass.asSubclass(classType), getMessage(),
    cause == null ? null : cause.deSerialize());
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestContainerManagerSecurity.java   
private void startContainer(final YarnRPC rpc,
    org.apache.hadoop.yarn.api.records.Token nmToken,
    org.apache.hadoop.yarn.api.records.Token containerToken,
    NodeId nodeId, String user) throws Exception {

  ContainerLaunchContext context =
      Records.newRecord(ContainerLaunchContext.class);
  StartContainerRequest scRequest =
      StartContainerRequest.newInstance(context,containerToken);
  List<StartContainerRequest> list = new ArrayList<StartContainerRequest>();
  list.add(scRequest);
  StartContainersRequest allRequests =
      StartContainersRequest.newInstance(list);
  ContainerManagementProtocol proxy = null;
  try {
    proxy = getContainerManagementProtocolProxy(rpc, nmToken, nodeId, user);
    StartContainersResponse response = proxy.startContainers(allRequests);
    for(SerializedException ex : response.getFailedRequests().values()){
      parseAndThrowException(ex.deSerialize());
    }
  } finally {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:hops    文件:TestContainerManagerSecurity.java   
private void startContainer(final YarnRPC rpc,
    org.apache.hadoop.yarn.api.records.Token nmToken,
    org.apache.hadoop.yarn.api.records.Token containerToken,
    NodeId nodeId, String user) throws Exception {

  ContainerLaunchContext context =
      Records.newRecord(ContainerLaunchContext.class);
  StartContainerRequest scRequest =
      StartContainerRequest.newInstance(context,containerToken);
  List<StartContainerRequest> list = new ArrayList<StartContainerRequest>();
  list.add(scRequest);
  StartContainersRequest allRequests =
      StartContainersRequest.newInstance(list);
  ContainerManagementProtocol proxy = null;
  try {
    proxy = getContainerManagementProtocolProxy(rpc, nmToken, nodeId, user);
    StartContainersResponse response = proxy.startContainers(allRequests);
    for(SerializedException ex : response.getFailedRequests().values()){
      parseAndThrowException(ex.deSerialize());
    }
  } finally {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
项目:hadoop-plus    文件:StopContainersResponsePBImpl.java   
private void addFailedRequestsToProto() {
  maybeInitBuilder();
  builder.clearFailedRequests();
  if (this.failedRequests == null)
    return;
  List<ContainerExceptionMapProto> protoList =
      new ArrayList<ContainerExceptionMapProto>();

  for (Map.Entry<ContainerId, SerializedException> entry : this.failedRequests
    .entrySet()) {
    protoList.add(ContainerExceptionMapProto.newBuilder()
      .setContainerId(convertToProtoFormat(entry.getKey()))
      .setException(convertToProtoFormat(entry.getValue())).build());
  }
  builder.addAllFailedRequests(protoList);
}
项目:hadoop-plus    文件:SerializedExceptionPBImpl.java   
@SuppressWarnings("unchecked")
@Override
public Throwable deSerialize() {

  SerializedException cause = getCause();
  SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder;
  Class<?> realClass = null;
  try {
    realClass = Class.forName(p.getClassName());
  } catch (ClassNotFoundException e) {
    throw new YarnRuntimeException(e);
  }
  Class classType = null;
  if (YarnException.class.isAssignableFrom(realClass)) {
    classType = YarnException.class;
  } else if (IOException.class.isAssignableFrom(realClass)) {
    classType = IOException.class;
  } else if (RuntimeException.class.isAssignableFrom(realClass)) {
    classType = RuntimeException.class;
  } else {
    classType = Exception.class;
  }
  return instantiateException(realClass.asSubclass(classType), getMessage(),
    cause == null ? null : cause.deSerialize());
}
项目:hadoop-plus    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:hadoop-plus    文件:TestPBRecordImpl.java   
static LocalResourceStatus createLocalResourceStatus() {
  LocalResourceStatus ret =
    recordFactory.newRecordInstance(LocalResourceStatus.class);
  assertTrue(ret instanceof LocalResourceStatusPBImpl);
  ret.setResource(createResource());
  ret.setLocalPath(
      ConverterUtils.getYarnUrlFromPath(
        new Path("file:///local/foo/bar")));
  ret.setStatus(ResourceStatusType.FETCH_SUCCESS);
  ret.setLocalSize(4443L);
  Exception e = new Exception("Dingos.");
  e.setStackTrace(new StackTraceElement[] {
      new StackTraceElement("foo", "bar", "baz", 10),
      new StackTraceElement("sbb", "one", "onm", 10) });
  ret.setException(SerializedException.newInstance(e));
  return ret;
}
项目:hops    文件:TestPBRecordImpl.java   
static LocalResourceStatus createLocalResourceStatus() {
  LocalResourceStatus ret =
    recordFactory.newRecordInstance(LocalResourceStatus.class);
  assertTrue(ret instanceof LocalResourceStatusPBImpl);
  ret.setResource(createResource());
  ret.setLocalPath(
      URL.fromPath(
        new Path("file:///local/foo/bar")));
  ret.setStatus(ResourceStatusType.FETCH_SUCCESS);
  ret.setLocalSize(4443L);
  Exception e = new Exception("Dingos.");
  e.setStackTrace(new StackTraceElement[] {
      new StackTraceElement("foo", "bar", "baz", 10),
      new StackTraceElement("sbb", "one", "onm", 10) });
  ret.setException(SerializedException.newInstance(e));
  return ret;
}
项目:hops    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  if (identifier == null) {
    throw RPCUtil.getRemoteException(INVALID_NMTOKEN_MSG);
  }
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:hops    文件:StopContainersResponsePBImpl.java   
private void addFailedRequestsToProto() {
  maybeInitBuilder();
  builder.clearFailedRequests();
  if (this.failedRequests == null)
    return;
  List<ContainerExceptionMapProto> protoList =
      new ArrayList<ContainerExceptionMapProto>();

  for (Map.Entry<ContainerId, SerializedException> entry : this.failedRequests
    .entrySet()) {
    protoList.add(ContainerExceptionMapProto.newBuilder()
      .setContainerId(convertToProtoFormat(entry.getKey()))
      .setException(convertToProtoFormat(entry.getValue())).build());
  }
  builder.addAllFailedRequests(protoList);
}
项目:hops    文件:StartContainersResponsePBImpl.java   
private void addFailedContainersToProto() {
  maybeInitBuilder();
  builder.clearFailedRequests();
  if (this.failedContainers == null)
    return;
  List<ContainerExceptionMapProto> protoList =
      new ArrayList<ContainerExceptionMapProto>();

  for (Map.Entry<ContainerId, SerializedException> entry : this.failedContainers
    .entrySet()) {
    protoList.add(ContainerExceptionMapProto.newBuilder()
      .setContainerId(convertToProtoFormat(entry.getKey()))
      .setException(convertToProtoFormat(entry.getValue())).build());
  }
  builder.addAllFailedRequests(protoList);
}
项目:hops    文件:IncreaseContainersResourceResponsePBImpl.java   
private void addFailedRequestsToProto() {
  maybeInitBuilder();
  builder.clearFailedRequests();
  if (this.failedRequests == null) {
    return;
  }
  List<ContainerExceptionMapProto> protoList =
      new ArrayList<ContainerExceptionMapProto>();

  for (Map.Entry<ContainerId, SerializedException> entry : this.failedRequests
      .entrySet()) {
    protoList.add(ContainerExceptionMapProto.newBuilder()
        .setContainerId(convertToProtoFormat(entry.getKey()))
        .setException(convertToProtoFormat(entry.getValue())).build());
  }
  builder.addAllFailedRequests(protoList);
}
项目:hadoop    文件:StopContainersResponsePBImpl.java   
private void initFailedRequests() {
  if (this.failedRequests != null) {
    return;
  }
  StopContainersResponseProtoOrBuilder p = viaProto ? proto : builder;
  List<ContainerExceptionMapProto> protoList = p.getFailedRequestsList();
  this.failedRequests = new HashMap<ContainerId, SerializedException>();
  for (ContainerExceptionMapProto ce : protoList) {
    this.failedRequests.put(convertFromProtoFormat(ce.getContainerId()),
      convertFromProtoFormat(ce.getException()));
  }
}
项目:hadoop    文件:StopContainersResponsePBImpl.java   
@Override
public void setFailedRequests(
    Map<ContainerId, SerializedException> failedRequests) {
  maybeInitBuilder();
  if (failedRequests == null)
    builder.clearFailedRequests();
  this.failedRequests = failedRequests;
}