Committed by
Gerrit Code Review
Revert "Migrating to latest Atomix"
This reverts commit aa3d598b Change-Id: Icd58278b1bbc8ca31887450f58220fba40cd309c
Showing
31 changed files
with
676 additions
and
399 deletions
... | @@ -39,6 +39,9 @@ import org.onosproject.store.service.LeaderElector; | ... | @@ -39,6 +39,9 @@ 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 | + | ||
42 | /** | 45 | /** |
43 | * Implementation of {@code LeadershipStore} that makes use of a {@link LeaderElector} | 46 | * Implementation of {@code LeadershipStore} that makes use of a {@link LeaderElector} |
44 | * primitive. | 47 | * primitive. |
... | @@ -59,11 +62,13 @@ public class NewDistributedLeadershipStore | ... | @@ -59,11 +62,13 @@ public class NewDistributedLeadershipStore |
59 | 62 | ||
60 | private NodeId localNodeId; | 63 | private NodeId localNodeId; |
61 | private LeaderElector leaderElector; | 64 | private LeaderElector leaderElector; |
65 | + private final Map<String, Leadership> leaderBoard = Maps.newConcurrentMap(); | ||
62 | 66 | ||
63 | private final Consumer<Change<Leadership>> leadershipChangeListener = | 67 | private final Consumer<Change<Leadership>> leadershipChangeListener = |
64 | change -> { | 68 | change -> { |
65 | Leadership oldValue = change.oldValue(); | 69 | Leadership oldValue = change.oldValue(); |
66 | Leadership newValue = change.newValue(); | 70 | Leadership newValue = change.newValue(); |
71 | + leaderBoard.put(newValue.topic(), newValue); | ||
67 | boolean leaderChanged = !Objects.equals(oldValue.leader(), newValue.leader()); | 72 | boolean leaderChanged = !Objects.equals(oldValue.leader(), newValue.leader()); |
68 | boolean candidatesChanged = !Objects.equals(oldValue.candidates(), newValue.candidates()); | 73 | boolean candidatesChanged = !Objects.equals(oldValue.candidates(), newValue.candidates()); |
69 | LeadershipEvent.Type eventType = null; | 74 | LeadershipEvent.Type eventType = null; |
... | @@ -87,6 +92,7 @@ public class NewDistributedLeadershipStore | ... | @@ -87,6 +92,7 @@ public class NewDistributedLeadershipStore |
87 | .build() | 92 | .build() |
88 | .asLeaderElector(); | 93 | .asLeaderElector(); |
89 | leaderElector.addChangeListener(leadershipChangeListener); | 94 | leaderElector.addChangeListener(leadershipChangeListener); |
95 | + leaderBoard.putAll(getLeaderships()); | ||
90 | log.info("Started"); | 96 | log.info("Started"); |
91 | } | 97 | } |
92 | 98 | ||
... | @@ -123,11 +129,11 @@ public class NewDistributedLeadershipStore | ... | @@ -123,11 +129,11 @@ public class NewDistributedLeadershipStore |
123 | 129 | ||
124 | @Override | 130 | @Override |
125 | public Leadership getLeadership(String topic) { | 131 | public Leadership getLeadership(String topic) { |
126 | - return leaderElector.getLeadership(topic); | 132 | + return leaderBoard.get(topic); |
127 | } | 133 | } |
128 | 134 | ||
129 | @Override | 135 | @Override |
130 | public Map<String, Leadership> getLeaderships() { | 136 | public Map<String, Leadership> getLeaderships() { |
131 | - return leaderElector.getLeaderships(); | 137 | + return ImmutableMap.copyOf(leaderBoard); |
132 | } | 138 | } |
133 | } | 139 | } | ... | ... |
... | @@ -3,12 +3,29 @@ COMPILE_DEPS = [ | ... | @@ -3,12 +3,29 @@ 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', | ||
6 | '//lib:atomix', | 19 | '//lib:atomix', |
20 | + '//lib:atomix-resource', | ||
21 | + '//lib:atomix-variables', | ||
22 | + '//lib:atomix-resource-manager', | ||
7 | ] | 23 | ] |
8 | 24 | ||
9 | TEST_DEPS = [ | 25 | TEST_DEPS = [ |
10 | '//lib:TEST', | 26 | '//lib:TEST', |
11 | '//core/api:onos-api-tests', | 27 | '//core/api:onos-api-tests', |
28 | + '//lib:onos-atomix', | ||
12 | ] | 29 | ] |
13 | 30 | ||
14 | osgi_jar_with_tests ( | 31 | osgi_jar_with_tests ( | ... | ... |
... | @@ -70,9 +70,9 @@ | ... | @@ -70,9 +70,9 @@ |
70 | </dependency> | 70 | </dependency> |
71 | 71 | ||
72 | <dependency> | 72 | <dependency> |
73 | - <groupId>io.atomix</groupId> | 73 | + <groupId>org.onosproject</groupId> |
74 | <artifactId>atomix</artifactId> | 74 | <artifactId>atomix</artifactId> |
75 | - <version>1.0.0-rc7</version> | 75 | + <version>1.0.onos-SNAPSHOT</version> |
76 | </dependency> | 76 | </dependency> |
77 | </dependencies> | 77 | </dependencies> |
78 | </project> | 78 | </project> | ... | ... |
... | @@ -19,8 +19,9 @@ import java.util.Arrays; | ... | @@ -19,8 +19,9 @@ 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; | ||
22 | import io.atomix.manager.util.ResourceManagerTypeResolver; | 23 | import io.atomix.manager.util.ResourceManagerTypeResolver; |
23 | -import io.atomix.variables.internal.LongCommands; | 24 | +import io.atomix.variables.state.LongCommands; |
24 | 25 | ||
25 | import org.onlab.util.Match; | 26 | import org.onlab.util.Match; |
26 | import org.onosproject.cluster.Leader; | 27 | import org.onosproject.cluster.Leader; |
... | @@ -62,7 +63,8 @@ public final class CatalystSerializers { | ... | @@ -62,7 +63,8 @@ public final class CatalystSerializers { |
62 | Transaction.State.class, | 63 | Transaction.State.class, |
63 | PrepareResult.class, | 64 | PrepareResult.class, |
64 | CommitResult.class, | 65 | CommitResult.class, |
65 | - RollbackResult.class)); | 66 | + RollbackResult.class, |
67 | + Query.ConsistencyLevel.class)); | ||
66 | // ONOS classes | 68 | // ONOS classes |
67 | serializer.register(Change.class, factory); | 69 | serializer.register(Change.class, factory); |
68 | serializer.register(Leader.class, factory); | 70 | 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.concurrent.ThreadContext; | 32 | +import io.atomix.catalyst.util.concurrent.ThreadContext; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * {@link Client} implementation for {@link CopycatTransport}. | 35 | * {@link Client} implementation for {@link CopycatTransport}. | ... | ... |
... | @@ -15,18 +15,6 @@ | ... | @@ -15,18 +15,6 @@ |
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 | - | ||
30 | import java.io.ByteArrayInputStream; | 18 | import java.io.ByteArrayInputStream; |
31 | import java.io.ByteArrayOutputStream; | 19 | import java.io.ByteArrayOutputStream; |
32 | import java.io.DataInputStream; | 20 | import java.io.DataInputStream; |
... | @@ -38,6 +26,8 @@ import java.util.Objects; | ... | @@ -38,6 +26,8 @@ import java.util.Objects; |
38 | import java.util.concurrent.CompletableFuture; | 26 | import java.util.concurrent.CompletableFuture; |
39 | import java.util.function.Consumer; | 27 | import java.util.function.Consumer; |
40 | 28 | ||
29 | + | ||
30 | + | ||
41 | import org.apache.commons.io.IOUtils; | 31 | import org.apache.commons.io.IOUtils; |
42 | import org.onlab.util.Tools; | 32 | import org.onlab.util.Tools; |
43 | import org.onosproject.cluster.PartitionId; | 33 | import org.onosproject.cluster.PartitionId; |
... | @@ -48,6 +38,18 @@ import com.google.common.base.MoreObjects; | ... | @@ -48,6 +38,18 @@ import com.google.common.base.MoreObjects; |
48 | import com.google.common.base.Throwables; | 38 | import com.google.common.base.Throwables; |
49 | import com.google.common.collect.Maps; | 39 | import com.google.common.collect.Maps; |
50 | 40 | ||
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 | + | ||
51 | /** | 53 | /** |
52 | * {@link Connection} implementation for CopycatTransport. | 54 | * {@link Connection} implementation for CopycatTransport. |
53 | */ | 55 | */ | ... | ... |
... | @@ -17,12 +17,6 @@ package org.onosproject.store.primitives.impl; | ... | @@ -17,12 +17,6 @@ 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; | ||
26 | 20 | ||
27 | import java.io.ByteArrayInputStream; | 21 | import java.io.ByteArrayInputStream; |
28 | import java.io.DataInputStream; | 22 | import java.io.DataInputStream; |
... | @@ -42,6 +36,13 @@ import org.slf4j.Logger; | ... | @@ -42,6 +36,13 @@ import org.slf4j.Logger; |
42 | 36 | ||
43 | import com.google.common.collect.Maps; | 37 | import com.google.common.collect.Maps; |
44 | 38 | ||
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 | + | ||
45 | /** | 46 | /** |
46 | * {@link Server} implementation for {@link CopycatTransport}. | 47 | * {@link Server} implementation for {@link CopycatTransport}. |
47 | */ | 48 | */ | ... | ... |
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,18 +16,22 @@ | ... | @@ -16,18 +16,22 @@ |
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; | ||
19 | import io.atomix.AtomixClient; | 20 | import io.atomix.AtomixClient; |
21 | +import io.atomix.catalyst.transport.Address; | ||
20 | import io.atomix.catalyst.transport.Transport; | 22 | import io.atomix.catalyst.transport.Transport; |
23 | +import io.atomix.catalyst.util.concurrent.CatalystThreadFactory; | ||
21 | import io.atomix.copycat.client.ConnectionStrategies; | 24 | import io.atomix.copycat.client.ConnectionStrategies; |
22 | import io.atomix.copycat.client.CopycatClient; | 25 | import io.atomix.copycat.client.CopycatClient; |
23 | import io.atomix.copycat.client.CopycatClient.State; | 26 | import io.atomix.copycat.client.CopycatClient.State; |
24 | import io.atomix.copycat.client.RecoveryStrategies; | 27 | import io.atomix.copycat.client.RecoveryStrategies; |
28 | +import io.atomix.copycat.client.RetryStrategies; | ||
25 | import io.atomix.copycat.client.ServerSelectionStrategies; | 29 | import io.atomix.copycat.client.ServerSelectionStrategies; |
26 | import io.atomix.manager.ResourceClient; | 30 | import io.atomix.manager.ResourceClient; |
27 | -import io.atomix.manager.ResourceManagerException; | 31 | +import io.atomix.manager.state.ResourceManagerException; |
28 | import io.atomix.manager.util.ResourceManagerTypeResolver; | 32 | import io.atomix.manager.util.ResourceManagerTypeResolver; |
29 | -import io.atomix.resource.ResourceRegistry; | ||
30 | import io.atomix.resource.ResourceType; | 33 | import io.atomix.resource.ResourceType; |
34 | +import io.atomix.resource.util.ResourceRegistry; | ||
31 | import io.atomix.variables.DistributedLong; | 35 | import io.atomix.variables.DistributedLong; |
32 | 36 | ||
33 | import java.util.Collection; | 37 | import java.util.Collection; |
... | @@ -66,8 +70,8 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana | ... | @@ -66,8 +70,8 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana |
66 | private final StoragePartition partition; | 70 | private final StoragePartition partition; |
67 | private final Transport transport; | 71 | private final Transport transport; |
68 | private final io.atomix.catalyst.serializer.Serializer serializer; | 72 | private final io.atomix.catalyst.serializer.Serializer serializer; |
69 | - private AtomixClient client; | 73 | + private Atomix client; |
70 | - private ResourceClient resourceClient; | 74 | + private CopycatClient copycatClient; |
71 | private static final String ATOMIC_VALUES_CONSISTENT_MAP_NAME = "onos-atomic-values"; | 75 | private static final String ATOMIC_VALUES_CONSISTENT_MAP_NAME = "onos-atomic-values"; |
72 | private final Supplier<AsyncConsistentMap<String, byte[]>> onosAtomicValuesMap = | 76 | private final Supplier<AsyncConsistentMap<String, byte[]>> onosAtomicValuesMap = |
73 | Suppliers.memoize(() -> newAsyncConsistentMap(ATOMIC_VALUES_CONSISTENT_MAP_NAME, | 77 | Suppliers.memoize(() -> newAsyncConsistentMap(ATOMIC_VALUES_CONSISTENT_MAP_NAME, |
... | @@ -95,15 +99,19 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana | ... | @@ -95,15 +99,19 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana |
95 | 99 | ||
96 | @Override | 100 | @Override |
97 | public CompletableFuture<Void> open() { | 101 | public CompletableFuture<Void> open() { |
102 | + if (client != null && client.isOpen()) { | ||
103 | + return CompletableFuture.completedFuture(null); | ||
104 | + } | ||
98 | synchronized (StoragePartitionClient.this) { | 105 | synchronized (StoragePartitionClient.this) { |
99 | - resourceClient = newResourceClient(transport, | 106 | + copycatClient = newCopycatClient(partition.getMemberAddresses(), |
107 | + transport, | ||
100 | serializer.clone(), | 108 | serializer.clone(), |
101 | StoragePartition.RESOURCE_TYPES); | 109 | StoragePartition.RESOURCE_TYPES); |
102 | - resourceClient.client().onStateChange(state -> log.debug("Partition {} client state" | 110 | + copycatClient.onStateChange(state -> log.debug("Partition {} client state" |
103 | + " changed to {}", partition.getId(), state)); | 111 | + " changed to {}", partition.getId(), state)); |
104 | - client = new AtomixClient(resourceClient); | 112 | + client = new AtomixClient(new ResourceClient(copycatClient)); |
105 | } | 113 | } |
106 | - return client.connect(partition.getMemberAddresses()).whenComplete((r, e) -> { | 114 | + return client.open().whenComplete((r, e) -> { |
107 | if (e == null) { | 115 | if (e == null) { |
108 | log.info("Successfully started client for partition {}", partition.getId()); | 116 | log.info("Successfully started client for partition {}", partition.getId()); |
109 | } else { | 117 | } else { |
... | @@ -124,7 +132,7 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana | ... | @@ -124,7 +132,7 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana |
124 | atomixConsistentMap.statusChangeListeners() | 132 | atomixConsistentMap.statusChangeListeners() |
125 | .forEach(listener -> listener.accept(mapper.apply(state))); | 133 | .forEach(listener -> listener.accept(mapper.apply(state))); |
126 | }; | 134 | }; |
127 | - resourceClient.client().onStateChange(statusListener); | 135 | + copycatClient.onStateChange(statusListener); |
128 | AsyncConsistentMap<String, byte[]> rawMap = | 136 | AsyncConsistentMap<String, byte[]> rawMap = |
129 | new DelegatingAsyncConsistentMap<String, byte[]>(atomixConsistentMap) { | 137 | new DelegatingAsyncConsistentMap<String, byte[]>(atomixConsistentMap) { |
130 | @Override | 138 | @Override |
... | @@ -165,15 +173,7 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana | ... | @@ -165,15 +173,7 @@ public class StoragePartitionClient implements DistributedPrimitiveCreator, Mana |
165 | 173 | ||
166 | @Override | 174 | @Override |
167 | public AsyncLeaderElector newAsyncLeaderElector(String name) { | 175 | public AsyncLeaderElector newAsyncLeaderElector(String name) { |
168 | - AtomixLeaderElector leaderElector = client.getResource(name, AtomixLeaderElector.class) | 176 | + return client.getResource(name, AtomixLeaderElector.class).join(); |
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 resourceClient.client().state() != State.CLOSED; | 191 | + return client.isOpen(); |
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 | - resourceClient.client().session().id(), | 201 | + copycatClient.session().id(), |
202 | - mapper.apply(resourceClient.client().state())); | 202 | + mapper.apply(copycatClient.state())); |
203 | } | 203 | } |
204 | 204 | ||
205 | - private ResourceClient newResourceClient(Transport transport, | 205 | + private CopycatClient newCopycatClient(Collection<Address> members, |
206 | + Transport transport, | ||
206 | io.atomix.catalyst.serializer.Serializer serializer, | 207 | io.atomix.catalyst.serializer.Serializer serializer, |
207 | Collection<ResourceType> resourceTypes) { | 208 | Collection<ResourceType> resourceTypes) { |
208 | ResourceRegistry registry = new ResourceRegistry(); | 209 | ResourceRegistry registry = new ResourceRegistry(); |
209 | resourceTypes.forEach(registry::register); | 210 | resourceTypes.forEach(registry::register); |
210 | - CopycatClient copycatClient = CopycatClient.builder() | 211 | + CopycatClient client = CopycatClient.builder(members) |
211 | .withServerSelectionStrategy(ServerSelectionStrategies.ANY) | 212 | .withServerSelectionStrategy(ServerSelectionStrategies.ANY) |
212 | .withConnectionStrategy(ConnectionStrategies.FIBONACCI_BACKOFF) | 213 | .withConnectionStrategy(ConnectionStrategies.FIBONACCI_BACKOFF) |
213 | .withRecoveryStrategy(RecoveryStrategies.RECOVER) | 214 | .withRecoveryStrategy(RecoveryStrategies.RECOVER) |
215 | + .withRetryStrategy(RetryStrategies.FIBONACCI_BACKOFF) | ||
214 | .withTransport(transport) | 216 | .withTransport(transport) |
215 | .withSerializer(serializer) | 217 | .withSerializer(serializer) |
218 | + .withThreadFactory(new CatalystThreadFactory(String.format("copycat-client-%s", partition.getId()))) | ||
216 | .build(); | 219 | .build(); |
217 | - copycatClient.serializer().resolve(new ResourceManagerTypeResolver()); | 220 | + client.serializer().resolve(new ResourceManagerTypeResolver()); |
218 | for (ResourceType type : registry.types()) { | 221 | for (ResourceType type : registry.types()) { |
219 | try { | 222 | try { |
220 | - type.factory() | 223 | + type.factory().newInstance().createSerializableTypeResolver().resolve(client.serializer().registry()); |
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 new ResourceClient(new QueryRetryingCopycatClient(copycatClient, 2, 100)); | 228 | + return client; |
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.internal.ResourceManagerState; | 25 | +import io.atomix.manager.state.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(); | 71 | + server = buildServer(partition.getMemberAddresses()); |
72 | } | 72 | } |
73 | - serverOpenFuture = server.bootstrap(partition.getMemberAddresses()); | 73 | + serverOpenFuture = server.start(); |
74 | } else { | 74 | } else { |
75 | serverOpenFuture = CompletableFuture.completedFuture(null); | 75 | serverOpenFuture = CompletableFuture.completedFuture(null); |
76 | } | 76 | } |
... | @@ -85,7 +85,11 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> { | ... | @@ -85,7 +85,11 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> { |
85 | 85 | ||
86 | @Override | 86 | @Override |
87 | public CompletableFuture<Void> close() { | 87 | public CompletableFuture<Void> close() { |
88 | - return server.shutdown(); | 88 | + /** |
89 | + * CopycatServer#kill just shuts down the server and does not result | ||
90 | + * in any cluster membership changes. | ||
91 | + */ | ||
92 | + return server.kill(); | ||
89 | } | 93 | } |
90 | 94 | ||
91 | /** | 95 | /** |
... | @@ -93,11 +97,11 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> { | ... | @@ -93,11 +97,11 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> { |
93 | * @return future that is completed when the operation is complete | 97 | * @return future that is completed when the operation is complete |
94 | */ | 98 | */ |
95 | public CompletableFuture<Void> closeAndExit() { | 99 | public CompletableFuture<Void> closeAndExit() { |
96 | - return server.leave(); | 100 | + return server.stop(); |
97 | } | 101 | } |
98 | 102 | ||
99 | - private CopycatServer buildServer() { | 103 | + private CopycatServer buildServer(Collection<Address> clusterMembers) { |
100 | - CopycatServer server = CopycatServer.builder(localAddress) | 104 | + CopycatServer server = CopycatServer.builder(localAddress, clusterMembers) |
101 | .withName("partition-" + partition.getId()) | 105 | .withName("partition-" + partition.getId()) |
102 | .withSerializer(serializer.clone()) | 106 | .withSerializer(serializer.clone()) |
103 | .withTransport(transport.get()) | 107 | .withTransport(transport.get()) |
... | @@ -114,8 +118,9 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> { | ... | @@ -114,8 +118,9 @@ public class StoragePartitionServer implements Managed<StoragePartitionServer> { |
114 | } | 118 | } |
115 | 119 | ||
116 | public CompletableFuture<Void> join(Collection<Address> otherMembers) { | 120 | public CompletableFuture<Void> join(Collection<Address> otherMembers) { |
117 | - server = buildServer(); | 121 | + server = buildServer(otherMembers); |
118 | - return server.join(otherMembers).whenComplete((r, e) -> { | 122 | + |
123 | + return server.start().whenComplete((r, e) -> { | ||
119 | if (e == null) { | 124 | if (e == null) { |
120 | log.info("Successfully joined partition {}", partition.getId()); | 125 | log.info("Successfully joined partition {}", partition.getId()); |
121 | } else { | 126 | } else { | ... | ... |
... | @@ -48,6 +48,10 @@ public final class AsyncConsistentMultimapCommands { | ... | @@ -48,6 +48,10 @@ 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 | + } | ||
51 | 55 | ||
52 | @Override | 56 | @Override |
53 | public String toString() { | 57 | public String toString() { | ... | ... |
... | @@ -70,90 +70,95 @@ public class AsyncConsistentSetMultimap | ... | @@ -70,90 +70,95 @@ public class AsyncConsistentSetMultimap |
70 | 70 | ||
71 | @Override | 71 | @Override |
72 | public CompletableFuture<Integer> size() { | 72 | public CompletableFuture<Integer> size() { |
73 | - return client.submit(new Size()); | 73 | + return submit(new Size()); |
74 | } | 74 | } |
75 | 75 | ||
76 | @Override | 76 | @Override |
77 | public CompletableFuture<Boolean> isEmpty() { | 77 | public CompletableFuture<Boolean> isEmpty() { |
78 | - return client.submit(new IsEmpty()); | 78 | + return 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 client.submit(new ContainsKey(key)); | 83 | + return 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 client.submit(new ContainsValue(value)); | 88 | + return 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 client.submit(new ContainsEntry(key, value)); | 93 | + return 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 client.submit(new Put(key, Lists.newArrayList(value), null)); | 98 | + return 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 client.submit(new MultiRemove(key, | 103 | + return 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(String key, Collection<? extends byte[]> values) { | 109 | + public CompletableFuture<Boolean> removeAll( |
110 | - return client.submit(new MultiRemove(key, (Collection<byte[]>) values, null)); | 110 | + String key, Collection<? extends byte[]> values) { |
111 | + return submit(new MultiRemove(key, (Collection<byte[]>) values, null)); | ||
111 | } | 112 | } |
112 | 113 | ||
113 | @Override | 114 | @Override |
114 | - public CompletableFuture<Versioned<Collection<? extends byte[]>>> removeAll(String key) { | 115 | + public CompletableFuture< |
115 | - return client.submit(new RemoveAll(key, null)); | 116 | + Versioned<Collection<? extends byte[]>>> removeAll(String key) { |
117 | + return submit(new RemoveAll(key, null)); | ||
116 | } | 118 | } |
117 | 119 | ||
118 | @Override | 120 | @Override |
119 | public CompletableFuture<Boolean> putAll( | 121 | public CompletableFuture<Boolean> putAll( |
120 | String key, Collection<? extends byte[]> values) { | 122 | String key, Collection<? extends byte[]> values) { |
121 | - return client.submit(new Put(key, values, null)); | 123 | + return submit(new Put(key, values, null)); |
122 | } | 124 | } |
123 | 125 | ||
124 | @Override | 126 | @Override |
125 | - public CompletableFuture<Versioned<Collection<? extends byte[]>>> replaceValues( | 127 | + public CompletableFuture< |
128 | + Versioned<Collection<? extends byte[]>>> replaceValues( | ||
126 | String key, Collection<byte[]> values) { | 129 | String key, Collection<byte[]> values) { |
127 | - return client.submit(new Replace(key, values, null)); | 130 | + return submit(new Replace(key, values, null)); |
128 | } | 131 | } |
129 | 132 | ||
130 | @Override | 133 | @Override |
131 | public CompletableFuture<Void> clear() { | 134 | public CompletableFuture<Void> clear() { |
132 | - return client.submit(new Clear()); | 135 | + return submit(new Clear()); |
133 | } | 136 | } |
134 | 137 | ||
135 | @Override | 138 | @Override |
136 | - public CompletableFuture<Versioned<Collection<? extends byte[]>>> get(String key) { | 139 | + public CompletableFuture< |
137 | - return client.submit(new Get(key)); | 140 | + Versioned<Collection<? extends byte[]>>> get(String key) { |
141 | + return submit(new Get(key)); | ||
138 | } | 142 | } |
139 | 143 | ||
140 | @Override | 144 | @Override |
141 | public CompletableFuture<Set<String>> keySet() { | 145 | public CompletableFuture<Set<String>> keySet() { |
142 | - return client.submit(new KeySet()); | 146 | + return submit(new KeySet()); |
143 | } | 147 | } |
144 | 148 | ||
145 | @Override | 149 | @Override |
146 | public CompletableFuture<Multiset<String>> keys() { | 150 | public CompletableFuture<Multiset<String>> keys() { |
147 | - return client.submit(new Keys()); | 151 | + return submit(new Keys()); |
148 | } | 152 | } |
149 | 153 | ||
154 | + @Override | ||
150 | public CompletableFuture<Multiset<byte[]>> values() { | 155 | public CompletableFuture<Multiset<byte[]>> values() { |
151 | - return client.submit(new Values()); | 156 | + return submit(new Values()); |
152 | } | 157 | } |
153 | 158 | ||
154 | @Override | 159 | @Override |
155 | public CompletableFuture<Collection<Map.Entry<String, byte[]>>> entries() { | 160 | public CompletableFuture<Collection<Map.Entry<String, byte[]>>> entries() { |
156 | - return client.submit(new Entries()); | 161 | + return submit(new Entries()); |
157 | } | 162 | } |
158 | 163 | ||
159 | @Override | 164 | @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 client.submit(new IsEmpty()); | 100 | + return submit(new IsEmpty()); |
101 | } | 101 | } |
102 | 102 | ||
103 | @Override | 103 | @Override |
104 | public CompletableFuture<Integer> size() { | 104 | public CompletableFuture<Integer> size() { |
105 | - return client.submit(new Size()); | 105 | + return 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 client.submit(new ContainsKey(key)); | 110 | + return 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 client.submit(new ContainsValue(value)); | 115 | + return 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 client.submit(new Get(key)); | 120 | + return 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 client.submit(new KeySet()); | 125 | + return 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 client.submit(new Values()); | 130 | + return 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 client.submit(new EntrySet()); | 135 | + return 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 client.submit(new UpdateAndGet(key, value, Match.ANY, Match.ANY)) | 141 | + return 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 client.submit(new UpdateAndGet(key, value, Match.ANY, Match.ANY)) | 149 | + return 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 client.submit(new UpdateAndGet(key, value, Match.NULL, Match.ANY)) | 157 | + return 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 client.submit(new UpdateAndGet(key, null, Match.ANY, Match.ANY)) | 164 | + return 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 client.submit(new UpdateAndGet(key, null, Match.ifValue(value), Match.ANY)) | 172 | + return 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 client.submit(new UpdateAndGet(key, null, Match.ANY, Match.ifValue(version))) | 180 | + return 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 client.submit(new UpdateAndGet(key, value, Match.NOT_NULL, Match.ANY)) | 188 | + return 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,7 +193,10 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> | ... | @@ -193,7 +193,10 @@ 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 client.submit(new UpdateAndGet(key, newValue, Match.ifValue(oldValue), Match.ANY)) | 196 | + return submit(new UpdateAndGet(key, |
197 | + newValue, | ||
198 | + Match.ifValue(oldValue), | ||
199 | + Match.ANY)) | ||
197 | .whenComplete((r, e) -> throwIfLocked(r.status())) | 200 | .whenComplete((r, e) -> throwIfLocked(r.status())) |
198 | .thenApply(v -> v.updated()); | 201 | .thenApply(v -> v.updated()); |
199 | } | 202 | } |
... | @@ -201,14 +204,17 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> | ... | @@ -201,14 +204,17 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> |
201 | @Override | 204 | @Override |
202 | @SuppressWarnings("unchecked") | 205 | @SuppressWarnings("unchecked") |
203 | public CompletableFuture<Boolean> replace(String key, long oldVersion, byte[] newValue) { | 206 | public CompletableFuture<Boolean> replace(String key, long oldVersion, byte[] newValue) { |
204 | - return client.submit(new UpdateAndGet(key, newValue, Match.ANY, Match.ifValue(oldVersion))) | 207 | + return submit(new UpdateAndGet(key, |
208 | + newValue, | ||
209 | + Match.ANY, | ||
210 | + Match.ifValue(oldVersion))) | ||
205 | .whenComplete((r, e) -> throwIfLocked(r.status())) | 211 | .whenComplete((r, e) -> throwIfLocked(r.status())) |
206 | .thenApply(v -> v.updated()); | 212 | .thenApply(v -> v.updated()); |
207 | } | 213 | } |
208 | 214 | ||
209 | @Override | 215 | @Override |
210 | public CompletableFuture<Void> clear() { | 216 | public CompletableFuture<Void> clear() { |
211 | - return client.submit(new Clear()) | 217 | + return submit(new Clear()) |
212 | .whenComplete((r, e) -> throwIfLocked(r)) | 218 | .whenComplete((r, e) -> throwIfLocked(r)) |
213 | .thenApply(v -> null); | 219 | .thenApply(v -> null); |
214 | } | 220 | } |
... | @@ -239,7 +245,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> | ... | @@ -239,7 +245,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> |
239 | } | 245 | } |
240 | Match<byte[]> valueMatch = r1 == null ? Match.NULL : Match.ANY; | 246 | Match<byte[]> valueMatch = r1 == null ? Match.NULL : Match.ANY; |
241 | Match<Long> versionMatch = r1 == null ? Match.ANY : Match.ifValue(r1.version()); | 247 | Match<Long> versionMatch = r1 == null ? Match.ANY : Match.ifValue(r1.version()); |
242 | - return client.submit(new UpdateAndGet(key, | 248 | + return submit(new UpdateAndGet(key, |
243 | computedValue.get(), | 249 | computedValue.get(), |
244 | valueMatch, | 250 | valueMatch, |
245 | versionMatch)) | 251 | versionMatch)) |
... | @@ -252,7 +258,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> | ... | @@ -252,7 +258,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> |
252 | public synchronized CompletableFuture<Void> addListener(MapEventListener<String, byte[]> listener, | 258 | public synchronized CompletableFuture<Void> addListener(MapEventListener<String, byte[]> listener, |
253 | Executor executor) { | 259 | Executor executor) { |
254 | if (mapEventListeners.isEmpty()) { | 260 | if (mapEventListeners.isEmpty()) { |
255 | - return client.submit(new Listen()).thenRun(() -> mapEventListeners.putIfAbsent(listener, executor)); | 261 | + return submit(new Listen()).thenRun(() -> mapEventListeners.putIfAbsent(listener, executor)); |
256 | } else { | 262 | } else { |
257 | mapEventListeners.put(listener, executor); | 263 | mapEventListeners.put(listener, executor); |
258 | return CompletableFuture.completedFuture(null); | 264 | return CompletableFuture.completedFuture(null); |
... | @@ -262,7 +268,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> | ... | @@ -262,7 +268,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> |
262 | @Override | 268 | @Override |
263 | public synchronized CompletableFuture<Void> removeListener(MapEventListener<String, byte[]> listener) { | 269 | public synchronized CompletableFuture<Void> removeListener(MapEventListener<String, byte[]> listener) { |
264 | if (mapEventListeners.remove(listener) != null && mapEventListeners.isEmpty()) { | 270 | if (mapEventListeners.remove(listener) != null && mapEventListeners.isEmpty()) { |
265 | - return client.submit(new Unlisten()).thenApply(v -> null); | 271 | + return submit(new Unlisten()).thenApply(v -> null); |
266 | } | 272 | } |
267 | return CompletableFuture.completedFuture(null); | 273 | return CompletableFuture.completedFuture(null); |
268 | } | 274 | } |
... | @@ -275,23 +281,23 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> | ... | @@ -275,23 +281,23 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> |
275 | 281 | ||
276 | @Override | 282 | @Override |
277 | public CompletableFuture<Boolean> prepare(MapTransaction<String, byte[]> transaction) { | 283 | public CompletableFuture<Boolean> prepare(MapTransaction<String, byte[]> transaction) { |
278 | - return client.submit(new TransactionPrepare(transaction)).thenApply(v -> v == PrepareResult.OK); | 284 | + return submit(new TransactionPrepare(transaction)).thenApply(v -> v == PrepareResult.OK); |
279 | } | 285 | } |
280 | 286 | ||
281 | @Override | 287 | @Override |
282 | public CompletableFuture<Void> commit(TransactionId transactionId) { | 288 | public CompletableFuture<Void> commit(TransactionId transactionId) { |
283 | - return client.submit(new TransactionCommit(transactionId)).thenApply(v -> null); | 289 | + return submit(new TransactionCommit(transactionId)).thenApply(v -> null); |
284 | } | 290 | } |
285 | 291 | ||
286 | @Override | 292 | @Override |
287 | public CompletableFuture<Void> rollback(TransactionId transactionId) { | 293 | public CompletableFuture<Void> rollback(TransactionId transactionId) { |
288 | - return client.submit(new TransactionRollback(transactionId)) | 294 | + return submit(new TransactionRollback(transactionId)) |
289 | .thenApply(v -> null); | 295 | .thenApply(v -> null); |
290 | } | 296 | } |
291 | 297 | ||
292 | @Override | 298 | @Override |
293 | public CompletableFuture<Boolean> prepareAndCommit(MapTransaction<String, byte[]> transaction) { | 299 | public CompletableFuture<Boolean> prepareAndCommit(MapTransaction<String, byte[]> transaction) { |
294 | - return client.submit(new TransactionPrepareAndCommit(transaction)).thenApply(v -> v == PrepareResult.OK); | 300 | + return submit(new TransactionPrepareAndCommit(transaction)).thenApply(v -> v == PrepareResult.OK); |
295 | } | 301 | } |
296 | 302 | ||
297 | @Override | 303 | @Override | ... | ... |
... | @@ -51,6 +51,11 @@ public final class AtomixConsistentMapCommands { | ... | @@ -51,6 +51,11 @@ 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 | ||
54 | public String toString() { | 59 | public String toString() { |
55 | return MoreObjects.toStringHelper(getClass()) | 60 | return MoreObjects.toStringHelper(getClass()) |
56 | .toString(); | 61 | .toString(); | ... | ... |
... | @@ -42,9 +42,6 @@ import org.onosproject.store.primitives.resources.impl.AtomixLeaderElectorComman | ... | @@ -42,9 +42,6 @@ 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; | ||
48 | import com.google.common.collect.Sets; | 45 | import com.google.common.collect.Sets; |
49 | 46 | ||
50 | /** | 47 | /** |
... | @@ -57,34 +54,11 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector> | ... | @@ -57,34 +54,11 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector> |
57 | Sets.newCopyOnWriteArraySet(); | 54 | Sets.newCopyOnWriteArraySet(); |
58 | private final Set<Consumer<Change<Leadership>>> leadershipChangeListeners = | 55 | private final Set<Consumer<Change<Leadership>>> leadershipChangeListeners = |
59 | Sets.newCopyOnWriteArraySet(); | 56 | Sets.newCopyOnWriteArraySet(); |
60 | - private final Consumer<Change<Leadership>> cacheUpdater; | ||
61 | - private final Consumer<Status> statusListener; | ||
62 | 57 | ||
63 | public static final String CHANGE_SUBJECT = "leadershipChangeEvents"; | 58 | public static final String CHANGE_SUBJECT = "leadershipChangeEvents"; |
64 | - private final LoadingCache<String, CompletableFuture<Leadership>> cache; | ||
65 | 59 | ||
66 | public AtomixLeaderElector(CopycatClient client, Properties properties) { | 60 | public AtomixLeaderElector(CopycatClient client, Properties properties) { |
67 | super(client, properties); | 61 | 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); | ||
88 | } | 62 | } |
89 | 63 | ||
90 | @Override | 64 | @Override |
... | @@ -100,57 +74,53 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector> | ... | @@ -100,57 +74,53 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector> |
100 | }); | 74 | }); |
101 | } | 75 | } |
102 | 76 | ||
103 | - public CompletableFuture<AtomixLeaderElector> setupCache() { | ||
104 | - return addChangeListener(cacheUpdater).thenApply(v -> this); | ||
105 | - } | ||
106 | - | ||
107 | private void handleEvent(List<Change<Leadership>> changes) { | 77 | private void handleEvent(List<Change<Leadership>> changes) { |
108 | changes.forEach(change -> leadershipChangeListeners.forEach(l -> l.accept(change))); | 78 | changes.forEach(change -> leadershipChangeListeners.forEach(l -> l.accept(change))); |
109 | } | 79 | } |
110 | 80 | ||
111 | @Override | 81 | @Override |
112 | public CompletableFuture<Leadership> run(String topic, NodeId nodeId) { | 82 | public CompletableFuture<Leadership> run(String topic, NodeId nodeId) { |
113 | - return client.submit(new Run(topic, nodeId)).whenComplete((r, e) -> cache.invalidate(topic)); | 83 | + return submit(new Run(topic, nodeId)); |
114 | } | 84 | } |
115 | 85 | ||
116 | @Override | 86 | @Override |
117 | public CompletableFuture<Void> withdraw(String topic) { | 87 | public CompletableFuture<Void> withdraw(String topic) { |
118 | - return client.submit(new Withdraw(topic)).whenComplete((r, e) -> cache.invalidate(topic)); | 88 | + return submit(new Withdraw(topic)); |
119 | } | 89 | } |
120 | 90 | ||
121 | @Override | 91 | @Override |
122 | public CompletableFuture<Boolean> anoint(String topic, NodeId nodeId) { | 92 | public CompletableFuture<Boolean> anoint(String topic, NodeId nodeId) { |
123 | - return client.submit(new Anoint(topic, nodeId)).whenComplete((r, e) -> cache.invalidate(topic)); | 93 | + return submit(new Anoint(topic, nodeId)); |
124 | } | 94 | } |
125 | 95 | ||
126 | @Override | 96 | @Override |
127 | public CompletableFuture<Boolean> promote(String topic, NodeId nodeId) { | 97 | public CompletableFuture<Boolean> promote(String topic, NodeId nodeId) { |
128 | - return client.submit(new Promote(topic, nodeId)).whenComplete((r, e) -> cache.invalidate(topic)); | 98 | + return submit(new Promote(topic, nodeId)); |
129 | } | 99 | } |
130 | 100 | ||
131 | @Override | 101 | @Override |
132 | public CompletableFuture<Void> evict(NodeId nodeId) { | 102 | public CompletableFuture<Void> evict(NodeId nodeId) { |
133 | - return client.submit(new AtomixLeaderElectorCommands.Evict(nodeId)); | 103 | + return submit(new AtomixLeaderElectorCommands.Evict(nodeId)); |
134 | } | 104 | } |
135 | 105 | ||
136 | @Override | 106 | @Override |
137 | public CompletableFuture<Leadership> getLeadership(String topic) { | 107 | public CompletableFuture<Leadership> getLeadership(String topic) { |
138 | - return cache.getUnchecked(topic); | 108 | + return submit(new GetLeadership(topic)); |
139 | } | 109 | } |
140 | 110 | ||
141 | @Override | 111 | @Override |
142 | public CompletableFuture<Map<String, Leadership>> getLeaderships() { | 112 | public CompletableFuture<Map<String, Leadership>> getLeaderships() { |
143 | - return client.submit(new GetAllLeaderships()); | 113 | + return submit(new GetAllLeaderships()); |
144 | } | 114 | } |
145 | 115 | ||
146 | public CompletableFuture<Set<String>> getElectedTopics(NodeId nodeId) { | 116 | public CompletableFuture<Set<String>> getElectedTopics(NodeId nodeId) { |
147 | - return client.submit(new GetElectedTopics(nodeId)); | 117 | + return submit(new GetElectedTopics(nodeId)); |
148 | } | 118 | } |
149 | 119 | ||
150 | @Override | 120 | @Override |
151 | public synchronized CompletableFuture<Void> addChangeListener(Consumer<Change<Leadership>> consumer) { | 121 | public synchronized CompletableFuture<Void> addChangeListener(Consumer<Change<Leadership>> consumer) { |
152 | if (leadershipChangeListeners.isEmpty()) { | 122 | if (leadershipChangeListeners.isEmpty()) { |
153 | - return client.submit(new Listen()).thenRun(() -> leadershipChangeListeners.add(consumer)); | 123 | + return submit(new Listen()).thenRun(() -> leadershipChangeListeners.add(consumer)); |
154 | } else { | 124 | } else { |
155 | leadershipChangeListeners.add(consumer); | 125 | leadershipChangeListeners.add(consumer); |
156 | return CompletableFuture.completedFuture(null); | 126 | return CompletableFuture.completedFuture(null); |
... | @@ -160,7 +130,7 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector> | ... | @@ -160,7 +130,7 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector> |
160 | @Override | 130 | @Override |
161 | public synchronized CompletableFuture<Void> removeChangeListener(Consumer<Change<Leadership>> consumer) { | 131 | public synchronized CompletableFuture<Void> removeChangeListener(Consumer<Change<Leadership>> consumer) { |
162 | if (leadershipChangeListeners.remove(consumer) && leadershipChangeListeners.isEmpty()) { | 132 | if (leadershipChangeListeners.remove(consumer) && leadershipChangeListeners.isEmpty()) { |
163 | - return client.submit(new Unlisten()).thenApply(v -> null); | 133 | + return submit(new Unlisten()).thenApply(v -> null); |
164 | } | 134 | } |
165 | return CompletableFuture.completedFuture(null); | 135 | return CompletableFuture.completedFuture(null); |
166 | } | 136 | } | ... | ... |
... | @@ -50,6 +50,11 @@ public final class AtomixLeaderElectorCommands { | ... | @@ -50,6 +50,11 @@ 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 | ||
53 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { | 58 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { |
54 | } | 59 | } |
55 | 60 | ||
... | @@ -98,6 +103,11 @@ public final class AtomixLeaderElectorCommands { | ... | @@ -98,6 +103,11 @@ public final class AtomixLeaderElectorCommands { |
98 | public abstract static class ElectionCommand<V> implements Command<V>, CatalystSerializable { | 103 | public abstract static class ElectionCommand<V> implements Command<V>, CatalystSerializable { |
99 | 104 | ||
100 | @Override | 105 | @Override |
106 | + public ConsistencyLevel consistency() { | ||
107 | + return ConsistencyLevel.LINEARIZABLE; | ||
108 | + } | ||
109 | + | ||
110 | + @Override | ||
101 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { | 111 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { |
102 | } | 112 | } |
103 | 113 | ... | ... |
... | @@ -302,10 +302,8 @@ public class AtomixLeaderElectorState extends ResourceStateMachine | ... | @@ -302,10 +302,8 @@ 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<>(); | ||
306 | try { | 305 | try { |
307 | - result.putAll(Maps.transformEntries(elections, (k, v) -> leadership(k))); | 306 | + return Maps.transformEntries(elections, (k, v) -> leadership(k)); |
308 | - return result; | ||
309 | } finally { | 307 | } finally { |
310 | commit.close(); | 308 | commit.close(); |
311 | } | 309 | } |
... | @@ -541,7 +539,7 @@ public class AtomixLeaderElectorState extends ResourceStateMachine | ... | @@ -541,7 +539,7 @@ public class AtomixLeaderElectorState extends ResourceStateMachine |
541 | byte[] encodedElections = serializer.encode(elections); | 539 | byte[] encodedElections = serializer.encode(elections); |
542 | writer.writeInt(encodedElections.length); | 540 | writer.writeInt(encodedElections.length); |
543 | writer.write(encodedElections); | 541 | writer.write(encodedElections); |
544 | - log.debug("Took state machine snapshot"); | 542 | + log.info("Took state machine snapshot"); |
545 | } | 543 | } |
546 | 544 | ||
547 | @Override | 545 | @Override |
... | @@ -554,7 +552,7 @@ public class AtomixLeaderElectorState extends ResourceStateMachine | ... | @@ -554,7 +552,7 @@ public class AtomixLeaderElectorState extends ResourceStateMachine |
554 | byte[] encodedElections = new byte[encodedElectionsSize]; | 552 | byte[] encodedElections = new byte[encodedElectionsSize]; |
555 | reader.read(encodedElections); | 553 | reader.read(encodedElections); |
556 | elections = serializer.decode(encodedElections); | 554 | elections = serializer.decode(encodedElections); |
557 | - log.debug("Reinstated state machine from snapshot"); | 555 | + log.info("Reinstated state machine from snapshot"); |
558 | } | 556 | } |
559 | 557 | ||
560 | private AtomicLong termCounter(String topic) { | 558 | private AtomicLong termCounter(String topic) { | ... | ... |
... | @@ -20,15 +20,13 @@ import com.google.common.collect.Lists; | ... | @@ -20,15 +20,13 @@ 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 | - | ||
24 | import io.atomix.catalyst.transport.Address; | 23 | import io.atomix.catalyst.transport.Address; |
25 | -import io.atomix.catalyst.transport.local.LocalTransport; | 24 | +import io.atomix.catalyst.transport.LocalTransport; |
26 | import io.atomix.copycat.server.CopycatServer; | 25 | import io.atomix.copycat.server.CopycatServer; |
27 | import io.atomix.copycat.server.storage.Storage; | 26 | import io.atomix.copycat.server.storage.Storage; |
28 | import io.atomix.copycat.server.storage.StorageLevel; | 27 | import io.atomix.copycat.server.storage.StorageLevel; |
29 | -import io.atomix.manager.internal.ResourceManagerState; | 28 | +import io.atomix.manager.state.ResourceManagerState; |
30 | import io.atomix.resource.ResourceType; | 29 | import io.atomix.resource.ResourceType; |
31 | - | ||
32 | import org.apache.commons.collections.keyvalue.DefaultMapEntry; | 30 | import org.apache.commons.collections.keyvalue.DefaultMapEntry; |
33 | import org.junit.Ignore; | 31 | import org.junit.Ignore; |
34 | import org.junit.Test; | 32 | import org.junit.Test; |
... | @@ -429,7 +427,7 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase { | ... | @@ -429,7 +427,7 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase { |
429 | 427 | ||
430 | @Override | 428 | @Override |
431 | protected CopycatServer createCopycatServer(Address address) { | 429 | protected CopycatServer createCopycatServer(Address address) { |
432 | - CopycatServer server = CopycatServer.builder(address) | 430 | + CopycatServer server = CopycatServer.builder(address, members) |
433 | .withTransport(new LocalTransport(registry)) | 431 | .withTransport(new LocalTransport(registry)) |
434 | .withStorage(Storage.builder() | 432 | .withStorage(Storage.builder() |
435 | .withStorageLevel(StorageLevel.MEMORY) | 433 | .withStorageLevel(StorageLevel.MEMORY) |
... | @@ -442,8 +440,7 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase { | ... | @@ -442,8 +440,7 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase { |
442 | .withSessionTimeout(Duration.ofMillis(100)) | 440 | .withSessionTimeout(Duration.ofMillis(100)) |
443 | .build(); | 441 | .build(); |
444 | copycatServers.add(server); | 442 | copycatServers.add(server); |
445 | - return server; | 443 | + return server; } |
446 | - } | ||
447 | 444 | ||
448 | /** | 445 | /** |
449 | * Returns two arrays contain the same set of elements, | 446 | * Returns two arrays contain the same set of elements, | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
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 | + | ||
19 | import static org.hamcrest.Matchers.*; | 20 | import static org.hamcrest.Matchers.*; |
20 | import static org.junit.Assert.*; | 21 | import static org.junit.Assert.*; |
21 | 22 | ||
... | @@ -27,6 +28,7 @@ import java.util.concurrent.BlockingQueue; | ... | @@ -27,6 +28,7 @@ import java.util.concurrent.BlockingQueue; |
27 | import java.util.concurrent.CompletionException; | 28 | import java.util.concurrent.CompletionException; |
28 | import java.util.stream.Collectors; | 29 | import java.util.stream.Collectors; |
29 | 30 | ||
31 | +import org.junit.Ignore; | ||
30 | import org.junit.Test; | 32 | import org.junit.Test; |
31 | import org.onlab.util.Tools; | 33 | import org.onlab.util.Tools; |
32 | import org.onosproject.store.primitives.MapUpdate; | 34 | import org.onosproject.store.primitives.MapUpdate; |
... | @@ -42,6 +44,7 @@ import com.google.common.collect.Sets; | ... | @@ -42,6 +44,7 @@ import com.google.common.collect.Sets; |
42 | /** | 44 | /** |
43 | * Unit tests for {@link AtomixConsistentMap}. | 45 | * Unit tests for {@link AtomixConsistentMap}. |
44 | */ | 46 | */ |
47 | +@Ignore | ||
45 | public class AtomixConsistentMapTest extends AtomixTestBase { | 48 | public class AtomixConsistentMapTest extends AtomixTestBase { |
46 | 49 | ||
47 | @Override | 50 | @Override |
... | @@ -54,6 +57,10 @@ public class AtomixConsistentMapTest extends AtomixTestBase { | ... | @@ -54,6 +57,10 @@ public class AtomixConsistentMapTest extends AtomixTestBase { |
54 | */ | 57 | */ |
55 | @Test | 58 | @Test |
56 | public void testBasicMapOperations() throws Throwable { | 59 | public void testBasicMapOperations() throws Throwable { |
60 | + basicMapOperationTests(1); | ||
61 | + clearTests(); | ||
62 | + basicMapOperationTests(2); | ||
63 | + clearTests(); | ||
57 | basicMapOperationTests(3); | 64 | basicMapOperationTests(3); |
58 | } | 65 | } |
59 | 66 | ||
... | @@ -62,6 +69,10 @@ public class AtomixConsistentMapTest extends AtomixTestBase { | ... | @@ -62,6 +69,10 @@ public class AtomixConsistentMapTest extends AtomixTestBase { |
62 | */ | 69 | */ |
63 | @Test | 70 | @Test |
64 | public void testMapComputeOperations() throws Throwable { | 71 | public void testMapComputeOperations() throws Throwable { |
72 | + mapComputeOperationTests(1); | ||
73 | + clearTests(); | ||
74 | + mapComputeOperationTests(2); | ||
75 | + clearTests(); | ||
65 | mapComputeOperationTests(3); | 76 | mapComputeOperationTests(3); |
66 | } | 77 | } |
67 | 78 | ||
... | @@ -70,6 +81,10 @@ public class AtomixConsistentMapTest extends AtomixTestBase { | ... | @@ -70,6 +81,10 @@ public class AtomixConsistentMapTest extends AtomixTestBase { |
70 | */ | 81 | */ |
71 | @Test | 82 | @Test |
72 | public void testMapListeners() throws Throwable { | 83 | public void testMapListeners() throws Throwable { |
84 | + mapListenerTests(1); | ||
85 | + clearTests(); | ||
86 | + mapListenerTests(2); | ||
87 | + clearTests(); | ||
73 | mapListenerTests(3); | 88 | mapListenerTests(3); |
74 | } | 89 | } |
75 | 90 | ||
... | @@ -78,6 +93,10 @@ public class AtomixConsistentMapTest extends AtomixTestBase { | ... | @@ -78,6 +93,10 @@ public class AtomixConsistentMapTest extends AtomixTestBase { |
78 | */ | 93 | */ |
79 | @Test | 94 | @Test |
80 | public void testTransactionCommit() throws Throwable { | 95 | public void testTransactionCommit() throws Throwable { |
96 | + transactionCommitTests(1); | ||
97 | + clearTests(); | ||
98 | + transactionCommitTests(2); | ||
99 | + clearTests(); | ||
81 | transactionCommitTests(3); | 100 | transactionCommitTests(3); |
82 | } | 101 | } |
83 | 102 | ||
... | @@ -86,6 +105,10 @@ public class AtomixConsistentMapTest extends AtomixTestBase { | ... | @@ -86,6 +105,10 @@ public class AtomixConsistentMapTest extends AtomixTestBase { |
86 | */ | 105 | */ |
87 | @Test | 106 | @Test |
88 | public void testTransactionRollback() throws Throwable { | 107 | public void testTransactionRollback() throws Throwable { |
108 | + transactionRollbackTests(1); | ||
109 | + clearTests(); | ||
110 | + transactionRollbackTests(2); | ||
111 | + clearTests(); | ||
89 | transactionRollbackTests(3); | 112 | transactionRollbackTests(3); |
90 | } | 113 | } |
91 | 114 | ... | ... |
... | @@ -20,6 +20,7 @@ import java.util.Queue; | ... | @@ -20,6 +20,7 @@ import java.util.Queue; |
20 | import java.util.concurrent.CompletableFuture; | 20 | import java.util.concurrent.CompletableFuture; |
21 | import java.util.function.Consumer; | 21 | import java.util.function.Consumer; |
22 | 22 | ||
23 | +import org.junit.Ignore; | ||
23 | import org.junit.Test; | 24 | import org.junit.Test; |
24 | 25 | ||
25 | import static org.junit.Assert.*; | 26 | import static org.junit.Assert.*; |
... | @@ -29,12 +30,12 @@ import org.onosproject.cluster.NodeId; | ... | @@ -29,12 +30,12 @@ import org.onosproject.cluster.NodeId; |
29 | import org.onosproject.event.Change; | 30 | import org.onosproject.event.Change; |
30 | 31 | ||
31 | import io.atomix.Atomix; | 32 | import io.atomix.Atomix; |
32 | -import io.atomix.AtomixClient; | ||
33 | import io.atomix.resource.ResourceType; | 33 | import io.atomix.resource.ResourceType; |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * Unit tests for {@link AtomixLeaderElector}. | 36 | * Unit tests for {@link AtomixLeaderElector}. |
37 | */ | 37 | */ |
38 | +@Ignore | ||
38 | public class AtomixLeaderElectorTest extends AtomixTestBase { | 39 | public class AtomixLeaderElectorTest extends AtomixTestBase { |
39 | 40 | ||
40 | NodeId node1 = new NodeId("node1"); | 41 | NodeId node1 = new NodeId("node1"); |
... | @@ -48,7 +49,12 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { | ... | @@ -48,7 +49,12 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { |
48 | 49 | ||
49 | @Test | 50 | @Test |
50 | public void testRun() throws Throwable { | 51 | public void testRun() throws Throwable { |
52 | + leaderElectorRunTests(1); | ||
53 | + clearTests(); | ||
54 | + leaderElectorRunTests(2); | ||
55 | + clearTests(); | ||
51 | leaderElectorRunTests(3); | 56 | leaderElectorRunTests(3); |
57 | + clearTests(); | ||
52 | } | 58 | } |
53 | 59 | ||
54 | private void leaderElectorRunTests(int numServers) throws Throwable { | 60 | private void leaderElectorRunTests(int numServers) throws Throwable { |
... | @@ -74,7 +80,12 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { | ... | @@ -74,7 +80,12 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { |
74 | 80 | ||
75 | @Test | 81 | @Test |
76 | public void testWithdraw() throws Throwable { | 82 | public void testWithdraw() throws Throwable { |
83 | + leaderElectorWithdrawTests(1); | ||
84 | + clearTests(); | ||
85 | + leaderElectorWithdrawTests(2); | ||
86 | + clearTests(); | ||
77 | leaderElectorWithdrawTests(3); | 87 | leaderElectorWithdrawTests(3); |
88 | + clearTests(); | ||
78 | } | 89 | } |
79 | 90 | ||
80 | private void leaderElectorWithdrawTests(int numServers) throws Throwable { | 91 | private void leaderElectorWithdrawTests(int numServers) throws Throwable { |
... | @@ -111,7 +122,12 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { | ... | @@ -111,7 +122,12 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { |
111 | 122 | ||
112 | @Test | 123 | @Test |
113 | public void testAnoint() throws Throwable { | 124 | public void testAnoint() throws Throwable { |
125 | + leaderElectorAnointTests(1); | ||
126 | + clearTests(); | ||
127 | + leaderElectorAnointTests(2); | ||
128 | + clearTests(); | ||
114 | leaderElectorAnointTests(3); | 129 | leaderElectorAnointTests(3); |
130 | + clearTests(); | ||
115 | } | 131 | } |
116 | 132 | ||
117 | private void leaderElectorAnointTests(int numServers) throws Throwable { | 133 | private void leaderElectorAnointTests(int numServers) throws Throwable { |
... | @@ -142,6 +158,9 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { | ... | @@ -142,6 +158,9 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { |
142 | elector3.anoint("foo", node2).thenAccept(result -> { | 158 | elector3.anoint("foo", node2).thenAccept(result -> { |
143 | assertTrue(result); | 159 | assertTrue(result); |
144 | }).join(); | 160 | }).join(); |
161 | + assertTrue(listener1.hasEvent()); | ||
162 | + assertTrue(listener2.hasEvent()); | ||
163 | + assertTrue(listener3.hasEvent()); | ||
145 | 164 | ||
146 | listener1.nextEvent().thenAccept(result -> { | 165 | listener1.nextEvent().thenAccept(result -> { |
147 | assertEquals(node2, result.newValue().leaderNodeId()); | 166 | assertEquals(node2, result.newValue().leaderNodeId()); |
... | @@ -165,16 +184,21 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { | ... | @@ -165,16 +184,21 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { |
165 | 184 | ||
166 | @Test | 185 | @Test |
167 | public void testPromote() throws Throwable { | 186 | public void testPromote() throws Throwable { |
187 | + leaderElectorPromoteTests(1); | ||
188 | + clearTests(); | ||
189 | + leaderElectorPromoteTests(2); | ||
190 | + clearTests(); | ||
168 | leaderElectorPromoteTests(3); | 191 | leaderElectorPromoteTests(3); |
192 | + clearTests(); | ||
169 | } | 193 | } |
170 | 194 | ||
171 | private void leaderElectorPromoteTests(int numServers) throws Throwable { | 195 | private void leaderElectorPromoteTests(int numServers) throws Throwable { |
172 | createCopycatServers(numServers); | 196 | createCopycatServers(numServers); |
173 | - AtomixClient client1 = createAtomixClient(); | 197 | + Atomix client1 = createAtomixClient(); |
174 | AtomixLeaderElector elector1 = client1.getResource("test-elector", AtomixLeaderElector.class).join(); | 198 | AtomixLeaderElector elector1 = client1.getResource("test-elector", AtomixLeaderElector.class).join(); |
175 | - AtomixClient client2 = createAtomixClient(); | 199 | + Atomix client2 = createAtomixClient(); |
176 | AtomixLeaderElector elector2 = client2.getResource("test-elector", AtomixLeaderElector.class).join(); | 200 | AtomixLeaderElector elector2 = client2.getResource("test-elector", AtomixLeaderElector.class).join(); |
177 | - AtomixClient client3 = createAtomixClient(); | 201 | + Atomix client3 = createAtomixClient(); |
178 | AtomixLeaderElector elector3 = client3.getResource("test-elector", AtomixLeaderElector.class).join(); | 202 | AtomixLeaderElector elector3 = client3.getResource("test-elector", AtomixLeaderElector.class).join(); |
179 | elector1.run("foo", node1).join(); | 203 | elector1.run("foo", node1).join(); |
180 | elector2.run("foo", node2).join(); | 204 | elector2.run("foo", node2).join(); |
... | @@ -196,15 +220,9 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { | ... | @@ -196,15 +220,9 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { |
196 | 220 | ||
197 | elector3.run("foo", node3).join(); | 221 | elector3.run("foo", node3).join(); |
198 | 222 | ||
199 | - listener1.nextEvent().thenAccept(result -> { | 223 | + listener1.clearEvents(); |
200 | - assertEquals(node3, result.newValue().candidates().get(2)); | 224 | + listener2.clearEvents(); |
201 | - }).join(); | 225 | + listener3.clearEvents(); |
202 | - listener2.nextEvent().thenAccept(result -> { | ||
203 | - assertEquals(node3, result.newValue().candidates().get(2)); | ||
204 | - }).join(); | ||
205 | - listener3.nextEvent().thenAccept(result -> { | ||
206 | - assertEquals(node3, result.newValue().candidates().get(2)); | ||
207 | - }).join(); | ||
208 | 226 | ||
209 | elector3.promote("foo", node3).thenAccept(result -> { | 227 | elector3.promote("foo", node3).thenAccept(result -> { |
210 | assertTrue(result); | 228 | assertTrue(result); |
... | @@ -223,12 +241,17 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { | ... | @@ -223,12 +241,17 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { |
223 | 241 | ||
224 | @Test | 242 | @Test |
225 | public void testLeaderSessionClose() throws Throwable { | 243 | public void testLeaderSessionClose() throws Throwable { |
244 | + leaderElectorLeaderSessionCloseTests(1); | ||
245 | + clearTests(); | ||
246 | + leaderElectorLeaderSessionCloseTests(2); | ||
247 | + clearTests(); | ||
226 | leaderElectorLeaderSessionCloseTests(3); | 248 | leaderElectorLeaderSessionCloseTests(3); |
249 | + clearTests(); | ||
227 | } | 250 | } |
228 | 251 | ||
229 | private void leaderElectorLeaderSessionCloseTests(int numServers) throws Throwable { | 252 | private void leaderElectorLeaderSessionCloseTests(int numServers) throws Throwable { |
230 | createCopycatServers(numServers); | 253 | createCopycatServers(numServers); |
231 | - AtomixClient client1 = createAtomixClient(); | 254 | + Atomix client1 = createAtomixClient(); |
232 | AtomixLeaderElector elector1 = client1.getResource("test-elector", AtomixLeaderElector.class).join(); | 255 | AtomixLeaderElector elector1 = client1.getResource("test-elector", AtomixLeaderElector.class).join(); |
233 | elector1.run("foo", node1).join(); | 256 | elector1.run("foo", node1).join(); |
234 | Atomix client2 = createAtomixClient(); | 257 | Atomix client2 = createAtomixClient(); |
... | @@ -246,7 +269,12 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { | ... | @@ -246,7 +269,12 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { |
246 | 269 | ||
247 | @Test | 270 | @Test |
248 | public void testNonLeaderSessionClose() throws Throwable { | 271 | public void testNonLeaderSessionClose() throws Throwable { |
272 | + leaderElectorNonLeaderSessionCloseTests(1); | ||
273 | + clearTests(); | ||
274 | + leaderElectorNonLeaderSessionCloseTests(2); | ||
275 | + clearTests(); | ||
249 | leaderElectorNonLeaderSessionCloseTests(3); | 276 | leaderElectorNonLeaderSessionCloseTests(3); |
277 | + clearTests(); | ||
250 | } | 278 | } |
251 | 279 | ||
252 | private void leaderElectorNonLeaderSessionCloseTests(int numServers) throws Throwable { | 280 | private void leaderElectorNonLeaderSessionCloseTests(int numServers) throws Throwable { |
... | @@ -254,7 +282,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { | ... | @@ -254,7 +282,7 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { |
254 | Atomix client1 = createAtomixClient(); | 282 | Atomix client1 = createAtomixClient(); |
255 | AtomixLeaderElector elector1 = client1.getResource("test-elector", AtomixLeaderElector.class).join(); | 283 | AtomixLeaderElector elector1 = client1.getResource("test-elector", AtomixLeaderElector.class).join(); |
256 | elector1.run("foo", node1).join(); | 284 | elector1.run("foo", node1).join(); |
257 | - AtomixClient client2 = createAtomixClient(); | 285 | + Atomix client2 = createAtomixClient(); |
258 | AtomixLeaderElector elector2 = client2.getResource("test-elector", AtomixLeaderElector.class).join(); | 286 | AtomixLeaderElector elector2 = client2.getResource("test-elector", AtomixLeaderElector.class).join(); |
259 | LeaderEventListener listener = new LeaderEventListener(); | 287 | LeaderEventListener listener = new LeaderEventListener(); |
260 | elector2.run("foo", node2).join(); | 288 | elector2.run("foo", node2).join(); |
... | @@ -269,7 +297,12 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { | ... | @@ -269,7 +297,12 @@ public class AtomixLeaderElectorTest extends AtomixTestBase { |
269 | 297 | ||
270 | @Test | 298 | @Test |
271 | public void testQueries() throws Throwable { | 299 | public void testQueries() throws Throwable { |
300 | + leaderElectorQueryTests(1); | ||
301 | + clearTests(); | ||
302 | + leaderElectorQueryTests(2); | ||
303 | + clearTests(); | ||
272 | leaderElectorQueryTests(3); | 304 | leaderElectorQueryTests(3); |
305 | + clearTests(); | ||
273 | } | 306 | } |
274 | 307 | ||
275 | private void leaderElectorQueryTests(int numServers) throws Throwable { | 308 | private void leaderElectorQueryTests(int numServers) throws Throwable { | ... | ... |
... | @@ -17,6 +17,7 @@ package org.onosproject.store.primitives.resources.impl; | ... | @@ -17,6 +17,7 @@ package org.onosproject.store.primitives.resources.impl; |
17 | 17 | ||
18 | import static org.junit.Assert.*; | 18 | import static org.junit.Assert.*; |
19 | 19 | ||
20 | +import org.junit.Ignore; | ||
20 | import org.junit.Test; | 21 | import org.junit.Test; |
21 | 22 | ||
22 | import io.atomix.Atomix; | 23 | import io.atomix.Atomix; |
... | @@ -26,6 +27,7 @@ import io.atomix.variables.DistributedLong; | ... | @@ -26,6 +27,7 @@ import io.atomix.variables.DistributedLong; |
26 | /** | 27 | /** |
27 | * Unit tests for {@link AtomixCounter}. | 28 | * Unit tests for {@link AtomixCounter}. |
28 | */ | 29 | */ |
30 | +@Ignore | ||
29 | public class AtomixLongTest extends AtomixTestBase { | 31 | public class AtomixLongTest extends AtomixTestBase { |
30 | 32 | ||
31 | @Override | 33 | @Override |
... | @@ -35,7 +37,12 @@ public class AtomixLongTest extends AtomixTestBase { | ... | @@ -35,7 +37,12 @@ public class AtomixLongTest extends AtomixTestBase { |
35 | 37 | ||
36 | @Test | 38 | @Test |
37 | public void testBasicOperations() throws Throwable { | 39 | public void testBasicOperations() throws Throwable { |
40 | + basicOperationsTest(1); | ||
41 | + clearTests(); | ||
42 | + basicOperationsTest(2); | ||
43 | + clearTests(); | ||
38 | basicOperationsTest(3); | 44 | basicOperationsTest(3); |
45 | + clearTests(); | ||
39 | } | 46 | } |
40 | 47 | ||
41 | protected void basicOperationsTest(int clusterSize) throws Throwable { | 48 | protected void basicOperationsTest(int clusterSize) throws Throwable { | ... | ... |
... | @@ -15,16 +15,17 @@ | ... | @@ -15,16 +15,17 @@ |
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; | ||
18 | import io.atomix.AtomixClient; | 19 | import io.atomix.AtomixClient; |
19 | import io.atomix.catalyst.serializer.Serializer; | 20 | import io.atomix.catalyst.serializer.Serializer; |
20 | import io.atomix.catalyst.transport.Address; | 21 | import io.atomix.catalyst.transport.Address; |
21 | -import io.atomix.catalyst.transport.local.LocalServerRegistry; | 22 | +import io.atomix.catalyst.transport.LocalServerRegistry; |
22 | -import io.atomix.catalyst.transport.local.LocalTransport; | 23 | +import io.atomix.catalyst.transport.LocalTransport; |
23 | import io.atomix.copycat.client.CopycatClient; | 24 | import io.atomix.copycat.client.CopycatClient; |
24 | import io.atomix.copycat.server.CopycatServer; | 25 | import io.atomix.copycat.server.CopycatServer; |
25 | import io.atomix.copycat.server.storage.Storage; | 26 | import io.atomix.copycat.server.storage.Storage; |
26 | import io.atomix.copycat.server.storage.StorageLevel; | 27 | import io.atomix.copycat.server.storage.StorageLevel; |
27 | -import io.atomix.manager.internal.ResourceManagerState; | 28 | +import io.atomix.manager.state.ResourceManagerState; |
28 | import io.atomix.resource.ResourceType; | 29 | import io.atomix.resource.ResourceType; |
29 | 30 | ||
30 | import java.io.File; | 31 | import java.io.File; |
... | @@ -52,7 +53,7 @@ public abstract class AtomixTestBase { | ... | @@ -52,7 +53,7 @@ public abstract class AtomixTestBase { |
52 | protected List<Address> members; | 53 | protected List<Address> members; |
53 | protected List<CopycatClient> copycatClients = new ArrayList<>(); | 54 | protected List<CopycatClient> copycatClients = new ArrayList<>(); |
54 | protected List<CopycatServer> copycatServers = new ArrayList<>(); | 55 | protected List<CopycatServer> copycatServers = new ArrayList<>(); |
55 | - protected List<AtomixClient> atomixClients = new ArrayList<>(); | 56 | + protected List<Atomix> atomixClients = new ArrayList<>(); |
56 | protected List<CopycatServer> atomixServers = new ArrayList<>(); | 57 | protected List<CopycatServer> atomixServers = new ArrayList<>(); |
57 | protected Serializer serializer = CatalystSerializers.getSerializer(); | 58 | protected Serializer serializer = CatalystSerializers.getSerializer(); |
58 | 59 | ||
... | @@ -88,7 +89,7 @@ public abstract class AtomixTestBase { | ... | @@ -88,7 +89,7 @@ public abstract class AtomixTestBase { |
88 | 89 | ||
89 | for (int i = 0; i < nodes; i++) { | 90 | for (int i = 0; i < nodes; i++) { |
90 | CopycatServer server = createCopycatServer(members.get(i)); | 91 | CopycatServer server = createCopycatServer(members.get(i)); |
91 | - server.bootstrap(members).thenRun(latch::countDown); | 92 | + server.start().thenRun(latch::countDown); |
92 | servers.add(server); | 93 | servers.add(server); |
93 | } | 94 | } |
94 | 95 | ||
... | @@ -101,7 +102,7 @@ public abstract class AtomixTestBase { | ... | @@ -101,7 +102,7 @@ public abstract class AtomixTestBase { |
101 | * Creates a Copycat server. | 102 | * Creates a Copycat server. |
102 | */ | 103 | */ |
103 | protected CopycatServer createCopycatServer(Address address) { | 104 | protected CopycatServer createCopycatServer(Address address) { |
104 | - CopycatServer server = CopycatServer.builder(address) | 105 | + CopycatServer server = CopycatServer.builder(address, members) |
105 | .withTransport(new LocalTransport(registry)) | 106 | .withTransport(new LocalTransport(registry)) |
106 | .withStorage(Storage.builder() | 107 | .withStorage(Storage.builder() |
107 | .withStorageLevel(StorageLevel.DISK) | 108 | .withStorageLevel(StorageLevel.DISK) |
... | @@ -126,11 +127,11 @@ public abstract class AtomixTestBase { | ... | @@ -126,11 +127,11 @@ public abstract class AtomixTestBase { |
126 | 127 | ||
127 | CompletableFuture<Void> closeClients = | 128 | CompletableFuture<Void> closeClients = |
128 | CompletableFuture.allOf(atomixClients.stream() | 129 | CompletableFuture.allOf(atomixClients.stream() |
129 | - .map(AtomixClient::close) | 130 | + .map(Atomix::close) |
130 | .toArray(CompletableFuture[]::new)); | 131 | .toArray(CompletableFuture[]::new)); |
131 | 132 | ||
132 | closeClients.thenCompose(v -> CompletableFuture.allOf(copycatServers.stream() | 133 | closeClients.thenCompose(v -> CompletableFuture.allOf(copycatServers.stream() |
133 | - .map(CopycatServer::shutdown) | 134 | + .map(CopycatServer::stop) |
134 | .toArray(CompletableFuture[]::new))).join(); | 135 | .toArray(CompletableFuture[]::new))).join(); |
135 | 136 | ||
136 | deleteDirectory(TEST_DIR); | 137 | deleteDirectory(TEST_DIR); |
... | @@ -162,13 +163,13 @@ public abstract class AtomixTestBase { | ... | @@ -162,13 +163,13 @@ public abstract class AtomixTestBase { |
162 | /** | 163 | /** |
163 | * Creates a Atomix client. | 164 | * Creates a Atomix client. |
164 | */ | 165 | */ |
165 | - protected AtomixClient createAtomixClient() { | 166 | + protected Atomix createAtomixClient() { |
166 | CountDownLatch latch = new CountDownLatch(1); | 167 | CountDownLatch latch = new CountDownLatch(1); |
167 | - AtomixClient client = AtomixClient.builder() | 168 | + Atomix client = AtomixClient.builder(members) |
168 | .withTransport(new LocalTransport(registry)) | 169 | .withTransport(new LocalTransport(registry)) |
169 | .withSerializer(serializer.clone()) | 170 | .withSerializer(serializer.clone()) |
170 | .build(); | 171 | .build(); |
171 | - client.connect(members).thenRun(latch::countDown); | 172 | + client.open().thenRun(latch::countDown); |
172 | atomixClients.add(client); | 173 | atomixClients.add(client); |
173 | Uninterruptibles.awaitUninterruptibly(latch); | 174 | Uninterruptibles.awaitUninterruptibly(latch); |
174 | return client; | 175 | return client; | ... | ... |
... | @@ -3,7 +3,6 @@ osgi_feature ( | ... | @@ -3,7 +3,6 @@ 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', | ||
7 | '//lib:commons-lang', | 6 | '//lib:commons-lang', |
8 | '//lib:commons-lang3', | 7 | '//lib:commons-lang3', |
9 | '//lib:commons-configuration', | 8 | '//lib:commons-configuration', |
... | @@ -34,6 +33,7 @@ osgi_feature ( | ... | @@ -34,6 +33,7 @@ osgi_feature ( |
34 | '//lib:typesafe-config', | 33 | '//lib:typesafe-config', |
35 | '//lib:concurrent-trees', | 34 | '//lib:concurrent-trees', |
36 | '//lib:commons-io', | 35 | '//lib:commons-io', |
36 | + '//lib:onos-atomix', | ||
37 | '//lib:jersey-client', | 37 | '//lib:jersey-client', |
38 | '//lib:mapdb', | 38 | '//lib:mapdb', |
39 | ] | 39 | ] | ... | ... |
... | @@ -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&Bundle-Version=2.4.0</bundle> | 57 | <bundle>wrap:mvn:com.googlecode.concurrent-trees/concurrent-trees/2.4.0$Bundle-SymbolicName=concurrent-trees&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:io.atomix/atomix-all/1.0.0-rc7</bundle> | 59 | + <bundle>mvn:org.onosproject/atomix/1.0.1.onos-SNAPSHOT</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 | ... | ... |
1 | -# ***** This file was auto-generated at Tue May 31 16:32:48 PDT 2016. Do not edit this file manually. ***** | 1 | +# ***** This file was auto-generated at Tue May 31 15:01:52 PDT 2016. Do not edit this file manually. ***** |
2 | osgi_feature_group( | 2 | osgi_feature_group( |
3 | name = 'COMPILE', | 3 | name = 'COMPILE', |
4 | visibility = ['PUBLIC'], | 4 | visibility = ['PUBLIC'], |
... | @@ -133,10 +133,109 @@ remote_jar ( | ... | @@ -133,10 +133,109 @@ remote_jar ( |
133 | 133 | ||
134 | remote_jar ( | 134 | remote_jar ( |
135 | name = 'atomix', | 135 | name = 'atomix', |
136 | - out = 'atomix-all-1.0.0-rc7.jar', | 136 | + out = 'atomix-1.0.0-rc3.jar', |
137 | - url = 'mvn:io.atomix:atomix-all:jar:1.0.0-rc7', | 137 | + url = 'mvn:io.atomix:atomix:jar:1.0.0-rc3', |
138 | - sha1 = 'ad103065adbf02971b6072719a02d6a93753125b', | 138 | + sha1 = 'a572aa9cd069b2d43481901dc901429d0b43332f', |
139 | - maven_coords = 'io.atomix:atomix-all:1.0.0-rc7', | 139 | + maven_coords = 'io.atomix:atomix:1.0.0-rc3', |
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', | ||
140 | visibility = [ 'PUBLIC' ], | 239 | visibility = [ 'PUBLIC' ], |
141 | ) | 240 | ) |
142 | 241 | ||
... | @@ -240,6 +339,87 @@ remote_jar ( | ... | @@ -240,6 +339,87 @@ remote_jar ( |
240 | ) | 339 | ) |
241 | 340 | ||
242 | remote_jar ( | 341 | 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 ( | ||
243 | name = 'easymock', | 423 | name = 'easymock', |
244 | out = 'easymock-3.4.jar', | 424 | out = 'easymock-3.4.jar', |
245 | url = 'mvn:org.easymock:easymock:jar:3.4', | 425 | url = 'mvn:org.easymock:easymock:jar:3.4', | ... | ... |
... | @@ -86,7 +86,19 @@ | ... | @@ -86,7 +86,19 @@ |
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-all:1.0.0-rc7", | 89 | + "atomix": "mvn:io.atomix:atomix:1.0.0-rc3", |
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", | ||
90 | "commons-codec": "mvn:commons-codec:commons-codec:1.10", | 102 | "commons-codec": "mvn:commons-codec:commons-codec:1.10", |
91 | "commons-collections": "mvn:commons-collections:commons-collections:3.2.2", | 103 | "commons-collections": "mvn:commons-collections:commons-collections:3.2.2", |
92 | "commons-configuration": "mvn:commons-configuration:commons-configuration:1.10", | 104 | "commons-configuration": "mvn:commons-configuration:commons-configuration:1.10", |
... | @@ -98,6 +110,15 @@ | ... | @@ -98,6 +110,15 @@ |
98 | "commons-pool": "mvn:commons-pool:commons-pool:1.6", | 110 | "commons-pool": "mvn:commons-pool:commons-pool:1.6", |
99 | "commons-beanutils": "mvn:commons-beanutils:commons-beanutils:1.9.2", | 111 | "commons-beanutils": "mvn:commons-beanutils:commons-beanutils:1.9.2", |
100 | "concurrent-trees": "mvn:com.googlecode.concurrent-trees:concurrent-trees:2.4.0", | 112 | "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", | ||
101 | "easymock": "mvn:org.easymock:easymock:3.4", | 122 | "easymock": "mvn:org.easymock:easymock:3.4", |
102 | "antlr": "mvn:antlr:antlr:2.7.7", | 123 | "antlr": "mvn:antlr:antlr:2.7.7", |
103 | "error_prone_annotations": "mvn:com.google.errorprone:error_prone_annotations:2.0.2", | 124 | "error_prone_annotations": "mvn:com.google.errorprone:error_prone_annotations:2.0.2", | ... | ... |
utils/atomix/pom.xml
0 → 100644
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 | +} |
... | @@ -32,6 +32,7 @@ | ... | @@ -32,6 +32,7 @@ |
32 | <description>Domain agnostic ON.Lab utilities</description> | 32 | <description>Domain agnostic ON.Lab utilities</description> |
33 | 33 | ||
34 | <modules> | 34 | <modules> |
35 | + <module>atomix</module> | ||
35 | <module>junit</module> | 36 | <module>junit</module> |
36 | <module>misc</module> | 37 | <module>misc</module> |
37 | <module>yangutils</module> | 38 | <module>yangutils</module> | ... | ... |
-
Please register or login to post a comment