[
https://issues.apache.org/jira/browse/BROOKLYN-143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14547792#comment-14547792
]
ASF GitHub Bot commented on BROOKLYN-143:
-----------------------------------------
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.
> Add support for Hazelcast
> -------------------------
>
> Key: BROOKLYN-143
> URL: https://issues.apache.org/jira/browse/BROOKLYN-143
> Project: Brooklyn
> Issue Type: New Feature
> Reporter: Yavor Yanchev
> Priority: Minor
>
> Hazelcast is a clustering and highly scalable data distribution platform for
> Java.
> Some of the features it provides
> Distributed java.util.{Queue, Set, List, Map}
> Distributed java.util.concurrency.locks.Lock
> Distributed java.util.concurrent.ExecutorService
> Distributed Indexing and Query support
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)