Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 961F5200B25 for ; Wed, 8 Jun 2016 12:24:18 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 94CB6160A2E; Wed, 8 Jun 2016 10:24:18 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E0019160A29 for ; Wed, 8 Jun 2016 12:24:17 +0200 (CEST) Received: (qmail 22698 invoked by uid 500); 8 Jun 2016 10:24:17 -0000 Mailing-List: contact dev-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list dev@brooklyn.apache.org Received: (qmail 22687 invoked by uid 99); 8 Jun 2016 10:24:16 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jun 2016 10:24:16 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 906E7DFF68; Wed, 8 Jun 2016 10:24:16 +0000 (UTC) From: neykov To: dev@brooklyn.apache.org Reply-To: dev@brooklyn.apache.org References: In-Reply-To: Subject: [GitHub] brooklyn-server pull request #177: Adds PublicNetworkFaceEnricher Content-Type: text/plain Message-Id: <20160608102416.906E7DFF68@git1-us-west.apache.org> Date: Wed, 8 Jun 2016 10:24:16 +0000 (UTC) archived-at: Wed, 08 Jun 2016 10:24:18 -0000 Github user neykov commented on a diff in the pull request: https://github.com/apache/brooklyn-server/pull/177#discussion_r66230638 --- Diff: core/src/main/java/org/apache/brooklyn/core/network/OnPublicNetworkEnricher.java --- @@ -0,0 +1,496 @@ +/* + * 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 org.apache.brooklyn.core.network; + +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Collection; + +import org.apache.brooklyn.api.entity.Entity; +import org.apache.brooklyn.api.entity.EntityLocal; +import org.apache.brooklyn.api.location.Location; +import org.apache.brooklyn.api.location.MachineLocation; +import org.apache.brooklyn.api.sensor.AttributeSensor; +import org.apache.brooklyn.api.sensor.Sensor; +import org.apache.brooklyn.api.sensor.SensorEvent; +import org.apache.brooklyn.api.sensor.SensorEventListener; +import org.apache.brooklyn.config.ConfigKey; +import org.apache.brooklyn.core.config.ConfigKeys; +import org.apache.brooklyn.core.enricher.AbstractEnricher; +import org.apache.brooklyn.core.entity.AbstractEntity; +import org.apache.brooklyn.core.location.Machines; +import org.apache.brooklyn.core.location.access.PortForwardManager; +import org.apache.brooklyn.core.location.access.PortForwardManagerLocationResolver; +import org.apache.brooklyn.core.location.access.PortForwardManager.AssociationListener; +import org.apache.brooklyn.core.location.access.PortForwardManager.AssociationMetadata; +import org.apache.brooklyn.core.sensor.Sensors; +import org.apache.brooklyn.util.core.flags.TypeCoercions; +import org.apache.brooklyn.util.exceptions.Exceptions; +import org.apache.brooklyn.util.guava.Maybe; +import org.apache.brooklyn.util.net.Networking; +import org.apache.brooklyn.util.text.StringPredicates; +import org.apache.brooklyn.util.text.Strings; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.annotations.Beta; +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.Lists; +import com.google.common.net.HostAndPort; +import com.google.common.reflect.TypeToken; + +/** + * Can be added to an entity so that it advertises its mapped ports (according to the port-mappings + * recorded in the PortForwardManager). This can be used with sensors of type URI, HostAndPort + * or plain integer port values. The port-mappings is retrieved by looking up the entity's machine + * and the private port, in the PortForwardManager's recorded port-mappings. + * + * For example, to configure each Tomcat node to publish its mapped uri, and to use that sensor + * in Nginx for the target servers: + *
    + * {@code
    + * services:
    + * - type: cluster
    + *   id: cluster
    + *   brooklyn.config:
    + *    memberSpec:
    + *      $brooklyn:entitySpec:
    + *        type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
    + *        brooklyn.enrichers:
    + *        - type: org.apache.brooklyn.core.location.access.PublicNetworkFaceEnricher
    --- End diff --
    
    Update class name in the example


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---