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 DDD0A11463 for ; Tue, 5 Aug 2014 13:11:33 +0000 (UTC) Received: (qmail 9216 invoked by uid 500); 5 Aug 2014 13:11:33 -0000 Delivered-To: apmail-brooklyn-dev-archive@brooklyn.apache.org Received: (qmail 9181 invoked by uid 500); 5 Aug 2014 13:11:33 -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 9170 invoked by uid 99); 5 Aug 2014 13:11:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Aug 2014 13:11:33 +0000 X-ASF-Spam-Status: No, hits=-2000.7 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 05 Aug 2014 13:11:32 +0000 Received: (qmail 8952 invoked by uid 99); 5 Aug 2014 13:11:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Aug 2014 13:11:12 +0000 Date: Tue, 5 Aug 2014 13:11:11 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@brooklyn.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (BROOKLYN-12) Add Node.JS application support MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/BROOKLYN-12?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14086239#comment-14086239 ] ASF GitHub Bot commented on BROOKLYN-12: ---------------------------------------- Github user aledsage commented on a diff in the pull request: https://github.com/apache/incubator-brooklyn/pull/94#discussion_r15810458 --- Diff: software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java --- @@ -0,0 +1,161 @@ +/* + * 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.webapp.nodejs; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import brooklyn.entity.basic.AbstractSoftwareProcessSshDriver; +import brooklyn.entity.basic.Attributes; +import brooklyn.entity.basic.SoftwareProcess; +import brooklyn.entity.webapp.WebAppService; +import brooklyn.location.basic.SshMachineLocation; +import brooklyn.util.collections.MutableList; +import brooklyn.util.collections.MutableMap; +import brooklyn.util.file.ArchiveUtils; +import brooklyn.util.os.Os; +import brooklyn.util.ssh.BashCommands; +import brooklyn.util.text.Strings; + +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; + +public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver implements NodeJsWebAppDriver { + + private static final Logger LOG = LoggerFactory.getLogger(NodeJsWebAppService.class); + + public NodeJsWebAppSshDriver(NodeJsWebAppServiceImpl entity, SshMachineLocation machine) { + super(entity, machine); + } + + public NodeJsWebAppServiceImpl getEntity() { + return (NodeJsWebAppServiceImpl) super.getEntity(); + } + + @Override + public Integer getHttpPort() { + return getEntity().getAttribute(Attributes.HTTP_PORT); + } + + @Override + public void postLaunch() { + String rootUrl = String.format("http://%s:%d/", getHostname(), getHttpPort()); + entity.setAttribute(WebAppService.ROOT_URL, rootUrl); + } + + protected Map getPortMap() { + return ImmutableMap.of("http", getEntity().getAttribute(WebAppService.HTTP_PORT)); + } + + @Override + public Set getPortsUsed() { + return ImmutableSet.builder() + .addAll(super.getPortsUsed()) + .addAll(getPortMap().values()) + .build(); + } + + @Override + public void install() { + List packages = getEntity().getConfig(NodeJsWebAppService.NODE_PACKAGE_LIST); + LOG.info("Installing Node.JS {} {}", getEntity().getConfig(SoftwareProcess.SUGGESTED_VERSION), Iterables.toString(packages)); + + List commands = MutableList.builder() --- End diff -- Personal preference for us to default to `ImmutableList` unless we really want to pass a null, or need the extra methods on the builder that aren't in the guava version. > Add Node.JS application support > ------------------------------- > > Key: BROOKLYN-12 > URL: https://issues.apache.org/jira/browse/BROOKLYN-12 > Project: Brooklyn > Issue Type: New Feature > Environment: Linux > Reporter: Andrew Kennedy > Assignee: Andrew Kennedy > > Create entities and blueprints to deploy and manage Node.JS applications and clustered services. -- This message was sent by Atlassian JIRA (v6.2#6252)