@Override public void copyCustomizeResources() { Map<String, String> customizeFiles = entity.getConfig(SoftwareProcess.CUSTOMIZE_FILES); Map<String, String> customizeTemplates = entity.getConfig(SoftwareProcess.CUSTOMIZE_TEMPLATES); if ((customizeFiles!=null && !customizeFiles.isEmpty()) || (customizeTemplates!=null && !customizeTemplates.isEmpty())) { // only do this if there are files, to prevent unnecessary `mkdir` super.copyCustomizeResources(); } }
@Override public void copyRuntimeResources() { Map<String, String> runtimeFiles = entity.getConfig(SoftwareProcess.RUNTIME_FILES); Map<String, String> runtimeTemplates = entity.getConfig(SoftwareProcess.RUNTIME_TEMPLATES); if ((runtimeFiles!=null && !runtimeFiles.isEmpty()) || (runtimeTemplates!=null && !runtimeTemplates.isEmpty())) { // only do this if there are files, to prevent unnecessary `mkdir` super.copyRuntimeResources(); } }
@Override public void copyRuntimeResources() { Map<String, String> runtimeFiles = entity.getConfig(SoftwareProcess.RUNTIME_FILES); Map<String, String> runtimeTemplates = entity.getConfig(SoftwareProcess.RUNTIME_TEMPLATES); if ((runtimeFiles!=null && !runtimeFiles.isEmpty()) || (runtimeTemplates!=null && !runtimeTemplates.isEmpty())) { // only do this if there are files, to prevent unnecessary `mkdir` super.copyRuntimeResources(); } }
public List<String> getZookeeperServers() { ZooKeeperEnsemble zooKeeperEnsemble = entity.getConfig(Storm.ZOOKEEPER_ENSEMBLE); Supplier<List<String>> supplier = Entities.attributeSupplierWhenReady(zooKeeperEnsemble, ZooKeeperEnsemble.ZOOKEEPER_SERVERS); return supplier.get(); }
public String getNimbusHostname() { String result = entity.getConfig(Storm.NIMBUS_HOSTNAME); if (result != null) return result; Entity nimbus = entity.getConfig(Storm.NIMBUS_ENTITY); if (nimbus == null) { log.warn("No nimbus hostname available; using 'localhost'"); return "localhost"; } return Entities.submit(entity, DependentConfiguration.attributeWhenReady(nimbus, Attributes.HOSTNAME)).getUnchecked(); }
@Override public void runPostInstallCommand() { if (Strings.isNonBlank(entity.getConfig(BrooklynConfigKeys.POST_INSTALL_COMMAND)) || Strings.isNonBlank(getEntity().getConfig(VanillaWindowsProcess.POST_INSTALL_POWERSHELL_COMMAND))) { executeCommandInTask( getEntity().getConfig(BrooklynConfigKeys.POST_INSTALL_COMMAND), getEntity().getConfig(VanillaWindowsProcess.POST_INSTALL_POWERSHELL_COMMAND), "post-install-command"); } }
@Override protected String getInstallLabelExtraSalt() { String downloadUrl = entity.getConfig(BrooklynNode.DOWNLOAD_URL); String uploadUrl = entity.getConfig(BrooklynNode.DISTRO_UPLOAD_URL); if (Objects.equal(downloadUrl, BrooklynNode.DOWNLOAD_URL.getConfigKey().getDefaultValue()) && Objects.equal(uploadUrl, BrooklynNode.DISTRO_UPLOAD_URL.getDefaultValue())) { // if both are at the default value, then no salt return null; } return Identifiers.makeIdFromHash(Objects.hashCode(downloadUrl, uploadUrl)); }
@Override public void customize() { if(Strings.isNonBlank(getEntity().getConfig(VanillaWindowsProcess.CUSTOMIZE_COMMAND)) || Strings.isNonBlank(getEntity().getConfig(VanillaWindowsProcess.CUSTOMIZE_POWERSHELL_COMMAND))) { executeCommandInTask( getEntity().getConfig(VanillaWindowsProcess.CUSTOMIZE_COMMAND), getEntity().getConfig(VanillaWindowsProcess.CUSTOMIZE_POWERSHELL_COMMAND), "customize-command"); } if (entity.getConfig(VanillaWindowsProcess.CUSTOMIZE_REBOOT_REQUIRED)) { rebootAndWait(); } }
@Override public void launch() { if (Strings.isNonBlank(getEntity().getConfig(VanillaWindowsProcess.LAUNCH_COMMAND)) || Strings.isNonBlank(getEntity().getConfig(VanillaWindowsProcess.LAUNCH_POWERSHELL_COMMAND))) { executeCommandInTask( getEntity().getConfig(VanillaWindowsProcess.LAUNCH_COMMAND), getEntity().getConfig(VanillaWindowsProcess.LAUNCH_POWERSHELL_COMMAND), "launch-command"); } }
private void executeSuccessfully(ConfigKey<String> configKey, String label) { if(Strings.isNonBlank(getEntity().getConfig(configKey))) { log.debug("Executing {} on entity {}", label, entity.getDisplayName()); int result = execute(ImmutableList.of(getEntity().getConfig(configKey)), label); if (0 != result) { log.debug("Executing {} failed with return code {}", label, result); throw new IllegalStateException("commands for " + configKey.getName() + " failed with return code " + result); } } }
/** * The environment variables to be set when executing the commands (for install, run, check running, etc). * @see SoftwareProcess#SHELL_ENVIRONMENT */ public Map<String, String> getShellEnvironment() { Map<String, Object> env = entity.getConfig(SoftwareProcess.SHELL_ENVIRONMENT); ShellEnvironmentSerializer envSerializer = new ShellEnvironmentSerializer(((EntityInternal)entity).getManagementContext()); return envSerializer.serialize(env); }
@Override public void customize() { newScript(CUSTOMIZING) .body.append("mkdir -p " + getDataLocation()) .execute(); copyTemplate(entity.getConfig(CrateNode.SERVER_CONFIG_URL), getConfigFileLocation()); }
@Override public void start() { WinRmMachineLocation machine = (WinRmMachineLocation) location; Integer port = entity.getConfig(WinRmTool.PROP_PORT); UserAndHostAndPort winrmAddress = UserAndHostAndPort.fromParts(machine.getUser(), machine.getAddress().getHostName(), Optional.fromNullable(port)); getEntity().sensors().set(Attributes.WINRM_ADDRESS, winrmAddress); super.start(); }
private String getConfigOrDefault(BasicAttributeSensorAndConfigKey<String> key, String def) { String val = entity.getConfig(key); if (Strings.isEmpty(val)) { val = entity.sensors().get(key); if (Strings.isEmpty(val)) { val = def; log.debug(entity + " has no config specified for " + key + "; using default `" + def + "`"); entity.sensors().set(key, val); } } return val; }
@Override public void customize() { DynamicTasks.queue(ChefSoloTasks.buildChefFile(getRunDir(), getInstallDir(), "launch", getRequiredConfig(CHEF_RUN_LIST), getEntity().getConfig(CHEF_LAUNCH_ATTRIBUTES))); }
@Override public void launch() { String launchCommand = getEntity().getConfig(VanillaSoftwareProcess.LAUNCH_COMMAND); if (Strings.isNonBlank(launchCommand)) { newScript(LAUNCHING) .failOnNonZeroResultCode() .body.append(launchCommand) .execute(); } }
@Override public void customize() { DynamicTasks.queue(ChefSoloTasks.buildChefFile(getRunDir(), getInstallDir(), "launch", getRequiredConfig(CHEF_RUN_LIST), getEntity().getConfig(CHEF_LAUNCH_ATTRIBUTES))); }
@Override public void stop() { newScript(MutableMap.of("usePidFile", false), STOPPING) .body.append(callPgctl((entity.getConfig(PostgreSqlNode.DISCONNECT_ON_STOP) ? "-m immediate " : "") + "stop", false)) .failOnNonZeroResultCode() .execute(); newScript(MutableMap.of("usePidFile", getPidFile(), "processOwner", "postgres"), STOPPING).execute(); }
@Override public void stop() { String customCommand = getEntity().getConfig(VanillaSoftwareProcess.STOP_COMMAND); ScriptHelper script = null; if (customCommand == null) { script = newScript(MutableMap.of(USE_PID_FILE, getPidFile()), STOPPING); } else { // TODO: template substitutions? script = newScript(STOPPING).body.append(customCommand); } script.execute(); }
@Override public void customize() { Networking.checkPortsValid(getPortMap()); newScript(CUSTOMIZING) .failOnNonZeroResultCode() .body.append(format("cp -R %s/* %s", getExpandedInstallDir(), getRunDir())) .execute(); String config = entity.getConfig(getConfigTemplateKey()); copyTemplate(config, getConfigFileName()); }