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 0C41B1190F for ; Wed, 9 Jul 2014 09:58:42 +0000 (UTC) Received: (qmail 20801 invoked by uid 500); 9 Jul 2014 09:58:42 -0000 Delivered-To: apmail-brooklyn-dev-archive@brooklyn.apache.org Received: (qmail 20755 invoked by uid 500); 9 Jul 2014 09:58:41 -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 20744 invoked by uid 99); 9 Jul 2014 09:58:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jul 2014 09:58:41 +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; Wed, 09 Jul 2014 09:58:40 +0000 Received: (qmail 20635 invoked by uid 99); 9 Jul 2014 09:58:20 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jul 2014 09:58:20 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id DC5419A91ED; Wed, 9 Jul 2014 09:58:19 +0000 (UTC) From: aledsage To: dev@brooklyn.incubator.apache.org Reply-To: dev@brooklyn.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-brooklyn pull request: Couchbase sync gateway Content-Type: text/plain Message-Id: <20140709095819.DC5419A91ED@tyr.zones.apache.org> Date: Wed, 9 Jul 2014 09:58:19 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Github user aledsage commented on a diff in the pull request: https://github.com/apache/incubator-brooklyn/pull/25#discussion_r14701633 --- Diff: software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewayImpl.java --- @@ -0,0 +1,66 @@ +package brooklyn.entity.nosql.couchbase; + + +import brooklyn.config.render.RendererHints; +import brooklyn.entity.basic.SoftwareProcessImpl; +import brooklyn.event.feed.http.HttpFeed; +import brooklyn.event.feed.http.HttpPollConfig; +import brooklyn.event.feed.http.HttpValueFunctions; +import brooklyn.location.access.BrooklynAccessUtils; + +import com.google.common.net.HostAndPort; + +public class CouchbaseSyncGatewayImpl extends SoftwareProcessImpl implements CouchbaseSyncGateway { + + private HttpFeed httpFeed; + + @Override + public Class getDriverInterface() { + return CouchbaseSyncGatewayDriver.class; + } + + @Override + protected void connectSensors() { + super.connectSensors(); + connectServiceUpIsRunning(); + } + + @Override + protected void connectServiceUpIsRunning() { + + + HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, + getAttribute(CouchbaseSyncGateway.ADMIN_REST_API_PORT)); + + String managementUri = String.format("http://%s:%s", + hp.getHostText(), hp.getPort()); + + setAttribute(MANAGEMENT_URL, managementUri); + + httpFeed = HttpFeed.builder() + .entity(this) + .period(200) + .baseUri(managementUri) + .poll(new HttpPollConfig(SERVICE_UP) + .onSuccess(HttpValueFunctions.responseCodeEquals(200))) + .build(); + + } + + @Override + protected void disconnectSensors() { + super.disconnectSensors(); + disconnectServiceUpIsRunning(); + } + + @Override + protected void disconnectServiceUpIsRunning() { + if (httpFeed != null) { + httpFeed.stop(); + } + } + + static { + RendererHints.register(MANAGEMENT_URL, new RendererHints.NamedActionWithUrl("Open")); --- End diff -- If the `MANAGEMENT_URL` were of type `URL` or `URI` then we could do this rendering automatically. That's a pretty good reason for using the stronger typing, rather than Strings everywhere. @grkvlt i presume you agree? Is it easy to add the rendering hint automatically for any attribute of type URI/URL? --- 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. ---