Madan Jampani
Committed by Gerrit Code Review

Using 1.0.0.rc2 version of Atomix

CopycatTransport updates

Change-Id: If384ac2574f098c327f0e5749766268c8d7f1ecd
Showing 15 changed files with 96 additions and 103 deletions
...@@ -120,6 +120,6 @@ public interface AsyncLeaderElector extends DistributedPrimitive { ...@@ -120,6 +120,6 @@ public interface AsyncLeaderElector extends DistributedPrimitive {
120 * @return new {@code LeaderElector} instance 120 * @return new {@code LeaderElector} instance
121 */ 121 */
122 default LeaderElector asLeaderElector() { 122 default LeaderElector asLeaderElector() {
123 - return asLeaderElector(DEFAULT_OPERTATION_TIMEOUT_MILLIS); 123 + return asLeaderElector(Long.MAX_VALUE);
124 } 124 }
125 } 125 }
......
...@@ -19,7 +19,7 @@ import java.util.Arrays; ...@@ -19,7 +19,7 @@ import java.util.Arrays;
19 19
20 import io.atomix.catalyst.serializer.Serializer; 20 import io.atomix.catalyst.serializer.Serializer;
21 import io.atomix.catalyst.serializer.TypeSerializerFactory; 21 import io.atomix.catalyst.serializer.TypeSerializerFactory;
22 -import io.atomix.copycat.client.Query; 22 +import io.atomix.copycat.Query;
23 23
24 import org.onlab.util.Match; 24 import org.onlab.util.Match;
25 import org.onosproject.cluster.Leader; 25 import org.onosproject.cluster.Leader;
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
16 package org.onosproject.store.primitives.impl; 16 package org.onosproject.store.primitives.impl;
17 17
18 import static com.google.common.base.Preconditions.checkNotNull; 18 import static com.google.common.base.Preconditions.checkNotNull;
19 -import static org.slf4j.LoggerFactory.getLogger;
20 19
21 import java.util.Set; 20 import java.util.Set;
22 import java.util.concurrent.CompletableFuture; 21 import java.util.concurrent.CompletableFuture;
...@@ -24,10 +23,8 @@ import java.util.concurrent.CompletableFuture; ...@@ -24,10 +23,8 @@ import java.util.concurrent.CompletableFuture;
24 import org.apache.commons.lang.math.RandomUtils; 23 import org.apache.commons.lang.math.RandomUtils;
25 import org.onosproject.cluster.PartitionId; 24 import org.onosproject.cluster.PartitionId;
26 import org.onosproject.store.cluster.messaging.MessagingService; 25 import org.onosproject.store.cluster.messaging.MessagingService;
27 -import org.slf4j.Logger;
28 26
29 import com.google.common.collect.Sets; 27 import com.google.common.collect.Sets;
30 -import com.google.common.primitives.Longs;
31 28
32 import io.atomix.catalyst.transport.Address; 29 import io.atomix.catalyst.transport.Address;
33 import io.atomix.catalyst.transport.Client; 30 import io.atomix.catalyst.transport.Client;
...@@ -39,42 +36,32 @@ import io.atomix.catalyst.util.concurrent.ThreadContext; ...@@ -39,42 +36,32 @@ import io.atomix.catalyst.util.concurrent.ThreadContext;
39 */ 36 */
40 public class CopycatTransportClient implements Client { 37 public class CopycatTransportClient implements Client {
41 38
42 - private final Logger log = getLogger(getClass());
43 private final PartitionId partitionId; 39 private final PartitionId partitionId;
44 private final MessagingService messagingService; 40 private final MessagingService messagingService;
45 private final CopycatTransport.Mode mode; 41 private final CopycatTransport.Mode mode;
46 - private final String newConnectionMessageSubject;
47 private final Set<CopycatTransportConnection> connections = Sets.newConcurrentHashSet(); 42 private final Set<CopycatTransportConnection> connections = Sets.newConcurrentHashSet();
48 43
49 CopycatTransportClient(PartitionId partitionId, MessagingService messagingService, CopycatTransport.Mode mode) { 44 CopycatTransportClient(PartitionId partitionId, MessagingService messagingService, CopycatTransport.Mode mode) {
50 this.partitionId = checkNotNull(partitionId); 45 this.partitionId = checkNotNull(partitionId);
51 this.messagingService = checkNotNull(messagingService); 46 this.messagingService = checkNotNull(messagingService);
52 this.mode = checkNotNull(mode); 47 this.mode = checkNotNull(mode);
53 - this.newConnectionMessageSubject = String.format("onos-copycat-server-connection-%s", partitionId);
54 } 48 }
55 49
56 @Override 50 @Override
57 public CompletableFuture<Connection> connect(Address remoteAddress) { 51 public CompletableFuture<Connection> connect(Address remoteAddress) {
58 ThreadContext context = ThreadContext.currentContextOrThrow(); 52 ThreadContext context = ThreadContext.currentContextOrThrow();
59 - return messagingService.sendAndReceive(CopycatTransport.toEndpoint(remoteAddress), 53 + CopycatTransportConnection connection = new CopycatTransportConnection(
60 - newConnectionMessageSubject, 54 + nextConnectionId(),
61 - Longs.toByteArray(nextConnectionId())) 55 + CopycatTransport.Mode.CLIENT,
62 - .thenApplyAsync(bytes -> { 56 + partitionId,
63 - long connectionId = Longs.fromByteArray(bytes); 57 + remoteAddress,
64 - CopycatTransportConnection connection = new CopycatTransportConnection( 58 + messagingService,
65 - connectionId, 59 + context);
66 - CopycatTransport.Mode.CLIENT, 60 + if (mode == CopycatTransport.Mode.CLIENT) {
67 - partitionId, 61 + connection.setBidirectional();
68 - remoteAddress, 62 + }
69 - messagingService, 63 + connections.add(connection);
70 - context); 64 + return CompletableFuture.supplyAsync(() -> connection, context.executor());
71 - if (mode == CopycatTransport.Mode.CLIENT) {
72 - connection.setBidirectional();
73 - }
74 - log.debug("Created new outgoing connection[id={}] to {}", connectionId, remoteAddress);
75 - connections.add(connection);
76 - return connection;
77 - }, context.executor());
78 } 65 }
79 66
80 @Override 67 @Override
......
...@@ -31,14 +31,12 @@ import org.apache.commons.io.IOUtils; ...@@ -31,14 +31,12 @@ import org.apache.commons.io.IOUtils;
31 import org.onlab.util.Tools; 31 import org.onlab.util.Tools;
32 import org.onosproject.cluster.PartitionId; 32 import org.onosproject.cluster.PartitionId;
33 import org.onosproject.store.cluster.messaging.MessagingService; 33 import org.onosproject.store.cluster.messaging.MessagingService;
34 -import org.slf4j.Logger;
35 34
36 import com.google.common.base.MoreObjects; 35 import com.google.common.base.MoreObjects;
37 import com.google.common.base.Throwables; 36 import com.google.common.base.Throwables;
38 import com.google.common.collect.Maps; 37 import com.google.common.collect.Maps;
39 38
40 import static com.google.common.base.Preconditions.checkNotNull; 39 import static com.google.common.base.Preconditions.checkNotNull;
41 -import static org.slf4j.LoggerFactory.getLogger;
42 import io.atomix.catalyst.transport.Address; 40 import io.atomix.catalyst.transport.Address;
43 import io.atomix.catalyst.transport.Connection; 41 import io.atomix.catalyst.transport.Connection;
44 import io.atomix.catalyst.transport.MessageHandler; 42 import io.atomix.catalyst.transport.MessageHandler;
...@@ -54,7 +52,6 @@ import io.atomix.catalyst.util.concurrent.ThreadContext; ...@@ -54,7 +52,6 @@ import io.atomix.catalyst.util.concurrent.ThreadContext;
54 */ 52 */
55 public class CopycatTransportConnection implements Connection { 53 public class CopycatTransportConnection implements Connection {
56 54
57 - private final Logger log = getLogger(getClass());
58 private final Listeners<Throwable> exceptionListeners = new Listeners<>(); 55 private final Listeners<Throwable> exceptionListeners = new Listeners<>();
59 private final Listeners<Connection> closeListeners = new Listeners<>(); 56 private final Listeners<Connection> closeListeners = new Listeners<>();
60 57
...@@ -85,11 +82,11 @@ public class CopycatTransportConnection implements Connection { ...@@ -85,11 +82,11 @@ public class CopycatTransportConnection implements Connection {
85 this.remoteAddress = checkNotNull(address); 82 this.remoteAddress = checkNotNull(address);
86 this.messagingService = checkNotNull(messagingService); 83 this.messagingService = checkNotNull(messagingService);
87 if (mode == CopycatTransport.Mode.CLIENT) { 84 if (mode == CopycatTransport.Mode.CLIENT) {
88 - this.outboundMessageSubject = String.format("onos-copycat-server-%s", partitionId); 85 + this.outboundMessageSubject = String.format("onos-copycat-%s", partitionId);
89 - this.inboundMessageSubject = String.format("onos-copycat-client-%s-%d", partitionId, connectionId); 86 + this.inboundMessageSubject = String.format("onos-copycat-%s-%d", partitionId, connectionId);
90 } else { 87 } else {
91 - this.outboundMessageSubject = String.format("onos-copycat-client-%s-%d", partitionId, connectionId); 88 + this.outboundMessageSubject = String.format("onos-copycat-%s-%d", partitionId, connectionId);
92 - this.inboundMessageSubject = String.format("onos-copycat-server-%s", partitionId); 89 + this.inboundMessageSubject = String.format("onos-copycat-%s", partitionId);
93 } 90 }
94 this.context = checkNotNull(context); 91 this.context = checkNotNull(context);
95 } 92 }
...@@ -206,7 +203,6 @@ public class CopycatTransportConnection implements Connection { ...@@ -206,7 +203,6 @@ public class CopycatTransportConnection implements Connection {
206 203
207 @Override 204 @Override
208 public CompletableFuture<Void> close() { 205 public CompletableFuture<Void> close() {
209 - log.debug("Closing connection[id={}, mode={}] to {}", connectionId, mode, remoteAddress);
210 closeListeners.forEach(listener -> listener.accept(this)); 206 closeListeners.forEach(listener -> listener.accept(this));
211 if (mode == CopycatTransport.Mode.CLIENT) { 207 if (mode == CopycatTransport.Mode.CLIENT) {
212 messagingService.unregisterHandler(inboundMessageSubject); 208 messagingService.unregisterHandler(inboundMessageSubject);
......
...@@ -35,7 +35,6 @@ import org.onosproject.store.cluster.messaging.MessagingService; ...@@ -35,7 +35,6 @@ import org.onosproject.store.cluster.messaging.MessagingService;
35 import org.slf4j.Logger; 35 import org.slf4j.Logger;
36 36
37 import com.google.common.collect.Maps; 37 import com.google.common.collect.Maps;
38 -import com.google.common.primitives.Longs;
39 38
40 import io.atomix.catalyst.transport.Address; 39 import io.atomix.catalyst.transport.Address;
41 import io.atomix.catalyst.transport.Connection; 40 import io.atomix.catalyst.transport.Connection;
...@@ -55,15 +54,13 @@ public class CopycatTransportServer implements Server { ...@@ -55,15 +54,13 @@ public class CopycatTransportServer implements Server {
55 private final ScheduledExecutorService executorService; 54 private final ScheduledExecutorService executorService;
56 private final PartitionId partitionId; 55 private final PartitionId partitionId;
57 private final MessagingService messagingService; 56 private final MessagingService messagingService;
58 - private final String protocolMessageSubject; 57 + private final String messageSubject;
59 - private final String newConnectionMessageSubject;
60 private final Map<Long, CopycatTransportConnection> connections = Maps.newConcurrentMap(); 58 private final Map<Long, CopycatTransportConnection> connections = Maps.newConcurrentMap();
61 59
62 CopycatTransportServer(PartitionId partitionId, MessagingService messagingService) { 60 CopycatTransportServer(PartitionId partitionId, MessagingService messagingService) {
63 this.partitionId = checkNotNull(partitionId); 61 this.partitionId = checkNotNull(partitionId);
64 this.messagingService = checkNotNull(messagingService); 62 this.messagingService = checkNotNull(messagingService);
65 - this.protocolMessageSubject = String.format("onos-copycat-server-%s", partitionId); 63 + this.messageSubject = String.format("onos-copycat-%s", partitionId);
66 - this.newConnectionMessageSubject = String.format("onos-copycat-server-connection-%s", partitionId);
67 this.executorService = Executors.newScheduledThreadPool(Math.min(4, Runtime.getRuntime().availableProcessors()), 64 this.executorService = Executors.newScheduledThreadPool(Math.min(4, Runtime.getRuntime().availableProcessors()),
68 new CatalystThreadFactory("copycat-server-p" + partitionId + "-%d")); 65 new CatalystThreadFactory("copycat-server-p" + partitionId + "-%d"));
69 } 66 }
...@@ -71,49 +68,49 @@ public class CopycatTransportServer implements Server { ...@@ -71,49 +68,49 @@ public class CopycatTransportServer implements Server {
71 @Override 68 @Override
72 public CompletableFuture<Void> listen(Address address, Consumer<Connection> listener) { 69 public CompletableFuture<Void> listen(Address address, Consumer<Connection> listener) {
73 if (listening.compareAndSet(false, true)) { 70 if (listening.compareAndSet(false, true)) {
74 - // message handler for all non-connection-establishment messages.
75 - messagingService.registerHandler(protocolMessageSubject, (sender, payload) -> {
76 - try (DataInputStream input = new DataInputStream(new ByteArrayInputStream(payload))) {
77 - long connectionId = input.readLong();
78 - CopycatTransportConnection connection = connections.get(connectionId);
79 - if (connection == null) {
80 - throw new IOException("Closed connection");
81 - }
82 - byte[] messagePayload = IOUtils.toByteArray(input);
83 - return connection.handle(messagePayload);
84 - } catch (IOException e) {
85 - return Tools.exceptionalFuture(e);
86 - }
87 - });
88 -
89 - // message handler for new connection attempts.
90 ThreadContext context = ThreadContext.currentContextOrThrow(); 71 ThreadContext context = ThreadContext.currentContextOrThrow();
91 - messagingService.registerHandler(newConnectionMessageSubject, (sender, payload) -> { 72 + listen(address, listener, context);
92 - long connectionId = Longs.fromByteArray(payload);
93 - CopycatTransportConnection connection = new CopycatTransportConnection(connectionId,
94 - CopycatTransport.Mode.SERVER,
95 - partitionId,
96 - CopycatTransport.toAddress(sender),
97 - messagingService,
98 - getOrCreateContext(context));
99 - connections.put(connectionId, connection);
100 - connection.closeListener(c -> connections.remove(connectionId, c));
101 - log.debug("Created new incoming connection[id={}] from {}", connectionId, sender);
102 - return CompletableFuture.supplyAsync(() -> {
103 - listener.accept(connection);
104 - // echo the connectionId back to indicate successful completion.
105 - return payload;
106 - }, context.executor());
107 - });
108 - context.execute(() -> listenFuture.complete(null));
109 } 73 }
110 return listenFuture; 74 return listenFuture;
111 } 75 }
112 76
77 + private void listen(Address address, Consumer<Connection> listener, ThreadContext context) {
78 + messagingService.registerHandler(messageSubject, (sender, payload) -> {
79 + try (DataInputStream input = new DataInputStream(new ByteArrayInputStream(payload))) {
80 + long connectionId = input.readLong();
81 + AtomicBoolean newConnectionCreated = new AtomicBoolean(false);
82 + CopycatTransportConnection connection = connections.computeIfAbsent(connectionId, k -> {
83 + newConnectionCreated.set(true);
84 + CopycatTransportConnection newConnection = new CopycatTransportConnection(connectionId,
85 + CopycatTransport.Mode.SERVER,
86 + partitionId,
87 + CopycatTransport.toAddress(sender),
88 + messagingService,
89 + getOrCreateContext(context));
90 + log.debug("Created new incoming connection {}", connectionId);
91 + newConnection.closeListener(c -> connections.remove(connectionId, c));
92 + return newConnection;
93 + });
94 + byte[] request = IOUtils.toByteArray(input);
95 + return CompletableFuture.supplyAsync(
96 + () -> {
97 + if (newConnectionCreated.get()) {
98 + listener.accept(connection);
99 + }
100 + return connection;
101 + }, context.executor()).thenCompose(c -> c.handle(request));
102 + } catch (IOException e) {
103 + return Tools.exceptionalFuture(e);
104 + }
105 + });
106 + context.execute(() -> {
107 + listenFuture.complete(null);
108 + });
109 + }
110 +
113 @Override 111 @Override
114 public CompletableFuture<Void> close() { 112 public CompletableFuture<Void> close() {
115 - messagingService.unregisterHandler(newConnectionMessageSubject); 113 + messagingService.unregisterHandler(messageSubject);
116 - messagingService.unregisterHandler(protocolMessageSubject);
117 executorService.shutdown(); 114 executorService.shutdown();
118 return CompletableFuture.completedFuture(null); 115 return CompletableFuture.completedFuture(null);
119 } 116 }
......
...@@ -105,14 +105,16 @@ public class PartitionManager extends AbstractListenerManager<PartitionEvent, Pa ...@@ -105,14 +105,16 @@ public class PartitionManager extends AbstractListenerManager<PartitionEvent, Pa
105 105
106 @Override 106 @Override
107 public CompletableFuture<Void> leave(PartitionId partitionId) { 107 public CompletableFuture<Void> leave(PartitionId partitionId) {
108 - // TODO: Implement 108 + return partitions.get(partitionId)
109 - return Tools.exceptionalFuture(new UnsupportedOperationException()); 109 + .server()
110 + .map(server -> server.close())
111 + .orElse(CompletableFuture.completedFuture(null));
110 } 112 }
111 113
112 @Override 114 @Override
113 public CompletableFuture<Void> join(PartitionId partitionId) { 115 public CompletableFuture<Void> join(PartitionId partitionId) {
114 - // TODO: Implement 116 + return partitions.get(partitionId)
115 - return Tools.exceptionalFuture(new UnsupportedOperationException()); 117 + .open();
116 } 118 }
117 119
118 @Override 120 @Override
......
...@@ -72,10 +72,22 @@ public class StoragePartition extends DefaultPartition implements Managed<Storag ...@@ -72,10 +72,22 @@ public class StoragePartition extends DefaultPartition implements Managed<Storag
72 this.logFolder = logFolder; 72 this.logFolder = logFolder;
73 } 73 }
74 74
75 + /**
76 + * Returns the partition client instance.
77 + * @return client
78 + */
75 public StoragePartitionClient client() { 79 public StoragePartitionClient client() {
76 return client; 80 return client;
77 } 81 }
78 82
83 + /**
84 + * Returns the optional server instance.
85 + * @return server
86 + */
87 + public Optional<StoragePartitionServer> server() {
88 + return server;
89 + }
90 +
79 @Override 91 @Override
80 public CompletableFuture<Void> open() { 92 public CompletableFuture<Void> open() {
81 return openServer().thenAccept(s -> server = Optional.ofNullable(s)) 93 return openServer().thenAccept(s -> server = Optional.ofNullable(s))
......
...@@ -114,8 +114,7 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> { ...@@ -114,8 +114,7 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> {
114 .withTransport(transport.get()) 114 .withTransport(transport.get())
115 .withStateMachine(() -> new ResourceManagerState(registry)) 115 .withStateMachine(() -> new ResourceManagerState(registry))
116 .withStorage(Storage.builder() 116 .withStorage(Storage.builder()
117 - // FIXME: StorageLevel should be DISK 117 + .withStorageLevel(StorageLevel.DISK)
118 - .withStorageLevel(StorageLevel.MEMORY)
119 .withCompactionThreads(1) 118 .withCompactionThreads(1)
120 .withDirectory(dataFolder) 119 .withDirectory(dataFolder)
121 .withMaxEntriesPerSegment(MAX_ENTRIES_PER_LOG_SEGMENT) 120 .withMaxEntriesPerSegment(MAX_ENTRIES_PER_LOG_SEGMENT)
......
...@@ -65,7 +65,7 @@ public class AtomixConsistentMap extends Resource<AtomixConsistentMap> ...@@ -65,7 +65,7 @@ public class AtomixConsistentMap extends Resource<AtomixConsistentMap>
65 @Override 65 @Override
66 public CompletableFuture<AtomixConsistentMap> open() { 66 public CompletableFuture<AtomixConsistentMap> open() {
67 return super.open().thenApply(result -> { 67 return super.open().thenApply(result -> {
68 - client.session().onEvent(CHANGE_SUBJECT, this::handleEvent); 68 + client.onEvent(CHANGE_SUBJECT, this::handleEvent);
69 return result; 69 return result;
70 }); 70 });
71 } 71 }
......
...@@ -22,8 +22,8 @@ import io.atomix.catalyst.serializer.SerializableTypeResolver; ...@@ -22,8 +22,8 @@ import io.atomix.catalyst.serializer.SerializableTypeResolver;
22 import io.atomix.catalyst.serializer.Serializer; 22 import io.atomix.catalyst.serializer.Serializer;
23 import io.atomix.catalyst.serializer.SerializerRegistry; 23 import io.atomix.catalyst.serializer.SerializerRegistry;
24 import io.atomix.catalyst.util.Assert; 24 import io.atomix.catalyst.util.Assert;
25 -import io.atomix.copycat.client.Command; 25 +import io.atomix.copycat.Command;
26 -import io.atomix.copycat.client.Query; 26 +import io.atomix.copycat.Query;
27 27
28 import java.util.Collection; 28 import java.util.Collection;
29 import java.util.Map; 29 import java.util.Map;
......
...@@ -18,7 +18,7 @@ package org.onosproject.store.primitives.resources.impl; ...@@ -18,7 +18,7 @@ package org.onosproject.store.primitives.resources.impl;
18 import static org.onosproject.store.service.MapEvent.Type.INSERT; 18 import static org.onosproject.store.service.MapEvent.Type.INSERT;
19 import static org.onosproject.store.service.MapEvent.Type.REMOVE; 19 import static org.onosproject.store.service.MapEvent.Type.REMOVE;
20 import static org.onosproject.store.service.MapEvent.Type.UPDATE; 20 import static org.onosproject.store.service.MapEvent.Type.UPDATE;
21 -import io.atomix.copycat.client.session.Session; 21 +import io.atomix.copycat.server.session.ServerSession;
22 import io.atomix.copycat.server.Commit; 22 import io.atomix.copycat.server.Commit;
23 import io.atomix.copycat.server.Snapshottable; 23 import io.atomix.copycat.server.Snapshottable;
24 import io.atomix.copycat.server.StateMachineExecutor; 24 import io.atomix.copycat.server.StateMachineExecutor;
...@@ -322,8 +322,8 @@ public class AtomixConsistentMapState extends ResourceStateMachine implements Se ...@@ -322,8 +322,8 @@ public class AtomixConsistentMapState extends ResourceStateMachine implements Se
322 commit.session() 322 commit.session()
323 .onStateChange( 323 .onStateChange(
324 state -> { 324 state -> {
325 - if (state == Session.State.CLOSED 325 + if (state == ServerSession.State.CLOSED
326 - || state == Session.State.EXPIRED) { 326 + || state == ServerSession.State.EXPIRED) {
327 Commit<? extends Listen> listener = listeners.remove(sessionId); 327 Commit<? extends Listen> listener = listeners.remove(sessionId);
328 if (listener != null) { 328 if (listener != null) {
329 listener.close(); 329 listener.close();
...@@ -503,21 +503,21 @@ public class AtomixConsistentMapState extends ResourceStateMachine implements Se ...@@ -503,21 +503,21 @@ public class AtomixConsistentMapState extends ResourceStateMachine implements Se
503 } 503 }
504 504
505 @Override 505 @Override
506 - public void register(Session session) { 506 + public void register(ServerSession session) {
507 } 507 }
508 508
509 @Override 509 @Override
510 - public void unregister(Session session) { 510 + public void unregister(ServerSession session) {
511 closeListener(session.id()); 511 closeListener(session.id());
512 } 512 }
513 513
514 @Override 514 @Override
515 - public void expire(Session session) { 515 + public void expire(ServerSession session) {
516 closeListener(session.id()); 516 closeListener(session.id());
517 } 517 }
518 518
519 @Override 519 @Override
520 - public void close(Session session) { 520 + public void close(ServerSession session) {
521 closeListener(session.id()); 521 closeListener(session.id());
522 } 522 }
523 523
......
...@@ -57,7 +57,7 @@ public class AtomixLeaderElector extends Resource<AtomixLeaderElector> ...@@ -57,7 +57,7 @@ public class AtomixLeaderElector extends Resource<AtomixLeaderElector>
57 @Override 57 @Override
58 public CompletableFuture<AtomixLeaderElector> open() { 58 public CompletableFuture<AtomixLeaderElector> open() {
59 return super.open().thenApply(result -> { 59 return super.open().thenApply(result -> {
60 - client.session().onEvent("change", this::handleEvent); 60 + client.onEvent("change", this::handleEvent);
61 return result; 61 return result;
62 }); 62 });
63 } 63 }
......
...@@ -32,8 +32,8 @@ import io.atomix.catalyst.serializer.SerializableTypeResolver; ...@@ -32,8 +32,8 @@ import io.atomix.catalyst.serializer.SerializableTypeResolver;
32 import io.atomix.catalyst.serializer.Serializer; 32 import io.atomix.catalyst.serializer.Serializer;
33 import io.atomix.catalyst.serializer.SerializerRegistry; 33 import io.atomix.catalyst.serializer.SerializerRegistry;
34 import io.atomix.catalyst.util.Assert; 34 import io.atomix.catalyst.util.Assert;
35 -import io.atomix.copycat.client.Command; 35 +import io.atomix.copycat.Command;
36 -import io.atomix.copycat.client.Query; 36 +import io.atomix.copycat.Query;
37 37
38 /** 38 /**
39 * {@link AtomixLeaderElector} resource state machine operations. 39 * {@link AtomixLeaderElector} resource state machine operations.
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
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 static org.slf4j.LoggerFactory.getLogger;
19 -import io.atomix.copycat.client.session.Session; 19 +import io.atomix.copycat.server.session.ServerSession;
20 import io.atomix.copycat.server.Commit; 20 import io.atomix.copycat.server.Commit;
21 import io.atomix.copycat.server.Snapshottable; 21 import io.atomix.copycat.server.Snapshottable;
22 import io.atomix.copycat.server.StateMachineExecutor; 22 import io.atomix.copycat.server.StateMachineExecutor;
...@@ -265,7 +265,7 @@ public class AtomixLeaderElectorState extends ResourceStateMachine ...@@ -265,7 +265,7 @@ public class AtomixLeaderElectorState extends ResourceStateMachine
265 return electionState == null ? new LinkedList<>() : electionState.candidates(); 265 return electionState == null ? new LinkedList<>() : electionState.candidates();
266 } 266 }
267 267
268 - private void onSessionEnd(Session session) { 268 + private void onSessionEnd(ServerSession session) {
269 Commit<? extends AtomixLeaderElectorCommands.Listen> listener = listeners.remove(session.id()); 269 Commit<? extends AtomixLeaderElectorCommands.Listen> listener = listeners.remove(session.id());
270 if (listener != null) { 270 if (listener != null) {
271 listener.close(); 271 listener.close();
...@@ -337,7 +337,7 @@ public class AtomixLeaderElectorState extends ResourceStateMachine ...@@ -337,7 +337,7 @@ public class AtomixLeaderElectorState extends ResourceStateMachine
337 this.termStartTime = termStartTime; 337 this.termStartTime = termStartTime;
338 } 338 }
339 339
340 - public ElectionState cleanup(Session session, Supplier<Long> termCounter) { 340 + public ElectionState cleanup(ServerSession session, Supplier<Long> termCounter) {
341 Optional<Registration> registration = 341 Optional<Registration> registration =
342 registrations.stream().filter(r -> r.sessionId() == session.id()).findFirst(); 342 registrations.stream().filter(r -> r.sessionId() == session.id()).findFirst();
343 if (registration.isPresent()) { 343 if (registration.isPresent()) {
...@@ -409,21 +409,21 @@ public class AtomixLeaderElectorState extends ResourceStateMachine ...@@ -409,21 +409,21 @@ public class AtomixLeaderElectorState extends ResourceStateMachine
409 } 409 }
410 410
411 @Override 411 @Override
412 - public void register(Session session) { 412 + public void register(ServerSession session) {
413 } 413 }
414 414
415 @Override 415 @Override
416 - public void unregister(Session session) { 416 + public void unregister(ServerSession session) {
417 onSessionEnd(session); 417 onSessionEnd(session);
418 } 418 }
419 419
420 @Override 420 @Override
421 - public void expire(Session session) { 421 + public void expire(ServerSession session) {
422 onSessionEnd(session); 422 onSessionEnd(session);
423 } 423 }
424 424
425 @Override 425 @Override
426 - public void close(Session session) { 426 + public void close(ServerSession session) {
427 onSessionEnd(session); 427 onSessionEnd(session);
428 } 428 }
429 429
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
79 <onos-build-conf.version>1.2-SNAPSHOT</onos-build-conf.version> 79 <onos-build-conf.version>1.2-SNAPSHOT</onos-build-conf.version>
80 <netty4.version>4.0.33.Final</netty4.version> 80 <netty4.version>4.0.33.Final</netty4.version>
81 <!-- TODO: replace with final release version when it is out --> 81 <!-- TODO: replace with final release version when it is out -->
82 - <atomix.version>1.0.0-rc1</atomix.version> 82 + <atomix.version>1.0.0-rc2</atomix.version>
83 <copycat.version>0.5.1.onos</copycat.version> 83 <copycat.version>0.5.1.onos</copycat.version>
84 <openflowj.version>0.9.1.onos</openflowj.version> 84 <openflowj.version>0.9.1.onos</openflowj.version>
85 <onos-maven-plugin.version>1.8-SNAPSHOT</onos-maven-plugin.version> 85 <onos-maven-plugin.version>1.8-SNAPSHOT</onos-maven-plugin.version>
......