Github user aledsage commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/642#discussion_r30494424
--- Diff:
sandbox/nosql/src/main/java/brooklyn/entity/nosql/hazelcast/HazelcastNodeSshDriver.java
---
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package brooklyn.entity.nosql.hazelcast;
+
+import static java.lang.String.format;
+import java.util.List;
+import brooklyn.entity.basic.AbstractSoftwareProcessSshDriver;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.EntityLocal;
+import brooklyn.location.basic.SshMachineLocation;
+import brooklyn.util.collections.MutableMap;
+import brooklyn.util.os.Os;
+import brooklyn.util.ssh.BashCommands;
+
+import com.google.common.collect.ImmutableList;
+
+public class HazelcastNodeSshDriver extends
AbstractSoftwareProcessSshDriver implements HazelcastNodeDriver {
+
+ public HazelcastNodeSshDriver(EntityLocal entity, SshMachineLocation
machine) {
+ super(entity, machine);
+ }
+
+ @Override
+ public void preInstall() {
+ resolver = Entities.newDownloader(this);
+ }
+
+ @Override
+ public void install() {
+ List<String> urls = resolver.getTargets();
+ String saveAs = resolver.getFilename();
+
+ List<String> commands = ImmutableList.<String>builder()
+ .add(BashCommands.installJavaLatestOrWarn())
+ .addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs))
+ .build();
+
+ newScript(INSTALLING).body.append(commands).execute();
+ }
+
+ @Override
+ public void customize() {
+
+ ImmutableList.Builder<String> commands = new
ImmutableList.Builder<String>()
+ .add("mkdir -p lib conf log")
+ .add(String.format("cp %s/%s %s/lib/", getInstallDir(),
resolver.getFilename(), getRunDir()));
+
+ newScript(CUSTOMIZING)
+ .body.append(commands.build())
+ .failOnNonZeroResultCode()
+ .execute();
+
+
copyTemplate(entity.getConfig(HazelcastNode.TEMPLATE_CONFIGURATION_URL),
Os.mergePaths(getRunDir(), "conf", getConfigFile()));
+
+ }
+
+ @Override
+ public void launch() {
+
+ entity.setAttribute(HazelcastNode.PID_FILE,
Os.mergePathsUnix(getRunDir(), PID_FILENAME));
+
+ StringBuilder commandBuilder = new StringBuilder()
+ .append(format("nohup java -cp ./lib/hazelcast-%s.jar",
getVersion()));
+
+ if (entity.getConfig(HazelcastNode.TEMPLATE_CONFIGURATION_URL) !=
null) {
+ commandBuilder.append(" -Dhazelcast.config=" +
Os.mergePaths(getRunDir(), "conf", getConfigFile()));
--- End diff --
I have a preference for using `Os.mergePathsUnix` instead. The `mergePaths`
(sort of) takes the settings of the OS running Brooklyn, rather than the target
OS that the hazelcast instance is being deployed to. But saying that, it always
uses '/' as the separator because that works on both unix and windows.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---