brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [2/4] brooklyn-library git commit: Remove deprecation and unnecessary syncronisation
Date Tue, 19 Jul 2016 11:56:56 GMT
Remove deprecation and unnecessary syncronisation


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

Branch: refs/heads/master
Commit: 3f965b0de8d5a60b4c26d2b4dd1868da4d5bca2a
Parents: 112080a
Author: Andrew Donald Kennedy <andrew.kennedy@cloudsoftcorp.com>
Authored: Sat Jun 25 02:25:53 2016 +0100
Committer: Andrew Donald Kennedy <andrew.kennedy@cloudsoftcorp.com>
Committed: Tue Jul 19 10:32:41 2016 +0100

----------------------------------------------------------------------
 .../brooklyn/entity/nosql/riak/RiakNode.java    | 25 +++------
 .../entity/nosql/riak/RiakNodeImpl.java         | 54 +++++++++-----------
 2 files changed, 30 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/3f965b0d/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/riak/RiakNode.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/riak/RiakNode.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/riak/RiakNode.java
index 117c31d..badfe30 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/riak/RiakNode.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/riak/RiakNode.java
@@ -21,9 +21,11 @@ package org.apache.brooklyn.entity.nosql.riak;
 import java.net.URI;
 import java.util.List;
 
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.TypeToken;
+
 import org.apache.brooklyn.api.catalog.Catalog;
 import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.api.location.PortRange;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.annotation.Effector;
@@ -31,7 +33,6 @@ import org.apache.brooklyn.core.annotation.EffectorParam;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.effector.MethodEffector;
 import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.location.PortRanges;
 import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
 import org.apache.brooklyn.core.sensor.PortAttributeSensorAndConfigKey;
 import org.apache.brooklyn.core.sensor.Sensors;
@@ -39,9 +40,6 @@ import org.apache.brooklyn.entity.java.UsesJava;
 import org.apache.brooklyn.entity.software.base.SoftwareProcess;
 import org.apache.brooklyn.util.core.flags.SetFromFlag;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.TypeToken;
-
 @Catalog(name="Riak Node", description="Riak is a distributed NoSQL key-value data store
that offers "
         + "extremely high availability, fault tolerance, operational simplicity and scalability.")
 @ImplementedBy(RiakNodeImpl.class)
@@ -133,25 +131,16 @@ public interface RiakNode extends SoftwareProcess, UsesJava {
      */
 
     @SetFromFlag("handoffListenerPort")
-    ConfigKey<Integer> HANDOFF_LISTENER_PORT = ConfigKeys.newIntegerConfigKey("riak.handoff.port.internal",
"Handoff Listener Port", 8099);
+    ConfigKey<Integer> HANDOFF_LISTENER_PORT = ConfigKeys.newIntegerConfigKey("riak.handoff.port",
"Handoff Listener Port", 8099);
 
     @SetFromFlag("epmdListenerPort")
-    ConfigKey<Integer> EPMD_LISTENER_PORT = ConfigKeys.newIntegerConfigKey("riak.epmd.port.internal",
"Erlang Port Mapper Daemon Listener Port", 4369);
-
-    @SetFromFlag("erlangPortRange")
-    ConfigKey<PortRange> ERLANG_PORT_RANGE = ConfigKeys.newConfigKey(PortRange.class,
"riak.erlang.portrange.internal", "Erlang Port Range", new PortRanges.LinearPortRange(6000,
7999));
-
-    // TODO Change {@link #ERLANG_PORT_RANGE_START} and {@link #ERLANG_PORT_RANGE_END} to
sensors
+    ConfigKey<Integer> EPMD_LISTENER_PORT = ConfigKeys.newIntegerConfigKey("riak.epmd.port",
"Erlang Port Mapper Daemon Listener Port", 4369);
 
-    /** @deprecated since 0.10.0; use {@link #ERLANG_PORT_RANGE} instead */
-    @Deprecated
     @SetFromFlag("erlangPortRangeStart")
-    AttributeSensorAndConfigKey<Integer, Integer> ERLANG_PORT_RANGE_START = ConfigKeys.newIntegerSensorAndConfigKey("riak.erlang.portrange.start.internal",
"Erlang Port Range Start");
+    AttributeSensorAndConfigKey<Integer, Integer> ERLANG_PORT_RANGE_START = ConfigKeys.newIntegerSensorAndConfigKey("riak.erlang.portrange.start",
"Erlang Port Range Start");
 
-    /** @deprecated since 0.10.0; use {@link #ERLANG_PORT_RANGE} instead */
-    @Deprecated
     @SetFromFlag("erlangPortRangeEnd")
-    AttributeSensorAndConfigKey<Integer, Integer> ERLANG_PORT_RANGE_END = ConfigKeys.newIntegerSensorAndConfigKey("riak.erlang.portrange.end.internal",
"Erlang Port Range End");
+    AttributeSensorAndConfigKey<Integer, Integer> ERLANG_PORT_RANGE_END = ConfigKeys.newIntegerSensorAndConfigKey("riak.erlang.portrange.end",
"Erlang Port Range End");
 
     @SetFromFlag("configInternalNetworking")
     ConfigKey<Boolean> CONFIGURE_INTERNAL_NETWORKING = ConfigKeys.newBooleanConfigKey("riak.networking.internal",
"Set up internal networking for intra-node communication", Boolean.TRUE);

http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/3f965b0d/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/riak/RiakNodeImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/riak/RiakNodeImpl.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/riak/RiakNodeImpl.java
index b5c6d85..1d3432d 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/riak/RiakNodeImpl.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/riak/RiakNodeImpl.java
@@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Function;
 import com.google.common.base.Functions;
 import com.google.common.base.Preconditions;
-import com.google.common.collect.Iterables;
 import com.google.common.net.HostAndPort;
 
 import org.jclouds.net.domain.IpPermission;
@@ -40,7 +39,6 @@ import org.jclouds.net.domain.IpProtocol;
 
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.location.MachineProvisioningLocation;
-import org.apache.brooklyn.api.location.PortRange;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.location.access.BrooklynAccessUtils;
@@ -110,11 +108,8 @@ public class RiakNodeImpl extends SoftwareProcessImpl implements RiakNode
{
 
     @Override
     protected Collection<Integer> getRequiredOpenPorts() {
-        PortRange erlangPorts = config().get(ERLANG_PORT_RANGE);
         Integer erlangRangeStart = config().get(ERLANG_PORT_RANGE_START);
         Integer erlangRangeEnd = config().get(ERLANG_PORT_RANGE_END);
-        if (erlangRangeStart == null) erlangRangeStart = Iterables.get(erlangPorts, 0);
-        if (erlangRangeEnd == null) erlangRangeEnd = Iterables.getLast(erlangPorts);
         sensors().set(ERLANG_PORT_RANGE_START, erlangRangeStart);
         sensors().set(ERLANG_PORT_RANGE_END, erlangRangeEnd);
 
@@ -135,34 +130,31 @@ public class RiakNodeImpl extends SoftwareProcessImpl implements RiakNode
{
         JcloudsMachineLocation machine = (JcloudsMachineLocation) location;
         JcloudsLocationSecurityGroupCustomizer customizer = JcloudsLocationSecurityGroupCustomizer.getInstance(getApplicationId());
 
-        synchronized (getParent()) {
-            String cidr = Cidr.UNIVERSAL.toString(); // TODO configure with a more restrictive
CIDR
-            Collection<IpPermission> permissions = MutableList.<IpPermission>builder()
-                    .add(IpPermission.builder()
-                            .ipProtocol(IpProtocol.TCP)
-                            .fromPort(sensors().get(ERLANG_PORT_RANGE_START))
-                            .toPort(sensors().get(ERLANG_PORT_RANGE_END))
-                            .cidrBlock(cidr)
-                            .build())
-                    .add(IpPermission.builder()
-                            .ipProtocol(IpProtocol.TCP)
-                            .fromPort(config().get(HANDOFF_LISTENER_PORT))
-                            .toPort(config().get(HANDOFF_LISTENER_PORT))
-                            .cidrBlock(cidr)
-                            .build())
-                    .add(IpPermission.builder()
-                            .ipProtocol(IpProtocol.TCP)
-                            .fromPort(config().get(EPMD_LISTENER_PORT))
-                            .toPort(config().get(EPMD_LISTENER_PORT))
-                            .cidrBlock(cidr)
-                            .build())
-                     .build();
-            LOG.debug("Applying custom security groups to {}: {}", machine, permissions);
-            customizer.addPermissionsToLocation(machine, permissions);
-        }
+        String cidr = Cidr.UNIVERSAL.toString(); // TODO configure with a more restrictive
CIDR
+        Collection<IpPermission> permissions = MutableList.<IpPermission>builder()
+                .add(IpPermission.builder()
+                        .ipProtocol(IpProtocol.TCP)
+                        .fromPort(sensors().get(ERLANG_PORT_RANGE_START))
+                        .toPort(sensors().get(ERLANG_PORT_RANGE_END))
+                        .cidrBlock(cidr)
+                        .build())
+                .add(IpPermission.builder()
+                        .ipProtocol(IpProtocol.TCP)
+                        .fromPort(config().get(HANDOFF_LISTENER_PORT))
+                        .toPort(config().get(HANDOFF_LISTENER_PORT))
+                        .cidrBlock(cidr)
+                        .build())
+                .add(IpPermission.builder()
+                        .ipProtocol(IpProtocol.TCP)
+                        .fromPort(config().get(EPMD_LISTENER_PORT))
+                        .toPort(config().get(EPMD_LISTENER_PORT))
+                        .cidrBlock(cidr)
+                        .build())
+                 .build();
+        LOG.debug("Applying custom security groups to {}: {}", machine, permissions);
+        customizer.addPermissionsToLocation(machine, permissions);
     }
 
-
     @Override
     public void connectSensors() {
         super.connectSensors();


Mime
View raw message