Search in sources :

Example 6 with NonTransientException

use of com.microsoft.frameworklauncher.common.exceptions.NonTransientException in project pai by Microsoft.

the class RequestManager method checkAmVersion.

/**
 * REGION InternalUtils
 */
// Throw NonTransientException to stop AM ASAP, in case the LauncherService or the NodeManager is down,
// which may lead AM process cannot be killed in time.
private void checkAmVersion() throws Exception {
    // LauncherStatus should always exist.
    LauncherStatus launcherStatus;
    try {
        launcherStatus = zkStore.getLauncherStatus();
    } catch (NoNodeException e) {
        throw new NonTransientException("Failed to getLauncherStatus to checkAmVersion, LauncherStatus is already deleted on ZK", e);
    }
    Integer newAmVersion = launcherStatus.getLauncherConfiguration().getAmVersion();
    if (!newAmVersion.equals(conf.getAmVersion())) {
        throw new NonTransientException(String.format("AmVersion mismatch: Local Version %s, Latest Version %s", conf.getAmVersion(), newAmVersion));
    }
}
Also used : NonTransientException(com.microsoft.frameworklauncher.common.exceptions.NonTransientException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException)

Example 7 with NonTransientException

use of com.microsoft.frameworklauncher.common.exceptions.NonTransientException in project pai by Microsoft.

the class Service method handleException.

@Override
protected Boolean handleException(Exception e) {
    super.handleException(e);
    if (e instanceof NonTransientException) {
        LOGGER.logError(e, "NonTransientException occurred in %1$s. %1$s will be stopped.", serviceName);
        stop(new StopStatus(GlobalConstants.EXIT_CODE_LAUNCHER_NON_TRANSIENT_FAILED, true, null, e));
        return false;
    } else {
        LOGGER.logError(e, "Exception occurred in %1$s. It should be transient. Will restart %1$s inplace.", serviceName);
        // TODO: Only Restart Service instead of exit whole process and Restart by external system.
        stop(new StopStatus(GlobalConstants.EXIT_CODE_LAUNCHER_UNKNOWN_FAILED, false, null, e));
        return true;
    }
}
Also used : NonTransientException(com.microsoft.frameworklauncher.common.exceptions.NonTransientException) StopStatus(com.microsoft.frameworklauncher.common.service.StopStatus)

Example 8 with NonTransientException

use of com.microsoft.frameworklauncher.common.exceptions.NonTransientException in project pai by Microsoft.

the class HadoopUtils method getFileStatusInHdfsInternal.

// Should success when the hdfsPath exists
private static FileStatus getFileStatusInHdfsInternal(String hdfsPath) throws Exception {
    try {
        FileSystem fs = FileSystem.get(CONF);
        LOGGER.logInfo("[hadoop fs -stat %%Y %s]", hdfsPath);
        return fs.getFileStatus(new Path(hdfsPath));
    } catch (PathNotFoundException | FileNotFoundException e) {
        throw new NonTransientException(e.getMessage(), e);
    }
}
Also used : NonTransientException(com.microsoft.frameworklauncher.common.exceptions.NonTransientException) FileNotFoundException(java.io.FileNotFoundException)

Example 9 with NonTransientException

use of com.microsoft.frameworklauncher.common.exceptions.NonTransientException in project pai by Microsoft.

the class HadoopUtils method uploadFileToHdfs.

// Should success when the localPath exists and the hdfsPath's parent paths are exists directories
public static void uploadFileToHdfs(String localPath, String hdfsPath) throws Exception {
    try {
        FileSystem fs = FileSystem.get(CONF);
        LOGGER.logInfo("[hadoop fs -put -f %s %s]", localPath, hdfsPath);
        fs.copyFromLocalFile(new Path(localPath), new Path(hdfsPath));
    } catch (PathNotFoundException e) {
        throw new NonTransientException(e.getMessage(), e);
    } catch (Exception e) {
        if (e.getMessage().toLowerCase().contains("not a directory")) {
            throw new NonTransientException(e.getMessage(), e);
        } else {
            throw e;
        }
    }
}
Also used : NonTransientException(com.microsoft.frameworklauncher.common.exceptions.NonTransientException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) FileNotFoundException(java.io.FileNotFoundException) NonTransientException(com.microsoft.frameworklauncher.common.exceptions.NonTransientException) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)

Example 10 with NonTransientException

use of com.microsoft.frameworklauncher.common.exceptions.NonTransientException in project pai by Microsoft.

the class WebServer method handleException.

protected Boolean handleException(Exception e) {
    super.handleException(e);
    if (e instanceof NonTransientException) {
        LOGGER.logError(e, "NonTransientException occurred in %1$s. %1$s will be stopped.", serviceName);
        stop(new StopStatus(GlobalConstants.EXIT_CODE_LAUNCHER_NON_TRANSIENT_FAILED, true, null, e));
        return false;
    } else {
        LOGGER.logError(e, "Exception occurred in %1$s. It should be transient. Will restart %1$s inplace.", serviceName);
        // TODO: Only Restart WebServer instead of exit whole process and Restart by external system.
        stop(new StopStatus(GlobalConstants.EXIT_CODE_LAUNCHER_UNKNOWN_FAILED, false, null, e));
        return true;
    }
}
Also used : NonTransientException(com.microsoft.frameworklauncher.common.exceptions.NonTransientException) StopStatus(com.microsoft.frameworklauncher.common.service.StopStatus)

Aggregations

NonTransientException (com.microsoft.frameworklauncher.common.exceptions.NonTransientException)10 FileNotFoundException (java.io.FileNotFoundException)4 StopStatus (com.microsoft.frameworklauncher.common.service.StopStatus)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)2 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)2 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)2 KeeperException (org.apache.zookeeper.KeeperException)1