Madan Jampani
Committed by Gerrit Code Review

Ensure exceptions in map event handling do not prevent event acknowledgement

Set default consistency for ConsistentMap operations to SEQUENTIAL

Change-Id: I8896ae953932bf323c4512842000e78bf395f9b1
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.store.primitives.resources.impl; 16 package org.onosproject.store.primitives.resources.impl;
17 17
18 +import static org.slf4j.LoggerFactory.getLogger;
18 import io.atomix.copycat.client.CopycatClient; 19 import io.atomix.copycat.client.CopycatClient;
19 import io.atomix.resource.AbstractResource; 20 import io.atomix.resource.AbstractResource;
20 import io.atomix.resource.ResourceTypeInfo; 21 import io.atomix.resource.ResourceTypeInfo;
...@@ -52,6 +53,7 @@ import org.onosproject.store.service.MapEvent; ...@@ -52,6 +53,7 @@ import org.onosproject.store.service.MapEvent;
52 import org.onosproject.store.service.MapEventListener; 53 import org.onosproject.store.service.MapEventListener;
53 import org.onosproject.store.service.MapTransaction; 54 import org.onosproject.store.service.MapTransaction;
54 import org.onosproject.store.service.Versioned; 55 import org.onosproject.store.service.Versioned;
56 +import org.slf4j.Logger;
55 57
56 import com.google.common.collect.Sets; 58 import com.google.common.collect.Sets;
57 59
...@@ -62,6 +64,7 @@ import com.google.common.collect.Sets; ...@@ -62,6 +64,7 @@ import com.google.common.collect.Sets;
62 public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> 64 public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
63 implements AsyncConsistentMap<String, byte[]> { 65 implements AsyncConsistentMap<String, byte[]> {
64 66
67 + private final Logger log = getLogger(getClass());
65 private final Set<MapEventListener<String, byte[]>> mapEventListeners = Sets.newCopyOnWriteArraySet(); 68 private final Set<MapEventListener<String, byte[]>> mapEventListeners = Sets.newCopyOnWriteArraySet();
66 69
67 public static final String CHANGE_SUBJECT = "changeEvents"; 70 public static final String CHANGE_SUBJECT = "changeEvents";
...@@ -84,7 +87,13 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> ...@@ -84,7 +87,13 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
84 } 87 }
85 88
86 private void handleEvent(List<MapEvent<String, byte[]>> events) { 89 private void handleEvent(List<MapEvent<String, byte[]>> events) {
87 - events.forEach(event -> mapEventListeners.forEach(listener -> listener.event(event))); 90 + events.forEach(event -> mapEventListeners.forEach(listener -> {
91 + try {
92 + listener.event(event);
93 + } catch (Exception e) {
94 + log.warn("Error processing map event", e);
95 + }
96 + }));
88 } 97 }
89 98
90 @Override 99 @Override
......
...@@ -52,7 +52,7 @@ public final class AtomixConsistentMapCommands { ...@@ -52,7 +52,7 @@ public final class AtomixConsistentMapCommands {
52 52
53 @Override 53 @Override
54 public ConsistencyLevel consistency() { 54 public ConsistencyLevel consistency() {
55 - return ConsistencyLevel.LINEARIZABLE; 55 + return ConsistencyLevel.SEQUENTIAL;
56 } 56 }
57 57
58 @Override 58 @Override
...@@ -78,7 +78,7 @@ public final class AtomixConsistentMapCommands { ...@@ -78,7 +78,7 @@ public final class AtomixConsistentMapCommands {
78 78
79 @Override 79 @Override
80 public ConsistencyLevel consistency() { 80 public ConsistencyLevel consistency() {
81 - return ConsistencyLevel.BOUNDED_LINEARIZABLE; 81 + return ConsistencyLevel.SEQUENTIAL;
82 } 82 }
83 83
84 @Override 84 @Override
......