Madan Jampani
Committed by Gerrit Code Review

Misc improvements. Primarily Javadoc.

Change-Id: I083bbf559d53fa25f79d4e1e53eb15c6b96290f2
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
16 package org.onosproject.store.service; 16 package org.onosproject.store.service;
17 17
18 /** 18 /**
19 - * An atomic counter dispenses monotonically increasing values. 19 + * Distributed version of java.util.concurrent.atomic.AtomicLong.
20 */ 20 */
21 public interface AtomicCounter { 21 public interface AtomicCounter {
22 22
......
...@@ -20,15 +20,23 @@ import com.google.common.base.MoreObjects; ...@@ -20,15 +20,23 @@ import com.google.common.base.MoreObjects;
20 import java.util.Objects; 20 import java.util.Objects;
21 21
22 /** 22 /**
23 - * Event object signalling that the map was modified. 23 + * Representation of a EventuallyConsistentMap update notification.
24 */ 24 */
25 public class EventuallyConsistentMapEvent<K, V> { 25 public class EventuallyConsistentMapEvent<K, V> {
26 26
27 public enum Type { 27 public enum Type {
28 + /**
29 + * Entry added to map or existing entry updated.
30 + */
28 PUT, 31 PUT,
32 +
33 + /**
34 + * Entry removed from map.
35 + */
29 REMOVE 36 REMOVE
30 } 37 }
31 38
39 + private final String name;
32 private final Type type; 40 private final Type type;
33 private final K key; 41 private final K key;
34 private final V value; 42 private final V value;
...@@ -36,17 +44,28 @@ public class EventuallyConsistentMapEvent<K, V> { ...@@ -36,17 +44,28 @@ public class EventuallyConsistentMapEvent<K, V> {
36 /** 44 /**
37 * Creates a new event object. 45 * Creates a new event object.
38 * 46 *
47 + * @param name map name
39 * @param type the type of the event 48 * @param type the type of the event
40 * @param key the key the event concerns 49 * @param key the key the event concerns
41 - * @param value the value related to the key, or null for remove events 50 + * @param value the value mapped to the key
42 */ 51 */
43 - public EventuallyConsistentMapEvent(Type type, K key, V value) { 52 + public EventuallyConsistentMapEvent(String name, Type type, K key, V value) {
53 + this.name = name;
44 this.type = type; 54 this.type = type;
45 this.key = key; 55 this.key = key;
46 this.value = value; 56 this.value = value;
47 } 57 }
48 58
49 /** 59 /**
60 + * Returns the map name.
61 + *
62 + * @return name of map
63 + */
64 + public String name() {
65 + return name;
66 + }
67 +
68 + /**
50 * Returns the type of the event. 69 * Returns the type of the event.
51 * 70 *
52 * @return the type of the event 71 * @return the type of the event
...@@ -65,9 +84,11 @@ public class EventuallyConsistentMapEvent<K, V> { ...@@ -65,9 +84,11 @@ public class EventuallyConsistentMapEvent<K, V> {
65 } 84 }
66 85
67 /** 86 /**
68 - * Returns the value associated with this event. 87 + * Returns the value associated with this event. If type is REMOVE,
88 + * this is the value that was removed. If type is PUT, this is
89 + * the new value.
69 * 90 *
70 - * @return the value, or null if the event was REMOVE 91 + * @return the value
71 */ 92 */
72 public V value() { 93 public V value() {
73 return value; 94 return value;
......
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
16 package org.onosproject.store.service; 16 package org.onosproject.store.service;
17 17
18 /** 18 /**
19 - * Listener interested in receiving modification events for an 19 + * Listener to be notified about updates to a EventuallyConsistentMap.
20 - * EventuallyConsistentMap.
21 */ 20 */
22 public interface EventuallyConsistentMapListener<K, V> { 21 public interface EventuallyConsistentMapListener<K, V> {
23 22
......
...@@ -20,7 +20,7 @@ import org.onosproject.store.Timestamp; ...@@ -20,7 +20,7 @@ import org.onosproject.store.Timestamp;
20 /** 20 /**
21 * Service that issues logical timestamps. 21 * Service that issues logical timestamps.
22 * <p> 22 * <p>
23 - * The logical timestamps are useful for establishing a total ordering of 23 + * Logical timestamps are useful for establishing a total ordering of
24 * arbitrary cluster wide events without relying on a fully synchronized 24 * arbitrary cluster wide events without relying on a fully synchronized
25 * system clock (wall clock) 25 * system clock (wall clock)
26 */ 26 */
......
...@@ -56,9 +56,9 @@ public class MapEvent<K, V> { ...@@ -56,9 +56,9 @@ public class MapEvent<K, V> {
56 * Creates a new event object. 56 * Creates a new event object.
57 * 57 *
58 * @param name map name 58 * @param name map name
59 - * @param type the type of the event 59 + * @param type type of event
60 - * @param key the key the event concerns 60 + * @param key key the event concerns
61 - * @param value the value related to the key, or null for remove events 61 + * @param value value key is mapped to
62 */ 62 */
63 public MapEvent(String name, Type type, K key, Versioned<V> value) { 63 public MapEvent(String name, Type type, K key, Versioned<V> value) {
64 this.name = name; 64 this.name = name;
...@@ -79,7 +79,7 @@ public class MapEvent<K, V> { ...@@ -79,7 +79,7 @@ public class MapEvent<K, V> {
79 /** 79 /**
80 * Returns the type of the event. 80 * Returns the type of the event.
81 * 81 *
82 - * @return the type of the event 82 + * @return the type of event
83 */ 83 */
84 public Type type() { 84 public Type type() {
85 return type; 85 return type;
...@@ -120,7 +120,7 @@ public class MapEvent<K, V> { ...@@ -120,7 +120,7 @@ public class MapEvent<K, V> {
120 120
121 @Override 121 @Override
122 public int hashCode() { 122 public int hashCode() {
123 - return Objects.hash(type, key, value); 123 + return Objects.hash(name, type, key, value);
124 } 124 }
125 125
126 @Override 126 @Override
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
16 package org.onosproject.store.service; 16 package org.onosproject.store.service;
17 17
18 /** 18 /**
19 - * Listener to be notified about updates to a ConsitentMap. 19 + * Listener to be notified about updates to a ConsistentMap.
20 */ 20 */
21 public interface MapEventListener<K, V> { 21 public interface MapEventListener<K, V> {
22 /** 22 /**
......
...@@ -22,7 +22,7 @@ import com.google.common.base.MoreObjects; ...@@ -22,7 +22,7 @@ import com.google.common.base.MoreObjects;
22 /** 22 /**
23 * Representation of a DistributedSet update notification. 23 * Representation of a DistributedSet update notification.
24 * 24 *
25 - * @param <E> element type 25 + * @param <E> set element type
26 */ 26 */
27 public class SetEvent<E> { 27 public class SetEvent<E> {
28 28
...@@ -49,8 +49,8 @@ public class SetEvent<E> { ...@@ -49,8 +49,8 @@ public class SetEvent<E> {
49 * Creates a new event object. 49 * Creates a new event object.
50 * 50 *
51 * @param name set name 51 * @param name set name
52 - * @param type the type of the event 52 + * @param type type of the event
53 - * @param entry the entry the event concerns 53 + * @param entry entry the event concerns
54 */ 54 */
55 public SetEvent(String name, Type type, E entry) { 55 public SetEvent(String name, Type type, E entry) {
56 this.name = name; 56 this.name = name;
...@@ -70,7 +70,7 @@ public class SetEvent<E> { ...@@ -70,7 +70,7 @@ public class SetEvent<E> {
70 /** 70 /**
71 * Returns the type of the event. 71 * Returns the type of the event.
72 * 72 *
73 - * @return the type of the event 73 + * @return type of the event
74 */ 74 */
75 public Type type() { 75 public Type type() {
76 return type; 76 return type;
......
...@@ -13,19 +13,15 @@ ...@@ -13,19 +13,15 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -
17 package org.onosproject.store.service; 16 package org.onosproject.store.service;
18 17
19 -
20 /** 18 /**
21 * Storage service. 19 * Storage service.
22 * <p> 20 * <p>
23 - * This service provides operations for creating key-value stores. 21 + * This service provides builders for various distributed primitives.
24 - * One can chose to create key-value stores with varying properties such
25 - * as strongly consistent vs eventually consistent, durable vs volatile.
26 * <p> 22 * <p>
27 - * Various store implementations should leverage the data structures provided 23 + * It is expected that services and applications will leverage the primitives indirectly provided by
28 - * by this service 24 + * this service for their distributed state management and coordination.
29 */ 25 */
30 public interface StorageService { 26 public interface StorageService {
31 27
...@@ -48,7 +44,7 @@ public interface StorageService { ...@@ -48,7 +44,7 @@ public interface StorageService {
48 <K, V> ConsistentMapBuilder<K, V> consistentMapBuilder(); 44 <K, V> ConsistentMapBuilder<K, V> consistentMapBuilder();
49 45
50 /** 46 /**
51 - * Creates a new distributed set builder. 47 + * Creates a new DistributedSetBuilder.
52 * 48 *
53 * @param <E> set element type 49 * @param <E> set element type
54 * @return builder for an distributed set 50 * @return builder for an distributed set
...@@ -56,7 +52,7 @@ public interface StorageService { ...@@ -56,7 +52,7 @@ public interface StorageService {
56 <E> DistributedSetBuilder<E> setBuilder(); 52 <E> DistributedSetBuilder<E> setBuilder();
57 53
58 /** 54 /**
59 - * Creates a new distributed queue builder. 55 + * Creates a new DistributedQueueBuilder.
60 * 56 *
61 * @param <E> queue entry type 57 * @param <E> queue entry type
62 * @return builder for an distributed queue 58 * @return builder for an distributed queue
......
...@@ -310,7 +310,7 @@ public class EventuallyConsistentMapImpl<K, V> ...@@ -310,7 +310,7 @@ public class EventuallyConsistentMapImpl<K, V>
310 MapValue<V> newValue = new MapValue<>(value, timestampProvider.apply(key, value)); 310 MapValue<V> newValue = new MapValue<>(value, timestampProvider.apply(key, value));
311 if (putInternal(key, newValue)) { 311 if (putInternal(key, newValue)) {
312 notifyPeers(new UpdateEntry<>(key, newValue), peerUpdateFunction.apply(key, value)); 312 notifyPeers(new UpdateEntry<>(key, newValue), peerUpdateFunction.apply(key, value));
313 - notifyListeners(new EventuallyConsistentMapEvent<>(PUT, key, value)); 313 + notifyListeners(new EventuallyConsistentMapEvent<>(mapName, PUT, key, value));
314 } 314 }
315 } 315 }
316 316
...@@ -335,7 +335,7 @@ public class EventuallyConsistentMapImpl<K, V> ...@@ -335,7 +335,7 @@ public class EventuallyConsistentMapImpl<K, V>
335 if (previousValue != null) { 335 if (previousValue != null) {
336 notifyPeers(new UpdateEntry<>(key, tombstone), peerUpdateFunction.apply(key, previousValue.get())); 336 notifyPeers(new UpdateEntry<>(key, tombstone), peerUpdateFunction.apply(key, previousValue.get()));
337 if (previousValue.isAlive()) { 337 if (previousValue.isAlive()) {
338 - notifyListeners(new EventuallyConsistentMapEvent<>(REMOVE, key, previousValue.get())); 338 + notifyListeners(new EventuallyConsistentMapEvent<>(mapName, REMOVE, key, previousValue.get()));
339 } 339 }
340 } 340 }
341 return previousValue != null ? previousValue.get() : null; 341 return previousValue != null ? previousValue.get() : null;
...@@ -406,7 +406,7 @@ public class EventuallyConsistentMapImpl<K, V> ...@@ -406,7 +406,7 @@ public class EventuallyConsistentMapImpl<K, V>
406 ? previousValue.get() == null ? null : previousValue.get().get() 406 ? previousValue.get() == null ? null : previousValue.get().get()
407 : computedValue.get(); 407 : computedValue.get();
408 if (value != null) { 408 if (value != null) {
409 - notifyListeners(new EventuallyConsistentMapEvent<>(updateType, key, value)); 409 + notifyListeners(new EventuallyConsistentMapEvent<>(mapName, updateType, key, value));
410 } 410 }
411 } 411 }
412 return computedValue.get(); 412 return computedValue.get();
...@@ -609,7 +609,7 @@ public class EventuallyConsistentMapImpl<K, V> ...@@ -609,7 +609,7 @@ public class EventuallyConsistentMapImpl<K, V>
609 Optional.empty(), 609 Optional.empty(),
610 MapValue.tombstone(remoteValueDigest.timestamp())); 610 MapValue.tombstone(remoteValueDigest.timestamp()));
611 if (previousValue != null && previousValue.isAlive()) { 611 if (previousValue != null && previousValue.isAlive()) {
612 - externalEvents.add(new EventuallyConsistentMapEvent<>(REMOVE, key, previousValue.get())); 612 + externalEvents.add(new EventuallyConsistentMapEvent<>(mapName, REMOVE, key, previousValue.get()));
613 } 613 }
614 } 614 }
615 }); 615 });
...@@ -626,10 +626,10 @@ public class EventuallyConsistentMapImpl<K, V> ...@@ -626,10 +626,10 @@ public class EventuallyConsistentMapImpl<K, V>
626 if (value.isTombstone()) { 626 if (value.isTombstone()) {
627 MapValue<V> previousValue = removeInternal(key, Optional.empty(), value); 627 MapValue<V> previousValue = removeInternal(key, Optional.empty(), value);
628 if (previousValue != null && previousValue.isAlive()) { 628 if (previousValue != null && previousValue.isAlive()) {
629 - notifyListeners(new EventuallyConsistentMapEvent<>(REMOVE, key, previousValue.get())); 629 + notifyListeners(new EventuallyConsistentMapEvent<>(mapName, REMOVE, key, previousValue.get()));
630 } 630 }
631 } else if (putInternal(key, value)) { 631 } else if (putInternal(key, value)) {
632 - notifyListeners(new EventuallyConsistentMapEvent<>(PUT, key, value.get())); 632 + notifyListeners(new EventuallyConsistentMapEvent<>(mapName, PUT, key, value.get()));
633 } 633 }
634 }); 634 });
635 } 635 }
......
...@@ -274,9 +274,9 @@ public class EventuallyConsistentMapImplTest { ...@@ -274,9 +274,9 @@ public class EventuallyConsistentMapImplTest {
274 EventuallyConsistentMapListener<String, String> listener 274 EventuallyConsistentMapListener<String, String> listener
275 = getListener(); 275 = getListener();
276 listener.event(new EventuallyConsistentMapEvent<>( 276 listener.event(new EventuallyConsistentMapEvent<>(
277 - EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1)); 277 + MAP_NAME, EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1));
278 listener.event(new EventuallyConsistentMapEvent<>( 278 listener.event(new EventuallyConsistentMapEvent<>(
279 - EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE2)); 279 + MAP_NAME, EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE2));
280 replay(listener); 280 replay(listener);
281 281
282 ecMap.addListener(listener); 282 ecMap.addListener(listener);
...@@ -325,11 +325,11 @@ public class EventuallyConsistentMapImplTest { ...@@ -325,11 +325,11 @@ public class EventuallyConsistentMapImplTest {
325 EventuallyConsistentMapListener<String, String> listener 325 EventuallyConsistentMapListener<String, String> listener
326 = getListener(); 326 = getListener();
327 listener.event(new EventuallyConsistentMapEvent<>( 327 listener.event(new EventuallyConsistentMapEvent<>(
328 - EventuallyConsistentMapEvent.Type.REMOVE, KEY1, VALUE1)); 328 + MAP_NAME, EventuallyConsistentMapEvent.Type.REMOVE, KEY1, VALUE1));
329 listener.event(new EventuallyConsistentMapEvent<>( 329 listener.event(new EventuallyConsistentMapEvent<>(
330 - EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1)); 330 + MAP_NAME, EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1));
331 listener.event(new EventuallyConsistentMapEvent<>( 331 listener.event(new EventuallyConsistentMapEvent<>(
332 - EventuallyConsistentMapEvent.Type.PUT, KEY2, VALUE2)); 332 + MAP_NAME, EventuallyConsistentMapEvent.Type.PUT, KEY2, VALUE2));
333 replay(listener); 333 replay(listener);
334 334
335 ecMap.addListener(listener); 335 ecMap.addListener(listener);
...@@ -388,11 +388,11 @@ public class EventuallyConsistentMapImplTest { ...@@ -388,11 +388,11 @@ public class EventuallyConsistentMapImplTest {
388 EventuallyConsistentMapListener<String, String> listener 388 EventuallyConsistentMapListener<String, String> listener
389 = getListener(); 389 = getListener();
390 listener.event(new EventuallyConsistentMapEvent<>( 390 listener.event(new EventuallyConsistentMapEvent<>(
391 - EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1)); 391 + MAP_NAME, EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1));
392 listener.event(new EventuallyConsistentMapEvent<>( 392 listener.event(new EventuallyConsistentMapEvent<>(
393 - EventuallyConsistentMapEvent.Type.REMOVE, KEY1, VALUE1)); 393 + MAP_NAME, EventuallyConsistentMapEvent.Type.REMOVE, KEY1, VALUE1));
394 listener.event(new EventuallyConsistentMapEvent<>( 394 listener.event(new EventuallyConsistentMapEvent<>(
395 - EventuallyConsistentMapEvent.Type.PUT, KEY2, VALUE2)); 395 + MAP_NAME, EventuallyConsistentMapEvent.Type.PUT, KEY2, VALUE2));
396 replay(listener); 396 replay(listener);
397 397
398 ecMap.addListener(listener); 398 ecMap.addListener(listener);
...@@ -457,9 +457,9 @@ public class EventuallyConsistentMapImplTest { ...@@ -457,9 +457,9 @@ public class EventuallyConsistentMapImplTest {
457 EventuallyConsistentMapListener<String, String> listener 457 EventuallyConsistentMapListener<String, String> listener
458 = getListener(); 458 = getListener();
459 listener.event(new EventuallyConsistentMapEvent<>( 459 listener.event(new EventuallyConsistentMapEvent<>(
460 - EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1)); 460 + MAP_NAME, EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1));
461 listener.event(new EventuallyConsistentMapEvent<>( 461 listener.event(new EventuallyConsistentMapEvent<>(
462 - EventuallyConsistentMapEvent.Type.PUT, KEY2, VALUE2)); 462 + MAP_NAME, EventuallyConsistentMapEvent.Type.PUT, KEY2, VALUE2));
463 replay(listener); 463 replay(listener);
464 464
465 ecMap.addListener(listener); 465 ecMap.addListener(listener);
...@@ -485,9 +485,9 @@ public class EventuallyConsistentMapImplTest { ...@@ -485,9 +485,9 @@ public class EventuallyConsistentMapImplTest {
485 EventuallyConsistentMapListener<String, String> listener 485 EventuallyConsistentMapListener<String, String> listener
486 = getListener(); 486 = getListener();
487 listener.event(new EventuallyConsistentMapEvent<>( 487 listener.event(new EventuallyConsistentMapEvent<>(
488 - EventuallyConsistentMapEvent.Type.REMOVE, KEY1, VALUE1)); 488 + MAP_NAME, EventuallyConsistentMapEvent.Type.REMOVE, KEY1, VALUE1));
489 listener.event(new EventuallyConsistentMapEvent<>( 489 listener.event(new EventuallyConsistentMapEvent<>(
490 - EventuallyConsistentMapEvent.Type.REMOVE, KEY2, VALUE2)); 490 + MAP_NAME, EventuallyConsistentMapEvent.Type.REMOVE, KEY2, VALUE2));
491 replay(listener); 491 replay(listener);
492 492
493 // clear() on an empty map is a no-op - no messages will be sent 493 // clear() on an empty map is a no-op - no messages will be sent
......