Brian O'Connor

GossipIntentStore: Renaming current and pending maps

currentState was poorly named, and also was hidden by a better named local variable.

Change-Id: Ia61eb73890009812d63026d5811553b2ff1bd94e
...@@ -60,10 +60,10 @@ public class GossipIntentStore ...@@ -60,10 +60,10 @@ public class GossipIntentStore
60 private final Logger log = getLogger(getClass()); 60 private final Logger log = getLogger(getClass());
61 61
62 // Map of intent key => current intent state 62 // Map of intent key => current intent state
63 - private EventuallyConsistentMap<Key, IntentData> currentState; 63 + private EventuallyConsistentMap<Key, IntentData> currentMap;
64 64
65 // Map of intent key => pending intent operation 65 // Map of intent key => pending intent operation
66 - private EventuallyConsistentMap<Key, IntentData> pending; 66 + private EventuallyConsistentMap<Key, IntentData> pendingMap;
67 67
68 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 68 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
69 protected ClusterCommunicationService clusterCommunicator; 69 protected ClusterCommunicationService clusterCommunicator;
...@@ -82,47 +82,47 @@ public class GossipIntentStore ...@@ -82,47 +82,47 @@ public class GossipIntentStore
82 .register(MultiValuedTimestamp.class) 82 .register(MultiValuedTimestamp.class)
83 .register(SystemClockTimestamp.class); 83 .register(SystemClockTimestamp.class);
84 84
85 - currentState = new EventuallyConsistentMapImpl<>("intent-current", 85 + currentMap = new EventuallyConsistentMapImpl<>("intent-current",
86 clusterService, 86 clusterService,
87 clusterCommunicator, 87 clusterCommunicator,
88 intentSerializer, 88 intentSerializer,
89 new IntentDataLogicalClockManager<>()); 89 new IntentDataLogicalClockManager<>());
90 90
91 - pending = new EventuallyConsistentMapImpl<>("intent-pending", 91 + pendingMap = new EventuallyConsistentMapImpl<>("intent-pending",
92 clusterService, 92 clusterService,
93 clusterCommunicator, 93 clusterCommunicator,
94 intentSerializer, // TODO 94 intentSerializer, // TODO
95 new IntentDataClockManager<>()); 95 new IntentDataClockManager<>());
96 96
97 - currentState.addListener(new InternalIntentStatesListener()); 97 + currentMap.addListener(new InternalIntentStatesListener());
98 - pending.addListener(new InternalPendingListener()); 98 + pendingMap.addListener(new InternalPendingListener());
99 99
100 log.info("Started"); 100 log.info("Started");
101 } 101 }
102 102
103 @Deactivate 103 @Deactivate
104 public void deactivate() { 104 public void deactivate() {
105 - currentState.destroy(); 105 + currentMap.destroy();
106 - pending.destroy(); 106 + pendingMap.destroy();
107 107
108 log.info("Stopped"); 108 log.info("Stopped");
109 } 109 }
110 110
111 @Override 111 @Override
112 public long getIntentCount() { 112 public long getIntentCount() {
113 - return currentState.size(); 113 + return currentMap.size();
114 } 114 }
115 115
116 @Override 116 @Override
117 public Iterable<Intent> getIntents() { 117 public Iterable<Intent> getIntents() {
118 - return currentState.values().stream() 118 + return currentMap.values().stream()
119 .map(IntentData::intent) 119 .map(IntentData::intent)
120 .collect(Collectors.toList()); 120 .collect(Collectors.toList());
121 } 121 }
122 122
123 @Override 123 @Override
124 public IntentState getIntentState(Key intentKey) { 124 public IntentState getIntentState(Key intentKey) {
125 - IntentData data = currentState.get(intentKey); 125 + IntentData data = currentMap.get(intentKey);
126 if (data != null) { 126 if (data != null) {
127 return data.state(); 127 return data.state();
128 } 128 }
...@@ -131,7 +131,7 @@ public class GossipIntentStore ...@@ -131,7 +131,7 @@ public class GossipIntentStore
131 131
132 @Override 132 @Override
133 public List<Intent> getInstallableIntents(Key intentKey) { 133 public List<Intent> getInstallableIntents(Key intentKey) {
134 - IntentData data = currentState.get(intentKey); 134 + IntentData data = currentMap.get(intentKey);
135 if (data != null) { 135 if (data != null) {
136 return data.installables(); 136 return data.installables();
137 } 137 }
...@@ -227,15 +227,15 @@ public class GossipIntentStore ...@@ -227,15 +227,15 @@ public class GossipIntentStore
227 public void write(IntentData newData) { 227 public void write(IntentData newData) {
228 //log.debug("writing intent {}", newData); 228 //log.debug("writing intent {}", newData);
229 229
230 - IntentData currentData = currentState.get(newData.key()); 230 + IntentData currentData = currentMap.get(newData.key());
231 231
232 if (isUpdateAcceptable(currentData, newData)) { 232 if (isUpdateAcceptable(currentData, newData)) {
233 // Only the master is modifying the current state. Therefore assume 233 // Only the master is modifying the current state. Therefore assume
234 // this always succeeds 234 // this always succeeds
235 - currentState.put(newData.key(), copyData(newData)); 235 + currentMap.put(newData.key(), copyData(newData));
236 236
237 // if current.put succeeded 237 // if current.put succeeded
238 - pending.remove(newData.key(), newData); 238 + pendingMap.remove(newData.key(), newData);
239 } else { 239 } else {
240 log.debug("not writing update: current {}, new {}", currentData, newData); 240 log.debug("not writing update: current {}, new {}", currentData, newData);
241 } 241 }
...@@ -254,7 +254,7 @@ public class GossipIntentStore ...@@ -254,7 +254,7 @@ public class GossipIntentStore
254 254
255 @Override 255 @Override
256 public Intent getIntent(Key key) { 256 public Intent getIntent(Key key) {
257 - IntentData data = currentState.get(key); 257 + IntentData data = currentMap.get(key);
258 if (data != null) { 258 if (data != null) {
259 return data.intent(); 259 return data.intent();
260 } 260 }
...@@ -263,7 +263,7 @@ public class GossipIntentStore ...@@ -263,7 +263,7 @@ public class GossipIntentStore
263 263
264 @Override 264 @Override
265 public IntentData getIntentData(Key key) { 265 public IntentData getIntentData(Key key) {
266 - return copyData(currentState.get(key)); 266 + return copyData(currentMap.get(key));
267 } 267 }
268 268
269 @Override 269 @Override
...@@ -272,7 +272,7 @@ public class GossipIntentStore ...@@ -272,7 +272,7 @@ public class GossipIntentStore
272 if (data.version() == null) { 272 if (data.version() == null) {
273 data.setVersion(new SystemClockTimestamp()); 273 data.setVersion(new SystemClockTimestamp());
274 } 274 }
275 - pending.put(data.key(), copyData(data)); 275 + pendingMap.put(data.key(), copyData(data));
276 } 276 }
277 277
278 @Override 278 @Override
...@@ -282,7 +282,7 @@ public class GossipIntentStore ...@@ -282,7 +282,7 @@ public class GossipIntentStore
282 282
283 @Override 283 @Override
284 public Iterable<Intent> getPending() { 284 public Iterable<Intent> getPending() {
285 - return pending.values().stream() 285 + return pendingMap.values().stream()
286 .map(IntentData::intent) 286 .map(IntentData::intent)
287 .collect(Collectors.toList()); 287 .collect(Collectors.toList());
288 } 288 }
......