Java Code Examples for org.apache.brooklyn.core.entity.Entities#newDownloader()
The following examples show how to use
org.apache.brooklyn.core.entity.Entities#newDownloader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CouchbaseSyncGatewaySshDriver.java From brooklyn-library with Apache License 2.0 | 6 votes |
@Override public void install() { //reference http://docs.couchbase.com/sync-gateway/#getting-started-with-sync-gateway DownloadResolver resolver = Entities.newDownloader(this); List<String> urls = resolver.getTargets(); String saveAs = resolver.getFilename(); OsDetails osDetails = getMachine().getMachineDetails().getOsDetails(); log.info("Installing couchbase-sync-gateway version: {}", getVersion()); if (osDetails.isLinux()) { List<String> commands = installLinux(urls, saveAs); newScript(INSTALLING) .body.append(commands).execute(); } }
Example 2
Source File: BrooklynNodeTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
private void runTestGeneratesCorrectDownloadUrl(String version, String expectedUrl) throws Exception { // TODO Using BrooklynNodeImpl directly, because want to instantiate a BroolynNodeSshDriver. // Really want to make that easier to test, without going through "wrong" code path for creating entity. BrooklynNode entity = app.addChild(EntitySpec.create(BrooklynNode.class) .configure(BrooklynNode.SUGGESTED_VERSION, version)); BrooklynNodeImpl entityImpl = (BrooklynNodeImpl) Entities.deproxy(entity); ConfigToAttributes.apply(entity); BrooklynNodeSshDriver driver = new BrooklynNodeSshDriver(entityImpl, loc); DownloadResolver resolver = Entities.newDownloader(driver); List<String> urls = resolver.getTargets(); System.out.println("urls=" + urls); assertTrue(urls.contains(expectedUrl), "urls=" + urls); }
Example 3
Source File: AbstractSoftwareProcessSshDriver.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Override public void prepare() { // Check if we should create a download resolver? String downloadUrl = getEntity().config().get(SoftwareProcess.DOWNLOAD_URL); if (Strings.isNonEmpty(downloadUrl)) { resolver = Entities.newDownloader(this); String formatString = getArchiveNameFormat(); if (Strings.isNonEmpty(formatString)) { setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(String.format(formatString, getVersion())))); } else { setExpandedInstallDir(getInstallDir()); } } }
Example 4
Source File: JBoss7SshDriver.java From brooklyn-library with Apache License 2.0 | 4 votes |
@Override public void prepare() { resolver = Entities.newDownloader(this); setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("jboss-as-%s", getVersion())))); }
Example 5
Source File: MySqlSshDriver.java From brooklyn-library with Apache License 2.0 | 4 votes |
@Override public void prepare() { resolver = Entities.newDownloader(this); String unpackedDirectoryName = resolver.getUnpackedDirectoryName(getDefaultUnpackedDirectoryName()); setExpandedInstallDir(Os.mergePaths(getInstallDir(), unpackedDirectoryName)); }
Example 6
Source File: MariaDbSshDriver.java From brooklyn-library with Apache License 2.0 | 4 votes |
@Override public void prepare() { resolver = Entities.newDownloader(this, ImmutableMap.of("filename", getInstallFilename())); setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("mariadb-%s-%s", getVersion(), getOsTag())))); }
Example 7
Source File: VanillaSoftwareProcessSshDriver.java From brooklyn-server with Apache License 2.0 | 4 votes |
@Override public void install() { Maybe<Object> url = ((EntityInternal)getEntity()).config().getRaw(SoftwareProcess.DOWNLOAD_URL); if (url.isPresentAndNonNull()) { DownloadResolver resolver = Entities.newDownloader(this); List<String> urls = resolver.getTargets(); downloadedFilename = resolver.getFilename(); List<String> commands = new LinkedList<String>(); commands.addAll(BashCommands.commandsToDownloadUrlsAs(urls, downloadedFilename)); commands.addAll(ArchiveUtils.installCommands(downloadedFilename)); int result = newScript(ImmutableMap.of(INSTALL_INCOMPLETE, true), INSTALLING) .failOnNonZeroResultCode(false) .body.append(commands) .execute(); if (result!=0) { // could not install at remote machine; try resolving URL here and copying across for (String urlI: urls) { result = ArchiveUtils.install(getMachine(), urlI, Urls.mergePaths(getInstallDir(), downloadedFilename)); if (result==0) break; } if (result != 0) throw new IllegalStateException("Error installing archive: " + downloadedFilename); } } // If downloadUrl did partial install (see INSTALL_INCOMPLETE above) then always execute install so mark it as completed. String installCommand = getEntity().getConfig(VanillaSoftwareProcess.INSTALL_COMMAND); if (url.isPresentAndNonNull() && Strings.isBlank(installCommand)) installCommand = "# mark as complete"; if (Strings.isNonBlank(installCommand)) { newScript(INSTALLING) .failOnNonZeroResultCode() .environmentVariablesReset(getShellEnvironment()) .body.append(installCommand) .execute(); } }