Example usage for org.apache.hadoop.ipc RemoteException unwrapRemoteException

List of usage examples for org.apache.hadoop.ipc RemoteException unwrapRemoteException

Introduction

In this page you can find the example usage for org.apache.hadoop.ipc RemoteException unwrapRemoteException.

Prototype

public IOException unwrapRemoteException(Class<?>... lookupTypes) 

Source Link

Document

If this remote exception wraps up one of the lookupTypes then return this exception.

Usage

From source file:com.alibaba.wasp.EntityGroupMovedException.java

License:Apache License

/**
 * Look for a EntityGroupMovedException in the exception: - hadoop.ipc wrapped
 * exceptions - nested exceptions Returns null if we didn't find the exception
 * or if it was not readable.//from ww  w  .j av a  2s . c om
 */
public static EntityGroupMovedException find(Object exception) {
    if (exception == null || !(exception instanceof Throwable)) {
        return null;
    }

    Throwable cur = (Throwable) exception;
    EntityGroupMovedException res = null;

    while (res == null && cur != null) {
        if (cur instanceof EntityGroupMovedException) {
            res = (EntityGroupMovedException) cur;
        } else {
            if (cur instanceof RemoteException) {
                RemoteException re = (RemoteException) cur;
                Exception e = re.unwrapRemoteException(EntityGroupMovedException.class);
                if (e == null) {
                    e = re.unwrapRemoteException();
                }
                // unwrapRemoteException can return the exception given as a parameter
                // when it cannot
                // unwrap it. In this case, there is no need to look further
                // noinspection ObjectEquality
                if (e != re) {
                    res = find(e);
                }
            }
            cur = cur.getCause();
        }
    }

    if (res != null && (res.getPort() < 0 || res.getHostname() == null)) {
        // We failed to parse the exception. Let's act as we don't find the
        // exception.
        return null;
    } else {
        return res;
    }
}

From source file:com.mellanox.r4h.DFSClient.java

License:Apache License

/**
 * Save namespace image./*  w w w.  j  a  v  a2s  . c  o  m*/
 * 
 * @see ClientProtocol#saveNamespace()
 */
void saveNamespace() throws AccessControlException, IOException {
    TraceScope scope = Trace.startSpan("saveNamespace", traceSampler);
    try {
        namenode.saveNamespace();
    } catch (RemoteException re) {
        throw re.unwrapRemoteException(AccessControlException.class);
    } finally {
        scope.close();
    }
}

From source file:com.mellanox.r4h.DFSClient.java

License:Apache License

/**
 * Rolls the edit log on the active NameNode.
 * /*from   w  w  w  .  ja va 2s . c o m*/
 * @return the txid of the new log segment
 *
 * @see ClientProtocol#rollEdits()
 */
long rollEdits() throws AccessControlException, IOException {
    TraceScope scope = Trace.startSpan("rollEdits", traceSampler);
    try {
        return namenode.rollEdits();
    } catch (RemoteException re) {
        throw re.unwrapRemoteException(AccessControlException.class);
    } finally {
        scope.close();
    }
}