brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [3/5] incubator-brooklyn git commit: Cassandra: change deprecated setConfig/setAttrib
Date Thu, 17 Sep 2015 10:31:00 GMT
Cassandra: change deprecated setConfig/setAttrib


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

Branch: refs/heads/master
Commit: 5385f347b5040f81343d3de57a6d9ac5b2acdb9d
Parents: a5c4b16
Author: Aled Sage <aled.sage@gmail.com>
Authored: Tue Sep 15 09:25:10 2015 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Tue Sep 15 11:06:58 2015 +0100

----------------------------------------------------------------------
 .../cassandra/CassandraDatacenterImpl.java      | 26 ++++++++++----------
 .../nosql/cassandra/CassandraFabricImpl.java    | 26 ++++++++++----------
 .../entity/nosql/cassandra/CassandraNode.java   |  1 +
 .../nosql/cassandra/CassandraNodeImpl.java      | 14 +++++------
 .../nosql/cassandra/CassandraNodeSshDriver.java | 10 ++++----
 .../nosql/cassandra/CassandraFabricTest.java    |  8 +++---
 6 files changed, 43 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5385f347/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterImpl.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterImpl.java
index 27f83aa..3678bb2 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterImpl.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterImpl.java
@@ -197,8 +197,8 @@ public class CassandraDatacenterImpl extends DynamicClusterImpl implements
Cassa
                     if (!(oldDcName.isPresent() && dcName.equals(oldDcName.get())))
{
                         mutableDatacenterUsage.values().remove(member);
                         mutableDatacenterUsage.put(dcName, member);
-                        setAttribute(DATACENTER_USAGE, mutableDatacenterUsage);
-                        setAttribute(DATACENTERS, Sets.newLinkedHashSet(mutableDatacenterUsage.keySet()));
+                        sensors().set(DATACENTER_USAGE, mutableDatacenterUsage);
+                        sensors().set(DATACENTERS, Sets.newLinkedHashSet(mutableDatacenterUsage.keySet()));
                     }
                 }
             }
@@ -218,8 +218,8 @@ public class CassandraDatacenterImpl extends DynamicClusterImpl implements
Cassa
                 if (datacenterUsage != null && datacenterUsage.containsValue(entity))
{
                     Multimap<String, Entity> mutableDatacenterUsage = LinkedHashMultimap.create(datacenterUsage);
                     mutableDatacenterUsage.values().remove(entity);
-                    setAttribute(DATACENTER_USAGE, mutableDatacenterUsage);
-                    setAttribute(DATACENTERS, Sets.newLinkedHashSet(mutableDatacenterUsage.keySet()));
+                    sensors().set(DATACENTER_USAGE, mutableDatacenterUsage);
+                    sensors().set(DATACENTERS, Sets.newLinkedHashSet(mutableDatacenterUsage.keySet()));
                 }
             }
         });
@@ -340,7 +340,7 @@ public class CassandraDatacenterImpl extends DynamicClusterImpl implements
Cassa
                 "due to assumptions Cassandra makes about the use of the same port numbers
used across the cluster.");
 
         // force this to be set - even if it is using the default
-        setAttribute(CLUSTER_NAME, getConfig(CLUSTER_NAME));
+        sensors().set(CLUSTER_NAME, getConfig(CLUSTER_NAME));
         
         super.start(locations);
 
@@ -457,8 +457,8 @@ public class CassandraDatacenterImpl extends DynamicClusterImpl implements
Cassa
             Optional<Entity> upNode = Iterables.tryFind(getMembers(), EntityPredicates.attributeEqualTo(SERVICE_UP,
Boolean.TRUE));
 
             if (upNode.isPresent()) {
-                setAttribute(HOSTNAME, upNode.get().getAttribute(Attributes.HOSTNAME));
-                setAttribute(THRIFT_PORT, upNode.get().getAttribute(CassandraNode.THRIFT_PORT));
+                sensors().set(HOSTNAME, upNode.get().getAttribute(Attributes.HOSTNAME));
+                sensors().set(THRIFT_PORT, upNode.get().getAttribute(CassandraNode.THRIFT_PORT));
 
                 List<String> currentNodes = getAttribute(CASSANDRA_CLUSTER_NODES);
                 Set<String> oldNodes = (currentNodes != null) ? ImmutableSet.copyOf(currentNodes)
: ImmutableSet.<String>of();
@@ -473,12 +473,12 @@ public class CassandraDatacenterImpl extends DynamicClusterImpl implements
Cassa
                     }
                 }
                 if (Sets.symmetricDifference(oldNodes, newNodes).size() > 0) {
-                    setAttribute(CASSANDRA_CLUSTER_NODES, MutableList.copyOf(newNodes));
+                    sensors().set(CASSANDRA_CLUSTER_NODES, MutableList.copyOf(newNodes));
                 }
             } else {
-                setAttribute(HOSTNAME, null);
-                setAttribute(THRIFT_PORT, null);
-                setAttribute(CASSANDRA_CLUSTER_NODES, Collections.<String>emptyList());
+                sensors().set(HOSTNAME, null);
+                sensors().set(THRIFT_PORT, null);
+                sensors().set(CASSANDRA_CLUSTER_NODES, Collections.<String>emptyList());
             }
 
             ServiceNotUpLogic.updateNotUpIndicatorRequiringNonEmptyList(this, CASSANDRA_CLUSTER_NODES);
@@ -563,9 +563,9 @@ public class CassandraDatacenterImpl extends DynamicClusterImpl implements
Cassa
                 if (log.isTraceEnabled()) log.debug("Seed refresh no-op for cluster {}: still={}",
new Object[] {CassandraDatacenterImpl.this, oldseeds});
             } else {
                 if (log.isDebugEnabled()) log.debug("Refreshing seeds of cluster {}: now={};
old={}", new Object[] {this, newseeds, oldseeds});
-                setAttribute(CURRENT_SEEDS, newseeds);
+                sensors().set(CURRENT_SEEDS, newseeds);
                 if (newseeds != null && newseeds.size() > 0) {
-                    setAttribute(HAS_PUBLISHED_SEEDS, true);
+                    sensors().set(HAS_PUBLISHED_SEEDS, true);
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5385f347/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricImpl.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricImpl.java
index b42b162..682d352 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricImpl.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricImpl.java
@@ -133,10 +133,10 @@ public class CassandraFabricImpl extends DynamicFabricImpl implements
CassandraF
                 }
                 
                 if (!Objects.equal(seeds, newseeds)) {
-                    setAttribute(CURRENT_SEEDS, newseeds);
+                    sensors().set(CURRENT_SEEDS, newseeds);
                     
                     if (newseeds != null && newseeds.size() > 0) {
-                        setAttribute(HAS_PUBLISHED_SEEDS, true);
+                        sensors().set(HAS_PUBLISHED_SEEDS, true);
                         
                         // Need to tell every datacenter that seeds are ready.
                         // Otherwise a datacenter might get no more changes (e.g. to nodes'
hostnames etc), 
@@ -204,8 +204,8 @@ public class CassandraFabricImpl extends DynamicFabricImpl implements
CassandraF
     public void init() {
         super.init();
 
-        if (!getConfigRaw(CassandraDatacenter.SEED_SUPPLIER, true).isPresentAndNonNull())
-            setConfig(CassandraDatacenter.SEED_SUPPLIER, getSeedSupplier());
+        if (!config().getRaw(CassandraDatacenter.SEED_SUPPLIER).isPresentAndNonNull())
+            config().set(CassandraDatacenter.SEED_SUPPLIER, getSeedSupplier());
         
         // track members
         addPolicy(PolicySpec.create(MemberTrackingPolicy.class)
@@ -219,9 +219,9 @@ public class CassandraFabricImpl extends DynamicFabricImpl implements
CassandraF
                 Long oldval = getAttribute(CassandraDatacenter.FIRST_NODE_STARTED_TIME_UTC);
                 Long newval = event.getValue();
                 if (oldval == null && newval != null) {
-                    setAttribute(CassandraDatacenter.FIRST_NODE_STARTED_TIME_UTC, newval);
+                    sensors().set(CassandraDatacenter.FIRST_NODE_STARTED_TIME_UTC, newval);
                     for (CassandraDatacenter member : Iterables.filter(getMembers(), CassandraDatacenter.class))
{
-                        ((EntityInternal)member).setAttribute(CassandraDatacenter.FIRST_NODE_STARTED_TIME_UTC,
newval);
+                        ((EntityInternal)member).sensors().set(CassandraDatacenter.FIRST_NODE_STARTED_TIME_UTC,
newval);
                     }
                 }
             }
@@ -232,15 +232,15 @@ public class CassandraFabricImpl extends DynamicFabricImpl implements
CassandraF
             @Override
             public void onEvent(SensorEvent<Multimap<String,Entity>> event) {
                 Multimap<String, Entity> usage = calculateDatacenterUsage();
-                setAttribute(DATACENTER_USAGE, usage);
-                setAttribute(DATACENTERS, usage.keySet());
+                sensors().set(DATACENTER_USAGE, usage);
+                sensors().set(DATACENTERS, usage.keySet());
             }
         });
         subscribe(this, DynamicGroup.MEMBER_REMOVED, new SensorEventListener<Entity>()
{
             @Override public void onEvent(SensorEvent<Entity> event) {
                 Multimap<String, Entity> usage = calculateDatacenterUsage();
-                setAttribute(DATACENTER_USAGE, usage);
-                setAttribute(DATACENTERS, usage.keySet());
+                sensors().set(DATACENTER_USAGE, usage);
+                sensors().set(DATACENTERS, usage.keySet());
             }
         });
     }
@@ -344,7 +344,7 @@ public class CassandraFabricImpl extends DynamicFabricImpl implements
CassandraF
 
         subscribeToMembers(this, SERVICE_UP, new SensorEventListener<Boolean>() {
             @Override public void onEvent(SensorEvent<Boolean> event) {
-                setAttribute(SERVICE_UP, calculateServiceUp());
+                sensors().set(SERVICE_UP, calculateServiceUp());
             }
         });
     }
@@ -386,8 +386,8 @@ public class CassandraFabricImpl extends DynamicFabricImpl implements
CassandraF
             Optional<Entity> upNode = Iterables.tryFind(getMembers(), EntityPredicates.attributeEqualTo(SERVICE_UP,
Boolean.TRUE));
 
             if (upNode.isPresent()) {
-                setAttribute(HOSTNAME, upNode.get().getAttribute(Attributes.HOSTNAME));
-                setAttribute(THRIFT_PORT, upNode.get().getAttribute(CassandraNode.THRIFT_PORT));
+                sensors().set(HOSTNAME, upNode.get().getAttribute(Attributes.HOSTNAME));
+                sensors().set(THRIFT_PORT, upNode.get().getAttribute(CassandraNode.THRIFT_PORT));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5385f347/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNode.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNode.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNode.java
index 683c16d..aaf1886 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNode.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNode.java
@@ -145,6 +145,7 @@ public interface CassandraNode extends DatastoreMixins.DatastoreCommon,
Software
             BigInteger.class, "cassandra.token", "Cassandra Token");
 
     @SetFromFlag("tokens")
+    @SuppressWarnings("serial")
     BasicAttributeSensorAndConfigKey<Set<BigInteger>> TOKENS = new BasicAttributeSensorAndConfigKey<Set<BigInteger>>(
             new TypeToken<Set<BigInteger>>() {}, "cassandra.tokens", "Cassandra
Tokens");
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5385f347/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeImpl.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeImpl.java
index dddc1cd..22d73ec 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeImpl.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeImpl.java
@@ -155,17 +155,17 @@ public class CassandraNodeImpl extends SoftwareProcessImpl implements
CassandraN
                              * (TODO internal access could be configured to improve performance
/ lower cost, 
                              * if we know all nodes are visible to each other) */
                             if (getConfig(LISTEN_ADDRESS_SENSOR)==null)
-                                setConfig(LISTEN_ADDRESS_SENSOR, CassandraNode.ADDRESS.getName());
+                                config().set(LISTEN_ADDRESS_SENSOR, CassandraNode.ADDRESS.getName());
                             if (getConfig(BROADCAST_ADDRESS_SENSOR)==null)
-                                setConfig(BROADCAST_ADDRESS_SENSOR, CassandraNode.ADDRESS.getName());
+                                config().set(BROADCAST_ADDRESS_SENSOR, CassandraNode.ADDRESS.getName());
                             result = "public IP for both listen and broadcast";
                         } else if (provider.contains("google-compute")) {
                             /* Google nodes cannot reach themselves/each-other on the public
IP,
                              * and there is no hostname, so use private IP here */
                             if (getConfig(LISTEN_ADDRESS_SENSOR)==null)
-                                setConfig(LISTEN_ADDRESS_SENSOR, CassandraNode.SUBNET_HOSTNAME.getName());
+                                config().set(LISTEN_ADDRESS_SENSOR, CassandraNode.SUBNET_HOSTNAME.getName());
                             if (getConfig(BROADCAST_ADDRESS_SENSOR)==null)
-                                setConfig(BROADCAST_ADDRESS_SENSOR, CassandraNode.SUBNET_HOSTNAME.getName());
+                                config().set(BROADCAST_ADDRESS_SENSOR, CassandraNode.SUBNET_HOSTNAME.getName());
                             result = "private IP for both listen and broadcast";
                         }
                     }
@@ -372,7 +372,7 @@ public class CassandraNodeImpl extends SoftwareProcessImpl implements
CassandraN
             if (name == null) {
                 name = "UNKNOWN_DATACENTER";
             }
-            setAttribute((AttributeSensor<String>)DATACENTER_NAME, name);
+            sensors().set((AttributeSensor<String>)DATACENTER_NAME, name);
         }
         return name;
     }
@@ -391,7 +391,7 @@ public class CassandraNodeImpl extends SoftwareProcessImpl implements
CassandraN
             if (name == null) {
                 name = "UNKNOWN_RACK";
             }
-            setAttribute((AttributeSensor<String>)RACK_NAME, name);
+            sensors().set((AttributeSensor<String>)RACK_NAME, name);
         }
         return name;
     }
@@ -420,7 +420,7 @@ public class CassandraNodeImpl extends SoftwareProcessImpl implements
CassandraN
     @Override
     protected void connectSensors() {
         // "cassandra" isn't really a protocol, but okay for now
-        setAttribute(DATASTORE_URL, "cassandra://"+getAttribute(HOSTNAME)+":"+getAttribute(THRIFT_PORT));
+        sensors().set(DATASTORE_URL, "cassandra://"+getAttribute(HOSTNAME)+":"+getAttribute(THRIFT_PORT));
         
         super.connectSensors();
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5385f347/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeSshDriver.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeSshDriver.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeSshDriver.java
index 193b49f..d3230f9 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeSshDriver.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeSshDriver.java
@@ -224,10 +224,10 @@ public class CassandraNodeSshDriver extends JavaSoftwareProcessSshDriver
impleme
     protected void customizeInitialSeeds() {
         if (entity.getConfig(CassandraNode.INITIAL_SEEDS)==null) {
             if (isClustered()) {
-                entity.setConfig(CassandraNode.INITIAL_SEEDS,
+                entity.config().set(CassandraNode.INITIAL_SEEDS,
                     DependentConfiguration.attributeWhenReady(entity.getParent(), CassandraDatacenter.CURRENT_SEEDS));
             } else {
-                entity.setConfig(CassandraNode.INITIAL_SEEDS, MutableSet.<Entity>of(entity));
+                entity.config().set(CassandraNode.INITIAL_SEEDS, MutableSet.<Entity>of(entity));
             }
         }
     }
@@ -273,10 +273,10 @@ public class CassandraNodeSshDriver extends JavaSoftwareProcessSshDriver
impleme
                 queuedStart = root.getAttribute(CassandraDatacenter.QUEUED_START_NODES);
                 if (queuedStart==null) {
                     queuedStart = new ArrayList<Entity>();
-                    ((EntityLocal)root).setAttribute(CassandraDatacenter.QUEUED_START_NODES,
queuedStart);
+                    ((EntityLocal)root).sensors().set(CassandraDatacenter.QUEUED_START_NODES,
queuedStart);
                 }
                 queuedStart.add(getEntity());
-                ((EntityLocal)root).setAttribute(CassandraDatacenter.QUEUED_START_NODES,
queuedStart);
+                ((EntityLocal)root).sensors().set(CassandraDatacenter.QUEUED_START_NODES,
queuedStart);
             }
             do {
                 // get it again in case it is backed by something external
@@ -316,7 +316,7 @@ public class CassandraNodeSshDriver extends JavaSoftwareProcessSshDriver
impleme
             }
             if (isClustered() && isFirst) {
                 for (Entity ancestor: getCassandraAncestors()) {
-                    ((EntityLocal)ancestor).setAttribute(CassandraDatacenter.FIRST_NODE_STARTED_TIME_UTC,
System.currentTimeMillis());
+                    ((EntityLocal)ancestor).sensors().set(CassandraDatacenter.FIRST_NODE_STARTED_TIME_UTC,
System.currentTimeMillis());
                 }
             }
         } finally {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5385f347/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricTest.java
b/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricTest.java
index d6df2ea..f28ddc1 100644
--- a/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricTest.java
+++ b/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricTest.java
@@ -131,12 +131,12 @@ public class CassandraFabricTest extends BrooklynAppUnitTestSupport
{
             final DummyCassandraNode d2a = (DummyCassandraNode) Iterables.get(d2.getMembers(),
0);
             final DummyCassandraNode d2b = (DummyCassandraNode) Iterables.get(d2.getMembers(),
1);
 
-            d1a.setAttribute(Attributes.HOSTNAME, "d1a");
-            d1b.setAttribute(Attributes.HOSTNAME, "d1b");
+            d1a.sensors().set(Attributes.HOSTNAME, "d1a");
+            d1b.sensors().set(Attributes.HOSTNAME, "d1b");
             
             Thread.sleep(1000);
-            d2a.setAttribute(Attributes.HOSTNAME, "d2a");
-            d2b.setAttribute(Attributes.HOSTNAME, "d2b");
+            d2a.sensors().set(Attributes.HOSTNAME, "d2a");
+            d2b.sensors().set(Attributes.HOSTNAME, "d2b");
             
             Predicate<Set<Entity>> predicate = new Predicate<Set<Entity>>()
{
                 @Override public boolean apply(Set<Entity> input) {


Mime
View raw message