Madan Jampani

Migrating to latest Atomix

Change-Id: Ife3ce0b9d9ede5d153d831bf656593ae807acd1d
Showing 31 changed files with 396 additions and 667 deletions
...@@ -39,9 +39,6 @@ import org.onosproject.store.service.LeaderElector; ...@@ -39,9 +39,6 @@ import org.onosproject.store.service.LeaderElector;
39 import org.onosproject.store.service.StorageService; 39 import org.onosproject.store.service.StorageService;
40 import org.slf4j.Logger; 40 import org.slf4j.Logger;
41 41
42 -import com.google.common.collect.ImmutableMap;
43 -import com.google.common.collect.Maps;
44 -
45 /** 42 /**
46 * Implementation of {@code LeadershipStore} that makes use of a {@link LeaderElector} 43 * Implementation of {@code LeadershipStore} that makes use of a {@link LeaderElector}
47 * primitive. 44 * primitive.
...@@ -62,13 +59,11 @@ public class NewDistributedLeadershipStore ...@@ -62,13 +59,11 @@ public class NewDistributedLeadershipStore
62 59
63 private NodeId localNodeId; 60 private NodeId localNodeId;
64 private LeaderElector leaderElector; 61 private LeaderElector leaderElector;
65 - private final Map<String, Leadership> leaderBoard = Maps.newConcurrentMap();
66 62
67 private final Consumer<Change<Leadership>> leadershipChangeListener = 63 private final Consumer<Change<Leadership>> leadershipChangeListener =
68 change -> { 64 change -> {
69 Leadership oldValue = change.oldValue(); 65 Leadership oldValue = change.oldValue();
70 Leadership newValue = change.newValue(); 66 Leadership newValue = change.newValue();
71 - leaderBoard.put(newValue.topic(), newValue);
72 boolean leaderChanged = !Objects.equals(oldValue.leader(), newValue.leader()); 67 boolean leaderChanged = !Objects.equals(oldValue.leader(), newValue.leader());
73 boolean candidatesChanged = !Objects.equals(oldValue.candidates(), newValue.candidates()); 68 boolean candidatesChanged = !Objects.equals(oldValue.candidates(), newValue.candidates());
74 LeadershipEvent.Type eventType = null; 69 LeadershipEvent.Type eventType = null;
...@@ -92,7 +87,6 @@ public class NewDistributedLeadershipStore ...@@ -92,7 +87,6 @@ public class NewDistributedLeadershipStore
92 .build() 87 .build()
93 .asLeaderElector(); 88 .asLeaderElector();
94 leaderElector.addChangeListener(leadershipChangeListener); 89 leaderElector.addChangeListener(leadershipChangeListener);
95 - leaderBoard.putAll(getLeaderships());
96 log.info("Started"); 90 log.info("Started");
97 } 91 }
98 92
...@@ -129,11 +123,11 @@ public class NewDistributedLeadershipStore ...@@ -129,11 +123,11 @@ public class NewDistributedLeadershipStore
129 123
130 @Override 124 @Override
131 public Leadership getLeadership(String topic) { 125 public Leadership getLeadership(String topic) {
132 - return leaderBoard.get(topic); 126 + return leaderElector.getLeadership(topic);
133 } 127 }
134 128
135 @Override 129 @Override
136 public Map<String, Leadership> getLeaderships() { 130 public Map<String, Leadership> getLeaderships() {
137 - return ImmutableMap.copyOf(leaderBoard); 131 + return leaderElector.getLeaderships();
138 } 132 }
139 } 133 }
......
1 COMPILE_DEPS = [ 1 COMPILE_DEPS = [
2 '//lib:CORE_DEPS', 2 '//lib:CORE_DEPS',
3 - '//lib:catalyst-serializer',
4 '//lib:mapdb', 3 '//lib:mapdb',
5 ] 4 ]
6 5
......
...@@ -3,29 +3,12 @@ COMPILE_DEPS = [ ...@@ -3,29 +3,12 @@ COMPILE_DEPS = [
3 '//core/common:onos-core-common', 3 '//core/common:onos-core-common',
4 '//incubator/api:onos-incubator-api', 4 '//incubator/api:onos-incubator-api',
5 '//core/store/serializers:onos-core-serializers', 5 '//core/store/serializers:onos-core-serializers',
6 - '//lib:copycat-client',
7 - '//lib:copycat-server',
8 - '//lib:copycat-protocol',
9 - '//lib:copycat-core',
10 - '//lib:typesafe-config',
11 - '//lib:copycat-api',
12 - '//lib:copycat-state-machine',
13 - '//lib:copycat-state-log',
14 - '//lib:catalyst-transport',
15 - '//lib:catalyst-buffer',
16 - '//lib:catalyst-common',
17 - '//lib:catalyst-local',
18 - '//lib:catalyst-serializer',
19 '//lib:atomix', 6 '//lib:atomix',
20 - '//lib:atomix-resource',
21 - '//lib:atomix-variables',
22 - '//lib:atomix-resource-manager',
23 ] 7 ]
24 8
25 TEST_DEPS = [ 9 TEST_DEPS = [
26 '//lib:TEST', 10 '//lib:TEST',
27 '//core/api:onos-api-tests', 11 '//core/api:onos-api-tests',
28 - '//lib:onos-atomix',
29 ] 12 ]
30 13
31 osgi_jar_with_tests ( 14 osgi_jar_with_tests (
......
...@@ -69,9 +69,9 @@ ...@@ -69,9 +69,9 @@
69 </dependency> 69 </dependency>
70 70
71 <dependency> 71 <dependency>
72 - <groupId>org.onosproject</groupId> 72 + <groupId>io.atomix</groupId>
73 <artifactId>atomix</artifactId> 73 <artifactId>atomix</artifactId>
74 - <version>1.0.onos-SNAPSHOT</version> 74 + <version>1.0.0-rc7</version>
75 </dependency> 75 </dependency>
76 </dependencies> 76 </dependencies>
77 </project> 77 </project>
......
...@@ -19,9 +19,8 @@ import java.util.Arrays; ...@@ -19,9 +19,8 @@ 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.Query;
23 import io.atomix.manager.util.ResourceManagerTypeResolver; 22 import io.atomix.manager.util.ResourceManagerTypeResolver;
24 -import io.atomix.variables.state.LongCommands; 23 +import io.atomix.variables.internal.LongCommands;
25 24
26 import org.onlab.util.Match; 25 import org.onlab.util.Match;
27 import org.onosproject.cluster.Leader; 26 import org.onosproject.cluster.Leader;
...@@ -63,8 +62,7 @@ public final class CatalystSerializers { ...@@ -63,8 +62,7 @@ public final class CatalystSerializers {
63 Transaction.State.class, 62 Transaction.State.class,
64 PrepareResult.class, 63 PrepareResult.class,
65 CommitResult.class, 64 CommitResult.class,
66 - RollbackResult.class, 65 + RollbackResult.class));
67 - Query.ConsistencyLevel.class));
68 // ONOS classes 66 // ONOS classes
69 serializer.register(Change.class, factory); 67 serializer.register(Change.class, factory);
70 serializer.register(Leader.class, factory); 68 serializer.register(Leader.class, factory);
......
...@@ -29,7 +29,7 @@ import com.google.common.collect.Sets; ...@@ -29,7 +29,7 @@ import com.google.common.collect.Sets;
29 import io.atomix.catalyst.transport.Address; 29 import io.atomix.catalyst.transport.Address;
30 import io.atomix.catalyst.transport.Client; 30 import io.atomix.catalyst.transport.Client;
31 import io.atomix.catalyst.transport.Connection; 31 import io.atomix.catalyst.transport.Connection;
32 -import io.atomix.catalyst.util.concurrent.ThreadContext; 32 +import io.atomix.catalyst.concurrent.ThreadContext;
33 33
34 /** 34 /**
35 * {@link Client} implementation for {@link CopycatTransport}. 35 * {@link Client} implementation for {@link CopycatTransport}.
......
...@@ -15,6 +15,18 @@ ...@@ -15,6 +15,18 @@
15 */ 15 */
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;
19 +import io.atomix.catalyst.concurrent.Listener;
20 +import io.atomix.catalyst.concurrent.Listeners;
21 +import io.atomix.catalyst.concurrent.ThreadContext;
22 +import io.atomix.catalyst.serializer.SerializationException;
23 +import io.atomix.catalyst.transport.Address;
24 +import io.atomix.catalyst.transport.Connection;
25 +import io.atomix.catalyst.transport.MessageHandler;
26 +import io.atomix.catalyst.transport.TransportException;
27 +import io.atomix.catalyst.util.Assert;
28 +import io.atomix.catalyst.util.reference.ReferenceCounted;
29 +
18 import java.io.ByteArrayInputStream; 30 import java.io.ByteArrayInputStream;
19 import java.io.ByteArrayOutputStream; 31 import java.io.ByteArrayOutputStream;
20 import java.io.DataInputStream; 32 import java.io.DataInputStream;
...@@ -26,8 +38,6 @@ import java.util.Objects; ...@@ -26,8 +38,6 @@ import java.util.Objects;
26 import java.util.concurrent.CompletableFuture; 38 import java.util.concurrent.CompletableFuture;
27 import java.util.function.Consumer; 39 import java.util.function.Consumer;
28 40
29 -
30 -
31 import org.apache.commons.io.IOUtils; 41 import org.apache.commons.io.IOUtils;
32 import org.onlab.util.Tools; 42 import org.onlab.util.Tools;
33 import org.onosproject.cluster.PartitionId; 43 import org.onosproject.cluster.PartitionId;
...@@ -38,18 +48,6 @@ import com.google.common.base.MoreObjects; ...@@ -38,18 +48,6 @@ import com.google.common.base.MoreObjects;
38 import com.google.common.base.Throwables; 48 import com.google.common.base.Throwables;
39 import com.google.common.collect.Maps; 49 import com.google.common.collect.Maps;
40 50
41 -import static com.google.common.base.Preconditions.checkNotNull;
42 -import io.atomix.catalyst.serializer.SerializationException;
43 -import io.atomix.catalyst.transport.Address;
44 -import io.atomix.catalyst.transport.Connection;
45 -import io.atomix.catalyst.transport.MessageHandler;
46 -import io.atomix.catalyst.transport.TransportException;
47 -import io.atomix.catalyst.util.Assert;
48 -import io.atomix.catalyst.util.Listener;
49 -import io.atomix.catalyst.util.Listeners;
50 -import io.atomix.catalyst.util.ReferenceCounted;
51 -import io.atomix.catalyst.util.concurrent.ThreadContext;
52 -
53 /** 51 /**
54 * {@link Connection} implementation for CopycatTransport. 52 * {@link Connection} implementation for CopycatTransport.
55 */ 53 */
......
...@@ -17,6 +17,12 @@ package org.onosproject.store.primitives.impl; ...@@ -17,6 +17,12 @@ 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; 19 import static org.slf4j.LoggerFactory.getLogger;
20 +import io.atomix.catalyst.concurrent.CatalystThreadFactory;
21 +import io.atomix.catalyst.concurrent.SingleThreadContext;
22 +import io.atomix.catalyst.concurrent.ThreadContext;
23 +import io.atomix.catalyst.transport.Address;
24 +import io.atomix.catalyst.transport.Connection;
25 +import io.atomix.catalyst.transport.Server;
20 26
21 import java.io.ByteArrayInputStream; 27 import java.io.ByteArrayInputStream;
22 import java.io.DataInputStream; 28 import java.io.DataInputStream;
...@@ -36,13 +42,6 @@ import org.slf4j.Logger; ...@@ -36,13 +42,6 @@ import org.slf4j.Logger;
36 42
37 import com.google.common.collect.Maps; 43 import com.google.common.collect.Maps;
38 44
39 -import io.atomix.catalyst.transport.Address;
40 -import io.atomix.catalyst.transport.Connection;
41 -import io.atomix.catalyst.transport.Server;
42 -import io.atomix.catalyst.util.concurrent.CatalystThreadFactory;
43 -import io.atomix.catalyst.util.concurrent.SingleThreadContext;
44 -import io.atomix.catalyst.util.concurrent.ThreadContext;
45 -
46 /** 45 /**
47 * {@link Server} implementation for {@link CopycatTransport}. 46 * {@link Server} implementation for {@link CopycatTransport}.
48 */ 47 */
......
1 +/*
2 + * Copyright 2016-present 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.primitives.impl;
17 +
18 +import io.atomix.catalyst.concurrent.Listener;
19 +import io.atomix.catalyst.concurrent.ThreadContext;
20 +import io.atomix.catalyst.serializer.Serializer;
21 +import io.atomix.catalyst.transport.Address;
22 +import io.atomix.catalyst.transport.Transport;
23 +import io.atomix.copycat.Command;
24 +import io.atomix.copycat.Query;
25 +import io.atomix.copycat.client.CopycatClient;
26 +import io.atomix.copycat.session.Session;
27 +
28 +import java.util.Collection;
29 +import java.util.concurrent.CompletableFuture;
30 +import java.util.function.Consumer;
31 +
32 +/**
33 + * {@code CopycatClient} that merely delegates control to
34 + * another CopycatClient.
35 + */
36 +public class DelegatingCopycatClient implements CopycatClient {
37 +
38 + protected final CopycatClient client;
39 +
40 + DelegatingCopycatClient(CopycatClient client) {
41 + this.client = client;
42 + }
43 +
44 + @Override
45 + public State state() {
46 + return client.state();
47 + }
48 +
49 + @Override
50 + public Listener<State> onStateChange(Consumer<State> callback) {
51 + return client.onStateChange(callback);
52 + }
53 +
54 + @Override
55 + public ThreadContext context() {
56 + return client.context();
57 + }
58 +
59 + @Override
60 + public Transport transport() {
61 + return client.transport();
62 + }
63 +
64 + @Override
65 + public Serializer serializer() {
66 + return client.serializer();
67 + }
68 +
69 + @Override
70 + public Session session() {
71 + return client.session();
72 + }
73 +
74 + @Override
75 + public <T> CompletableFuture<T> submit(Command<T> command) {
76 + return client.submit(command);
77 + }
78 +
79 + @Override
80 + public <T> CompletableFuture<T> submit(Query<T> query) {
81 + return client.submit(query);
82 + }
83 +
84 + @Override
85 + public Listener<Void> onEvent(String event, Runnable callback) {
86 + return client.onEvent(event, callback);
87 + }
88 +
89 + @Override
90 + public <T> Listener<T> onEvent(String event, Consumer<T> callback) {
91 + return client.onEvent(event, callback);
92 + }
93 +
94 + @Override
95 + public CompletableFuture<CopycatClient> connect(Collection<Address> members) {
96 + return client.connect(members);
97 + }
98 +
99 + @Override
100 + public CompletableFuture<CopycatClient> recover() {
101 + return client.recover();
102 + }
103 +
104 + @Override
105 + public CompletableFuture<Void> close() {
106 + return client.close();
107 + }
108 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.primitives.impl;
17 +
18 +import static org.slf4j.LoggerFactory.getLogger;
19 +
20 +import java.net.ConnectException;
21 +import java.nio.channels.ClosedChannelException;
22 +import java.util.concurrent.CompletableFuture;
23 +import java.util.concurrent.Executors;
24 +import java.util.concurrent.ScheduledExecutorService;
25 +import java.util.concurrent.TimeUnit;
26 +import java.util.concurrent.TimeoutException;
27 +import java.util.function.Predicate;
28 +
29 +import org.slf4j.Logger;
30 +
31 +import com.google.common.base.Throwables;
32 +
33 +import io.atomix.catalyst.transport.TransportException;
34 +import io.atomix.copycat.Query;
35 +import io.atomix.copycat.client.CopycatClient;
36 +import io.atomix.copycat.error.QueryException;
37 +import io.atomix.copycat.error.UnknownSessionException;
38 +import io.atomix.copycat.session.ClosedSessionException;
39 +
40 +/**
41 + * {@code CopycatClient} that can retry when certain recoverable errors are encoutered.
42 + */
43 +public class QueryRetryingCopycatClient extends DelegatingCopycatClient {
44 +
45 + private final int maxRetries;
46 + private final long delayBetweenRetriesMillis;
47 + private final ScheduledExecutorService executor;
48 + private final Logger log = getLogger(getClass());
49 +
50 + private final Predicate<Throwable> retryableCheck = e -> e instanceof ConnectException
51 + || e instanceof TimeoutException
52 + || e instanceof TransportException
53 + || e instanceof ClosedChannelException
54 + || e instanceof QueryException
55 + || e instanceof UnknownSessionException
56 + || e instanceof ClosedSessionException;
57 +
58 + QueryRetryingCopycatClient(CopycatClient client, int maxRetries, long delayBetweenRetriesMillis) {
59 + super(client);
60 + this.maxRetries = maxRetries;
61 + this.delayBetweenRetriesMillis = delayBetweenRetriesMillis;
62 + this.executor = Executors.newSingleThreadScheduledExecutor();
63 + }
64 +
65 + @Override
66 + public CompletableFuture<Void> close() {
67 + executor.shutdown();
68 + return super.close();
69 + }
70 +
71 + @Override
72 + public <T> CompletableFuture<T> submit(Query<T> query) {
73 + CompletableFuture<T> future = new CompletableFuture<>();
74 + executor.submit(() -> submit(query, 1, future));
75 + return future;
76 + }
77 +
78 + private <T> void submit(Query<T> query, int attemptIndex, CompletableFuture<T> future) {
79 + client.submit(query).whenComplete((r, e) -> {
80 + if (e != null) {
81 + if (attemptIndex < maxRetries + 1 && retryableCheck.test(Throwables.getRootCause(e))) {
82 + log.debug("Retry attempt ({} of {}). Failure due to {}",
83 + attemptIndex, maxRetries, Throwables.getRootCause(e).getClass());
84 + executor.schedule(() ->
85 + submit(query, attemptIndex + 1, future), delayBetweenRetriesMillis, TimeUnit.MILLISECONDS);
86 + } else {
87 + future.completeExceptionally(e);
88 + }
89 + } else {
90 + future.complete(r);
91 + }
92 + });
93 + }
94 +}
...@@ -16,22 +16,18 @@ ...@@ -16,22 +16,18 @@
16 package org.onosproject.store.primitives.impl; 16 package org.onosproject.store.primitives.impl;
17 17
18 import static org.slf4j.LoggerFactory.getLogger; 18 import static org.slf4j.LoggerFactory.getLogger;
19 -import io.atomix.Atomix;
20 import io.atomix.AtomixClient; 19 import io.atomix.AtomixClient;
21 -import io.atomix.catalyst.transport.Address;
22 import io.atomix.catalyst.transport.Transport; 20 import io.atomix.catalyst.transport.Transport;
23 -import io.atomix.catalyst.util.concurrent.CatalystThreadFactory;
24 import io.atomix.copycat.client.ConnectionStrategies; 21 import io.atomix.copycat.client.ConnectionStrategies;
25 import io.atomix.copycat.client.CopycatClient; 22 import io.atomix.copycat.client.CopycatClient;
26 import io.atomix.copycat.client.CopycatClient.State; 23 import io.atomix.copycat.client.CopycatClient.State;
27 import io.atomix.copycat.client.RecoveryStrategies; 24 import io.atomix.copycat.client.RecoveryStrategies;
28 -import io.atomix.copycat.client.RetryStrategies;
29 import io.atomix.copycat.client.ServerSelectionStrategies; 25 import io.atomix.copycat.client.ServerSelectionStrategies;
30 import io.atomix.manager.ResourceClient; 26 import io.atomix.manager.ResourceClient;
31 -import io.atomix.manager.state.ResourceManagerException; 27 +import io.atomix.manager.ResourceManagerException;
32 import io.atomix.manager.util.ResourceManagerTypeResolver; 28 import io.atomix.manager.util.ResourceManagerTypeResolver;
29 +import io.atomix.resource.ResourceRegistry;
33 import io.atomix.resource.ResourceType; 30 import io.atomix.resource.ResourceType;
34 -import io.atomix.resource.util.ResourceRegistry;
35 import io.atomix.variables.DistributedLong; 31 import io.atomix.variables.DistributedLong;
36 32
37 import java.util.Collection; 33 import java.util.Collection;
...@@ -70,8 +66,8 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana ...@@ -70,8 +66,8 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana
70 private final StoragePartition partition; 66 private final StoragePartition partition;
71 private final Transport transport; 67 private final Transport transport;
72 private final io.atomix.catalyst.serializer.Serializer serializer; 68 private final io.atomix.catalyst.serializer.Serializer serializer;
73 - private Atomix client; 69 + private AtomixClient client;
74 - private CopycatClient copycatClient; 70 + private ResourceClient resourceClient;
75 private static final String ATOMIC_VALUES_CONSISTENT_MAP_NAME = "onos-atomic-values"; 71 private static final String ATOMIC_VALUES_CONSISTENT_MAP_NAME = "onos-atomic-values";
76 private final Supplier<AsyncConsistentMap<String, byte[]>> onosAtomicValuesMap = 72 private final Supplier<AsyncConsistentMap<String, byte[]>> onosAtomicValuesMap =
77 Suppliers.memoize(() -> newAsyncConsistentMap(ATOMIC_VALUES_CONSISTENT_MAP_NAME, 73 Suppliers.memoize(() -> newAsyncConsistentMap(ATOMIC_VALUES_CONSISTENT_MAP_NAME,
...@@ -99,19 +95,15 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana ...@@ -99,19 +95,15 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana
99 95
100 @Override 96 @Override
101 public CompletableFuture<Void> open() { 97 public CompletableFuture<Void> open() {
102 - if (client != null && client.isOpen()) {
103 - return CompletableFuture.completedFuture(null);
104 - }
105 synchronized (StoragePartitionClient.this) { 98 synchronized (StoragePartitionClient.this) {
106 - copycatClient = newCopycatClient(partition.getMemberAddresses(), 99 + resourceClient = newResourceClient(transport,
107 - transport,
108 serializer.clone(), 100 serializer.clone(),
109 StoragePartition.RESOURCE_TYPES); 101 StoragePartition.RESOURCE_TYPES);
110 - copycatClient.onStateChange(state -> log.debug("Partition {} client state" 102 + resourceClient.client().onStateChange(state -> log.debug("Partition {} client state"
111 + " changed to {}", partition.getId(), state)); 103 + " changed to {}", partition.getId(), state));
112 - client = new AtomixClient(new ResourceClient(copycatClient)); 104 + client = new AtomixClient(resourceClient);
113 } 105 }
114 - return client.open().whenComplete((r, e) -> { 106 + return client.connect(partition.getMemberAddresses()).whenComplete((r, e) -> {
115 if (e == null) { 107 if (e == null) {
116 log.info("Successfully started client for partition {}", partition.getId()); 108 log.info("Successfully started client for partition {}", partition.getId());
117 } else { 109 } else {
...@@ -132,7 +124,7 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana ...@@ -132,7 +124,7 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana
132 atomixConsistentMap.statusChangeListeners() 124 atomixConsistentMap.statusChangeListeners()
133 .forEach(listener -> listener.accept(mapper.apply(state))); 125 .forEach(listener -> listener.accept(mapper.apply(state)));
134 }; 126 };
135 - copycatClient.onStateChange(statusListener); 127 + resourceClient.client().onStateChange(statusListener);
136 AsyncConsistentMap<String, byte[]> rawMap = 128 AsyncConsistentMap<String, byte[]> rawMap =
137 new DelegatingAsyncConsistentMap<String, byte[]>(atomixConsistentMap) { 129 new DelegatingAsyncConsistentMap<String, byte[]>(atomixConsistentMap) {
138 @Override 130 @Override
...@@ -173,7 +165,15 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana ...@@ -173,7 +165,15 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana
173 165
174 @Override 166 @Override
175 public AsyncLeaderElector newAsyncLeaderElector(String name) { 167 public AsyncLeaderElector newAsyncLeaderElector(String name) {
176 - return client.getResource(name, AtomixLeaderElector.class).join(); 168 + AtomixLeaderElector leaderElector = client.getResource(name, AtomixLeaderElector.class)
169 + .thenCompose(AtomixLeaderElector::setupCache)
170 + .join();
171 + Consumer<State> statusListener = state -> {
172 + leaderElector.statusChangeListeners()
173 + .forEach(listener -> listener.accept(mapper.apply(state)));
174 + };
175 + resourceClient.client().onStateChange(statusListener);
176 + return leaderElector;
177 } 177 }
178 178
179 @Override 179 @Override
...@@ -188,7 +188,7 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana ...@@ -188,7 +188,7 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana
188 188
189 @Override 189 @Override
190 public boolean isOpen() { 190 public boolean isOpen() {
191 - return client.isOpen(); 191 + return resourceClient.client().state() != State.CLOSED;
192 } 192 }
193 193
194 /** 194 /**
...@@ -198,33 +198,33 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana ...@@ -198,33 +198,33 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana
198 public PartitionClientInfo clientInfo() { 198 public PartitionClientInfo clientInfo() {
199 return new PartitionClientInfo(partition.getId(), 199 return new PartitionClientInfo(partition.getId(),
200 partition.getMembers(), 200 partition.getMembers(),
201 - copycatClient.session().id(), 201 + resourceClient.client().session().id(),
202 - mapper.apply(copycatClient.state())); 202 + mapper.apply(resourceClient.client().state()));
203 } 203 }
204 204
205 - private CopycatClient newCopycatClient(Collection<Address> members, 205 + private ResourceClient newResourceClient(Transport transport,
206 - Transport transport,
207 io.atomix.catalyst.serializer.Serializer serializer, 206 io.atomix.catalyst.serializer.Serializer serializer,
208 Collection<ResourceType> resourceTypes) { 207 Collection<ResourceType> resourceTypes) {
209 ResourceRegistry registry = new ResourceRegistry(); 208 ResourceRegistry registry = new ResourceRegistry();
210 resourceTypes.forEach(registry::register); 209 resourceTypes.forEach(registry::register);
211 - CopycatClient client = CopycatClient.builder(members) 210 + CopycatClient copycatClient = CopycatClient.builder()
212 .withServerSelectionStrategy(ServerSelectionStrategies.ANY) 211 .withServerSelectionStrategy(ServerSelectionStrategies.ANY)
213 .withConnectionStrategy(ConnectionStrategies.FIBONACCI_BACKOFF) 212 .withConnectionStrategy(ConnectionStrategies.FIBONACCI_BACKOFF)
214 .withRecoveryStrategy(RecoveryStrategies.RECOVER) 213 .withRecoveryStrategy(RecoveryStrategies.RECOVER)
215 - .withRetryStrategy(RetryStrategies.FIBONACCI_BACKOFF)
216 .withTransport(transport) 214 .withTransport(transport)
217 .withSerializer(serializer) 215 .withSerializer(serializer)
218 - .withThreadFactory(new CatalystThreadFactory(String.format("copycat-client-%s", partition.getId())))
219 .build(); 216 .build();
220 - client.serializer().resolve(new ResourceManagerTypeResolver()); 217 + copycatClient.serializer().resolve(new ResourceManagerTypeResolver());
221 for (ResourceType type : registry.types()) { 218 for (ResourceType type : registry.types()) {
222 try { 219 try {
223 - type.factory().newInstance().createSerializableTypeResolver().resolve(client.serializer().registry()); 220 + type.factory()
221 + .newInstance()
222 + .createSerializableTypeResolver()
223 + .resolve(copycatClient.serializer().registry());
224 } catch (InstantiationException | IllegalAccessException e) { 224 } catch (InstantiationException | IllegalAccessException e) {
225 throw new ResourceManagerException(e); 225 throw new ResourceManagerException(e);
226 } 226 }
227 } 227 }
228 - return client; 228 + return new ResourceClient(new QueryRetryingCopycatClient(copycatClient, 2, 100));
229 } 229 }
230 } 230 }
......
...@@ -22,7 +22,7 @@ import io.atomix.catalyst.transport.Transport; ...@@ -22,7 +22,7 @@ import io.atomix.catalyst.transport.Transport;
22 import io.atomix.copycat.server.CopycatServer; 22 import io.atomix.copycat.server.CopycatServer;
23 import io.atomix.copycat.server.storage.Storage; 23 import io.atomix.copycat.server.storage.Storage;
24 import io.atomix.copycat.server.storage.StorageLevel; 24 import io.atomix.copycat.server.storage.StorageLevel;
25 -import io.atomix.manager.state.ResourceManagerState; 25 +import io.atomix.manager.internal.ResourceManagerState;
26 import io.atomix.manager.util.ResourceManagerTypeResolver; 26 import io.atomix.manager.util.ResourceManagerTypeResolver;
27 27
28 import java.io.File; 28 import java.io.File;
...@@ -68,9 +68,9 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> { ...@@ -68,9 +68,9 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> {
68 return CompletableFuture.completedFuture(null); 68 return CompletableFuture.completedFuture(null);
69 } 69 }
70 synchronized (this) { 70 synchronized (this) {
71 - server = buildServer(partition.getMemberAddresses()); 71 + server = buildServer();
72 } 72 }
73 - serverOpenFuture = server.start(); 73 + serverOpenFuture = server.bootstrap(partition.getMemberAddresses());
74 } else { 74 } else {
75 serverOpenFuture = CompletableFuture.completedFuture(null); 75 serverOpenFuture = CompletableFuture.completedFuture(null);
76 } 76 }
...@@ -85,11 +85,7 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> { ...@@ -85,11 +85,7 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> {
85 85
86 @Override 86 @Override
87 public CompletableFuture<Void> close() { 87 public CompletableFuture<Void> close() {
88 - /** 88 + return server.shutdown();
89 - * CopycatServer#kill just shuts down the server and does not result
90 - * in any cluster membership changes.
91 - */
92 - return server.kill();
93 } 89 }
94 90
95 /** 91 /**
...@@ -97,11 +93,11 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> { ...@@ -97,11 +93,11 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> {
97 * @return future that is completed when the operation is complete 93 * @return future that is completed when the operation is complete
98 */ 94 */
99 public CompletableFuture<Void> closeAndExit() { 95 public CompletableFuture<Void> closeAndExit() {
100 - return server.stop(); 96 + return server.leave();
101 } 97 }
102 98
103 - private CopycatServer buildServer(Collection<Address> clusterMembers) { 99 + private CopycatServer buildServer() {
104 - CopycatServer server = CopycatServer.builder(localAddress, clusterMembers) 100 + CopycatServer server = CopycatServer.builder(localAddress)
105 .withName("partition-" + partition.getId()) 101 .withName("partition-" + partition.getId())
106 .withSerializer(serializer.clone()) 102 .withSerializer(serializer.clone())
107 .withTransport(transport.get()) 103 .withTransport(transport.get())
...@@ -118,9 +114,8 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> { ...@@ -118,9 +114,8 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> {
118 } 114 }
119 115
120 public CompletableFuture<Void> join(Collection<Address> otherMembers) { 116 public CompletableFuture<Void> join(Collection<Address> otherMembers) {
121 - server = buildServer(otherMembers); 117 + server = buildServer();
122 - 118 + return server.join(otherMembers).whenComplete((r, e) -> {
123 - return server.start().whenComplete((r, e) -> {
124 if (e == null) { 119 if (e == null) {
125 log.info("Successfully joined partition {}", partition.getId()); 120 log.info("Successfully joined partition {}", partition.getId());
126 } else { 121 } else {
......
...@@ -48,10 +48,6 @@ public final class AsyncConsistentMultimapCommands { ...@@ -48,10 +48,6 @@ public final class AsyncConsistentMultimapCommands {
48 @SuppressWarnings("serial") 48 @SuppressWarnings("serial")
49 public abstract static class MultimapCommand<V> implements Command<V>, 49 public abstract static class MultimapCommand<V> implements Command<V>,
50 CatalystSerializable { 50 CatalystSerializable {
51 - @Override
52 - public ConsistencyLevel consistency() {
53 - return ConsistencyLevel.SEQUENTIAL;
54 - }
55 51
56 @Override 52 @Override
57 public String toString() { 53 public String toString() {
......
...@@ -70,95 +70,90 @@ public class AsyncConsistentSetMultimap ...@@ -70,95 +70,90 @@ public class AsyncConsistentSetMultimap
70 70
71 @Override 71 @Override
72 public CompletableFuture<Integer> size() { 72 public CompletableFuture<Integer> size() {
73 - return submit(new Size()); 73 + return client.submit(new Size());
74 } 74 }
75 75
76 @Override 76 @Override
77 public CompletableFuture<Boolean> isEmpty() { 77 public CompletableFuture<Boolean> isEmpty() {
78 - return submit(new IsEmpty()); 78 + return client.submit(new IsEmpty());
79 } 79 }
80 80
81 @Override 81 @Override
82 public CompletableFuture<Boolean> containsKey(String key) { 82 public CompletableFuture<Boolean> containsKey(String key) {
83 - return submit(new ContainsKey(key)); 83 + return client.submit(new ContainsKey(key));
84 } 84 }
85 85
86 @Override 86 @Override
87 public CompletableFuture<Boolean> containsValue(byte[] value) { 87 public CompletableFuture<Boolean> containsValue(byte[] value) {
88 - return submit(new ContainsValue(value)); 88 + return client.submit(new ContainsValue(value));
89 } 89 }
90 90
91 @Override 91 @Override
92 public CompletableFuture<Boolean> containsEntry(String key, byte[] value) { 92 public CompletableFuture<Boolean> containsEntry(String key, byte[] value) {
93 - return submit(new ContainsEntry(key, value)); 93 + return client.submit(new ContainsEntry(key, value));
94 } 94 }
95 95
96 @Override 96 @Override
97 public CompletableFuture<Boolean> put(String key, byte[] value) { 97 public CompletableFuture<Boolean> put(String key, byte[] value) {
98 - return submit(new Put(key, Lists.newArrayList(value), null)); 98 + return client.submit(new Put(key, Lists.newArrayList(value), null));
99 } 99 }
100 100
101 @Override 101 @Override
102 public CompletableFuture<Boolean> remove(String key, byte[] value) { 102 public CompletableFuture<Boolean> remove(String key, byte[] value) {
103 - return submit(new MultiRemove(key, 103 + return client.submit(new MultiRemove(key,
104 Lists.newArrayList(value), 104 Lists.newArrayList(value),
105 null)); 105 null));
106 } 106 }
107 107
108 @Override 108 @Override
109 - public CompletableFuture<Boolean> removeAll( 109 + public CompletableFuture<Boolean> removeAll(String key, Collection<? extends byte[]> values) {
110 - String key, Collection<? extends byte[]> values) { 110 + return client.submit(new MultiRemove(key, (Collection<byte[]>) values, null));
111 - return submit(new MultiRemove(key, (Collection<byte[]>) values, null));
112 } 111 }
113 112
114 @Override 113 @Override
115 - public CompletableFuture< 114 + public CompletableFuture<Versioned<Collection<? extends byte[]>>> removeAll(String key) {
116 - Versioned<Collection<? extends byte[]>>> removeAll(String key) { 115 + return client.submit(new RemoveAll(key, null));
117 - return submit(new RemoveAll(key, null));
118 } 116 }
119 117
120 @Override 118 @Override
121 public CompletableFuture<Boolean> putAll( 119 public CompletableFuture<Boolean> putAll(
122 String key, Collection<? extends byte[]> values) { 120 String key, Collection<? extends byte[]> values) {
123 - return submit(new Put(key, values, null)); 121 + return client.submit(new Put(key, values, null));
124 } 122 }
125 123
126 @Override 124 @Override
127 - public CompletableFuture< 125 + public CompletableFuture<Versioned<Collection<? extends byte[]>>> replaceValues(
128 - Versioned<Collection<? extends byte[]>>> replaceValues(
129 String key, Collection<byte[]> values) { 126 String key, Collection<byte[]> values) {
130 - return submit(new Replace(key, values, null)); 127 + return client.submit(new Replace(key, values, null));
131 } 128 }
132 129
133 @Override 130 @Override
134 public CompletableFuture<Void> clear() { 131 public CompletableFuture<Void> clear() {
135 - return submit(new Clear()); 132 + return client.submit(new Clear());
136 } 133 }
137 134
138 @Override 135 @Override
139 - public CompletableFuture< 136 + public CompletableFuture<Versioned<Collection<? extends byte[]>>> get(String key) {
140 - Versioned<Collection<? extends byte[]>>> get(String key) { 137 + return client.submit(new Get(key));
141 - return submit(new Get(key));
142 } 138 }
143 139
144 @Override 140 @Override
145 public CompletableFuture<Set<String>> keySet() { 141 public CompletableFuture<Set<String>> keySet() {
146 - return submit(new KeySet()); 142 + return client.submit(new KeySet());
147 } 143 }
148 144
149 @Override 145 @Override
150 public CompletableFuture<Multiset<String>> keys() { 146 public CompletableFuture<Multiset<String>> keys() {
151 - return submit(new Keys()); 147 + return client.submit(new Keys());
152 } 148 }
153 149
154 - @Override
155 public CompletableFuture<Multiset<byte[]>> values() { 150 public CompletableFuture<Multiset<byte[]>> values() {
156 - return submit(new Values()); 151 + return client.submit(new Values());
157 } 152 }
158 153
159 @Override 154 @Override
160 public CompletableFuture<Collection<Map.Entry<String, byte[]>>> entries() { 155 public CompletableFuture<Collection<Map.Entry<String, byte[]>>> entries() {
161 - return submit(new Entries()); 156 + return client.submit(new Entries());
162 } 157 }
163 158
164 @Override 159 @Override
......
...@@ -97,48 +97,48 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> ...@@ -97,48 +97,48 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
97 97
98 @Override 98 @Override
99 public CompletableFuture<Boolean> isEmpty() { 99 public CompletableFuture<Boolean> isEmpty() {
100 - return submit(new IsEmpty()); 100 + return client.submit(new IsEmpty());
101 } 101 }
102 102
103 @Override 103 @Override
104 public CompletableFuture<Integer> size() { 104 public CompletableFuture<Integer> size() {
105 - return submit(new Size()); 105 + return client.submit(new Size());
106 } 106 }
107 107
108 @Override 108 @Override
109 public CompletableFuture<Boolean> containsKey(String key) { 109 public CompletableFuture<Boolean> containsKey(String key) {
110 - return submit(new ContainsKey(key)); 110 + return client.submit(new ContainsKey(key));
111 } 111 }
112 112
113 @Override 113 @Override
114 public CompletableFuture<Boolean> containsValue(byte[] value) { 114 public CompletableFuture<Boolean> containsValue(byte[] value) {
115 - return submit(new ContainsValue(value)); 115 + return client.submit(new ContainsValue(value));
116 } 116 }
117 117
118 @Override 118 @Override
119 public CompletableFuture<Versioned<byte[]>> get(String key) { 119 public CompletableFuture<Versioned<byte[]>> get(String key) {
120 - return submit(new Get(key)); 120 + return client.submit(new Get(key));
121 } 121 }
122 122
123 @Override 123 @Override
124 public CompletableFuture<Set<String>> keySet() { 124 public CompletableFuture<Set<String>> keySet() {
125 - return submit(new KeySet()); 125 + return client.submit(new KeySet());
126 } 126 }
127 127
128 @Override 128 @Override
129 public CompletableFuture<Collection<Versioned<byte[]>>> values() { 129 public CompletableFuture<Collection<Versioned<byte[]>>> values() {
130 - return submit(new Values()); 130 + return client.submit(new Values());
131 } 131 }
132 132
133 @Override 133 @Override
134 public CompletableFuture<Set<Entry<String, Versioned<byte[]>>>> entrySet() { 134 public CompletableFuture<Set<Entry<String, Versioned<byte[]>>>> entrySet() {
135 - return submit(new EntrySet()); 135 + return client.submit(new EntrySet());
136 } 136 }
137 137
138 @Override 138 @Override
139 @SuppressWarnings("unchecked") 139 @SuppressWarnings("unchecked")
140 public CompletableFuture<Versioned<byte[]>> put(String key, byte[] value) { 140 public CompletableFuture<Versioned<byte[]>> put(String key, byte[] value) {
141 - return submit(new UpdateAndGet(key, value, Match.ANY, Match.ANY)) 141 + return client.submit(new UpdateAndGet(key, value, Match.ANY, Match.ANY))
142 .whenComplete((r, e) -> throwIfLocked(r.status())) 142 .whenComplete((r, e) -> throwIfLocked(r.status()))
143 .thenApply(v -> v.oldValue()); 143 .thenApply(v -> v.oldValue());
144 } 144 }
...@@ -146,7 +146,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> ...@@ -146,7 +146,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
146 @Override 146 @Override
147 @SuppressWarnings("unchecked") 147 @SuppressWarnings("unchecked")
148 public CompletableFuture<Versioned<byte[]>> putAndGet(String key, byte[] value) { 148 public CompletableFuture<Versioned<byte[]>> putAndGet(String key, byte[] value) {
149 - return submit(new UpdateAndGet(key, value, Match.ANY, Match.ANY)) 149 + return client.submit(new UpdateAndGet(key, value, Match.ANY, Match.ANY))
150 .whenComplete((r, e) -> throwIfLocked(r.status())) 150 .whenComplete((r, e) -> throwIfLocked(r.status()))
151 .thenApply(v -> v.newValue()); 151 .thenApply(v -> v.newValue());
152 } 152 }
...@@ -154,14 +154,14 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> ...@@ -154,14 +154,14 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
154 @Override 154 @Override
155 @SuppressWarnings("unchecked") 155 @SuppressWarnings("unchecked")
156 public CompletableFuture<Versioned<byte[]>> putIfAbsent(String key, byte[] value) { 156 public CompletableFuture<Versioned<byte[]>> putIfAbsent(String key, byte[] value) {
157 - return submit(new UpdateAndGet(key, value, Match.NULL, Match.ANY)) 157 + return client.submit(new UpdateAndGet(key, value, Match.NULL, Match.ANY))
158 .whenComplete((r, e) -> throwIfLocked(r.status())) 158 .whenComplete((r, e) -> throwIfLocked(r.status()))
159 .thenApply(v -> v.oldValue()); 159 .thenApply(v -> v.oldValue());
160 } 160 }
161 @Override 161 @Override
162 @SuppressWarnings("unchecked") 162 @SuppressWarnings("unchecked")
163 public CompletableFuture<Versioned<byte[]>> remove(String key) { 163 public CompletableFuture<Versioned<byte[]>> remove(String key) {
164 - return submit(new UpdateAndGet(key, null, Match.ANY, Match.ANY)) 164 + return client.submit(new UpdateAndGet(key, null, Match.ANY, Match.ANY))
165 .whenComplete((r, e) -> throwIfLocked(r.status())) 165 .whenComplete((r, e) -> throwIfLocked(r.status()))
166 .thenApply(v -> v.oldValue()); 166 .thenApply(v -> v.oldValue());
167 } 167 }
...@@ -169,7 +169,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> ...@@ -169,7 +169,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
169 @Override 169 @Override
170 @SuppressWarnings("unchecked") 170 @SuppressWarnings("unchecked")
171 public CompletableFuture<Boolean> remove(String key, byte[] value) { 171 public CompletableFuture<Boolean> remove(String key, byte[] value) {
172 - return submit(new UpdateAndGet(key, null, Match.ifValue(value), Match.ANY)) 172 + return client.submit(new UpdateAndGet(key, null, Match.ifValue(value), Match.ANY))
173 .whenComplete((r, e) -> throwIfLocked(r.status())) 173 .whenComplete((r, e) -> throwIfLocked(r.status()))
174 .thenApply(v -> v.updated()); 174 .thenApply(v -> v.updated());
175 } 175 }
...@@ -177,7 +177,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> ...@@ -177,7 +177,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
177 @Override 177 @Override
178 @SuppressWarnings("unchecked") 178 @SuppressWarnings("unchecked")
179 public CompletableFuture<Boolean> remove(String key, long version) { 179 public CompletableFuture<Boolean> remove(String key, long version) {
180 - return submit(new UpdateAndGet(key, null, Match.ANY, Match.ifValue(version))) 180 + return client.submit(new UpdateAndGet(key, null, Match.ANY, Match.ifValue(version)))
181 .whenComplete((r, e) -> throwIfLocked(r.status())) 181 .whenComplete((r, e) -> throwIfLocked(r.status()))
182 .thenApply(v -> v.updated()); 182 .thenApply(v -> v.updated());
183 } 183 }
...@@ -185,7 +185,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> ...@@ -185,7 +185,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
185 @Override 185 @Override
186 @SuppressWarnings("unchecked") 186 @SuppressWarnings("unchecked")
187 public CompletableFuture<Versioned<byte[]>> replace(String key, byte[] value) { 187 public CompletableFuture<Versioned<byte[]>> replace(String key, byte[] value) {
188 - return submit(new UpdateAndGet(key, value, Match.NOT_NULL, Match.ANY)) 188 + return client.submit(new UpdateAndGet(key, value, Match.NOT_NULL, Match.ANY))
189 .whenComplete((r, e) -> throwIfLocked(r.status())) 189 .whenComplete((r, e) -> throwIfLocked(r.status()))
190 .thenApply(v -> v.oldValue()); 190 .thenApply(v -> v.oldValue());
191 } 191 }
...@@ -193,10 +193,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> ...@@ -193,10 +193,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
193 @Override 193 @Override
194 @SuppressWarnings("unchecked") 194 @SuppressWarnings("unchecked")
195 public CompletableFuture<Boolean> replace(String key, byte[] oldValue, byte[] newValue) { 195 public CompletableFuture<Boolean> replace(String key, byte[] oldValue, byte[] newValue) {
196 - return submit(new UpdateAndGet(key, 196 + return client.submit(new UpdateAndGet(key, newValue, Match.ifValue(oldValue), Match.ANY))
197 - newValue,
198 - Match.ifValue(oldValue),
199 - Match.ANY))
200 .whenComplete((r, e) -> throwIfLocked(r.status())) 197 .whenComplete((r, e) -> throwIfLocked(r.status()))
201 .thenApply(v -> v.updated()); 198 .thenApply(v -> v.updated());
202 } 199 }
...@@ -204,17 +201,14 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> ...@@ -204,17 +201,14 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
204 @Override 201 @Override
205 @SuppressWarnings("unchecked") 202 @SuppressWarnings("unchecked")
206 public CompletableFuture<Boolean> replace(String key, long oldVersion, byte[] newValue) { 203 public CompletableFuture<Boolean> replace(String key, long oldVersion, byte[] newValue) {
207 - return submit(new UpdateAndGet(key, 204 + return client.submit(new UpdateAndGet(key, newValue, Match.ANY, Match.ifValue(oldVersion)))
208 - newValue,
209 - Match.ANY,
210 - Match.ifValue(oldVersion)))
211 .whenComplete((r, e) -> throwIfLocked(r.status())) 205 .whenComplete((r, e) -> throwIfLocked(r.status()))
212 .thenApply(v -> v.updated()); 206 .thenApply(v -> v.updated());
213 } 207 }
214 208
215 @Override 209 @Override
216 public CompletableFuture<Void> clear() { 210 public CompletableFuture<Void> clear() {
217 - return submit(new Clear()) 211 + return client.submit(new Clear())
218 .whenComplete((r, e) -> throwIfLocked(r)) 212 .whenComplete((r, e) -> throwIfLocked(r))
219 .thenApply(v -> null); 213 .thenApply(v -> null);
220 } 214 }
...@@ -245,7 +239,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> ...@@ -245,7 +239,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
245 } 239 }
246 Match<byte[]> valueMatch = r1 == null ? Match.NULL : Match.ANY; 240 Match<byte[]> valueMatch = r1 == null ? Match.NULL : Match.ANY;
247 Match<Long> versionMatch = r1 == null ? Match.ANY : Match.ifValue(r1.version()); 241 Match<Long> versionMatch = r1 == null ? Match.ANY : Match.ifValue(r1.version());
248 - return submit(new UpdateAndGet(key, 242 + return client.submit(new UpdateAndGet(key,
249 computedValue.get(), 243 computedValue.get(),
250 valueMatch, 244 valueMatch,
251 versionMatch)) 245 versionMatch))
...@@ -258,7 +252,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> ...@@ -258,7 +252,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
258 public synchronized CompletableFuture<Void> addListener(MapEventListener<String, byte[]> listener, 252 public synchronized CompletableFuture<Void> addListener(MapEventListener<String, byte[]> listener,
259 Executor executor) { 253 Executor executor) {
260 if (mapEventListeners.isEmpty()) { 254 if (mapEventListeners.isEmpty()) {
261 - return submit(new Listen()).thenRun(() -> mapEventListeners.putIfAbsent(listener, executor)); 255 + return client.submit(new Listen()).thenRun(() -> mapEventListeners.putIfAbsent(listener, executor));
262 } else { 256 } else {
263 mapEventListeners.put(listener, executor); 257 mapEventListeners.put(listener, executor);
264 return CompletableFuture.completedFuture(null); 258 return CompletableFuture.completedFuture(null);
...@@ -268,7 +262,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> ...@@ -268,7 +262,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
268 @Override 262 @Override
269 public synchronized CompletableFuture<Void> removeListener(MapEventListener<String, byte[]> listener) { 263 public synchronized CompletableFuture<Void> removeListener(MapEventListener<String, byte[]> listener) {
270 if (mapEventListeners.remove(listener) != null && mapEventListeners.isEmpty()) { 264 if (mapEventListeners.remove(listener) != null && mapEventListeners.isEmpty()) {
271 - return submit(new Unlisten()).thenApply(v -> null); 265 + return client.submit(new Unlisten()).thenApply(v -> null);
272 } 266 }
273 return CompletableFuture.completedFuture(null); 267 return CompletableFuture.completedFuture(null);
274 } 268 }
...@@ -281,23 +275,23 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> ...@@ -281,23 +275,23 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap>
281 275
282 @Override 276 @Override
283 public CompletableFuture<Boolean> prepare(MapTransaction<String, byte[]> transaction) { 277 public CompletableFuture<Boolean> prepare(MapTransaction<String, byte[]> transaction) {
284 - return submit(new TransactionPrepare(transaction)).thenApply(v -> v == PrepareResult.OK); 278 + return client.submit(new TransactionPrepare(transaction)).thenApply(v -> v == PrepareResult.OK);
285 } 279 }
286 280
287 @Override 281 @Override
288 public CompletableFuture<Void> commit(TransactionId transactionId) { 282 public CompletableFuture<Void> commit(TransactionId transactionId) {
289 - return submit(new TransactionCommit(transactionId)).thenApply(v -> null); 283 + return client.submit(new TransactionCommit(transactionId)).thenApply(v -> null);
290 } 284 }
291 285
292 @Override 286 @Override
293 public CompletableFuture<Void> rollback(TransactionId transactionId) { 287 public CompletableFuture<Void> rollback(TransactionId transactionId) {
294 - return submit(new TransactionRollback(transactionId)) 288 + return client.submit(new TransactionRollback(transactionId))
295 .thenApply(v -> null); 289 .thenApply(v -> null);
296 } 290 }
297 291
298 @Override 292 @Override
299 public CompletableFuture<Boolean> prepareAndCommit(MapTransaction<String, byte[]> transaction) { 293 public CompletableFuture<Boolean> prepareAndCommit(MapTransaction<String, byte[]> transaction) {
300 - return submit(new TransactionPrepareAndCommit(transaction)).thenApply(v -> v == PrepareResult.OK); 294 + return client.submit(new TransactionPrepareAndCommit(transaction)).thenApply(v -> v == PrepareResult.OK);
301 } 295 }
302 296
303 @Override 297 @Override
......
...@@ -51,11 +51,6 @@ public final class AtomixConsistentMapCommands { ...@@ -51,11 +51,6 @@ public final class AtomixConsistentMapCommands {
51 public abstract static class MapCommand<V> implements Command<V>, CatalystSerializable { 51 public abstract static class MapCommand<V> implements Command<V>, CatalystSerializable {
52 52
53 @Override 53 @Override
54 - public ConsistencyLevel consistency() {
55 - return ConsistencyLevel.SEQUENTIAL;
56 - }
57 -
58 - @Override
59 public String toString() { 54 public String toString() {
60 return MoreObjects.toStringHelper(getClass()) 55 return MoreObjects.toStringHelper(getClass())
61 .toString(); 56 .toString();
......
...@@ -42,6 +42,9 @@ import org.onosproject.store.primitives.resources.impl.AtomixLeaderElectorComman ...@@ -42,6 +42,9 @@ import org.onosproject.store.primitives.resources.impl.AtomixLeaderElectorComman
42 import org.onosproject.store.service.AsyncLeaderElector; 42 import org.onosproject.store.service.AsyncLeaderElector;
43 43
44 import com.google.common.collect.ImmutableSet; 44 import com.google.common.collect.ImmutableSet;
45 +import com.google.common.cache.CacheBuilder;
46 +import com.google.common.cache.CacheLoader;
47 +import com.google.common.cache.LoadingCache;
45 import com.google.common.collect.Sets; 48 import com.google.common.collect.Sets;
46 49
47 /** 50 /**
...@@ -54,11 +57,34 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector> ...@@ -54,11 +57,34 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector>
54 Sets.newCopyOnWriteArraySet(); 57 Sets.newCopyOnWriteArraySet();
55 private final Set<Consumer<Change<Leadership>>> leadershipChangeListeners = 58 private final Set<Consumer<Change<Leadership>>> leadershipChangeListeners =
56 Sets.newCopyOnWriteArraySet(); 59 Sets.newCopyOnWriteArraySet();
60 + private final Consumer<Change<Leadership>> cacheUpdater;
61 + private final Consumer<Status> statusListener;
57 62
58 public static final String CHANGE_SUBJECT = "leadershipChangeEvents"; 63 public static final String CHANGE_SUBJECT = "leadershipChangeEvents";
64 + private final LoadingCache<String, CompletableFuture<Leadership>> cache;
59 65
60 public AtomixLeaderElector(CopycatClient client, Properties properties) { 66 public AtomixLeaderElector(CopycatClient client, Properties properties) {
61 super(client, properties); 67 super(client, properties);
68 + cache = CacheBuilder.newBuilder()
69 + .maximumSize(1000)
70 + .build(CacheLoader.from(topic -> this.client.submit(new GetLeadership(topic))));
71 +
72 + cacheUpdater = change -> {
73 + Leadership leadership = change.newValue();
74 + cache.put(leadership.topic(), CompletableFuture.completedFuture(leadership));
75 + };
76 + statusListener = status -> {
77 + if (status == Status.SUSPENDED || status == Status.INACTIVE) {
78 + cache.invalidateAll();
79 + }
80 + };
81 + addStatusChangeListener(statusListener);
82 + }
83 +
84 + @Override
85 + public CompletableFuture<Void> destroy() {
86 + removeStatusChangeListener(statusListener);
87 + return removeChangeListener(cacheUpdater);
62 } 88 }
63 89
64 @Override 90 @Override
...@@ -74,53 +100,57 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector> ...@@ -74,53 +100,57 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector>
74 }); 100 });
75 } 101 }
76 102
103 + public CompletableFuture<AtomixLeaderElector> setupCache() {
104 + return addChangeListener(cacheUpdater).thenApply(v -> this);
105 + }
106 +
77 private void handleEvent(List<Change<Leadership>> changes) { 107 private void handleEvent(List<Change<Leadership>> changes) {
78 changes.forEach(change -> leadershipChangeListeners.forEach(l -> l.accept(change))); 108 changes.forEach(change -> leadershipChangeListeners.forEach(l -> l.accept(change)));
79 } 109 }
80 110
81 @Override 111 @Override
82 public CompletableFuture<Leadership> run(String topic, NodeId nodeId) { 112 public CompletableFuture<Leadership> run(String topic, NodeId nodeId) {
83 - return submit(new Run(topic, nodeId)); 113 + return client.submit(new Run(topic, nodeId)).whenComplete((r, e) -> cache.invalidate(topic));
84 } 114 }
85 115
86 @Override 116 @Override
87 public CompletableFuture<Void> withdraw(String topic) { 117 public CompletableFuture<Void> withdraw(String topic) {
88 - return submit(new Withdraw(topic)); 118 + return client.submit(new Withdraw(topic)).whenComplete((r, e) -> cache.invalidate(topic));
89 } 119 }
90 120
91 @Override 121 @Override
92 public CompletableFuture<Boolean> anoint(String topic, NodeId nodeId) { 122 public CompletableFuture<Boolean> anoint(String topic, NodeId nodeId) {
93 - return submit(new Anoint(topic, nodeId)); 123 + return client.submit(new Anoint(topic, nodeId)).whenComplete((r, e) -> cache.invalidate(topic));
94 } 124 }
95 125
96 @Override 126 @Override
97 public CompletableFuture<Boolean> promote(String topic, NodeId nodeId) { 127 public CompletableFuture<Boolean> promote(String topic, NodeId nodeId) {
98 - return submit(new Promote(topic, nodeId)); 128 + return client.submit(new Promote(topic, nodeId)).whenComplete((r, e) -> cache.invalidate(topic));
99 } 129 }
100 130
101 @Override 131 @Override
102 public CompletableFuture<Void> evict(NodeId nodeId) { 132 public CompletableFuture<Void> evict(NodeId nodeId) {
103 - return submit(new AtomixLeaderElectorCommands.Evict(nodeId)); 133 + return client.submit(new AtomixLeaderElectorCommands.Evict(nodeId));
104 } 134 }
105 135
106 @Override 136 @Override
107 public CompletableFuture<Leadership> getLeadership(String topic) { 137 public CompletableFuture<Leadership> getLeadership(String topic) {
108 - return submit(new GetLeadership(topic)); 138 + return cache.getUnchecked(topic);
109 } 139 }
110 140
111 @Override 141 @Override
112 public CompletableFuture<Map<String, Leadership>> getLeaderships() { 142 public CompletableFuture<Map<String, Leadership>> getLeaderships() {
113 - return submit(new GetAllLeaderships()); 143 + return client.submit(new GetAllLeaderships());
114 } 144 }
115 145
116 public CompletableFuture<Set<String>> getElectedTopics(NodeId nodeId) { 146 public CompletableFuture<Set<String>> getElectedTopics(NodeId nodeId) {
117 - return submit(new GetElectedTopics(nodeId)); 147 + return client.submit(new GetElectedTopics(nodeId));
118 } 148 }
119 149
120 @Override 150 @Override
121 public synchronized CompletableFuture<Void> addChangeListener(Consumer<Change<Leadership>> consumer) { 151 public synchronized CompletableFuture<Void> addChangeListener(Consumer<Change<Leadership>> consumer) {
122 if (leadershipChangeListeners.isEmpty()) { 152 if (leadershipChangeListeners.isEmpty()) {
123 - return submit(new Listen()).thenRun(() -> leadershipChangeListeners.add(consumer)); 153 + return client.submit(new Listen()).thenRun(() -> leadershipChangeListeners.add(consumer));
124 } else { 154 } else {
125 leadershipChangeListeners.add(consumer); 155 leadershipChangeListeners.add(consumer);
126 return CompletableFuture.completedFuture(null); 156 return CompletableFuture.completedFuture(null);
...@@ -130,7 +160,7 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector> ...@@ -130,7 +160,7 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector>
130 @Override 160 @Override
131 public synchronized CompletableFuture<Void> removeChangeListener(Consumer<Change<Leadership>> consumer) { 161 public synchronized CompletableFuture<Void> removeChangeListener(Consumer<Change<Leadership>> consumer) {
132 if (leadershipChangeListeners.remove(consumer) && leadershipChangeListeners.isEmpty()) { 162 if (leadershipChangeListeners.remove(consumer) && leadershipChangeListeners.isEmpty()) {
133 - return submit(new Unlisten()).thenApply(v -> null); 163 + return client.submit(new Unlisten()).thenApply(v -> null);
134 } 164 }
135 return CompletableFuture.completedFuture(null); 165 return CompletableFuture.completedFuture(null);
136 } 166 }
......
...@@ -50,11 +50,6 @@ public final class AtomixLeaderElectorCommands { ...@@ -50,11 +50,6 @@ public final class AtomixLeaderElectorCommands {
50 public abstract static class ElectionQuery<V> implements Query<V>, CatalystSerializable { 50 public abstract static class ElectionQuery<V> implements Query<V>, CatalystSerializable {
51 51
52 @Override 52 @Override
53 - public ConsistencyLevel consistency() {
54 - return ConsistencyLevel.BOUNDED_LINEARIZABLE;
55 - }
56 -
57 - @Override
58 public void writeObject(BufferOutput<?> buffer, Serializer serializer) { 53 public void writeObject(BufferOutput<?> buffer, Serializer serializer) {
59 } 54 }
60 55
...@@ -103,11 +98,6 @@ public final class AtomixLeaderElectorCommands { ...@@ -103,11 +98,6 @@ public final class AtomixLeaderElectorCommands {
103 public abstract static class ElectionCommand<V> implements Command<V>, CatalystSerializable { 98 public abstract static class ElectionCommand<V> implements Command<V>, CatalystSerializable {
104 99
105 @Override 100 @Override
106 - public ConsistencyLevel consistency() {
107 - return ConsistencyLevel.LINEARIZABLE;
108 - }
109 -
110 - @Override
111 public void writeObject(BufferOutput<?> buffer, Serializer serializer) { 101 public void writeObject(BufferOutput<?> buffer, Serializer serializer) {
112 } 102 }
113 103
......
...@@ -302,8 +302,10 @@ public class AtomixLeaderElectorState extends ResourceStateMachine ...@@ -302,8 +302,10 @@ public class AtomixLeaderElectorState extends ResourceStateMachine
302 * @return topic to leader mapping 302 * @return topic to leader mapping
303 */ 303 */
304 public Map<String, Leadership> allLeaderships(Commit<? extends GetAllLeaderships> commit) { 304 public Map<String, Leadership> allLeaderships(Commit<? extends GetAllLeaderships> commit) {
305 + Map<String, Leadership> result = new HashMap<>();
305 try { 306 try {
306 - return Maps.transformEntries(elections, (k, v) -> leadership(k)); 307 + result.putAll(Maps.transformEntries(elections, (k, v) -> leadership(k)));
308 + return result;
307 } finally { 309 } finally {
308 commit.close(); 310 commit.close();
309 } 311 }
...@@ -539,7 +541,7 @@ public class AtomixLeaderElectorState extends ResourceStateMachine ...@@ -539,7 +541,7 @@ public class AtomixLeaderElectorState extends ResourceStateMachine
539 byte[] encodedElections = serializer.encode(elections); 541 byte[] encodedElections = serializer.encode(elections);
540 writer.writeInt(encodedElections.length); 542 writer.writeInt(encodedElections.length);
541 writer.write(encodedElections); 543 writer.write(encodedElections);
542 - log.info("Took state machine snapshot"); 544 + log.debug("Took state machine snapshot");
543 } 545 }
544 546
545 @Override 547 @Override
...@@ -552,7 +554,7 @@ public class AtomixLeaderElectorState extends ResourceStateMachine ...@@ -552,7 +554,7 @@ public class AtomixLeaderElectorState extends ResourceStateMachine
552 byte[] encodedElections = new byte[encodedElectionsSize]; 554 byte[] encodedElections = new byte[encodedElectionsSize];
553 reader.read(encodedElections); 555 reader.read(encodedElections);
554 elections = serializer.decode(encodedElections); 556 elections = serializer.decode(encodedElections);
555 - log.info("Reinstated state machine from snapshot"); 557 + log.debug("Reinstated state machine from snapshot");
556 } 558 }
557 559
558 private AtomicLong termCounter(String topic) { 560 private AtomicLong termCounter(String topic) {
......
...@@ -20,13 +20,15 @@ import com.google.common.collect.Lists; ...@@ -20,13 +20,15 @@ import com.google.common.collect.Lists;
20 import com.google.common.collect.Multiset; 20 import com.google.common.collect.Multiset;
21 import com.google.common.collect.TreeMultiset; 21 import com.google.common.collect.TreeMultiset;
22 import com.google.common.io.Files; 22 import com.google.common.io.Files;
23 +
23 import io.atomix.catalyst.transport.Address; 24 import io.atomix.catalyst.transport.Address;
24 -import io.atomix.catalyst.transport.LocalTransport; 25 +import io.atomix.catalyst.transport.local.LocalTransport;
25 import io.atomix.copycat.server.CopycatServer; 26 import io.atomix.copycat.server.CopycatServer;
26 import io.atomix.copycat.server.storage.Storage; 27 import io.atomix.copycat.server.storage.Storage;
27 import io.atomix.copycat.server.storage.StorageLevel; 28 import io.atomix.copycat.server.storage.StorageLevel;
28 -import io.atomix.manager.state.ResourceManagerState; 29 +import io.atomix.manager.internal.ResourceManagerState;
29 import io.atomix.resource.ResourceType; 30 import io.atomix.resource.ResourceType;
31 +
30 import org.apache.commons.collections.keyvalue.DefaultMapEntry; 32 import org.apache.commons.collections.keyvalue.DefaultMapEntry;
31 import org.junit.Ignore; 33 import org.junit.Ignore;
32 import org.junit.Test; 34 import org.junit.Test;
...@@ -427,7 +429,7 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase { ...@@ -427,7 +429,7 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase {
427 429
428 @Override 430 @Override
429 protected CopycatServer createCopycatServer(Address address) { 431 protected CopycatServer createCopycatServer(Address address) {
430 - CopycatServer server = CopycatServer.builder(address, members) 432 + CopycatServer server = CopycatServer.builder(address)
431 .withTransport(new LocalTransport(registry)) 433 .withTransport(new LocalTransport(registry))
432 .withStorage(Storage.builder() 434 .withStorage(Storage.builder()
433 .withStorageLevel(StorageLevel.MEMORY) 435 .withStorageLevel(StorageLevel.MEMORY)
...@@ -440,7 +442,8 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase { ...@@ -440,7 +442,8 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase {
440 .withSessionTimeout(Duration.ofMillis(100)) 442 .withSessionTimeout(Duration.ofMillis(100))
441 .build(); 443 .build();
442 copycatServers.add(server); 444 copycatServers.add(server);
443 - return server; } 445 + return server;
446 + }
444 447
445 /** 448 /**
446 * Returns two arrays contain the same set of elements, 449 * Returns two arrays contain the same set of elements,
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
16 package org.onosproject.store.primitives.resources.impl; 16 package org.onosproject.store.primitives.resources.impl;
17 17
18 import io.atomix.resource.ResourceType; 18 import io.atomix.resource.ResourceType;
19 -
20 import static org.hamcrest.Matchers.*; 19 import static org.hamcrest.Matchers.*;
21 import static org.junit.Assert.*; 20 import static org.junit.Assert.*;
22 21
...@@ -57,10 +56,6 @@ public class AtomixConsistentMapTest extends AtomixTestBase { ...@@ -57,10 +56,6 @@ public class AtomixConsistentMapTest extends AtomixTestBase {
57 */ 56 */
58 @Test 57 @Test
59 public void testBasicMapOperations() throws Throwable { 58 public void testBasicMapOperations() throws Throwable {
60 - basicMapOperationTests(1);
61 - clearTests();
62 - basicMapOperationTests(2);
63 - clearTests();
64 basicMapOperationTests(3); 59 basicMapOperationTests(3);
65 } 60 }
66 61
...@@ -69,10 +64,6 @@ public class AtomixConsistentMapTest extends AtomixTestBase { ...@@ -69,10 +64,6 @@ public class AtomixConsistentMapTest extends AtomixTestBase {
69 */ 64 */
70 @Test 65 @Test
71 public void testMapComputeOperations() throws Throwable { 66 public void testMapComputeOperations() throws Throwable {
72 - mapComputeOperationTests(1);
73 - clearTests();
74 - mapComputeOperationTests(2);
75 - clearTests();
76 mapComputeOperationTests(3); 67 mapComputeOperationTests(3);
77 } 68 }
78 69
...@@ -81,10 +72,6 @@ public class AtomixConsistentMapTest extends AtomixTestBase { ...@@ -81,10 +72,6 @@ public class AtomixConsistentMapTest extends AtomixTestBase {
81 */ 72 */
82 @Test 73 @Test
83 public void testMapListeners() throws Throwable { 74 public void testMapListeners() throws Throwable {
84 - mapListenerTests(1);
85 - clearTests();
86 - mapListenerTests(2);
87 - clearTests();
88 mapListenerTests(3); 75 mapListenerTests(3);
89 } 76 }
90 77
...@@ -93,10 +80,6 @@ public class AtomixConsistentMapTest extends AtomixTestBase { ...@@ -93,10 +80,6 @@ public class AtomixConsistentMapTest extends AtomixTestBase {
93 */ 80 */
94 @Test 81 @Test
95 public void testTransactionCommit() throws Throwable { 82 public void testTransactionCommit() throws Throwable {
96 - transactionCommitTests(1);
97 - clearTests();
98 - transactionCommitTests(2);
99 - clearTests();
100 transactionCommitTests(3); 83 transactionCommitTests(3);
101 } 84 }
102 85
...@@ -105,10 +88,6 @@ public class AtomixConsistentMapTest extends AtomixTestBase { ...@@ -105,10 +88,6 @@ public class AtomixConsistentMapTest extends AtomixTestBase {
105 */ 88 */
106 @Test 89 @Test
107 public void testTransactionRollback() throws Throwable { 90 public void testTransactionRollback() throws Throwable {
108 - transactionRollbackTests(1);
109 - clearTests();
110 - transactionRollbackTests(2);
111 - clearTests();
112 transactionRollbackTests(3); 91 transactionRollbackTests(3);
113 } 92 }
114 93
......
...@@ -30,6 +30,7 @@ import org.onosproject.cluster.NodeId; ...@@ -30,6 +30,7 @@ import org.onosproject.cluster.NodeId;
30 import org.onosproject.event.Change; 30 import org.onosproject.event.Change;
31 31
32 import io.atomix.Atomix; 32 import io.atomix.Atomix;
33 +import io.atomix.AtomixClient;
33 import io.atomix.resource.ResourceType; 34 import io.atomix.resource.ResourceType;
34 35
35 /** 36 /**
...@@ -49,12 +50,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { ...@@ -49,12 +50,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase {
49 50
50 @Test 51 @Test
51 public void testRun() throws Throwable { 52 public void testRun() throws Throwable {
52 - leaderElectorRunTests(1);
53 - clearTests();
54 - leaderElectorRunTests(2);
55 - clearTests();
56 leaderElectorRunTests(3); 53 leaderElectorRunTests(3);
57 - clearTests();
58 } 54 }
59 55
60 private void leaderElectorRunTests(int numServers) throws Throwable { 56 private void leaderElectorRunTests(int numServers) throws Throwable {
...@@ -80,12 +76,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { ...@@ -80,12 +76,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase {
80 76
81 @Test 77 @Test
82 public void testWithdraw() throws Throwable { 78 public void testWithdraw() throws Throwable {
83 - leaderElectorWithdrawTests(1);
84 - clearTests();
85 - leaderElectorWithdrawTests(2);
86 - clearTests();
87 leaderElectorWithdrawTests(3); 79 leaderElectorWithdrawTests(3);
88 - clearTests();
89 } 80 }
90 81
91 private void leaderElectorWithdrawTests(int numServers) throws Throwable { 82 private void leaderElectorWithdrawTests(int numServers) throws Throwable {
...@@ -122,12 +113,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { ...@@ -122,12 +113,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase {
122 113
123 @Test 114 @Test
124 public void testAnoint() throws Throwable { 115 public void testAnoint() throws Throwable {
125 - leaderElectorAnointTests(1);
126 - clearTests();
127 - leaderElectorAnointTests(2);
128 - clearTests();
129 leaderElectorAnointTests(3); 116 leaderElectorAnointTests(3);
130 - clearTests();
131 } 117 }
132 118
133 private void leaderElectorAnointTests(int numServers) throws Throwable { 119 private void leaderElectorAnointTests(int numServers) throws Throwable {
...@@ -158,9 +144,6 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { ...@@ -158,9 +144,6 @@ public class AtomixLeaderElectorTest extends AtomixTestBase {
158 elector3.anoint("foo", node2).thenAccept(result -> { 144 elector3.anoint("foo", node2).thenAccept(result -> {
159 assertTrue(result); 145 assertTrue(result);
160 }).join(); 146 }).join();
161 - assertTrue(listener1.hasEvent());
162 - assertTrue(listener2.hasEvent());
163 - assertTrue(listener3.hasEvent());
164 147
165 listener1.nextEvent().thenAccept(result -> { 148 listener1.nextEvent().thenAccept(result -> {
166 assertEquals(node2, result.newValue().leaderNodeId()); 149 assertEquals(node2, result.newValue().leaderNodeId());
...@@ -184,21 +167,16 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { ...@@ -184,21 +167,16 @@ public class AtomixLeaderElectorTest extends AtomixTestBase {
184 167
185 @Test 168 @Test
186 public void testPromote() throws Throwable { 169 public void testPromote() throws Throwable {
187 - leaderElectorPromoteTests(1);
188 - clearTests();
189 - leaderElectorPromoteTests(2);
190 - clearTests();
191 leaderElectorPromoteTests(3); 170 leaderElectorPromoteTests(3);
192 - clearTests();
193 } 171 }
194 172
195 private void leaderElectorPromoteTests(int numServers) throws Throwable { 173 private void leaderElectorPromoteTests(int numServers) throws Throwable {
196 createCopycatServers(numServers); 174 createCopycatServers(numServers);
197 - Atomix client1 = createAtomixClient(); 175 + AtomixClient client1 = createAtomixClient();
198 AtomixLeaderElector elector1 = client1.getResource("test-elector", AtomixLeaderElector.class).join(); 176 AtomixLeaderElector elector1 = client1.getResource("test-elector", AtomixLeaderElector.class).join();
199 - Atomix client2 = createAtomixClient(); 177 + AtomixClient client2 = createAtomixClient();
200 AtomixLeaderElector elector2 = client2.getResource("test-elector", AtomixLeaderElector.class).join(); 178 AtomixLeaderElector elector2 = client2.getResource("test-elector", AtomixLeaderElector.class).join();
201 - Atomix client3 = createAtomixClient(); 179 + AtomixClient client3 = createAtomixClient();
202 AtomixLeaderElector elector3 = client3.getResource("test-elector", AtomixLeaderElector.class).join(); 180 AtomixLeaderElector elector3 = client3.getResource("test-elector", AtomixLeaderElector.class).join();
203 elector1.run("foo", node1).join(); 181 elector1.run("foo", node1).join();
204 elector2.run("foo", node2).join(); 182 elector2.run("foo", node2).join();
...@@ -220,9 +198,15 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { ...@@ -220,9 +198,15 @@ public class AtomixLeaderElectorTest extends AtomixTestBase {
220 198
221 elector3.run("foo", node3).join(); 199 elector3.run("foo", node3).join();
222 200
223 - listener1.clearEvents(); 201 + listener1.nextEvent().thenAccept(result -> {
224 - listener2.clearEvents(); 202 + assertEquals(node3, result.newValue().candidates().get(2));
225 - listener3.clearEvents(); 203 + }).join();
204 + listener2.nextEvent().thenAccept(result -> {
205 + assertEquals(node3, result.newValue().candidates().get(2));
206 + }).join();
207 + listener3.nextEvent().thenAccept(result -> {
208 + assertEquals(node3, result.newValue().candidates().get(2));
209 + }).join();
226 210
227 elector3.promote("foo", node3).thenAccept(result -> { 211 elector3.promote("foo", node3).thenAccept(result -> {
228 assertTrue(result); 212 assertTrue(result);
...@@ -241,17 +225,12 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { ...@@ -241,17 +225,12 @@ public class AtomixLeaderElectorTest extends AtomixTestBase {
241 225
242 @Test 226 @Test
243 public void testLeaderSessionClose() throws Throwable { 227 public void testLeaderSessionClose() throws Throwable {
244 - leaderElectorLeaderSessionCloseTests(1);
245 - clearTests();
246 - leaderElectorLeaderSessionCloseTests(2);
247 - clearTests();
248 leaderElectorLeaderSessionCloseTests(3); 228 leaderElectorLeaderSessionCloseTests(3);
249 - clearTests();
250 } 229 }
251 230
252 private void leaderElectorLeaderSessionCloseTests(int numServers) throws Throwable { 231 private void leaderElectorLeaderSessionCloseTests(int numServers) throws Throwable {
253 createCopycatServers(numServers); 232 createCopycatServers(numServers);
254 - Atomix client1 = createAtomixClient(); 233 + AtomixClient client1 = createAtomixClient();
255 AtomixLeaderElector elector1 = client1.getResource("test-elector", AtomixLeaderElector.class).join(); 234 AtomixLeaderElector elector1 = client1.getResource("test-elector", AtomixLeaderElector.class).join();
256 elector1.run("foo", node1).join(); 235 elector1.run("foo", node1).join();
257 Atomix client2 = createAtomixClient(); 236 Atomix client2 = createAtomixClient();
...@@ -269,12 +248,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { ...@@ -269,12 +248,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase {
269 248
270 @Test 249 @Test
271 public void testNonLeaderSessionClose() throws Throwable { 250 public void testNonLeaderSessionClose() throws Throwable {
272 - leaderElectorNonLeaderSessionCloseTests(1);
273 - clearTests();
274 - leaderElectorNonLeaderSessionCloseTests(2);
275 - clearTests();
276 leaderElectorNonLeaderSessionCloseTests(3); 251 leaderElectorNonLeaderSessionCloseTests(3);
277 - clearTests();
278 } 252 }
279 253
280 private void leaderElectorNonLeaderSessionCloseTests(int numServers) throws Throwable { 254 private void leaderElectorNonLeaderSessionCloseTests(int numServers) throws Throwable {
...@@ -282,7 +256,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { ...@@ -282,7 +256,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase {
282 Atomix client1 = createAtomixClient(); 256 Atomix client1 = createAtomixClient();
283 AtomixLeaderElector elector1 = client1.getResource("test-elector", AtomixLeaderElector.class).join(); 257 AtomixLeaderElector elector1 = client1.getResource("test-elector", AtomixLeaderElector.class).join();
284 elector1.run("foo", node1).join(); 258 elector1.run("foo", node1).join();
285 - Atomix client2 = createAtomixClient(); 259 + AtomixClient client2 = createAtomixClient();
286 AtomixLeaderElector elector2 = client2.getResource("test-elector", AtomixLeaderElector.class).join(); 260 AtomixLeaderElector elector2 = client2.getResource("test-elector", AtomixLeaderElector.class).join();
287 LeaderEventListener listener = new LeaderEventListener(); 261 LeaderEventListener listener = new LeaderEventListener();
288 elector2.run("foo", node2).join(); 262 elector2.run("foo", node2).join();
...@@ -297,12 +271,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { ...@@ -297,12 +271,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase {
297 271
298 @Test 272 @Test
299 public void testQueries() throws Throwable { 273 public void testQueries() throws Throwable {
300 - leaderElectorQueryTests(1);
301 - clearTests();
302 - leaderElectorQueryTests(2);
303 - clearTests();
304 leaderElectorQueryTests(3); 274 leaderElectorQueryTests(3);
305 - clearTests();
306 } 275 }
307 276
308 private void leaderElectorQueryTests(int numServers) throws Throwable { 277 private void leaderElectorQueryTests(int numServers) throws Throwable {
......
...@@ -37,12 +37,7 @@ public class AtomixLongTest extends AtomixTestBase { ...@@ -37,12 +37,7 @@ public class AtomixLongTest extends AtomixTestBase {
37 37
38 @Test 38 @Test
39 public void testBasicOperations() throws Throwable { 39 public void testBasicOperations() throws Throwable {
40 - basicOperationsTest(1);
41 - clearTests();
42 - basicOperationsTest(2);
43 - clearTests();
44 basicOperationsTest(3); 40 basicOperationsTest(3);
45 - clearTests();
46 } 41 }
47 42
48 protected void basicOperationsTest(int clusterSize) throws Throwable { 43 protected void basicOperationsTest(int clusterSize) throws Throwable {
......
...@@ -15,17 +15,16 @@ ...@@ -15,17 +15,16 @@
15 */ 15 */
16 package org.onosproject.store.primitives.resources.impl; 16 package org.onosproject.store.primitives.resources.impl;
17 17
18 -import io.atomix.Atomix;
19 import io.atomix.AtomixClient; 18 import io.atomix.AtomixClient;
20 import io.atomix.catalyst.serializer.Serializer; 19 import io.atomix.catalyst.serializer.Serializer;
21 import io.atomix.catalyst.transport.Address; 20 import io.atomix.catalyst.transport.Address;
22 -import io.atomix.catalyst.transport.LocalServerRegistry; 21 +import io.atomix.catalyst.transport.local.LocalServerRegistry;
23 -import io.atomix.catalyst.transport.LocalTransport; 22 +import io.atomix.catalyst.transport.local.LocalTransport;
24 import io.atomix.copycat.client.CopycatClient; 23 import io.atomix.copycat.client.CopycatClient;
25 import io.atomix.copycat.server.CopycatServer; 24 import io.atomix.copycat.server.CopycatServer;
26 import io.atomix.copycat.server.storage.Storage; 25 import io.atomix.copycat.server.storage.Storage;
27 import io.atomix.copycat.server.storage.StorageLevel; 26 import io.atomix.copycat.server.storage.StorageLevel;
28 -import io.atomix.manager.state.ResourceManagerState; 27 +import io.atomix.manager.internal.ResourceManagerState;
29 import io.atomix.resource.ResourceType; 28 import io.atomix.resource.ResourceType;
30 29
31 import java.io.File; 30 import java.io.File;
...@@ -53,7 +52,7 @@ public abstract class AtomixTestBase { ...@@ -53,7 +52,7 @@ public abstract class AtomixTestBase {
53 protected List<Address> members; 52 protected List<Address> members;
54 protected List<CopycatClient> copycatClients = new ArrayList<>(); 53 protected List<CopycatClient> copycatClients = new ArrayList<>();
55 protected List<CopycatServer> copycatServers = new ArrayList<>(); 54 protected List<CopycatServer> copycatServers = new ArrayList<>();
56 - protected List<Atomix> atomixClients = new ArrayList<>(); 55 + protected List<AtomixClient> atomixClients = new ArrayList<>();
57 protected List<CopycatServer> atomixServers = new ArrayList<>(); 56 protected List<CopycatServer> atomixServers = new ArrayList<>();
58 protected Serializer serializer = CatalystSerializers.getSerializer(); 57 protected Serializer serializer = CatalystSerializers.getSerializer();
59 58
...@@ -89,7 +88,7 @@ public abstract class AtomixTestBase { ...@@ -89,7 +88,7 @@ public abstract class AtomixTestBase {
89 88
90 for (int i = 0; i < nodes; i++) { 89 for (int i = 0; i < nodes; i++) {
91 CopycatServer server = createCopycatServer(members.get(i)); 90 CopycatServer server = createCopycatServer(members.get(i));
92 - server.start().thenRun(latch::countDown); 91 + server.bootstrap(members).thenRun(latch::countDown);
93 servers.add(server); 92 servers.add(server);
94 } 93 }
95 94
...@@ -102,7 +101,7 @@ public abstract class AtomixTestBase { ...@@ -102,7 +101,7 @@ public abstract class AtomixTestBase {
102 * Creates a Copycat server. 101 * Creates a Copycat server.
103 */ 102 */
104 protected CopycatServer createCopycatServer(Address address) { 103 protected CopycatServer createCopycatServer(Address address) {
105 - CopycatServer server = CopycatServer.builder(address, members) 104 + CopycatServer server = CopycatServer.builder(address)
106 .withTransport(new LocalTransport(registry)) 105 .withTransport(new LocalTransport(registry))
107 .withStorage(Storage.builder() 106 .withStorage(Storage.builder()
108 .withStorageLevel(StorageLevel.DISK) 107 .withStorageLevel(StorageLevel.DISK)
...@@ -127,11 +126,11 @@ public abstract class AtomixTestBase { ...@@ -127,11 +126,11 @@ public abstract class AtomixTestBase {
127 126
128 CompletableFuture<Void> closeClients = 127 CompletableFuture<Void> closeClients =
129 CompletableFuture.allOf(atomixClients.stream() 128 CompletableFuture.allOf(atomixClients.stream()
130 - .map(Atomix::close) 129 + .map(AtomixClient::close)
131 .toArray(CompletableFuture[]::new)); 130 .toArray(CompletableFuture[]::new));
132 131
133 closeClients.thenCompose(v -> CompletableFuture.allOf(copycatServers.stream() 132 closeClients.thenCompose(v -> CompletableFuture.allOf(copycatServers.stream()
134 - .map(CopycatServer::stop) 133 + .map(CopycatServer::shutdown)
135 .toArray(CompletableFuture[]::new))).join(); 134 .toArray(CompletableFuture[]::new))).join();
136 135
137 deleteDirectory(TEST_DIR); 136 deleteDirectory(TEST_DIR);
...@@ -163,13 +162,13 @@ public abstract class AtomixTestBase { ...@@ -163,13 +162,13 @@ public abstract class AtomixTestBase {
163 /** 162 /**
164 * Creates a Atomix client. 163 * Creates a Atomix client.
165 */ 164 */
166 - protected Atomix createAtomixClient() { 165 + protected AtomixClient createAtomixClient() {
167 CountDownLatch latch = new CountDownLatch(1); 166 CountDownLatch latch = new CountDownLatch(1);
168 - Atomix client = AtomixClient.builder(members) 167 + AtomixClient client = AtomixClient.builder()
169 .withTransport(new LocalTransport(registry)) 168 .withTransport(new LocalTransport(registry))
170 .withSerializer(serializer.clone()) 169 .withSerializer(serializer.clone())
171 .build(); 170 .build();
172 - client.open().thenRun(latch::countDown); 171 + client.connect(members).thenRun(latch::countDown);
173 atomixClients.add(client); 172 atomixClients.add(client);
174 Uninterruptibles.awaitUninterruptibly(latch); 173 Uninterruptibles.awaitUninterruptibly(latch);
175 return client; 174 return client;
......
...@@ -3,6 +3,7 @@ osgi_feature ( ...@@ -3,6 +3,7 @@ osgi_feature (
3 title="ONOS 3rd party dependencies", 3 title="ONOS 3rd party dependencies",
4 required_features = [], 4 required_features = [],
5 included_bundles = [ 5 included_bundles = [
6 + '//lib:atomix',
6 '//lib:commons-lang', 7 '//lib:commons-lang',
7 '//lib:commons-lang3', 8 '//lib:commons-lang3',
8 '//lib:commons-configuration', 9 '//lib:commons-configuration',
...@@ -32,7 +33,6 @@ osgi_feature ( ...@@ -32,7 +33,6 @@ osgi_feature (
32 '//lib:typesafe-config', 33 '//lib:typesafe-config',
33 '//lib:concurrent-trees', 34 '//lib:concurrent-trees',
34 '//lib:commons-io', 35 '//lib:commons-io',
35 - '//lib:onos-atomix',
36 '//lib:jersey-client', 36 '//lib:jersey-client',
37 '//lib:mapdb', 37 '//lib:mapdb',
38 ] 38 ]
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
56 <bundle>mvn:com.typesafe/config/1.2.1</bundle> 56 <bundle>mvn:com.typesafe/config/1.2.1</bundle>
57 <bundle>wrap:mvn:com.googlecode.concurrent-trees/concurrent-trees/2.4.0$Bundle-SymbolicName=concurrent-trees&amp;Bundle-Version=2.4.0</bundle> 57 <bundle>wrap:mvn:com.googlecode.concurrent-trees/concurrent-trees/2.4.0$Bundle-SymbolicName=concurrent-trees&amp;Bundle-Version=2.4.0</bundle>
58 <bundle>mvn:commons-io/commons-io/2.4</bundle> 58 <bundle>mvn:commons-io/commons-io/2.4</bundle>
59 - <bundle>mvn:org.onosproject/atomix/1.0.1.onos-SNAPSHOT</bundle> 59 + <bundle>mvn:io.atomix/atomix-all/1.0.0-rc7</bundle>
60 60
61 <bundle>mvn:org.glassfish.jersey.core/jersey-client/2.22.2</bundle> 61 <bundle>mvn:org.glassfish.jersey.core/jersey-client/2.22.2</bundle>
62 62
......
...@@ -133,109 +133,10 @@ remote_jar ( ...@@ -133,109 +133,10 @@ remote_jar (
133 133
134 remote_jar ( 134 remote_jar (
135 name = 'atomix', 135 name = 'atomix',
136 - out = 'atomix-1.0.0-rc3.jar', 136 + out = 'atomix-all-1.0.0-rc8.jar',
137 - url = 'mvn:io.atomix:atomix:jar:1.0.0-rc3', 137 + url = 'mvn:io.atomix:atomix-all:jar:1.0.0-rc8',
138 - sha1 = 'a572aa9cd069b2d43481901dc901429d0b43332f', 138 + sha1 = 'ed6259ce60ecf00f40e61d814b74515324c6c9fb',
139 - maven_coords = 'io.atomix:atomix:1.0.0-rc3', 139 + maven_coords = 'io.atomix:atomix-all:1.0.0-rc8',
140 - visibility = [ 'PUBLIC' ],
141 -)
142 -
143 -remote_jar (
144 - name = 'atomix-collections',
145 - out = 'atomix-collections-1.0.0-rc3.jar',
146 - url = 'mvn:io.atomix:atomix-collections:jar:1.0.0-rc3',
147 - sha1 = '161dbfd046cefabe7e6c972e70823c11f7abe65e',
148 - maven_coords = 'io.atomix:atomix-collections:1.0.0-rc3',
149 - visibility = [ 'PUBLIC' ],
150 -)
151 -
152 -remote_jar (
153 - name = 'atomix-messaging',
154 - out = 'atomix-messaging-1.0.0-rc3.jar',
155 - url = 'mvn:io.atomix:atomix-messaging:jar:1.0.0-rc3',
156 - sha1 = '58b570d8e3e76a0d0c649b97f3ee0a6e3885958a',
157 - maven_coords = 'io.atomix:atomix-messaging:1.0.0-rc3',
158 - visibility = [ 'PUBLIC' ],
159 -)
160 -
161 -remote_jar (
162 - name = 'atomix-resource',
163 - out = 'atomix-resource-1.0.0-rc3.jar',
164 - url = 'mvn:io.atomix:atomix-resource:jar:1.0.0-rc3',
165 - sha1 = 'e47a40d38e6241544ec75df0e6906c209190aebf',
166 - maven_coords = 'io.atomix:atomix-resource:1.0.0-rc3',
167 - visibility = [ 'PUBLIC' ],
168 -)
169 -
170 -remote_jar (
171 - name = 'atomix-resource-manager',
172 - out = 'atomix-resource-manager-1.0.0-rc3.jar',
173 - url = 'mvn:io.atomix:atomix-resource-manager:jar:1.0.0-rc3',
174 - sha1 = '41a4cf53c27df12efb04832e1314a81c09c857cb',
175 - maven_coords = 'io.atomix:atomix-resource-manager:1.0.0-rc3',
176 - visibility = [ 'PUBLIC' ],
177 -)
178 -
179 -remote_jar (
180 - name = 'atomix-variables',
181 - out = 'atomix-variables-1.0.0-rc3.jar',
182 - url = 'mvn:io.atomix:atomix-variables:jar:1.0.0-rc3',
183 - sha1 = 'dd0ca3c0d211b17b291877e21f0ef10f2aa4a9bd',
184 - maven_coords = 'io.atomix:atomix-variables:1.0.0-rc3',
185 - visibility = [ 'PUBLIC' ],
186 -)
187 -
188 -remote_jar (
189 - name = 'onos-atomix',
190 - out = 'atomix-1.0.0.onos.jar',
191 - url = 'mvn:org.onosproject:atomix:jar:1.0.0.onos',
192 - sha1 = '3d1a645b783a61b673aa71dbcc71a1bdd3afdaa2',
193 - maven_coords = 'org.onosproject:atomix:1.0.0.onos',
194 - visibility = [ 'PUBLIC' ],
195 -)
196 -
197 -remote_jar (
198 - name = 'catalyst-buffer',
199 - out = 'catalyst-buffer-1.0.4.jar',
200 - url = 'mvn:io.atomix.catalyst:catalyst-buffer:jar:1.0.4',
201 - sha1 = '00fb023ebd860d44385750790328aa26a529c75f',
202 - maven_coords = 'io.atomix.catalyst:catalyst-buffer:1.0.4',
203 - visibility = [ 'PUBLIC' ],
204 -)
205 -
206 -remote_jar (
207 - name = 'catalyst-common',
208 - out = 'catalyst-common-1.0.4.jar',
209 - url = 'mvn:io.atomix.catalyst:catalyst-common:jar:1.0.4',
210 - sha1 = '69d50a64ecf9f63de430aead9dc4b743d29f0195',
211 - maven_coords = 'io.atomix.catalyst:catalyst-common:jar:NON-OSGI:1.0.4',
212 - visibility = [ 'PUBLIC' ],
213 -)
214 -
215 -remote_jar (
216 - name = 'catalyst-local',
217 - out = 'catalyst-local-1.0.4.jar',
218 - url = 'mvn:io.atomix.catalyst:catalyst-local:jar:1.0.4',
219 - sha1 = 'cbee759c63ce9127c979f4f399d327551644270f',
220 - maven_coords = 'io.atomix.catalyst:catalyst-local:1.0.4',
221 - visibility = [ 'PUBLIC' ],
222 -)
223 -
224 -remote_jar (
225 - name = 'catalyst-serializer',
226 - out = 'catalyst-serializer-1.0.4.jar',
227 - url = 'mvn:io.atomix.catalyst:catalyst-serializer:jar:1.0.4',
228 - sha1 = 'e86352776cf4fa17eabf4e1d90fe0587ced4f788',
229 - maven_coords = 'io.atomix.catalyst:catalyst-serializer:1.0.4',
230 - visibility = [ 'PUBLIC' ],
231 -)
232 -
233 -remote_jar (
234 - name = 'catalyst-transport',
235 - out = 'catalyst-transport-1.0.4.jar',
236 - url = 'mvn:io.atomix.catalyst:catalyst-transport:jar:1.0.4',
237 - sha1 = 'f36600add086a8848290cad9d6d117634b5bf069',
238 - maven_coords = 'io.atomix.catalyst:catalyst-transport:jar:NON-OSGI:1.0.4',
239 visibility = [ 'PUBLIC' ], 140 visibility = [ 'PUBLIC' ],
240 ) 141 )
241 142
...@@ -339,87 +240,6 @@ remote_jar ( ...@@ -339,87 +240,6 @@ remote_jar (
339 ) 240 )
340 241
341 remote_jar ( 242 remote_jar (
342 - name = 'copycat-api',
343 - out = 'copycat-api-0.5.1.onos.jar',
344 - url = 'mvn:org.onosproject:copycat-api:jar:0.5.1.onos',
345 - sha1 = 'b947348875485814e2a175a0435cdae4138452fc',
346 - maven_coords = 'org.onosproject:copycat-api:jar:NON-OSGI:0.5.1.onos',
347 - visibility = [ 'PUBLIC' ],
348 -)
349 -
350 -remote_jar (
351 - name = 'copycat-client',
352 - out = 'copycat-client-1.0.0-rc4.jar',
353 - url = 'mvn:io.atomix.copycat:copycat-client:jar:1.0.0-rc4',
354 - sha1 = '9373c8920a57356b78896d791296a74a2eb868b4',
355 - maven_coords = 'io.atomix.copycat:copycat-client:1.0.0-rc4',
356 - visibility = [ 'PUBLIC' ],
357 -)
358 -
359 -remote_jar (
360 - name = 'copycat-core',
361 - out = 'copycat-core-0.5.1.onos.jar',
362 - url = 'mvn:org.onosproject:copycat-core:jar:0.5.1.onos',
363 - sha1 = 'b268f3cbdd57f28244b21b2b8fc08116f63d736d',
364 - maven_coords = 'org.onosproject:copycat-core:jar:NON-OSGI:0.5.1.onos',
365 - visibility = [ 'PUBLIC' ],
366 -)
367 -
368 -remote_jar (
369 - name = 'copycat-event-log',
370 - out = 'copycat-event-log-0.5.1.onos.jar',
371 - url = 'mvn:org.onosproject:copycat-event-log:jar:0.5.1.onos',
372 - sha1 = 'a9e32b13e6500c66113202e7d123e7184b726054',
373 - maven_coords = 'org.onosproject:copycat-event-log:jar:NON-OSGI:0.5.1.onos',
374 - visibility = [ 'PUBLIC' ],
375 -)
376 -
377 -remote_jar (
378 - name = 'copycat-leader-election',
379 - out = 'copycat-leader-election-0.5.1.onos.jar',
380 - url = 'mvn:org.onosproject:copycat-leader-election:jar:0.5.1.onos',
381 - sha1 = 'a33617e98caf4e909d7ac744e1f6cdd1ba4b1698',
382 - maven_coords = 'org.onosproject:copycat-leader-election:jar:NON-OSGI:0.5.1.onos',
383 - visibility = [ 'PUBLIC' ],
384 -)
385 -
386 -remote_jar (
387 - name = 'copycat-protocol',
388 - out = 'copycat-protocol-1.0.0-rc4.jar',
389 - url = 'mvn:io.atomix.copycat:copycat-protocol:jar:1.0.0-rc4',
390 - sha1 = 'cea774c2e4ce7021a6bfca64fd885e875f01f4dc',
391 - maven_coords = 'io.atomix.copycat:copycat-protocol:1.0.0-rc4',
392 - visibility = [ 'PUBLIC' ],
393 -)
394 -
395 -remote_jar (
396 - name = 'copycat-server',
397 - out = 'copycat-server-1.0.0-rc4.jar',
398 - url = 'mvn:io.atomix.copycat:copycat-server:jar:1.0.0-rc4',
399 - sha1 = 'e2b6603dbd299d7b21685211df509dd4fbd2f0e9',
400 - maven_coords = 'io.atomix.copycat:copycat-server:1.0.0-rc4',
401 - visibility = [ 'PUBLIC' ],
402 -)
403 -
404 -remote_jar (
405 - name = 'copycat-state-log',
406 - out = 'copycat-state-log-0.5.1.onos.jar',
407 - url = 'mvn:org.onosproject:copycat-state-log:jar:0.5.1.onos',
408 - sha1 = '1dfa2b4c6da1cdc453fd3740cd506b9570f118ea',
409 - maven_coords = 'org.onosproject:copycat-state-log:jar:NON-OSGI:0.5.1.onos',
410 - visibility = [ 'PUBLIC' ],
411 -)
412 -
413 -remote_jar (
414 - name = 'copycat-state-machine',
415 - out = 'copycat-state-machine-0.5.1.onos.jar',
416 - url = 'mvn:org.onosproject:copycat-state-machine:jar:0.5.1.onos',
417 - sha1 = '03f924b5c818c0684bdfa6c502e5fff8e07d6b77',
418 - maven_coords = 'org.onosproject:copycat-state-machine:jar:NON-OSGI:0.5.1.onos',
419 - visibility = [ 'PUBLIC' ],
420 -)
421 -
422 -remote_jar (
423 name = 'easymock', 243 name = 'easymock',
424 out = 'easymock-3.4.jar', 244 out = 'easymock-3.4.jar',
425 url = 'mvn:org.easymock:easymock:jar:3.4', 245 url = 'mvn:org.easymock:easymock:jar:3.4',
......
...@@ -86,19 +86,7 @@ ...@@ -86,19 +86,7 @@
86 "gmetric4j": "mvn:info.ganglia.gmetric4j:gmetric4j:1.0.10", 86 "gmetric4j": "mvn:info.ganglia.gmetric4j:gmetric4j:1.0.10",
87 "aopalliance-repackaged": "mvn:org.glassfish.hk2.external:aopalliance-repackaged:2.4.0-b34", 87 "aopalliance-repackaged": "mvn:org.glassfish.hk2.external:aopalliance-repackaged:2.4.0-b34",
88 "asm": "mvn:org.ow2.asm:asm:5.0.3", 88 "asm": "mvn:org.ow2.asm:asm:5.0.3",
89 - "atomix": "mvn:io.atomix:atomix:1.0.0-rc3", 89 + "atomix": "mvn:io.atomix:atomix-all:1.0.0-rc8",
90 - "atomix-collections": "mvn:io.atomix:atomix-collections:1.0.0-rc3",
91 - "atomix-messaging": "mvn:io.atomix:atomix-messaging:1.0.0-rc3",
92 - "atomix-resource": "mvn:io.atomix:atomix-resource:1.0.0-rc3",
93 - "atomix-resource-manager": "mvn:io.atomix:atomix-resource-manager:1.0.0-rc3",
94 - "atomix-variables": "mvn:io.atomix:atomix-variables:1.0.0-rc3",
95 - "onos-atomix": "mvn:org.onosproject:atomix:1.0.0.onos",
96 - "catalyst-buffer": "mvn:io.atomix.catalyst:catalyst-buffer:1.0.4",
97 - "catalyst-common": "mvn:io.atomix.catalyst:catalyst-common:1.0.4",
98 - "catalyst-local": "mvn:io.atomix.catalyst:catalyst-local:1.0.4",
99 - "catalyst-serializer": "mvn:io.atomix.catalyst:catalyst-serializer:1.0.4",
100 - "catalyst-transport": "mvn:io.atomix.catalyst:catalyst-transport:1.0.4",
101 - "catalyst-transport": "mvn:io.atomix.catalyst:catalyst-transport:1.0.4",
102 "commons-codec": "mvn:commons-codec:commons-codec:1.10", 90 "commons-codec": "mvn:commons-codec:commons-codec:1.10",
103 "commons-collections": "mvn:commons-collections:commons-collections:3.2.2", 91 "commons-collections": "mvn:commons-collections:commons-collections:3.2.2",
104 "commons-configuration": "mvn:commons-configuration:commons-configuration:1.10", 92 "commons-configuration": "mvn:commons-configuration:commons-configuration:1.10",
...@@ -110,15 +98,6 @@ ...@@ -110,15 +98,6 @@
110 "commons-pool": "mvn:commons-pool:commons-pool:1.6", 98 "commons-pool": "mvn:commons-pool:commons-pool:1.6",
111 "commons-beanutils": "mvn:commons-beanutils:commons-beanutils:1.9.2", 99 "commons-beanutils": "mvn:commons-beanutils:commons-beanutils:1.9.2",
112 "concurrent-trees": "mvn:com.googlecode.concurrent-trees:concurrent-trees:2.4.0", 100 "concurrent-trees": "mvn:com.googlecode.concurrent-trees:concurrent-trees:2.4.0",
113 - "copycat-api": "mvn:org.onosproject:copycat-api:0.5.1.onos",
114 - "copycat-client": "mvn:io.atomix.copycat:copycat-client:1.0.0-rc4",
115 - "copycat-core": "mvn:org.onosproject:copycat-core:0.5.1.onos",
116 - "copycat-event-log": "mvn:org.onosproject:copycat-event-log:0.5.1.onos",
117 - "copycat-leader-election": "mvn:org.onosproject:copycat-leader-election:0.5.1.onos",
118 - "copycat-protocol": "mvn:io.atomix.copycat:copycat-protocol:1.0.0-rc4",
119 - "copycat-server": "mvn:io.atomix.copycat:copycat-server:1.0.0-rc4",
120 - "copycat-state-log": "mvn:org.onosproject:copycat-state-log:0.5.1.onos",
121 - "copycat-state-machine": "mvn:org.onosproject:copycat-state-machine:0.5.1.onos",
122 "easymock": "mvn:org.easymock:easymock:3.4", 101 "easymock": "mvn:org.easymock:easymock:3.4",
123 "antlr": "mvn:antlr:antlr:2.7.7", 102 "antlr": "mvn:antlr:antlr:2.7.7",
124 "error_prone_annotations": "mvn:com.google.errorprone:error_prone_annotations:2.0.2", 103 "error_prone_annotations": "mvn:com.google.errorprone:error_prone_annotations:2.0.2",
......
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2016-present Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<project xmlns="http://maven.apache.org/POM/4.0.0"
18 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 - <modelVersion>4.0.0</modelVersion>
21 -
22 - <parent>
23 - <groupId>org.onosproject</groupId>
24 - <artifactId>onos-base</artifactId>
25 - <version>1</version>
26 - <relativePath/>
27 - </parent>
28 -
29 - <groupId>org.onosproject</groupId>
30 - <artifactId>atomix</artifactId>
31 - <packaging>bundle</packaging>
32 - <version>1.0.1.onos-SNAPSHOT</version>
33 -
34 - <description>Atomix shaded OSGi JAR</description>
35 - <url>http://onosproject.org/</url>
36 -
37 - <scm>
38 - <connection>scm:git:https://gerrit.onosproject.org/onos</connection>
39 - <developerConnection>scm:git:https://gerrit.onosproject.org/onos
40 - </developerConnection>
41 - <url>http://gerrit.onosproject.org/</url>
42 - </scm>
43 -
44 - <licenses>
45 - <license>
46 - <name>Apache License, Version 2.0</name>
47 - <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
48 - </license>
49 - </licenses>
50 -
51 - <properties>
52 - <!-- TODO: replace with final release version when it is out -->
53 - <catalyst.version>1.0.6</catalyst.version>
54 - <atomix.version>1.0.0-rc3</atomix.version>
55 - <copycat.version>1.0.0-rc6</copycat.version>
56 - </properties>
57 -
58 - <dependencies>
59 - <dependency>
60 - <groupId>io.atomix.catalyst</groupId>
61 - <artifactId>catalyst-transport</artifactId>
62 - <version>${catalyst.version}</version>
63 - </dependency>
64 -
65 - <dependency>
66 - <groupId>io.atomix.catalyst</groupId>
67 - <artifactId>catalyst-serializer</artifactId>
68 - <version>${catalyst.version}</version>
69 - </dependency>
70 -
71 - <dependency>
72 - <groupId>io.atomix</groupId>
73 - <artifactId>atomix</artifactId>
74 - <version>${atomix.version}</version>
75 - </dependency>
76 -
77 - <dependency>
78 - <groupId>io.atomix.copycat</groupId>
79 - <artifactId>copycat-client</artifactId>
80 - <version>${copycat.version}</version>
81 - </dependency>
82 -
83 - <dependency>
84 - <groupId>io.atomix.copycat</groupId>
85 - <artifactId>copycat-server</artifactId>
86 - <version>${copycat.version}</version>
87 - </dependency>
88 -
89 - </dependencies>
90 -
91 - <build>
92 - <plugins>
93 - <plugin>
94 - <groupId>org.apache.maven.plugins</groupId>
95 - <artifactId>maven-compiler-plugin</artifactId>
96 - <!-- TODO: update once following issue is fixed. -->
97 - <!-- https://jira.codehaus.org/browse/MCOMPILER-205 -->
98 - <version>2.5.1</version>
99 - <configuration>
100 - <source>1.8</source>
101 - <target>1.8</target>
102 - </configuration>
103 - </plugin>
104 -
105 - <plugin>
106 - <groupId>org.apache.maven.plugins</groupId>
107 - <artifactId>maven-shade-plugin</artifactId>
108 - <version>2.4.2</version>
109 - <configuration>
110 - <createSourcesJar>true</createSourcesJar>
111 - <artifactSet>
112 - <excludes>
113 - <!-- exclude OSGi-ready transitive dependencies -->
114 - <exclude>com.google.guava:guava</exclude>
115 - <exclude>com.esotericsoftware:*</exclude>
116 - <exclude>org.ow2.asm:asm</exclude>
117 - <exclude>org.objenesis:objenesis</exclude>
118 - <exclude>io.netty:*</exclude>
119 - <exclude>commons-io:commons-io</exclude>
120 - </excludes>
121 - </artifactSet>
122 - <filters>
123 - <filter>
124 - <artifact>io.atomix:atomix-all</artifact>
125 - <includes>
126 - <include>**</include>
127 - </includes>
128 - </filter>
129 - </filters>
130 - </configuration>
131 - <executions>
132 - <execution>
133 - <phase>package</phase>
134 - <goals>
135 - <goal>shade</goal>
136 - </goals>
137 - </execution>
138 - </executions>
139 - </plugin>
140 - <plugin>
141 - <groupId>org.apache.felix</groupId>
142 - <artifactId>maven-bundle-plugin</artifactId>
143 - <version>3.0.1</version>
144 - <extensions>true</extensions>
145 - <configuration>
146 - <instructions>
147 - <Export-Package>
148 - io.atomix.*
149 - </Export-Package>
150 - <Import-Package>
151 - !sun.nio.ch,!sun.misc,*
152 - </Import-Package>
153 - </instructions>
154 - </configuration>
155 - </plugin>
156 - </plugins>
157 - </build>
158 -
159 -</project>
1 -/*
2 - * Copyright 2016-present 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.onlab.atomix;
17 -
18 -/**
19 - * Empty class required to get the atomix module to build properly.
20 - *
21 - * NOTE Required for shade plugin to operate.
22 - */
23 -public class AtomixShaded {
24 -
25 -}
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
31 <description>Domain agnostic ON.Lab utilities</description> 31 <description>Domain agnostic ON.Lab utilities</description>
32 32
33 <modules> 33 <modules>
34 - <module>atomix</module>
35 <module>junit</module> 34 <module>junit</module>
36 <module>misc</module> 35 <module>misc</module>
37 <module>yangutils</module> 36 <module>yangutils</module>
......