Committed by
Gerrit Code Review
Misc bug fixes in preparation for enabling StorageManager
Change-Id: I953414891c901e5d1f92844ca8c4eaa8c042dd53
Showing
3 changed files
with
13 additions
and
24 deletions
... | @@ -24,12 +24,14 @@ import java.io.InputStream; | ... | @@ -24,12 +24,14 @@ import java.io.InputStream; |
24 | import java.util.Map; | 24 | import java.util.Map; |
25 | import java.util.Objects; | 25 | import java.util.Objects; |
26 | import java.util.concurrent.CompletableFuture; | 26 | import java.util.concurrent.CompletableFuture; |
27 | -import java.util.concurrent.atomic.AtomicInteger; | ||
28 | import java.util.function.Consumer; | 27 | import java.util.function.Consumer; |
29 | 28 | ||
29 | + | ||
30 | + | ||
30 | import org.apache.commons.io.IOUtils; | 31 | import org.apache.commons.io.IOUtils; |
31 | import org.onlab.util.Tools; | 32 | import org.onlab.util.Tools; |
32 | import org.onosproject.cluster.PartitionId; | 33 | import org.onosproject.cluster.PartitionId; |
34 | +import org.onosproject.store.cluster.messaging.MessagingException; | ||
33 | import org.onosproject.store.cluster.messaging.MessagingService; | 35 | import org.onosproject.store.cluster.messaging.MessagingService; |
34 | 36 | ||
35 | import com.google.common.base.MoreObjects; | 37 | import com.google.common.base.MoreObjects; |
... | @@ -41,6 +43,7 @@ import io.atomix.catalyst.serializer.SerializationException; | ... | @@ -41,6 +43,7 @@ import io.atomix.catalyst.serializer.SerializationException; |
41 | import io.atomix.catalyst.transport.Address; | 43 | import io.atomix.catalyst.transport.Address; |
42 | import io.atomix.catalyst.transport.Connection; | 44 | import io.atomix.catalyst.transport.Connection; |
43 | import io.atomix.catalyst.transport.MessageHandler; | 45 | import io.atomix.catalyst.transport.MessageHandler; |
46 | +import io.atomix.catalyst.transport.TransportException; | ||
44 | import io.atomix.catalyst.util.Assert; | 47 | import io.atomix.catalyst.util.Assert; |
45 | import io.atomix.catalyst.util.Listener; | 48 | import io.atomix.catalyst.util.Listener; |
46 | import io.atomix.catalyst.util.Listeners; | 49 | import io.atomix.catalyst.util.Listeners; |
... | @@ -66,10 +69,6 @@ public class CopycatTransportConnection implements Connection { | ... | @@ -66,10 +69,6 @@ public class CopycatTransportConnection implements Connection { |
66 | private final String inboundMessageSubject; | 69 | private final String inboundMessageSubject; |
67 | private final ThreadContext context; | 70 | private final ThreadContext context; |
68 | private final Map<Class<?>, InternalHandler> handlers = Maps.newConcurrentMap(); | 71 | private final Map<Class<?>, InternalHandler> handlers = Maps.newConcurrentMap(); |
69 | - private final AtomicInteger messagesSent = new AtomicInteger(0); | ||
70 | - private final AtomicInteger sendFailures = new AtomicInteger(0); | ||
71 | - private final AtomicInteger messagesReceived = new AtomicInteger(0); | ||
72 | - private final AtomicInteger receiveFailures = new AtomicInteger(0); | ||
73 | 72 | ||
74 | CopycatTransportConnection(long connectionId, | 73 | CopycatTransportConnection(long connectionId, |
75 | CopycatTransport.Mode mode, | 74 | CopycatTransport.Mode mode, |
... | @@ -120,12 +119,14 @@ public class CopycatTransportConnection implements Connection { | ... | @@ -120,12 +119,14 @@ public class CopycatTransportConnection implements Connection { |
120 | baos.toByteArray(), | 119 | baos.toByteArray(), |
121 | context.executor()) | 120 | context.executor()) |
122 | .whenComplete((r, e) -> { | 121 | .whenComplete((r, e) -> { |
123 | - if (e == null) { | 122 | + Throwable wrappedError = e; |
124 | - messagesSent.incrementAndGet(); | 123 | + if (e != null) { |
125 | - } else { | 124 | + Throwable rootCause = Throwables.getRootCause(e); |
126 | - sendFailures.incrementAndGet(); | 125 | + if (MessagingException.class.isAssignableFrom(rootCause.getClass())) { |
126 | + wrappedError = new TransportException(e); | ||
127 | + } | ||
127 | } | 128 | } |
128 | - handleResponse(r, e, result, context); | 129 | + handleResponse(r, wrappedError, result, context); |
129 | }); | 130 | }); |
130 | } catch (SerializationException | IOException e) { | 131 | } catch (SerializationException | IOException e) { |
131 | result.completeExceptionally(e); | 132 | result.completeExceptionally(e); |
... | @@ -172,11 +173,6 @@ public class CopycatTransportConnection implements Connection { | ... | @@ -172,11 +173,6 @@ public class CopycatTransportConnection implements Connection { |
172 | "No handler registered for " + request.getClass())); | 173 | "No handler registered for " + request.getClass())); |
173 | } | 174 | } |
174 | return handler.handle(request).handle((result, error) -> { | 175 | return handler.handle(request).handle((result, error) -> { |
175 | - if (error == null) { | ||
176 | - messagesReceived.incrementAndGet(); | ||
177 | - } else { | ||
178 | - receiveFailures.incrementAndGet(); | ||
179 | - } | ||
180 | try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { | 176 | try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { |
181 | baos.write(error != null ? FAILURE : SUCCESS); | 177 | baos.write(error != null ? FAILURE : SUCCESS); |
182 | context.serializer().writeObject(error != null ? error : result, baos); | 178 | context.serializer().writeObject(error != null ? error : result, baos); |
... | @@ -220,7 +216,6 @@ public class CopycatTransportConnection implements Connection { | ... | @@ -220,7 +216,6 @@ public class CopycatTransportConnection implements Connection { |
220 | if (!(other instanceof CopycatTransportConnection)) { | 216 | if (!(other instanceof CopycatTransportConnection)) { |
221 | return false; | 217 | return false; |
222 | } | 218 | } |
223 | - | ||
224 | return connectionId == ((CopycatTransportConnection) other).connectionId; | 219 | return connectionId == ((CopycatTransportConnection) other).connectionId; |
225 | } | 220 | } |
226 | 221 | ||
... | @@ -228,10 +223,6 @@ public class CopycatTransportConnection implements Connection { | ... | @@ -228,10 +223,6 @@ public class CopycatTransportConnection implements Connection { |
228 | public String toString() { | 223 | public String toString() { |
229 | return MoreObjects.toStringHelper(getClass()) | 224 | return MoreObjects.toStringHelper(getClass()) |
230 | .add("id", connectionId) | 225 | .add("id", connectionId) |
231 | - .add("sent", messagesSent.get()) | ||
232 | - .add("received", messagesReceived.get()) | ||
233 | - .add("sendFailures", sendFailures.get()) | ||
234 | - .add("receiveFailures", receiveFailures.get()) | ||
235 | .toString(); | 226 | .toString(); |
236 | } | 227 | } |
237 | 228 | ... | ... |
... | @@ -18,7 +18,6 @@ package org.onosproject.store.primitives.impl; | ... | @@ -18,7 +18,6 @@ package org.onosproject.store.primitives.impl; |
18 | import io.atomix.catalyst.serializer.Serializer; | 18 | import io.atomix.catalyst.serializer.Serializer; |
19 | import io.atomix.catalyst.transport.Address; | 19 | import io.atomix.catalyst.transport.Address; |
20 | import io.atomix.resource.ResourceType; | 20 | import io.atomix.resource.ResourceType; |
21 | -import io.atomix.variables.DistributedLong; | ||
22 | 21 | ||
23 | import java.io.File; | 22 | import java.io.File; |
24 | import java.util.Collection; | 23 | import java.util.Collection; |
... | @@ -57,7 +56,6 @@ public class StoragePartition implements Managed<StoragePartition> { | ... | @@ -57,7 +56,6 @@ public class StoragePartition implements Managed<StoragePartition> { |
57 | private StoragePartitionClient client; | 56 | private StoragePartitionClient client; |
58 | 57 | ||
59 | public static final Collection<ResourceType> RESOURCE_TYPES = ImmutableSet.of( | 58 | public static final Collection<ResourceType> RESOURCE_TYPES = ImmutableSet.of( |
60 | - new ResourceType(DistributedLong.class), | ||
61 | new ResourceType(AtomixLeaderElector.class), | 59 | new ResourceType(AtomixLeaderElector.class), |
62 | new ResourceType(AtomixConsistentMap.class)); | 60 | new ResourceType(AtomixConsistentMap.class)); |
63 | 61 | ... | ... |
... | @@ -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.SEQUENTIAL; | 55 | + return ConsistencyLevel.LINEARIZABLE; |
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.SEQUENTIAL; | 81 | + return ConsistencyLevel.BOUNDED_LINEARIZABLE; |
82 | } | 82 | } |
83 | 83 | ||
84 | @Override | 84 | @Override | ... | ... |
-
Please register or login to post a comment