@Override public RabbitBrokerImpl getEntity() { return (RabbitBrokerImpl) super.getEntity(); }
public int copyResource(File file, String target) { return copyResource(file.toURI().toASCIIString(), target); } public int copyResource(String resource, String target) {
public int copyTemplate(String template, String target) { return copyTemplate(template, target, ImmutableMap.<String, String>of()); }
/** * Name to be used in the local repo, when looking for the download file. * If null, will */ public String getDownloadFilename() { return getEntity().getEntityType().getSimpleName().toLowerCase() + "-"+getVersion() + ".tar.gz"; }
public String getVersion() { return elvis(getEntity().getConfig(SoftwareProcess.SUGGESTED_VERSION), getDefaultVersion()); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public int execute(Map flags2, List<String> script, String summaryForLogging) { Map flags = new LinkedHashMap(); if (!flags2.containsKey(IGNORE_ENTITY_SSH_FLAGS)) flags.putAll(getSshFlags()); flags.putAll(flags2); Map<String, String> environment = (Map<String, String>) ((flags.get("env") != null) ? flags.get("env") : getShellEnvironment()); if (!flags.containsKey("logPrefix")) flags.put("logPrefix", ""+entity.getId()+"@"+getLocation().getDisplayName()); return getMachine().execScript(flags, summaryForLogging, script, environment); }
/** * Sets all JVM options (-X.. -D..) in an environment var JAVA_OPTS. * <p> * That variable is constructed from getJavaOpts(), then wrapped _unescaped_ in double quotes. An * error is thrown if there is an unescaped double quote in the string. All other unescaped * characters are permitted, but unless $var expansion or `command` execution is desired (although * this is not confirmed as supported) the generally caller should escape any such characters, for * example using {@link BashStringEscapes#escapeLiteralForDoubleQuotedBash(String)}. */ @Override public Map<String, String> getShellEnvironment() { for (String it : getJavaOpts()) { BashStringEscapes.assertValidForDoubleQuotingInBash(it); } // do not double quote here; the env var is double quoted subsequently; // spaces should be preceded by double-quote // (if dbl quotes are needed we could pass on the command-line instead of in an env var) String sJavaOpts = Joiner.on(" ").join(getJavaOpts()); // println "using java opts: $sJavaOpts" return MutableMap.<String, String> builder().putAll(super.getShellEnvironment()).put("JAVA_OPTS", sJavaOpts).build(); }
public int execute(List<String> script, String summaryForLogging) { return execute(Maps.newLinkedHashMap(), script, summaryForLogging); }
/** @deprecated since 0.5.0, should use {@link copyResource(File, String)}. */ @Deprecated public void copyFile(File src, String destination) { copyFile(MutableMap.of(), src, destination); } /** @deprecated since 0.5.0, destination should be a string not a File */
@Override public Map<String, String> getShellEnvironment() { return MutableMap.<String, String>builder() .putAll(super.getShellEnvironment()) .put("RABBITMQ_HOME", getRunDir()) .put("RABBITMQ_LOG_BASE", getRunDir()) .put("RABBITMQ_NODENAME", getEntity().getId()) .put("RABBITMQ_NODE_PORT", getAmqpPort().toString()) .put("RABBITMQ_PID_FILE", getRunDir()+"/"+getPidFile()) .build(); } }
public MariaDbNodeImpl getEntity() { return (MariaDbNodeImpl) super.getEntity(); } public int getPort() { return getEntity().getPort(); }
public void copyResources(Map<String, String> resources) { if (resources != null && resources.size() > 0) { log.info("Customising {} with resources: {}", entity, resources); for (Map.Entry<String, String> entry : resources.entrySet()) { String source = entry.getValue(); String dest = entry.getKey(); copyResource(source, dest); } } }
public int copyTemplate(File template, String target) { return copyTemplate(template.toURI().toASCIIString(), target); } public int copyTemplate(String template, String target) {
@Override public NginxControllerImpl getEntity() { return (NginxControllerImpl) super.getEntity(); }
public int copyResource(String resource, String target) { return copyResource(MutableMap.of(), resource, target); } @SuppressWarnings({ "unchecked", "rawtypes" })
public void copyTemplates(Map<String, String> templates) { if (templates != null && templates.size() > 0) { log.info("Customising {} with templates: {}", entity, templates); for (Map.Entry<String, String> entry : templates.entrySet()) { String source = entry.getValue(); String dest = entry.getKey(); copyTemplate(source, dest); } } }
@Override public PostgreSqlNodeImpl getEntity() { return (PostgreSqlNodeImpl) super.getEntity(); }
@Override public BindDnsServerImpl getEntity() { return (BindDnsServerImpl) super.getEntity(); }
public MySqlNodeImpl getEntity() { return (MySqlNodeImpl) super.getEntity(); } public int getPort() { return getEntity().getPort(); }
/** extracts the values for the main brooklyn.ssh.config.* config keys (i.e. those declared in ConfigKeys) * as declared on the entity, and inserts them in a map using the unprefixed state, for ssh. */ /* currently this is computed for each call, which may be wasteful, but it is reliable in the face of config changes. * we could cache the Map. note that we do _not_ cache (or even own) the SshTool; * the SshTool is created or re-used by the SshMachineLocation making use of these properties */ protected Map<String, Object> getSshFlags() { Map<String, Object> result = Maps.newLinkedHashMap(); StringConfigMap globalConfig = ((EntityInternal)getEntity()).getManagementContext().getConfig(); Map<ConfigKey<?>, Object> mgmtConfig = globalConfig.getAllConfig(); Map<ConfigKey<?>, Object> entityConfig = ((EntityInternal)getEntity()).getAllConfig(); Map<ConfigKey<?>, Object> allConfig = MutableMap.<ConfigKey<?>, Object>builder().putAll(mgmtConfig).putAll(entityConfig).build(); for (ConfigKey<?> key : allConfig.keySet()) { if (key.getName().startsWith(SshTool.BROOKLYN_CONFIG_KEY_PREFIX)) { // have to use raw config to test whether the config is set Object val = ((EntityInternal)getEntity()).getConfigMap().getRawConfig(key); if (val!=null) { val = getEntity().getConfig(key); } else { val = globalConfig.getRawConfig(key); if (val!=null) val = globalConfig.getConfig(key); } if (val!=null) { result.put(ConfigUtils.unprefixedKey(SshTool.BROOKLYN_CONFIG_KEY_PREFIX, key).getName(), val); } } } return result; }