Java Code Examples for org.apache.brooklyn.util.os.Os#mergePathsUnix()
The following examples show how to use
org.apache.brooklyn.util.os.Os#mergePathsUnix() .
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: CouchDBNodeSshDriver.java From brooklyn-library with Apache License 2.0 | 6 votes |
@Override public void customize() { log.info("Customizing {} (Cluster {})", entity, getClusterName()); Networking.checkPortsValid(getPortMap()); ScriptHelper script = newScript(CUSTOMIZING).body .append(format("mkdir -p %s", getRunDir())); if (isV2()) { script.body.append(format("mkdir -p %s/rel/couchdb/etc/local.d", getExpandedInstallDir())); } else { script.body.append(format("cp -R %s/dist/{bin,etc,lib,share,var} %s", getExpandedInstallDir(), getRunDir())); } script.execute(); String destinationConfigFile = Os.mergePathsUnix(getRunDir(), getCouchDBConfigFileName()); if (isV2()) { destinationConfigFile = Os.mergePathsUnix(getExpandedInstallDir(), "/rel/couchdb/etc/local.d", getCouchDBConfigFileName()); } // Copy the configuration files across copyTemplate(getCouchDBConfigTemplateUrl(), destinationConfigFile); String destinationUriFile = Os.mergePathsUnix(getRunDir(), "couch.uri"); copyTemplate(getCouchDBUriTemplateUrl(), destinationUriFile); }
Example 2
Source File: ActiveMQSshDriver.java From brooklyn-library with Apache License 2.0 | 6 votes |
@Override public void customize() { Networking.checkPortsValid(ImmutableMap.of("jmxPort", getJmxPort(), "openWirePort", getOpenWirePort())); newScript(CUSTOMIZING) .body.append( format("cp -R %s/{bin,conf,data,lib,webapps} .", getExpandedInstallDir()), // Required in version 5.5.1 (at least), but not in version 5.7.0 "sed -i.bk 's/\\[-z \"$JAVA_HOME\"]/\\[ -z \"$JAVA_HOME\" ]/g' bin/activemq", // Stop it writing to dev null on start "sed -i.bk \"s/\\(ACTIVEMQ_HOME..bin.run.jar.*\\)>.dev.null/\\1/\" bin/activemq", // Required if launching multiple AMQ's, prevent jetty port conflicts "sed -i.bk 's/8161/"+getEntity().getAttribute(ActiveMQBroker.AMQ_JETTY_PORT)+"/g' conf/jetty.xml" // TODO disable persistence (this should be a flag -- but it seems to have no effect, despite ): // "sed -i.bk 's/broker /broker persistent=\"false\" /g' conf/activemq.xml", ) .execute(); // Copy the configuration file across String destinationConfigFile = Os.mergePathsUnix(getRunDir(), "conf/activemq.xml"); copyTemplate(getTemplateConfigurationUrl(), destinationConfigFile); }
Example 3
Source File: MySqlClusterIntegrationTest.java From brooklyn-library with Apache License 2.0 | 5 votes |
private boolean fileExists(MySqlNode node, String binLogName) { String dataDir = Strings.nullToEmpty(node.getConfig(MySqlNode.DATA_DIR)); String path = Os.mergePathsUnix(dataDir, binLogName); String cmd = BashCommands.chain( "cd $RUN_DIR", BashCommands.requireTest(String.format("-f \"%s\"", path), "File " + path + " doesn't exist.")); String summary = "Check if file " + path + " exists"; SshMachineLocation machine = EffectorTasks.getSshMachine(node); return Entities.submit(node, SshTasks.newSshExecTaskFactory(machine, cmd) .allowingNonZeroExitCode() .environmentVariable("RUN_DIR", node.getAttribute(SoftwareProcess.RUN_DIR)) .summary(summary) .allowingNonZeroExitCode()).asTask().getUnchecked() == 0; }
Example 4
Source File: AbstractSoftwareProcessSshDriver.java From brooklyn-server with Apache License 2.0 | 5 votes |
/** * Input stream will be closed automatically. * <p> * If using {@link SshjTool} usage, consider using {@link KnownSizeInputStream} to avoid having * to write out stream once to find its size! * * @see #copyResource(Map, String, String) for parameter descriptions. */ @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public int copyResource(Map<Object,Object> sshFlags, InputStream source, String target, boolean createParentDir) { Map flags = Maps.newLinkedHashMap(); if (!sshFlags.containsKey(IGNORE_ENTITY_SSH_FLAGS)) { flags.putAll(getSshFlags()); } flags.putAll(sshFlags); String destination = Os.isAbsolutish(target) ? target : Os.mergePathsUnix(getRunDir(), target); if (createParentDir) { // don't use File.separator because it's remote machine's format, rather than local machine's int lastSlashIndex = destination.lastIndexOf("/"); String parent = (lastSlashIndex > 0) ? destination.substring(0, lastSlashIndex) : null; if (parent != null) { getMachine().execCommands("createParentDir", ImmutableList.of("mkdir -p "+parent)); } } // TODO SshMachineLocation.copyTo currently doesn't log warn on non-zero or set blocking details // (because delegated to by installTo, for multiple calls). So do it here for now. int result; String prevBlockingDetails = Tasks.setBlockingDetails("copying resource to server at "+destination); try { result = getMachine().copyTo(flags, source, destination); } finally { Tasks.setBlockingDetails(prevBlockingDetails); } if (result == 0) { log.debug("copying stream complete; {} on {}", new Object[] { destination, getMachine() }); } else { log.warn("copying stream failed; {} on {}: {}", new Object[] { destination, getMachine(), result }); } return result; }
Example 5
Source File: JavaSoftwareProcessSshDriverIntegrationTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test(groups = "Integration") public void testStartsInAppSpecifiedDirectoryUnderHome() throws Exception { String dir = Os.mergePathsUnix("~/.brooklyn-test-"+Strings.makeRandomId(4)); try { app.config().set(BrooklynConfigKeys.ONBOX_BASE_DIR, dir); doTestSpecifiedDirectory(dir, dir); } finally { Os.deleteRecursively(dir); } }
Example 6
Source File: CassandraNodeSshDriver.java From brooklyn-library with Apache License 2.0 | 5 votes |
@Override public ProcessTaskWrapper<Integer> executeScriptAsync(String commands) { String fileToRun = Os.mergePathsUnix("brooklyn_commands", "cassandra-commands-"+Identifiers.makeRandomId(8)); TaskWrapper<Void> task = SshEffectorTasks.put(Os.mergePathsUnix(getRunDir(), fileToRun)) .machine(getMachine()) .contents(commands) .summary("copying cassandra script to execute "+fileToRun) .newTask(); DynamicTasks.queueIfPossible(task).orSubmitAndBlock(getEntity()).andWaitForSuccess(); return executeScriptFromInstalledFileAsync(fileToRun); }
Example 7
Source File: JavaSoftwareProcessSshDriverIntegrationTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test(groups = "Integration") public void testStartsInMgmtSpecifiedDirectory() throws Exception { String dir = Os.mergePathsUnix(Os.tmp(), "/brooklyn-test-"+Strings.makeRandomId(4)); tearDown(); mgmt = new LocalManagementContextForTests(); mgmt.getBrooklynProperties().put(BrooklynConfigKeys.ONBOX_BASE_DIR, dir); setUp(); doTestSpecifiedDirectory(dir, dir); Os.deleteRecursively(dir); }
Example 8
Source File: CassandraNodeSshDriver.java From brooklyn-library with Apache License 2.0 | 5 votes |
@Override public void customize() { log.debug("Customizing {} (Cluster {})", entity, getClusterName()); Networking.checkPortsValid(getPortMap()); customizeInitialSeeds(); String logFileEscaped = getLogFileLocation().replace("/", "\\/"); // escape slashes ImmutableList.Builder<String> commands = new ImmutableList.Builder<String>() .add(String.format("cp -R %s/{bin,conf,lib,interface,pylib,tools} .", getExpandedInstallDir())) .add("mkdir -p data") .add("mkdir -p brooklyn_commands") .add(String.format("sed -i.bk 's/log4j.appender.R.File=.*/log4j.appender.R.File=%s/g' %s/conf/log4j-server.properties", logFileEscaped, getRunDir())) .add(String.format("sed -i.bk '/JMX_PORT/d' %s/conf/cassandra-env.sh", getRunDir())) // Script sets 180k on Linux which gives Java error: The stack size specified is too small, Specify at least 228k .add(String.format("sed -i.bk 's/-Xss180k/-Xss280k/g' %s/conf/cassandra-env.sh", getRunDir())); newScript(CUSTOMIZING) .body.append(commands.build()) .failOnNonZeroResultCode() .execute(); // Copy the cassandra.yaml configuration file across String destinationConfigFile = Os.mergePathsUnix(getRunDir(), "conf", getCassandraConfigFileName()); copyTemplate(getCassandraConfigTemplateUrl(), destinationConfigFile); // Copy the cassandra-rackdc.properties configuration file across String rackdcDestinationFile = Os.mergePathsUnix(getRunDir(), "conf", getCassandraRackdcConfigFileName()); copyTemplate(getCassandraRackdcConfigTemplateUrl(), rackdcDestinationFile); customizeCopySnitch(); }
Example 9
Source File: StormSshDriver.java From brooklyn-library with Apache License 2.0 | 4 votes |
@Override protected String getLogFileLocation() { return Os.mergePathsUnix(getRunDir(), "logs", format("%s.log", getRoleName())); }
Example 10
Source File: TomcatSshDriver.java From brooklyn-library with Apache License 2.0 | 4 votes |
@Override protected String getLogFileLocation() { return Os.mergePathsUnix(getRunDir(), "logs/catalina.out"); }
Example 11
Source File: AbstractSoftwareProcessDriver.java From brooklyn-server with Apache License 2.0 | 4 votes |
protected String mergePaths(String ...s) { return Os.mergePathsUnix(s); }
Example 12
Source File: ZooKeeperSshDriver.java From brooklyn-library with Apache License 2.0 | 4 votes |
@Override protected String getLogFileLocation() { return Os.mergePathsUnix(getRunDir(), "console.out"); }
Example 13
Source File: BrooklynNodeSshDriver.java From brooklyn-server with Apache License 2.0 | 4 votes |
protected String getPidFile() { return Os.mergePathsUnix(getRunDir(), "pid_java"); }
Example 14
Source File: JBoss6SshDriver.java From brooklyn-library with Apache License 2.0 | 4 votes |
@Override protected String getLogFileLocation() { return Os.mergePathsUnix(getRunDir(), "server", SERVER_TYPE, "log/server.log"); }
Example 15
Source File: BrooklynNodeSshDriver.java From brooklyn-server with Apache License 2.0 | 4 votes |
@Override protected String getLogFileLocation() { return Os.mergePathsUnix(getRunDir(), "console"); }
Example 16
Source File: ActiveMQSshDriver.java From brooklyn-library with Apache License 2.0 | 4 votes |
@Override protected String getLogFileLocation() { return Os.mergePathsUnix(getRunDir(), "data/activemq.log"); }
Example 17
Source File: VanillaSoftwareProcessSshDriver.java From brooklyn-server with Apache License 2.0 | 4 votes |
public String getPidFile() { // TODO see note in VanillaSoftwareProcess about PID_FILE as a config key // if (getEntity().getConfigRaw(PID_FILE, includeInherited)) ... return Os.mergePathsUnix(getRunDir(), PID_FILENAME); }
Example 18
Source File: JBoss7SshDriver.java From brooklyn-library with Apache License 2.0 | 4 votes |
/** * AS7 config notes and TODOs: * We're using the http management interface on port managementPort * We're not using any JMX. * - AS 7 simply doesn't boot with Sun JMX enabled (https://issues.jboss.org/browse/JBAS-7427) * - 7.1 onwards uses Remoting 3, which we haven't configured * - We have generic support for jmxmp, which one could configure * We're completely disabling security on the management interface. * - In the future we probably want to use the as7/bin/add-user.sh script using config keys for user and password * - Or we could create our own security realm and use that. * We disable the root welcome page, since we can't deploy our own root otherwise * We bind all interfaces to entity.hostname, rather than 127.0.0.1. */ @Override public void customize() { // Check that a password was set for the management user Preconditions.checkState(Strings.isNonBlank(getManagementUsername()), "User for management realm required"); String managementPassword = getManagementPassword(); if (Strings.isBlank(managementPassword)) { LOG.debug(this+" has no password specified for "+JBoss7Server.MANAGEMENT_PASSWORD.getName()+"; using a random string"); entity.config().set(JBoss7Server.MANAGEMENT_PASSWORD, Identifiers.makeRandomPassword(8)); } String hashedPassword = hashPassword(getManagementUsername(), getManagementPassword(), MANAGEMENT_REALM); // Check that ports are all configured Map<String,Integer> ports = MutableMap.<String,Integer>builder() .put("managementHttpPort", getManagementHttpPort()) .put("managementHttpsPort", getManagementHttpsPort()) .put("managementNativePort", getManagementNativePort()) .build(); if (isProtocolEnabled("HTTP")) { ports.put("httpPort", getHttpPort()); } if (isProtocolEnabled("HTTPS")) { ports.put("httpsPort", getHttpsPort()); } Networking.checkPortsValid(ports); // Check hostname is defined String hostname = entity.getAttribute(SoftwareProcess.HOSTNAME); Preconditions.checkNotNull(hostname, "AS 7 entity must set hostname otherwise server will only be visible on localhost"); // Copy the install files to the run-dir and add the management user newScript(CUSTOMIZING) // don't set vars yet -- it resolves dependencies (e.g. DB) which we don't want until we start .environmentVariablesReset() .body.append( format("cp -r %s/%s . || exit $!", getExpandedInstallDir(), SERVER_TYPE), format("echo -e '\n%s=%s' >> %s/%s/configuration/mgmt-users.properties", getManagementUsername(), hashedPassword, getRunDir(), SERVER_TYPE) ) .execute(); // Copy the keystore across, if there is one if (isProtocolEnabled("HTTPS")) { String keystoreUrl = Preconditions.checkNotNull(getSslKeystoreUrl(), "keystore URL must be specified if using HTTPS for "+entity); String destinationSslKeystoreFile = getSslKeystoreFile(); InputStream keystoreStream = resource.getResourceFromUrl(keystoreUrl); getMachine().copyTo(keystoreStream, destinationSslKeystoreFile); } // Copy the configuration file across String destinationConfigFile = Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "configuration", CONFIG_FILE); copyTemplate(getTemplateConfigurationUrl(), destinationConfigFile); // Copy the initial wars to the deploys directory getEntity().deployInitialWars(); }
Example 19
Source File: CouchDBNodeSshDriver.java From brooklyn-library with Apache License 2.0 | votes |
public String getPidFile() { return Os.mergePathsUnix(getRunDir(), "couchdb.pid"); }
Example 20
Source File: CouchDBNodeSshDriver.java From brooklyn-library with Apache License 2.0 | votes |
public String getLogFileLocation() { return Os.mergePathsUnix(getRunDir(), "couchdb.log"); }