Committed by
Ray Milkey
adding sender-side accumulator to ecmap
Change-Id: I63de27131c067c07b41ca311b14ef3ac85b6ae3e
Showing
6 changed files
with
83 additions
and
189 deletions
... | @@ -15,51 +15,55 @@ | ... | @@ -15,51 +15,55 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.store.ecmap; | 16 | package org.onosproject.store.ecmap; |
17 | 17 | ||
18 | -import com.google.common.collect.ImmutableList; | ||
19 | import org.onosproject.store.Timestamp; | 18 | import org.onosproject.store.Timestamp; |
20 | 19 | ||
21 | -import java.util.List; | ||
22 | - | ||
23 | import static com.google.common.base.Preconditions.checkNotNull; | 20 | import static com.google.common.base.Preconditions.checkNotNull; |
24 | 21 | ||
25 | /** | 22 | /** |
26 | - * Internal inter-instance event used by EventuallyConsistentMap for PUT events. | 23 | + * Base class for events in an EventuallyConsistentMap. |
27 | */ | 24 | */ |
28 | -final class InternalPutEvent<K, V> { | 25 | +public abstract class AbstractEntry<K, V> implements Comparable<AbstractEntry<K, V>> { |
29 | - private final List<PutEntry<K, V>> entries; | 26 | + private final K key; |
27 | + private final Timestamp timestamp; | ||
30 | 28 | ||
31 | /** | 29 | /** |
32 | - * Creates a put event for a single key. | 30 | + * Creates a new put entry. |
33 | * | 31 | * |
34 | - * @param key key the event concerns | 32 | + * @param key key of the entry |
35 | - * @param value value of the key | 33 | + * @param timestamp timestamp of the put event |
36 | - * @param timestamp timestamp of the event | ||
37 | */ | 34 | */ |
38 | - public InternalPutEvent(K key, V value, Timestamp timestamp) { | 35 | + public AbstractEntry(K key, Timestamp timestamp) { |
39 | - entries = ImmutableList.of(new PutEntry<>(key, value, timestamp)); | 36 | + this.key = checkNotNull(key); |
37 | + this.timestamp = checkNotNull(timestamp); | ||
38 | + } | ||
39 | + | ||
40 | + // Needed for serialization. | ||
41 | + @SuppressWarnings("unused") | ||
42 | + protected AbstractEntry() { | ||
43 | + this.key = null; | ||
44 | + this.timestamp = null; | ||
40 | } | 45 | } |
41 | 46 | ||
42 | /** | 47 | /** |
43 | - * Creates a put event for multiple keys. | 48 | + * Returns the key of the entry. |
44 | * | 49 | * |
45 | - * @param entries list of put entries to send an event for | 50 | + * @return the key |
46 | */ | 51 | */ |
47 | - public InternalPutEvent(List<PutEntry<K, V>> entries) { | 52 | + public K key() { |
48 | - this.entries = checkNotNull(entries); | 53 | + return key; |
49 | - } | ||
50 | - | ||
51 | - // Needed for serialization. | ||
52 | - @SuppressWarnings("unused") | ||
53 | - private InternalPutEvent() { | ||
54 | - entries = null; | ||
55 | } | 54 | } |
56 | 55 | ||
57 | /** | 56 | /** |
58 | - * Returns the list of put entries this event concerns. | 57 | + * Returns the timestamp of the event. |
59 | * | 58 | * |
60 | - * @return list of put entries | 59 | + * @return the timestamp |
61 | */ | 60 | */ |
62 | - public List<PutEntry<K, V>> entries() { | 61 | + public Timestamp timestamp() { |
63 | - return entries; | 62 | + return timestamp; |
63 | + } | ||
64 | + | ||
65 | + @Override | ||
66 | + public int compareTo(AbstractEntry<K, V> o) { | ||
67 | + return this.timestamp.compareTo(o.timestamp); | ||
64 | } | 68 | } |
65 | } | 69 | } | ... | ... |
This diff is collapsed. Click to expand it.
core/store/dist/src/main/java/org/onosproject/store/ecmap/InternalRemoveEvent.java
deleted
100644 → 0
1 | -/* | ||
2 | - * Copyright 2015 Open Networking Laboratory | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | -package org.onosproject.store.ecmap; | ||
17 | - | ||
18 | -import com.google.common.collect.ImmutableList; | ||
19 | -import org.onosproject.store.Timestamp; | ||
20 | - | ||
21 | -import java.util.List; | ||
22 | - | ||
23 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
24 | - | ||
25 | -/** | ||
26 | - * Internal inter-instance event used by EventuallyConsistentMap for REMOVE | ||
27 | - * events. | ||
28 | - */ | ||
29 | -final class InternalRemoveEvent<K> { | ||
30 | - private final List<RemoveEntry<K>> entries; | ||
31 | - | ||
32 | - /** | ||
33 | - * Creates a remove event for a single key. | ||
34 | - * | ||
35 | - * @param key key the event concerns | ||
36 | - * @param timestamp timestamp of the event | ||
37 | - */ | ||
38 | - public InternalRemoveEvent(K key, Timestamp timestamp) { | ||
39 | - entries = ImmutableList.of(new RemoveEntry<>(key, timestamp)); | ||
40 | - } | ||
41 | - | ||
42 | - /** | ||
43 | - * Creates a remove event for multiple keys. | ||
44 | - * | ||
45 | - * @param entries list of remove entries to send an event for | ||
46 | - */ | ||
47 | - public InternalRemoveEvent(List<RemoveEntry<K>> entries) { | ||
48 | - this.entries = checkNotNull(entries); | ||
49 | - } | ||
50 | - | ||
51 | - // Needed for serialization. | ||
52 | - @SuppressWarnings("unused") | ||
53 | - private InternalRemoveEvent() { | ||
54 | - entries = null; | ||
55 | - } | ||
56 | - | ||
57 | - /** | ||
58 | - * Returns the list of remove entries this event concerns. | ||
59 | - * | ||
60 | - * @return list of remove entries | ||
61 | - */ | ||
62 | - public List<RemoveEntry<K>> entries() { | ||
63 | - return entries; | ||
64 | - } | ||
65 | -} |
... | @@ -23,10 +23,8 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -23,10 +23,8 @@ import static com.google.common.base.Preconditions.checkNotNull; |
23 | /** | 23 | /** |
24 | * Describes a single put event in an EventuallyConsistentMap. | 24 | * Describes a single put event in an EventuallyConsistentMap. |
25 | */ | 25 | */ |
26 | -final class PutEntry<K, V> { | 26 | +final class PutEntry<K, V> extends AbstractEntry<K, V> { |
27 | - private final K key; | ||
28 | private final V value; | 27 | private final V value; |
29 | - private final Timestamp timestamp; | ||
30 | 28 | ||
31 | /** | 29 | /** |
32 | * Creates a new put entry. | 30 | * Creates a new put entry. |
... | @@ -36,26 +34,15 @@ final class PutEntry<K, V> { | ... | @@ -36,26 +34,15 @@ final class PutEntry<K, V> { |
36 | * @param timestamp timestamp of the put event | 34 | * @param timestamp timestamp of the put event |
37 | */ | 35 | */ |
38 | public PutEntry(K key, V value, Timestamp timestamp) { | 36 | public PutEntry(K key, V value, Timestamp timestamp) { |
39 | - this.key = checkNotNull(key); | 37 | + super(key, timestamp); |
40 | this.value = checkNotNull(value); | 38 | this.value = checkNotNull(value); |
41 | - this.timestamp = checkNotNull(timestamp); | ||
42 | } | 39 | } |
43 | 40 | ||
44 | // Needed for serialization. | 41 | // Needed for serialization. |
45 | @SuppressWarnings("unused") | 42 | @SuppressWarnings("unused") |
46 | private PutEntry() { | 43 | private PutEntry() { |
47 | - this.key = null; | 44 | + super(); |
48 | this.value = null; | 45 | this.value = null; |
49 | - this.timestamp = null; | ||
50 | - } | ||
51 | - | ||
52 | - /** | ||
53 | - * Returns the key of the entry. | ||
54 | - * | ||
55 | - * @return the key | ||
56 | - */ | ||
57 | - public K key() { | ||
58 | - return key; | ||
59 | } | 46 | } |
60 | 47 | ||
61 | /** | 48 | /** |
... | @@ -67,21 +54,12 @@ final class PutEntry<K, V> { | ... | @@ -67,21 +54,12 @@ final class PutEntry<K, V> { |
67 | return value; | 54 | return value; |
68 | } | 55 | } |
69 | 56 | ||
70 | - /** | ||
71 | - * Returns the timestamp of the event. | ||
72 | - * | ||
73 | - * @return the timestamp | ||
74 | - */ | ||
75 | - public Timestamp timestamp() { | ||
76 | - return timestamp; | ||
77 | - } | ||
78 | - | ||
79 | @Override | 57 | @Override |
80 | public String toString() { | 58 | public String toString() { |
81 | return MoreObjects.toStringHelper(getClass()) | 59 | return MoreObjects.toStringHelper(getClass()) |
82 | - .add("key", key) | 60 | + .add("key", key()) |
83 | .add("value", value) | 61 | .add("value", value) |
84 | - .add("timestamp", timestamp) | 62 | + .add("timestamp", timestamp()) |
85 | .toString(); | 63 | .toString(); |
86 | } | 64 | } |
87 | } | 65 | } | ... | ... |
... | @@ -18,15 +18,10 @@ package org.onosproject.store.ecmap; | ... | @@ -18,15 +18,10 @@ package org.onosproject.store.ecmap; |
18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
19 | import org.onosproject.store.Timestamp; | 19 | import org.onosproject.store.Timestamp; |
20 | 20 | ||
21 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
22 | - | ||
23 | /** | 21 | /** |
24 | * Describes a single remove event in an EventuallyConsistentMap. | 22 | * Describes a single remove event in an EventuallyConsistentMap. |
25 | */ | 23 | */ |
26 | -final class RemoveEntry<K> { | 24 | +final class RemoveEntry<K, V> extends AbstractEntry<K, V> { |
27 | - private final K key; | ||
28 | - private final Timestamp timestamp; | ||
29 | - | ||
30 | /** | 25 | /** |
31 | * Creates a new remove entry. | 26 | * Creates a new remove entry. |
32 | * | 27 | * |
... | @@ -34,40 +29,20 @@ final class RemoveEntry<K> { | ... | @@ -34,40 +29,20 @@ final class RemoveEntry<K> { |
34 | * @param timestamp timestamp of the remove event | 29 | * @param timestamp timestamp of the remove event |
35 | */ | 30 | */ |
36 | public RemoveEntry(K key, Timestamp timestamp) { | 31 | public RemoveEntry(K key, Timestamp timestamp) { |
37 | - this.key = checkNotNull(key); | 32 | + super(key, timestamp); |
38 | - this.timestamp = checkNotNull(timestamp); | ||
39 | } | 33 | } |
40 | 34 | ||
41 | // Needed for serialization. | 35 | // Needed for serialization. |
42 | @SuppressWarnings("unused") | 36 | @SuppressWarnings("unused") |
43 | private RemoveEntry() { | 37 | private RemoveEntry() { |
44 | - this.key = null; | 38 | + super(); |
45 | - this.timestamp = null; | ||
46 | - } | ||
47 | - | ||
48 | - /** | ||
49 | - * Returns the key of the entry. | ||
50 | - * | ||
51 | - * @return the key | ||
52 | - */ | ||
53 | - public K key() { | ||
54 | - return key; | ||
55 | - } | ||
56 | - | ||
57 | - /** | ||
58 | - * Returns the timestamp of the event. | ||
59 | - * | ||
60 | - * @return the timestamp | ||
61 | - */ | ||
62 | - public Timestamp timestamp() { | ||
63 | - return timestamp; | ||
64 | } | 39 | } |
65 | 40 | ||
66 | @Override | 41 | @Override |
67 | public String toString() { | 42 | public String toString() { |
68 | return MoreObjects.toStringHelper(getClass()) | 43 | return MoreObjects.toStringHelper(getClass()) |
69 | - .add("key", key) | 44 | + .add("key", key()) |
70 | - .add("timestamp", timestamp) | 45 | + .add("timestamp", timestamp()) |
71 | .toString(); | 46 | .toString(); |
72 | } | 47 | } |
73 | } | 48 | } | ... | ... |
... | @@ -17,6 +17,7 @@ package org.onosproject.store.ecmap; | ... | @@ -17,6 +17,7 @@ package org.onosproject.store.ecmap; |
17 | 17 | ||
18 | import com.google.common.collect.ComparisonChain; | 18 | import com.google.common.collect.ComparisonChain; |
19 | import com.google.common.collect.ImmutableSet; | 19 | import com.google.common.collect.ImmutableSet; |
20 | +import com.google.common.collect.Lists; | ||
20 | import com.google.common.util.concurrent.ListenableFuture; | 21 | import com.google.common.util.concurrent.ListenableFuture; |
21 | import com.google.common.util.concurrent.MoreExecutors; | 22 | import com.google.common.util.concurrent.MoreExecutors; |
22 | import org.junit.After; | 23 | import org.junit.After; |
... | @@ -67,10 +68,8 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -67,10 +68,8 @@ public class EventuallyConsistentMapImplTest { |
67 | private SequentialClockService<String, String> clockService; | 68 | private SequentialClockService<String, String> clockService; |
68 | 69 | ||
69 | private static final String MAP_NAME = "test"; | 70 | private static final String MAP_NAME = "test"; |
70 | - private static final MessageSubject PUT_MESSAGE_SUBJECT | 71 | + private static final MessageSubject UPDATE_MESSAGE_SUBJECT |
71 | = new MessageSubject("ecm-" + MAP_NAME + "-update"); | 72 | = new MessageSubject("ecm-" + MAP_NAME + "-update"); |
72 | - private static final MessageSubject REMOVE_MESSAGE_SUBJECT | ||
73 | - = new MessageSubject("ecm-" + MAP_NAME + "-remove"); | ||
74 | private static final MessageSubject ANTI_ENTROPY_MESSAGE_SUBJECT | 73 | private static final MessageSubject ANTI_ENTROPY_MESSAGE_SUBJECT |
75 | = new MessageSubject("ecm-" + MAP_NAME + "-anti-entropy"); | 74 | = new MessageSubject("ecm-" + MAP_NAME + "-anti-entropy"); |
76 | 75 | ||
... | @@ -82,8 +81,7 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -82,8 +81,7 @@ public class EventuallyConsistentMapImplTest { |
82 | private final ControllerNode self = | 81 | private final ControllerNode self = |
83 | new DefaultControllerNode(new NodeId("local"), IpAddress.valueOf(1)); | 82 | new DefaultControllerNode(new NodeId("local"), IpAddress.valueOf(1)); |
84 | 83 | ||
85 | - private ClusterMessageHandler putHandler; | 84 | + private ClusterMessageHandler updateHandler; |
86 | - private ClusterMessageHandler removeHandler; | ||
87 | private ClusterMessageHandler antiEntropyHandler; | 85 | private ClusterMessageHandler antiEntropyHandler; |
88 | 86 | ||
89 | /* | 87 | /* |
... | @@ -105,8 +103,6 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -105,8 +103,6 @@ public class EventuallyConsistentMapImplTest { |
105 | .register(PutEntry.class) | 103 | .register(PutEntry.class) |
106 | .register(RemoveEntry.class) | 104 | .register(RemoveEntry.class) |
107 | .register(ArrayList.class) | 105 | .register(ArrayList.class) |
108 | - .register(InternalPutEvent.class) | ||
109 | - .register(InternalRemoveEvent.class) | ||
110 | .register(AntiEntropyAdvertisement.class) | 106 | .register(AntiEntropyAdvertisement.class) |
111 | .register(HashMap.class) | 107 | .register(HashMap.class) |
112 | .build(); | 108 | .build(); |
... | @@ -237,7 +233,7 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -237,7 +233,7 @@ public class EventuallyConsistentMapImplTest { |
237 | ecMap.addListener(new TestListener(latch)); | 233 | ecMap.addListener(new TestListener(latch)); |
238 | 234 | ||
239 | assertNull(ecMap.get(KEY2)); | 235 | assertNull(ecMap.get(KEY2)); |
240 | - putHandler.handle(message); | 236 | + updateHandler.handle(message); |
241 | assertTrue("External listener never got notified of internal event", | 237 | assertTrue("External listener never got notified of internal event", |
242 | latch.await(100, TimeUnit.MILLISECONDS)); | 238 | latch.await(100, TimeUnit.MILLISECONDS)); |
243 | assertEquals(VALUE2, ecMap.get(KEY2)); | 239 | assertEquals(VALUE2, ecMap.get(KEY2)); |
... | @@ -254,7 +250,7 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -254,7 +250,7 @@ public class EventuallyConsistentMapImplTest { |
254 | latch = new CountDownLatch(1); | 250 | latch = new CountDownLatch(1); |
255 | ecMap.addListener(new TestListener(latch)); | 251 | ecMap.addListener(new TestListener(latch)); |
256 | 252 | ||
257 | - removeHandler.handle(removeMessage); | 253 | + updateHandler.handle(removeMessage); |
258 | assertTrue("External listener never got notified of internal event", | 254 | assertTrue("External listener never got notified of internal event", |
259 | latch.await(100, TimeUnit.MILLISECONDS)); | 255 | latch.await(100, TimeUnit.MILLISECONDS)); |
260 | assertNull(ecMap.get(KEY1)); | 256 | assertNull(ecMap.get(KEY1)); |
... | @@ -568,8 +564,7 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -568,8 +564,7 @@ public class EventuallyConsistentMapImplTest { |
568 | 564 | ||
569 | @Test | 565 | @Test |
570 | public void testDestroy() throws Exception { | 566 | public void testDestroy() throws Exception { |
571 | - clusterCommunicator.removeSubscriber(PUT_MESSAGE_SUBJECT); | 567 | + clusterCommunicator.removeSubscriber(UPDATE_MESSAGE_SUBJECT); |
572 | - clusterCommunicator.removeSubscriber(REMOVE_MESSAGE_SUBJECT); | ||
573 | clusterCommunicator.removeSubscriber(ANTI_ENTROPY_MESSAGE_SUBJECT); | 568 | clusterCommunicator.removeSubscriber(ANTI_ENTROPY_MESSAGE_SUBJECT); |
574 | 569 | ||
575 | replay(clusterCommunicator); | 570 | replay(clusterCommunicator); |
... | @@ -594,12 +589,11 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -594,12 +589,11 @@ public class EventuallyConsistentMapImplTest { |
594 | } | 589 | } |
595 | 590 | ||
596 | private ClusterMessage generatePutMessage(String key, String value, Timestamp timestamp) { | 591 | private ClusterMessage generatePutMessage(String key, String value, Timestamp timestamp) { |
597 | - InternalPutEvent<String, String> event = | 592 | + PutEntry<String, String> event = new PutEntry<>(key, value, timestamp); |
598 | - new InternalPutEvent<>(key, value, timestamp); | ||
599 | 593 | ||
600 | return new ClusterMessage( | 594 | return new ClusterMessage( |
601 | - clusterService.getLocalNode().id(), PUT_MESSAGE_SUBJECT, | 595 | + clusterService.getLocalNode().id(), UPDATE_MESSAGE_SUBJECT, |
602 | - SERIALIZER.encode(event)); | 596 | + SERIALIZER.encode(Lists.newArrayList(event))); |
603 | } | 597 | } |
604 | 598 | ||
605 | private ClusterMessage generatePutMessage(String key1, String value1, String key2, String value2) { | 599 | private ClusterMessage generatePutMessage(String key1, String value1, String key2, String value2) { |
... | @@ -614,38 +608,35 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -614,38 +608,35 @@ public class EventuallyConsistentMapImplTest { |
614 | list.add(pe1); | 608 | list.add(pe1); |
615 | list.add(pe2); | 609 | list.add(pe2); |
616 | 610 | ||
617 | - InternalPutEvent<String, String> event = new InternalPutEvent<>(list); | ||
618 | 611 | ||
619 | return new ClusterMessage( | 612 | return new ClusterMessage( |
620 | - clusterService.getLocalNode().id(), PUT_MESSAGE_SUBJECT, | 613 | + clusterService.getLocalNode().id(), UPDATE_MESSAGE_SUBJECT, |
621 | - SERIALIZER.encode(event)); | 614 | + SERIALIZER.encode(list)); |
622 | } | 615 | } |
623 | 616 | ||
624 | private ClusterMessage generateRemoveMessage(String key, Timestamp timestamp) { | 617 | private ClusterMessage generateRemoveMessage(String key, Timestamp timestamp) { |
625 | - InternalRemoveEvent<String> event = new InternalRemoveEvent<>(key, timestamp); | 618 | + RemoveEntry<String, String> event = new RemoveEntry<>(key, timestamp); |
626 | 619 | ||
627 | return new ClusterMessage( | 620 | return new ClusterMessage( |
628 | - clusterService.getLocalNode().id(), REMOVE_MESSAGE_SUBJECT, | 621 | + clusterService.getLocalNode().id(), UPDATE_MESSAGE_SUBJECT, |
629 | - SERIALIZER.encode(event)); | 622 | + SERIALIZER.encode(Lists.newArrayList(event))); |
630 | } | 623 | } |
631 | 624 | ||
632 | private ClusterMessage generateRemoveMessage(String key1, String key2) { | 625 | private ClusterMessage generateRemoveMessage(String key1, String key2) { |
633 | - ArrayList<RemoveEntry<String>> list = new ArrayList<>(); | 626 | + ArrayList<RemoveEntry<String, String>> list = new ArrayList<>(); |
634 | 627 | ||
635 | Timestamp timestamp1 = clockService.peek(1); | 628 | Timestamp timestamp1 = clockService.peek(1); |
636 | Timestamp timestamp2 = clockService.peek(2); | 629 | Timestamp timestamp2 = clockService.peek(2); |
637 | 630 | ||
638 | - RemoveEntry<String> re1 = new RemoveEntry<>(key1, timestamp1); | 631 | + RemoveEntry<String, String> re1 = new RemoveEntry<>(key1, timestamp1); |
639 | - RemoveEntry<String> re2 = new RemoveEntry<>(key2, timestamp2); | 632 | + RemoveEntry<String, String> re2 = new RemoveEntry<>(key2, timestamp2); |
640 | 633 | ||
641 | list.add(re1); | 634 | list.add(re1); |
642 | list.add(re2); | 635 | list.add(re2); |
643 | 636 | ||
644 | - InternalRemoveEvent<String> event = new InternalRemoveEvent<>(list); | ||
645 | - | ||
646 | return new ClusterMessage( | 637 | return new ClusterMessage( |
647 | - clusterService.getLocalNode().id(), REMOVE_MESSAGE_SUBJECT, | 638 | + clusterService.getLocalNode().id(), UPDATE_MESSAGE_SUBJECT, |
648 | - SERIALIZER.encode(event)); | 639 | + SERIALIZER.encode(list)); |
649 | } | 640 | } |
650 | 641 | ||
651 | /** | 642 | /** |
... | @@ -655,10 +646,14 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -655,10 +646,14 @@ public class EventuallyConsistentMapImplTest { |
655 | * @param m message we expect to be sent | 646 | * @param m message we expect to be sent |
656 | * @param clusterCommunicator a mock ClusterCommunicationService to set up | 647 | * @param clusterCommunicator a mock ClusterCommunicationService to set up |
657 | */ | 648 | */ |
649 | + //FIXME rename | ||
658 | private static void expectSpecificBroadcastMessage(ClusterMessage m, | 650 | private static void expectSpecificBroadcastMessage(ClusterMessage m, |
659 | ClusterCommunicationService clusterCommunicator) { | 651 | ClusterCommunicationService clusterCommunicator) { |
660 | reset(clusterCommunicator); | 652 | reset(clusterCommunicator); |
661 | - expect(clusterCommunicator.broadcast(m)).andReturn(true); | 653 | +// expect(clusterCommunicator.broadcast(m)).andReturn(true); |
654 | + expect(clusterCommunicator.unicast(eq(m), anyObject(NodeId.class))) | ||
655 | + .andReturn(true) | ||
656 | + .anyTimes(); | ||
662 | replay(clusterCommunicator); | 657 | replay(clusterCommunicator); |
663 | } | 658 | } |
664 | 659 | ||
... | @@ -669,10 +664,14 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -669,10 +664,14 @@ public class EventuallyConsistentMapImplTest { |
669 | * @param m message we expect to be sent | 664 | * @param m message we expect to be sent |
670 | * @param clusterCommunicator a mock ClusterCommunicationService to set up | 665 | * @param clusterCommunicator a mock ClusterCommunicationService to set up |
671 | */ | 666 | */ |
667 | + //FIXME rename | ||
672 | private static void expectSpecificMulticastMessage(ClusterMessage m, | 668 | private static void expectSpecificMulticastMessage(ClusterMessage m, |
673 | ClusterCommunicationService clusterCommunicator) { | 669 | ClusterCommunicationService clusterCommunicator) { |
674 | reset(clusterCommunicator); | 670 | reset(clusterCommunicator); |
675 | - expect(clusterCommunicator.multicast(eq(m), anyObject(Set.class))).andReturn(true); | 671 | +// expect(clusterCommunicator.multicast(eq(m), anyObject(Set.class))).andReturn(true); |
672 | + expect(clusterCommunicator.unicast(eq(m), anyObject(NodeId.class))) | ||
673 | + .andReturn(true) | ||
674 | + .anyTimes(); | ||
676 | replay(clusterCommunicator); | 675 | replay(clusterCommunicator); |
677 | } | 676 | } |
678 | 677 | ||
... | @@ -684,10 +683,13 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -684,10 +683,13 @@ public class EventuallyConsistentMapImplTest { |
684 | * | 683 | * |
685 | * @param clusterCommunicator a mock ClusterCommunicationService to set up | 684 | * @param clusterCommunicator a mock ClusterCommunicationService to set up |
686 | */ | 685 | */ |
686 | + //FIXME rename | ||
687 | private void expectPeerMessage(ClusterCommunicationService clusterCommunicator) { | 687 | private void expectPeerMessage(ClusterCommunicationService clusterCommunicator) { |
688 | reset(clusterCommunicator); | 688 | reset(clusterCommunicator); |
689 | - expect(clusterCommunicator.multicast(anyObject(ClusterMessage.class), | 689 | +// expect(clusterCommunicator.multicast(anyObject(ClusterMessage.class), |
690 | - anyObject(Iterable.class))) | 690 | +// anyObject(Iterable.class))) |
691 | + expect(clusterCommunicator.unicast(anyObject(ClusterMessage.class), | ||
692 | + anyObject(NodeId.class))) | ||
691 | .andReturn(true) | 693 | .andReturn(true) |
692 | .anyTimes(); | 694 | .anyTimes(); |
693 | replay(clusterCommunicator); | 695 | replay(clusterCommunicator); |
... | @@ -700,9 +702,13 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -700,9 +702,13 @@ public class EventuallyConsistentMapImplTest { |
700 | * | 702 | * |
701 | * @param clusterCommunicator a mock ClusterCommunicationService to set up | 703 | * @param clusterCommunicator a mock ClusterCommunicationService to set up |
702 | */ | 704 | */ |
705 | + //FIXME rename | ||
703 | private void expectBroadcastMessage(ClusterCommunicationService clusterCommunicator) { | 706 | private void expectBroadcastMessage(ClusterCommunicationService clusterCommunicator) { |
704 | reset(clusterCommunicator); | 707 | reset(clusterCommunicator); |
705 | - expect(clusterCommunicator.broadcast(anyObject(ClusterMessage.class))) | 708 | +// expect(clusterCommunicator.broadcast(anyObject(ClusterMessage.class))) |
709 | +// .andReturn(true) | ||
710 | +// .anyTimes(); | ||
711 | + expect(clusterCommunicator.unicast(anyObject(ClusterMessage.class), anyObject(NodeId.class))) | ||
706 | .andReturn(true) | 712 | .andReturn(true) |
707 | .anyTimes(); | 713 | .anyTimes(); |
708 | replay(clusterCommunicator); | 714 | replay(clusterCommunicator); |
... | @@ -747,10 +753,8 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -747,10 +753,8 @@ public class EventuallyConsistentMapImplTest { |
747 | @Override | 753 | @Override |
748 | public void addSubscriber(MessageSubject subject, | 754 | public void addSubscriber(MessageSubject subject, |
749 | ClusterMessageHandler subscriber) { | 755 | ClusterMessageHandler subscriber) { |
750 | - if (subject.equals(PUT_MESSAGE_SUBJECT)) { | 756 | + if (subject.equals(UPDATE_MESSAGE_SUBJECT)) { |
751 | - putHandler = subscriber; | 757 | + updateHandler = subscriber; |
752 | - } else if (subject.equals(REMOVE_MESSAGE_SUBJECT)) { | ||
753 | - removeHandler = subscriber; | ||
754 | } else if (subject.equals(ANTI_ENTROPY_MESSAGE_SUBJECT)) { | 758 | } else if (subject.equals(ANTI_ENTROPY_MESSAGE_SUBJECT)) { |
755 | antiEntropyHandler = subscriber; | 759 | antiEntropyHandler = subscriber; |
756 | } else { | 760 | } else { |
... | @@ -762,10 +766,8 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -762,10 +766,8 @@ public class EventuallyConsistentMapImplTest { |
762 | public void addSubscriber(MessageSubject subject, | 766 | public void addSubscriber(MessageSubject subject, |
763 | ClusterMessageHandler subscriber, | 767 | ClusterMessageHandler subscriber, |
764 | ExecutorService executor) { | 768 | ExecutorService executor) { |
765 | - if (subject.equals(PUT_MESSAGE_SUBJECT)) { | 769 | + if (subject.equals(UPDATE_MESSAGE_SUBJECT)) { |
766 | - putHandler = subscriber; | 770 | + updateHandler = subscriber; |
767 | - } else if (subject.equals(REMOVE_MESSAGE_SUBJECT)) { | ||
768 | - removeHandler = subscriber; | ||
769 | } else if (subject.equals(ANTI_ENTROPY_MESSAGE_SUBJECT)) { | 771 | } else if (subject.equals(ANTI_ENTROPY_MESSAGE_SUBJECT)) { |
770 | antiEntropyHandler = subscriber; | 772 | antiEntropyHandler = subscriber; |
771 | } else { | 773 | } else { | ... | ... |
-
Please register or login to post a comment