brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Couchbase sync gateway
Date Wed, 09 Jul 2014 09:58:19 GMT
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<CouchbaseSyncGatewayDriver> 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<Boolean>(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.
---

Mime
View raw message