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));
}
}
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;
}
}
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);
}
}
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;
}
}
}
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;
}
}
Aggregations