LocalResource packageResource = Records.newRecord(LocalResource.class);
FileSystem fs = FileSystem.get(conf);
Path packageFile = new Path(conf.get("bsp.jar"));
// FIXME there seems to be a problem with the converter utils and URL
// transformation
URL packageUrl = ConverterUtils.getYarnUrlFromPath(packageFile
.makeQualified(fs.getUri(), fs.getWorkingDirectory()));
LOG.info("PackageURL has been composed to " + packageUrl.toString());
try {
LOG.info("Reverting packageURL to path: "
+ ConverterUtils.getPathFromYarnURL(packageUrl));
} catch (URISyntaxException e) {
LOG.fatal("If you see this error the workarround does not work", e);
}
FileStatus fileStatus = fs.getFileStatus(packageFile);
packageResource.setResource(packageUrl);
packageResource.setSize(fileStatus.getLen());
packageResource.setTimestamp(fileStatus.getModificationTime());
packageResource.setType(LocalResourceType.ARCHIVE);
packageResource.setVisibility(LocalResourceVisibility.APPLICATION);
LOG.info("Package resource: " + packageResource.getResource());
ctx.setLocalResources(Collections.singletonMap("package", packageResource));
/*
* TODO Package classpath seems not to work if you're in pseudo distributed
* mode, because the resource must not be moved, it will never be unpacked.
* So we will check if our jar file has the file:// prefix and put it into
* the CP directly
*/
String cp = "$CLASSPATH:./*:./package/*:./*:";
if (packageUrl.getScheme() != null && packageUrl.getScheme().equals("file")) {
cp += packageFile.makeQualified(fs.getUri(), fs.getWorkingDirectory())
.toString() + ":";
LOG.info("Localized file scheme detected, adjusting CP to: " + cp);
}
String[] cmds = {