public static void main(String[] args) { String url = "scp://root@sol10-2/root/alex/agent.zip?password=password"; TemplateDownloader td = new ScpTemplateDownloader(null, url, "/tmp/mysql", TemplateDownloader.DEFAULT_MAX_TEMPLATE_SIZE_IN_BYTES, null); long bytes = td.download(true, null); if (bytes > 0) { System.out.println("Downloaded (" + bytes + " bytes)" + " in " + td.getDownloadTime() / 1000 + " secs"); } else { System.out.println("Failed download"); } } }
@Override public String getDownloadError(String jobId) { DownloadJob dj = jobs.get(jobId); if (dj != null) { return dj.getTemplateDownloader().getDownloadError(); } return null; }
public void cleanup() { if (td != null) { String dnldPath = td.getDownloadLocalPath(); if (dnldPath != null) { File f = new File(dnldPath); File dir = f.getParentFile(); f.delete(); if (dir != null) { dir.delete(); } } } }
s_logger.info("local: " + td.getDownloadLocalPath() + ", bytes=" + td.getDownloadedBytes() + ", error=" + td.getDownloadError() + ", pct=" + td.getDownloadPercent()); case IN_PROGRESS: s_logger.info("Resuming jobId: " + jobId + ", status=" + status); td.setResume(true); threadPool.execute(td); break; td.setDownloadError("Download success, starting install "); String result = postRemoteDownload(jobId); if (result != null) { s_logger.error("Failed post download install: " + result); td.setStatus(Status.UNRECOVERABLE_ERROR); td.setDownloadError("Failed post download install: " + result); ((S3TemplateDownloader) td).cleanupAfterError(); } else { td.setStatus(Status.POST_DOWNLOAD_FINISHED); td.setDownloadError("Install completed successfully at " + new SimpleDateFormat().format(new Date())); td.setDownloadError("Download success, starting install "); String result = postLocalDownload(jobId); if (result != null) { s_logger.error("Failed post download script: " + result); td.setStatus(Status.UNRECOVERABLE_ERROR); td.setDownloadError("Failed post download script: " + result); } else { td.setStatus(Status.POST_DOWNLOAD_FINISHED); td.setDownloadError("Install completed successfully at " + new SimpleDateFormat().format(new Date()));
File originalTemplate = new File(td.getDownloadLocalPath()); ChecksumValue oldValue = new ChecksumValue(dnld.getChecksum()); ChecksumValue newValue = null; int imgSizeGigs = (int)Math.ceil(_storage.getSize(td.getDownloadLocalPath()) * 1.0d / (1024 * 1024 * 1024)); scr = new Script(script, timeout, s_logger); scr.add("-s", Integer.toString(imgSizeGigs)); scr.add("-S", Long.toString(td.getMaxTemplateSizeInBytes())); if (dnld.getDescription() != null && dnld.getDescription().length() > 1) { scr.add("-d", dnld.getDescription()); scr.add("-f", td.getDownloadLocalPath()); // this is the temporary template file downloaded scr.add("-u"); // cleanup String result;
@Override public int getDownloadPct(String jobId) { DownloadJob dj = jobs.get(jobId); if (dj != null) { return dj.getTemplateDownloader().getDownloadPercent(); } return 0; }
@Override public Status getDownloadStatus(String jobId) { DownloadJob job = jobs.get(jobId); if (job != null) { TemplateDownloader td = job.getTemplateDownloader(); if (td != null) { return td.getStatus(); } } return Status.UNKNOWN; }
public static void main(String[] args) { String url = "http:// dev.mysql.com/get/Downloads/MySQL-5.0/mysql-noinstall-5.0.77-win32.zip/from/http://mirror.services.wisc.edu/mysql/"; try { new java.net.URI(url); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } TemplateDownloader td = new HttpTemplateDownloader(null, url, "/tmp/mysql", null, TemplateDownloader.DEFAULT_MAX_TEMPLATE_SIZE_IN_BYTES, null, null, null, null); long bytes = td.download(true, null); if (bytes > 0) { System.out.println("Downloaded (" + bytes + " bytes)" + " in " + td.getDownloadTime() / 1000 + " secs"); } else { System.out.println("Failed download"); } }
public String getDownloadLocalPath(String jobId) { DownloadJob dj = jobs.get(jobId); if (dj != null) { return dj.getTemplateDownloader().getDownloadLocalPath(); } return null; }