private void installYarn() throws InstallationException {
try {
logger.info("Installing Yarn version {}", yarnVersion);
String downloadUrl = yarnDownloadRoot + yarnVersion;
String extension = "tar.gz";
String fileending = "/yarn-" + yarnVersion + "." + extension;
downloadUrl += fileending;
CacheDescriptor cacheDescriptor = new CacheDescriptor("yarn", yarnVersion, extension);
File archive = config.getCacheResolver().resolve(cacheDescriptor);
downloadFileIfMissing(downloadUrl, archive, userName, password);
File installDirectory = getInstallDirectory();
try {
if (installDirectory.isDirectory()) {
FileUtils.deleteDirectory(installDirectory);
}
} catch (IOException e) {
logger.warn("Failed to delete existing Yarn installation.");
}
extractFile(archive, installDirectory);
ensureCorrectYarnRootDirectory(installDirectory, yarnVersion);
logger.info("Installed Yarn locally.");
} catch (DownloadException e) {
throw new InstallationException("Could not download Yarn", e);
} catch (ArchiveExtractionException | IOException e) {
throw new InstallationException("Could not extract the Yarn archive", e);
}
}