You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ri...@apache.org on 2014/05/28 18:05:33 UTC

[17/21] git commit: minor changes

minor changes


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/3bb421a5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/3bb421a5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/3bb421a5

Branch: refs/heads/master
Commit: 3bb421a5aedc46b809dd69c615f9af4b870dc4b0
Parents: 5257cc7
Author: ZaidM <za...@cloudsoftcorp.com>
Authored: Tue May 27 10:29:47 2014 +0100
Committer: Andrew Kennedy <an...@cloudsoftcorp.com>
Committed: Wed May 28 16:48:25 2014 +0100

----------------------------------------------------------------------
 .../brooklyn/entity/nosql/riak/RiakCluster.java |  2 +-
 .../entity/nosql/riak/RiakClusterImpl.java      | 13 ++---
 .../brooklyn/entity/nosql/riak/RiakNode.java    |  1 +
 .../entity/nosql/riak/RiakNodeImpl.java         | 59 ++++++++++++++------
 .../entity/nosql/riak/RiakNodeSshDriver.java    |  9 +--
 5 files changed, 50 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3bb421a5/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakCluster.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakCluster.java b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakCluster.java
index de65c74..af0bfee 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakCluster.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakCluster.java
@@ -21,7 +21,7 @@ public interface RiakCluster extends DynamicCluster {
     }, "riak.cluster.nodes", "Names of all active Riak nodes in the cluster <Entity,Riak Name>");
 
     @SetFromFlag("delayBeforeAdvertisingCluster")
-    ConfigKey<Duration> DELAY_BEFORE_ADVERTISING_CLUSTER = ConfigKeys.newConfigKey(Duration.class, "couchbase.cluster.delayBeforeAdvertisingCluster", "Delay after cluster is started before checking and advertising its availability", Duration.seconds(2 * 60));
+    ConfigKey<Duration> DELAY_BEFORE_ADVERTISING_CLUSTER = ConfigKeys.newConfigKey(Duration.class, "riak.cluster.delayBeforeAdvertisingCluster", "Delay after cluster is started before checking and advertising its availability", Duration.seconds(2 * 60));
 
     AttributeSensor<Boolean> IS_CLUSTER_INIT = Sensors.newBooleanSensor("riak.cluster.isClusterInit", "flag to determine if the cluster was already initialized");
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3bb421a5/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakClusterImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakClusterImpl.java b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakClusterImpl.java
index 3db99d8..183061f 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakClusterImpl.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakClusterImpl.java
@@ -66,11 +66,9 @@ public class RiakClusterImpl extends DynamicClusterImpl implements RiakCluster {
         }
     }
 
-
     protected EntitySpec<?> getMemberSpec() {
-        EntitySpec<?> result = super.getMemberSpec();
-        if (result != null) return result;
-        return EntitySpec.create(RiakNode.class);
+        return getConfig(MEMBER_SPEC, EntitySpec.create(RiakNode.class));
+
     }
 
     protected void connectSensors() {
@@ -159,8 +157,6 @@ public class RiakClusterImpl extends DynamicClusterImpl implements RiakCluster {
         if (log.isTraceEnabled()) log.trace("Done {} checkEntity {}", this, member);
     }
 
-    ;
-
     protected boolean belongsInServerPool(Entity member) {
         if (!groovyTruth(member.getAttribute(Startable.SERVICE_UP))) {
             if (log.isTraceEnabled()) log.trace("Members of {}, checking {}, eliminating because not up", this, member);
@@ -181,8 +177,8 @@ public class RiakClusterImpl extends DynamicClusterImpl implements RiakCluster {
         return node.getAttribute(RiakNode.RIAK_NODE_NAME);
     }
 
-    private Boolean hasMemberJoinedCluster(Entity member) {
-        return Optional.fromNullable(member.getAttribute(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER)).or(Boolean.FALSE);
+    private boolean hasMemberJoinedCluster(Entity member) {
+        return ((RiakNode) member).hasJoinedCluster();
     }
 
     public static class MemberTrackingPolicy extends AbstractMembershipTrackingPolicy {
@@ -191,5 +187,4 @@ public class RiakClusterImpl extends DynamicClusterImpl implements RiakCluster {
             ((RiakClusterImpl) super.entity).onServerPoolMemberChanged(entity);
         }
     }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3bb421a5/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNode.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNode.java b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNode.java
index d77e73b..47e9b5a 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNode.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNode.java
@@ -101,4 +101,5 @@ public interface RiakNode extends SoftwareProcess {
     @Effector(description = "commit changes made to a Riak cluster")
     public void commitCluster();
 
+    public boolean hasJoinedCluster();
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3bb421a5/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java
index f5e2dac..de66130 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java
@@ -9,6 +9,9 @@ import java.util.concurrent.TimeUnit;
 
 import javax.annotation.Nullable;
 
+import com.google.common.base.Function;
+import com.google.common.base.Functions;
+
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.basic.SoftwareProcessImpl;
 import brooklyn.entity.webapp.WebAppServiceMethods;
@@ -20,9 +23,6 @@ import brooklyn.location.cloud.CloudLocationConfig;
 import brooklyn.util.collections.MutableSet;
 import brooklyn.util.config.ConfigBag;
 
-import com.google.common.base.Function;
-import com.google.common.base.Functions;
-
 public class RiakNodeImpl extends SoftwareProcessImpl implements RiakNode {
 
     private volatile HttpFeed httpFeed;
@@ -44,24 +44,24 @@ public class RiakNodeImpl extends SoftwareProcessImpl implements RiakNode {
         Entities.getRequiredUrlConfig(this, RIAK_VM_ARGS_TEMPLATE_URL);
         Entities.getRequiredUrlConfig(this, RIAK_APP_CONFIG_TEMPLATE_URL);
     }
-    
+
     @Override
     protected Map<String, Object> obtainProvisioningFlags(@SuppressWarnings("rawtypes") MachineProvisioningLocation location) {
-        ConfigBag result = ConfigBag.newInstance( super.obtainProvisioningFlags(location) );
+        ConfigBag result = ConfigBag.newInstance(super.obtainProvisioningFlags(location));
         result.configure(CloudLocationConfig.OS_64_BIT, true);
         return result.getAllConfig();
     }
-    
+
     @Override
     protected Collection<Integer> getRequiredOpenPorts() {
         // TODO this creates a huge list of inbound ports; much better to define on a security group using range syntax!
         int erlangRangeStart = getConfig(ERLANG_PORT_RANGE_START).iterator().next();
         int erlangRangeEnd = getConfig(ERLANG_PORT_RANGE_END).iterator().next();
-        
-        Set<Integer> newPorts = MutableSet.<Integer>copyOf( super.getRequiredOpenPorts() );
+
+        Set<Integer> newPorts = MutableSet.<Integer>copyOf(super.getRequiredOpenPorts());
         newPorts.remove(erlangRangeStart);
         newPorts.remove(erlangRangeEnd);
-        for (int i=erlangRangeStart; i<=erlangRangeEnd; i++)
+        for (int i = erlangRangeStart; i <= erlangRangeEnd; i++)
             newPorts.add(i);
         return newPorts;
     }
@@ -125,7 +125,8 @@ public class RiakNodeImpl extends SoftwareProcessImpl implements RiakNode {
                                     public List<String> apply(@Nullable String[] strings) {
                                         return Arrays.asList(strings);
                                     }
-                                }))
+                                }
+                        ))
                         .onFailureOrException(Functions.constant(Arrays.asList(new String[0]))))
                 .build();
 
@@ -151,18 +152,42 @@ public class RiakNodeImpl extends SoftwareProcessImpl implements RiakNode {
     }
 
     @Override
-    public void commitCluster(){ getDriver().commitCluster();}
+    public void commitCluster() {
+        getDriver().commitCluster();
+    }
+
+    @Override
+    public boolean hasJoinedCluster() {
+        return Boolean.TRUE.equals(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER);
+    }
 
     @Override
     public void recoverFailedNode(String nodeName) {
         getDriver().recoverFailedNode(nodeName);
     }
 
-    public Integer getRiakWebPort() { return getAttribute(RiakNode.RIAK_WEB_PORT); }
-    public Integer getRiakPbPort() { return getAttribute(RiakNode.RIAK_PB_PORT); }
-    public Integer getHandoffListenerPort() { return getAttribute(RiakNode.HANDOFF_LISTENER_PORT); }
-    public Integer getEpmdListenerPort() { return getAttribute(RiakNode.EPMD_LISTENER_PORT); }
-    public Integer getErlangPortRangeStart() { return getAttribute(RiakNode.ERLANG_PORT_RANGE_START); }
-    public Integer getErlangPortRangeEnd() { return getAttribute(RiakNode.ERLANG_PORT_RANGE_END); }
+    public Integer getRiakWebPort() {
+        return getAttribute(RiakNode.RIAK_WEB_PORT);
+    }
+
+    public Integer getRiakPbPort() {
+        return getAttribute(RiakNode.RIAK_PB_PORT);
+    }
+
+    public Integer getHandoffListenerPort() {
+        return getAttribute(RiakNode.HANDOFF_LISTENER_PORT);
+    }
+
+    public Integer getEpmdListenerPort() {
+        return getAttribute(RiakNode.EPMD_LISTENER_PORT);
+    }
+
+    public Integer getErlangPortRangeStart() {
+        return getAttribute(RiakNode.ERLANG_PORT_RANGE_START);
+    }
+
+    public Integer getErlangPortRangeEnd() {
+        return getAttribute(RiakNode.ERLANG_PORT_RANGE_END);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3bb421a5/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java
index fc36198..fce24a5 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java
@@ -48,7 +48,7 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver implemen
         MutableMap<String, String> result = MutableMap.copyOf(super.getShellEnvironment());
         // how to change epmd port, according to 
         // http://serverfault.com/questions/582787/how-to-change-listening-interface-of-rabbitmqs-epmd-port-4369
-        result.put("ERL_EPMD_PORT", "" + getEntity().getEpmdListenerPort());
+        result.put("ERL_EPMD_PORT", "" + Integer.toString(getEntity().getEpmdListenerPort()));
         return result;
     }
 
@@ -156,7 +156,6 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver implemen
             log.warn("riak command not found on PATH. Altering future commands' environment variables from {} to {}", getShellEnvironment(), newPathVariable);
             customizeScript.environmentVariablesReset(newPathVariable);
         }
-
         customizeScript.execute();
 
         //set the riak node name
@@ -177,7 +176,6 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver implemen
             log.warn("riak command not found on PATH. Altering future commands' environment variables from {} to {}", getShellEnvironment(), newPathVariable);
             launchScript.environmentVariablesReset(newPathVariable);
         }
-
         launchScript.execute();
     }
 
@@ -199,7 +197,6 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver implemen
         }
 
         int result = stopScript.execute();
-
         if (result != 0) {
             newScript(ImmutableMap.of(USE_PID_FILE, ""), STOPPING).execute();
         }
@@ -216,9 +213,7 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver implemen
             log.warn("riak command not found on PATH. Altering future commands' environment variables from {} to {}", getShellEnvironment(), newPathVariable);
             checkRunningScript.environmentVariablesReset(newPathVariable);
         }
-
         return (checkRunningScript.execute() == 0);
-
     }
 
     public String getRiakEtcDir() {
@@ -364,7 +359,7 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver implemen
     }
 
     private Boolean hasJoinedCluster() {
-        return Optional.fromNullable(entity.getAttribute(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER)).or(Boolean.FALSE);
+        return ((RiakNode) entity).hasJoinedCluster();
     }
 
     private boolean isRiakOnPath() {