Package org.apache.hadoop.yarn.api.records

Examples of org.apache.hadoop.yarn.api.records.SerializedException


  @Test(timeout=10000)
  public void testSerializedExceptionDeSer() throws Exception{
    // without cause
    YarnException yarnEx = new YarnException("Yarn_Exception");
    SerializedException serEx = SerializedException.newInstance(yarnEx);
    Throwable throwable = serEx.deSerialize();
    Assert.assertEquals(yarnEx.getClass(), throwable.getClass());
    Assert.assertEquals(yarnEx.getMessage(), throwable.getMessage());

    // with cause
    IOException ioe = new IOException("Test_IOException");
    RuntimeException runtimeException =
        new RuntimeException("Test_RuntimeException", ioe);
    YarnException yarnEx2 =
        new YarnException("Test_YarnException", runtimeException);

    SerializedException serEx2 = SerializedException.newInstance(yarnEx2);
    Throwable throwable2 = serEx2.deSerialize();
    throwable2.printStackTrace();
    Assert.assertEquals(yarnEx2.getClass(), throwable2.getClass());
    Assert.assertEquals(yarnEx2.getMessage(), throwable2.getMessage());

    Assert.assertEquals(runtimeException.getClass(), throwable2.getCause().getClass());
View Full Code Here


  @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());
  }
View Full Code Here

  @Test(timeout=10000)
  public void testSerializedExceptionDeSer() throws Exception{
    // without cause
    YarnException yarnEx = new YarnException("Yarn_Exception");
    SerializedException serEx = SerializedException.newInstance(yarnEx);
    Throwable throwable = serEx.deSerialize();
    Assert.assertEquals(yarnEx.getClass(), throwable.getClass());
    Assert.assertEquals(yarnEx.getMessage(), throwable.getMessage());

    // with cause
    IOException ioe = new IOException("Test_IOException");
    RuntimeException runtimeException =
        new RuntimeException("Test_RuntimeException", ioe);
    YarnException yarnEx2 =
        new YarnException("Test_YarnException", runtimeException);

    SerializedException serEx2 = SerializedException.newInstance(yarnEx2);
    Throwable throwable2 = serEx2.deSerialize();
    throwable2.printStackTrace();
    Assert.assertEquals(yarnEx2.getClass(), throwable2.getClass());
    Assert.assertEquals(yarnEx2.getMessage(), throwable2.getMessage());

    Assert.assertEquals(runtimeException.getClass(), throwable2.getCause().getClass());
View Full Code Here

  @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());
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.yarn.api.records.SerializedException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.