use of org.apache.oozie.dependency.FSURIHandler in project oozie by apache.
the class URIHandlerService method init.
private void init(Configuration conf) throws ClassNotFoundException {
cache = new HashMap<String, URIHandler>();
String[] classes = ConfigurationService.getStrings(conf, URI_HANDLERS);
for (String classname : classes) {
Class<?> clazz = Class.forName(classname.trim());
URIHandler uriHandler = (URIHandler) ReflectionUtils.newInstance(clazz, null);
uriHandler.init(conf);
for (String scheme : uriHandler.getSupportedSchemes()) {
cache.put(scheme, uriHandler);
}
}
Class<?> defaultClass = conf.getClass(URI_HANDLER_DEFAULT, null);
defaultHandler = (defaultClass == null) ? new FSURIHandler() : (URIHandler) ReflectionUtils.newInstance(defaultClass, null);
defaultHandler.init(conf);
for (String scheme : defaultHandler.getSupportedSchemes()) {
cache.put(scheme, defaultHandler);
}
initLauncherClassesToShip();
initLauncherURIHandlerConf();
LOG.info("Loaded urihandlers {0}", Arrays.toString(classes));
LOG.info("Loaded default urihandler {0}", defaultHandler.getClass().getName());
}
use of org.apache.oozie.dependency.FSURIHandler in project oozie by apache.
the class FsActionExecutor method delete.
/**
* Delete path
*
* @param context
* @param fsConf
* @param nameNodePath
* @param path
* @param skipTrash flag to skip the trash.
* @throws ActionExecutorException
*/
public void delete(Context context, XConfiguration fsConf, Path nameNodePath, Path path, boolean skipTrash) throws ActionExecutorException {
LOG.info("Deleting [{0}]. Skipping trash: [{1}]", path, skipTrash);
URI uri = path.toUri();
URIHandler handler;
org.apache.oozie.dependency.URIHandler.Context hcatContext = null;
try {
handler = Services.get().get(URIHandlerService.class).getURIHandler(uri);
if (handler instanceof FSURIHandler) {
// Use legacy code to handle hdfs partition deletion
path = resolveToFullPath(nameNodePath, path, true);
final FileSystem fs = getFileSystemFor(path, context, fsConf);
Path[] pathArr = FileUtil.stat2Paths(fs.globStatus(path));
if (pathArr != null && pathArr.length > 0) {
checkGlobMax(pathArr);
for (final Path p : pathArr) {
if (fs.exists(p)) {
if (!skipTrash) {
// Moving directory/file to trash of user.
UserGroupInformationService ugiService = Services.get().get(UserGroupInformationService.class);
UserGroupInformation ugi = ugiService.getProxyUser(fs.getConf().get(OozieClient.USER_NAME));
ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
@Override
public FileSystem run() throws Exception {
Trash trash = new Trash(fs.getConf());
if (!trash.moveToTrash(p)) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "FS005", "Could not move path [{0}] to trash on delete", p);
}
return null;
}
});
} else if (!fs.delete(p, true)) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "FS005", "delete, path [{0}] could not delete path", p);
}
}
}
}
} else {
hcatContext = handler.getContext(uri, fsConf, context.getWorkflow().getUser(), false);
handler.delete(uri, hcatContext);
}
} catch (Exception ex) {
throw convertException(ex);
} finally {
if (hcatContext != null) {
hcatContext.destroy();
}
}
}
Aggregations