Return-Path: X-Original-To: apmail-brooklyn-dev-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 65B5818177 for ; Mon, 18 May 2015 09:49:07 +0000 (UTC) Received: (qmail 24777 invoked by uid 500); 18 May 2015 09:49:07 -0000 Delivered-To: apmail-brooklyn-dev-archive@brooklyn.apache.org Received: (qmail 24737 invoked by uid 500); 18 May 2015 09:49:07 -0000 Mailing-List: contact dev-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list dev@brooklyn.incubator.apache.org Received: (qmail 24724 invoked by uid 99); 18 May 2015 09:49:07 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 May 2015 09:49:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id D2C7E1823FE for ; Mon, 18 May 2015 09:49:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.971 X-Spam-Level: X-Spam-Status: No, score=0.971 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id R85YnvfcUbps for ; Mon, 18 May 2015 09:49:00 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id 6160A2143E for ; Mon, 18 May 2015 09:49:00 +0000 (UTC) Received: (qmail 24568 invoked by uid 99); 18 May 2015 09:49:00 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 May 2015 09:49:00 +0000 Date: Mon, 18 May 2015 09:49:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@brooklyn.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (BROOKLYN-143) Add support for Hazelcast MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/BROOKLYN-143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14547786#comment-14547786 ] 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_r30493993 --- 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 urls = resolver.getTargets(); + String saveAs = resolver.getFilename(); + + List commands = ImmutableList.builder() + .add(BashCommands.installJavaLatestOrWarn()) + .addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs)) + .build(); + + newScript(INSTALLING).body.append(commands).execute(); + } + + @Override + public void customize() { + + ImmutableList.Builder commands = new ImmutableList.Builder() + .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())); --- End diff -- I see you've followed the same pattern as elsewhere for setting the `resolver` field in the superclass. However, I think that might be a (subtly) bad pattern. If we stop and restart Brooklyn, then it restores the entities based on their config+attributes, and calling `rebind()`. I don't think anything will re-set the `resolver` field in the driver. I suggest you don't worry about that in your pull request. We should refactor + fix that across the board (probably in the super-class) in a separate pull request, rather than doing something specific for hazelcast. > 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)