You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/03/28 12:13:18 UTC
[2/5] brooklyn-server git commit: Force perist after mutating the
location configuration maps
Force perist after mutating the location configuration maps
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/84c21a87
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/84c21a87
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/84c21a87
Branch: refs/heads/master
Commit: 84c21a8758944ff21664a0688cf4a970f7105af9
Parents: 4e04776
Author: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Authored: Thu Mar 24 15:31:11 2016 +0000
Committer: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Committed: Thu Mar 24 20:03:12 2016 +0000
----------------------------------------------------------------------
.../SoftLayerSameVlanLocationCustomizer.java | 53 ++++++++++++--------
1 file changed, 31 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/84c21a87/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/softlayer/SoftLayerSameVlanLocationCustomizer.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/softlayer/SoftLayerSameVlanLocationCustomizer.java b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/softlayer/SoftLayerSameVlanLocationCustomizer.java
index 4c980d8..720657c 100644
--- a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/softlayer/SoftLayerSameVlanLocationCustomizer.java
+++ b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/softlayer/SoftLayerSameVlanLocationCustomizer.java
@@ -325,14 +325,15 @@ public class SoftLayerSameVlanLocationCustomizer extends BasicJcloudsLocationCus
*/
protected CountDownLatch createCountDownLatch(JcloudsLocation location, String scopeUid) {
synchronized (lock) {
- Map<String, CountDownLatch> map = location.config().get(COUNTDOWN_LATCH_MAP);
- if (map == null) { map = MutableMap.of(); }
+ Map<String, CountDownLatch> map = MutableMap.copyOf(location.config().get(COUNTDOWN_LATCH_MAP));
if (!map.containsKey(scopeUid)) {
map.put(scopeUid, new CountDownLatch(1));
}
CountDownLatch latch = map.get(scopeUid);
- location.config().set(COUNTDOWN_LATCH_MAP, map);
+
+ location.config().set(COUNTDOWN_LATCH_MAP, ImmutableMap.copyOf(map));
+ location.getManagementContext().getRebindManager().forcePersistNow(false, null);
return latch;
}
@@ -343,21 +344,25 @@ public class SoftLayerSameVlanLocationCustomizer extends BasicJcloudsLocationCus
*/
protected void removeCountDownLatch(JcloudsLocation location, String scopeUid) {
synchronized (lock) {
- Map<String, CountDownLatch> map = location.config().get(COUNTDOWN_LATCH_MAP);
- if (map != null) {
- map.remove(scopeUid);
- }
+ Map<String, CountDownLatch> map = MutableMap.copyOf(location.config().get(COUNTDOWN_LATCH_MAP));
+
+ map.remove(scopeUid);
+
+ location.config().set(COUNTDOWN_LATCH_MAP, ImmutableMap.copyOf(map));
+ location.getManagementContext().getRebindManager().forcePersistNow(false, null);
}
}
/** Return the public VLAN number for a scope. */
protected Integer lookupPublicVlanId(JcloudsLocation location, String scopeUid) {
- synchronized (SoftLayerSameVlanLocationCustomizer.class) {
- Map<String, Integer> map = location.config().get(PUBLIC_VLAN_ID_MAP);
- if (map == null) {
- map = MutableMap.of();
- location.config().set(PUBLIC_VLAN_ID_MAP, map);
+ synchronized (lock) {
+ Map<String, Integer> map = MutableMap.copyOf(location.config().get(PUBLIC_VLAN_ID_MAP));
+
+ if (map.isEmpty()) {
+ location.config().set(PUBLIC_VLAN_ID_MAP, ImmutableMap.copyOf(map));
+ location.getManagementContext().getRebindManager().forcePersistNow(false, null);
}
+
return map.get(scopeUid);
}
}
@@ -365,22 +370,25 @@ public class SoftLayerSameVlanLocationCustomizer extends BasicJcloudsLocationCus
/** Save the public VLAN number for a scope. */
protected void savePublicVlanId(JcloudsLocation location, String scopeUid, Integer publicVlanId) {
synchronized (lock) {
- Map<String, Integer> map = location.config().get(PUBLIC_VLAN_ID_MAP);
- if (map == null) { map = MutableMap.of(); }
+ Map<String, Integer> map = MutableMap.copyOf(location.config().get(PUBLIC_VLAN_ID_MAP));
map.put(scopeUid, publicVlanId);
- location.config().set(PUBLIC_VLAN_ID_MAP, map);
+
+ location.config().set(PUBLIC_VLAN_ID_MAP, ImmutableMap.copyOf(map));
+ location.getManagementContext().getRebindManager().forcePersistNow(false, null);
}
}
/** Return the private VLAN number for a scope. */
protected Integer lookupPrivateVlanId(JcloudsLocation location, String scopeUid) {
synchronized (lock) {
- Map<String, Integer> map = location.config().get(PRIVATE_VLAN_ID_MAP);
- if (map == null) {
- map = MutableMap.of();
- location.config().set(PRIVATE_VLAN_ID_MAP, map);
+ Map<String, Integer> map = MutableMap.copyOf(location.config().get(PRIVATE_VLAN_ID_MAP));
+
+ if (map.isEmpty()) {
+ location.config().set(PRIVATE_VLAN_ID_MAP, ImmutableMap.copyOf(map));
+ location.getManagementContext().getRebindManager().forcePersistNow(false, null);
}
+
return map.get(scopeUid);
}
}
@@ -388,11 +396,12 @@ public class SoftLayerSameVlanLocationCustomizer extends BasicJcloudsLocationCus
/** Save the private VLAN number for a scope. */
protected void savePrivateVlanId(JcloudsLocation location, String scopeUid, Integer privateVlanId) {
synchronized (lock) {
- Map<String, Integer> map = location.config().get(PRIVATE_VLAN_ID_MAP);
- if (map == null) { map = MutableMap.of(); }
+ Map<String, Integer> map = MutableMap.copyOf(location.config().get(PRIVATE_VLAN_ID_MAP));
map.put(scopeUid, privateVlanId);
- location.config().set(PRIVATE_VLAN_ID_MAP, map);
+
+ location.config().set(PRIVATE_VLAN_ID_MAP, ImmutableMap.copyOf(map));
+ location.getManagementContext().getRebindManager().forcePersistNow(false, null);
}
}
}
\ No newline at end of file