mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-18 10:51:04 +02:00
Misc bug fixes in preparation for enabling StorageManager
Change-Id: I953414891c901e5d1f92844ca8c4eaa8c042dd53
This commit is contained in:
parent
7ff7978530
commit
6f74371b5e
@ -24,12 +24,14 @@ import java.io.InputStream;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.onlab.util.Tools;
|
import org.onlab.util.Tools;
|
||||||
import org.onosproject.cluster.PartitionId;
|
import org.onosproject.cluster.PartitionId;
|
||||||
|
import org.onosproject.store.cluster.messaging.MessagingException;
|
||||||
import org.onosproject.store.cluster.messaging.MessagingService;
|
import org.onosproject.store.cluster.messaging.MessagingService;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
@ -41,6 +43,7 @@ import io.atomix.catalyst.serializer.SerializationException;
|
|||||||
import io.atomix.catalyst.transport.Address;
|
import io.atomix.catalyst.transport.Address;
|
||||||
import io.atomix.catalyst.transport.Connection;
|
import io.atomix.catalyst.transport.Connection;
|
||||||
import io.atomix.catalyst.transport.MessageHandler;
|
import io.atomix.catalyst.transport.MessageHandler;
|
||||||
|
import io.atomix.catalyst.transport.TransportException;
|
||||||
import io.atomix.catalyst.util.Assert;
|
import io.atomix.catalyst.util.Assert;
|
||||||
import io.atomix.catalyst.util.Listener;
|
import io.atomix.catalyst.util.Listener;
|
||||||
import io.atomix.catalyst.util.Listeners;
|
import io.atomix.catalyst.util.Listeners;
|
||||||
@ -66,10 +69,6 @@ public class CopycatTransportConnection implements Connection {
|
|||||||
private final String inboundMessageSubject;
|
private final String inboundMessageSubject;
|
||||||
private final ThreadContext context;
|
private final ThreadContext context;
|
||||||
private final Map<Class<?>, InternalHandler> handlers = Maps.newConcurrentMap();
|
private final Map<Class<?>, InternalHandler> handlers = Maps.newConcurrentMap();
|
||||||
private final AtomicInteger messagesSent = new AtomicInteger(0);
|
|
||||||
private final AtomicInteger sendFailures = new AtomicInteger(0);
|
|
||||||
private final AtomicInteger messagesReceived = new AtomicInteger(0);
|
|
||||||
private final AtomicInteger receiveFailures = new AtomicInteger(0);
|
|
||||||
|
|
||||||
CopycatTransportConnection(long connectionId,
|
CopycatTransportConnection(long connectionId,
|
||||||
CopycatTransport.Mode mode,
|
CopycatTransport.Mode mode,
|
||||||
@ -120,12 +119,14 @@ public class CopycatTransportConnection implements Connection {
|
|||||||
baos.toByteArray(),
|
baos.toByteArray(),
|
||||||
context.executor())
|
context.executor())
|
||||||
.whenComplete((r, e) -> {
|
.whenComplete((r, e) -> {
|
||||||
if (e == null) {
|
Throwable wrappedError = e;
|
||||||
messagesSent.incrementAndGet();
|
if (e != null) {
|
||||||
} else {
|
Throwable rootCause = Throwables.getRootCause(e);
|
||||||
sendFailures.incrementAndGet();
|
if (MessagingException.class.isAssignableFrom(rootCause.getClass())) {
|
||||||
|
wrappedError = new TransportException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
handleResponse(r, e, result, context);
|
handleResponse(r, wrappedError, result, context);
|
||||||
});
|
});
|
||||||
} catch (SerializationException | IOException e) {
|
} catch (SerializationException | IOException e) {
|
||||||
result.completeExceptionally(e);
|
result.completeExceptionally(e);
|
||||||
@ -172,11 +173,6 @@ public class CopycatTransportConnection implements Connection {
|
|||||||
"No handler registered for " + request.getClass()));
|
"No handler registered for " + request.getClass()));
|
||||||
}
|
}
|
||||||
return handler.handle(request).handle((result, error) -> {
|
return handler.handle(request).handle((result, error) -> {
|
||||||
if (error == null) {
|
|
||||||
messagesReceived.incrementAndGet();
|
|
||||||
} else {
|
|
||||||
receiveFailures.incrementAndGet();
|
|
||||||
}
|
|
||||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||||
baos.write(error != null ? FAILURE : SUCCESS);
|
baos.write(error != null ? FAILURE : SUCCESS);
|
||||||
context.serializer().writeObject(error != null ? error : result, baos);
|
context.serializer().writeObject(error != null ? error : result, baos);
|
||||||
@ -220,7 +216,6 @@ public class CopycatTransportConnection implements Connection {
|
|||||||
if (!(other instanceof CopycatTransportConnection)) {
|
if (!(other instanceof CopycatTransportConnection)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return connectionId == ((CopycatTransportConnection) other).connectionId;
|
return connectionId == ((CopycatTransportConnection) other).connectionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,10 +223,6 @@ public class CopycatTransportConnection implements Connection {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return MoreObjects.toStringHelper(getClass())
|
return MoreObjects.toStringHelper(getClass())
|
||||||
.add("id", connectionId)
|
.add("id", connectionId)
|
||||||
.add("sent", messagesSent.get())
|
|
||||||
.add("received", messagesReceived.get())
|
|
||||||
.add("sendFailures", sendFailures.get())
|
|
||||||
.add("receiveFailures", receiveFailures.get())
|
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ package org.onosproject.store.primitives.impl;
|
|||||||
import io.atomix.catalyst.serializer.Serializer;
|
import io.atomix.catalyst.serializer.Serializer;
|
||||||
import io.atomix.catalyst.transport.Address;
|
import io.atomix.catalyst.transport.Address;
|
||||||
import io.atomix.resource.ResourceType;
|
import io.atomix.resource.ResourceType;
|
||||||
import io.atomix.variables.DistributedLong;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -57,7 +56,6 @@ public class StoragePartition implements Managed<StoragePartition> {
|
|||||||
private StoragePartitionClient client;
|
private StoragePartitionClient client;
|
||||||
|
|
||||||
public static final Collection<ResourceType> RESOURCE_TYPES = ImmutableSet.of(
|
public static final Collection<ResourceType> RESOURCE_TYPES = ImmutableSet.of(
|
||||||
new ResourceType(DistributedLong.class),
|
|
||||||
new ResourceType(AtomixLeaderElector.class),
|
new ResourceType(AtomixLeaderElector.class),
|
||||||
new ResourceType(AtomixConsistentMap.class));
|
new ResourceType(AtomixConsistentMap.class));
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public final class AtomixConsistentMapCommands {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConsistencyLevel consistency() {
|
public ConsistencyLevel consistency() {
|
||||||
return ConsistencyLevel.SEQUENTIAL;
|
return ConsistencyLevel.LINEARIZABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -78,7 +78,7 @@ public final class AtomixConsistentMapCommands {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConsistencyLevel consistency() {
|
public ConsistencyLevel consistency() {
|
||||||
return ConsistencyLevel.SEQUENTIAL;
|
return ConsistencyLevel.BOUNDED_LINEARIZABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user