Committed by
Gerrit Code Review
Moving from local to netty transport.
Change-Id: Id37af6fa4d0971fd34ed18951196dde47bc4a12d
Showing
13 changed files
with
129 additions
and
78 deletions
... | @@ -9,6 +9,12 @@ COMPILE_DEPS = [ | ... | @@ -9,6 +9,12 @@ COMPILE_DEPS = [ |
9 | TEST_DEPS = [ | 9 | TEST_DEPS = [ |
10 | '//lib:TEST', | 10 | '//lib:TEST', |
11 | '//core/api:onos-api-tests', | 11 | '//core/api:onos-api-tests', |
12 | + '//lib:netty-transport', | ||
13 | + '//lib:catalyst-transport', | ||
14 | + '//lib:netty-handler', | ||
15 | + '//lib:netty-buffer', | ||
16 | + '//lib:netty-codec', | ||
17 | + | ||
12 | ] | 18 | ] |
13 | 19 | ||
14 | osgi_jar_with_tests ( | 20 | osgi_jar_with_tests ( | ... | ... |
... | @@ -73,5 +73,22 @@ | ... | @@ -73,5 +73,22 @@ |
73 | <artifactId>atomix</artifactId> | 73 | <artifactId>atomix</artifactId> |
74 | <version>1.0.0-rc8</version> | 74 | <version>1.0.0-rc8</version> |
75 | </dependency> | 75 | </dependency> |
76 | + | ||
77 | + <dependency> | ||
78 | + <groupId>io.atomix.catalyst</groupId> | ||
79 | + <artifactId>catalyst-netty</artifactId> | ||
80 | + <version>1.1.1</version> | ||
81 | + </dependency> | ||
82 | + <dependency> | ||
83 | + <groupId>io.atomix.catalyst</groupId> | ||
84 | + <artifactId>catalyst-transport</artifactId> | ||
85 | + <version>1.1.1</version> | ||
86 | + </dependency> | ||
87 | + <dependency> | ||
88 | + <groupId>org.onosproject</groupId> | ||
89 | + <artifactId>onlab-junit</artifactId> | ||
90 | + <version>${project.version}</version> | ||
91 | + <scope>test</scope> | ||
92 | + </dependency> | ||
76 | </dependencies> | 93 | </dependencies> |
77 | </project> | 94 | </project> | ... | ... |
... | @@ -166,11 +166,13 @@ public final class AsyncConsistentMultimapCommands { | ... | @@ -166,11 +166,13 @@ public final class AsyncConsistentMultimapCommands { |
166 | public void writeObject(BufferOutput<?> buffer, | 166 | public void writeObject(BufferOutput<?> buffer, |
167 | Serializer serializer) { | 167 | Serializer serializer) { |
168 | super.writeObject(buffer, serializer); | 168 | super.writeObject(buffer, serializer); |
169 | + serializer.writeObject(value, buffer); | ||
169 | } | 170 | } |
170 | 171 | ||
171 | @Override | 172 | @Override |
172 | public void readObject(BufferInput<?> buffer, Serializer serializer) { | 173 | public void readObject(BufferInput<?> buffer, Serializer serializer) { |
173 | super.readObject(buffer, serializer); | 174 | super.readObject(buffer, serializer); |
175 | + value = serializer.readObject(buffer); | ||
174 | } | 176 | } |
175 | } | 177 | } |
176 | 178 | ||
... | @@ -548,6 +550,9 @@ public final class AsyncConsistentMultimapCommands { | ... | @@ -548,6 +550,9 @@ public final class AsyncConsistentMultimapCommands { |
548 | */ | 550 | */ |
549 | public static class Get extends | 551 | public static class Get extends |
550 | KeyQuery<Versioned<Collection<? extends byte[]>>> { | 552 | KeyQuery<Versioned<Collection<? extends byte[]>>> { |
553 | + public Get() { | ||
554 | + } | ||
555 | + | ||
551 | public Get(String key) { | 556 | public Get(String key) { |
552 | super(key); | 557 | super(key); |
553 | } | 558 | } | ... | ... |
... | @@ -19,6 +19,7 @@ package org.onosproject.store.primitives.resources.impl; | ... | @@ -19,6 +19,7 @@ package org.onosproject.store.primitives.resources.impl; |
19 | import com.google.common.base.Preconditions; | 19 | import com.google.common.base.Preconditions; |
20 | import com.google.common.collect.HashMultimap; | 20 | import com.google.common.collect.HashMultimap; |
21 | import com.google.common.collect.HashMultiset; | 21 | import com.google.common.collect.HashMultiset; |
22 | +import com.google.common.collect.ImmutableSet; | ||
22 | import com.google.common.collect.Lists; | 23 | import com.google.common.collect.Lists; |
23 | import com.google.common.collect.Maps; | 24 | import com.google.common.collect.Maps; |
24 | import com.google.common.collect.Multiset; | 25 | import com.google.common.collect.Multiset; |
... | @@ -170,6 +171,9 @@ public class AsyncConsistentSetMultimapState extends ResourceStateMachine | ... | @@ -170,6 +171,9 @@ public class AsyncConsistentSetMultimapState extends ResourceStateMachine |
170 | */ | 171 | */ |
171 | protected boolean containsValue(Commit<? extends ContainsValue> commit) { | 172 | protected boolean containsValue(Commit<? extends ContainsValue> commit) { |
172 | try { | 173 | try { |
174 | + if (backingMap.values().isEmpty()) { | ||
175 | + return false; | ||
176 | + } | ||
173 | Match<byte[]> match = Match.ifValue(commit.operation().value()); | 177 | Match<byte[]> match = Match.ifValue(commit.operation().value()); |
174 | return backingMap | 178 | return backingMap |
175 | .values() | 179 | .values() |
... | @@ -230,7 +234,7 @@ public class AsyncConsistentSetMultimapState extends ResourceStateMachine | ... | @@ -230,7 +234,7 @@ public class AsyncConsistentSetMultimapState extends ResourceStateMachine |
230 | */ | 234 | */ |
231 | protected Set<String> keySet(Commit<? extends KeySet> commit) { | 235 | protected Set<String> keySet(Commit<? extends KeySet> commit) { |
232 | try { | 236 | try { |
233 | - return backingMap.keySet(); | 237 | + return ImmutableSet.copyOf(backingMap.keySet()); |
234 | } finally { | 238 | } finally { |
235 | commit.close(); | 239 | commit.close(); |
236 | } | 240 | } |
... | @@ -444,7 +448,7 @@ public class AsyncConsistentSetMultimapState extends ResourceStateMachine | ... | @@ -444,7 +448,7 @@ public class AsyncConsistentSetMultimapState extends ResourceStateMachine |
444 | 448 | ||
445 | @Override | 449 | @Override |
446 | public Collection<? extends byte[]> values() { | 450 | public Collection<? extends byte[]> values() { |
447 | - return valueCountdownMap.keySet(); | 451 | + return ImmutableSet.copyOf(valueCountdownMap.keySet()); |
448 | } | 452 | } |
449 | 453 | ||
450 | @Override | 454 | @Override |
... | @@ -747,4 +751,4 @@ public class AsyncConsistentSetMultimapState extends ResourceStateMachine | ... | @@ -747,4 +751,4 @@ public class AsyncConsistentSetMultimapState extends ResourceStateMachine |
747 | } | 751 | } |
748 | } | 752 | } |
749 | } | 753 | } |
750 | -} | 754 | + } | ... | ... |
... | @@ -182,6 +182,18 @@ public final class AtomixLeaderElectorCommands { | ... | @@ -182,6 +182,18 @@ public final class AtomixLeaderElectorCommands { |
182 | .add("nodeId", nodeId) | 182 | .add("nodeId", nodeId) |
183 | .toString(); | 183 | .toString(); |
184 | } | 184 | } |
185 | + | ||
186 | + @Override | ||
187 | + public void writeObject(BufferOutput<?> buffer, Serializer serializer) { | ||
188 | + super.writeObject(buffer, serializer); | ||
189 | + serializer.writeObject(nodeId, buffer); | ||
190 | + } | ||
191 | + | ||
192 | + @Override | ||
193 | + public void readObject(BufferInput<?> buffer, Serializer serializer) { | ||
194 | + super.readObject(buffer, serializer); | ||
195 | + nodeId = serializer.readObject(buffer); | ||
196 | + } | ||
185 | } | 197 | } |
186 | 198 | ||
187 | /** | 199 | /** | ... | ... |
... | @@ -16,6 +16,8 @@ | ... | @@ -16,6 +16,8 @@ |
16 | package org.onosproject.store.primitives.resources.impl; | 16 | package org.onosproject.store.primitives.resources.impl; |
17 | 17 | ||
18 | import static org.slf4j.LoggerFactory.getLogger; | 18 | import static org.slf4j.LoggerFactory.getLogger; |
19 | + | ||
20 | +import com.google.common.collect.ImmutableSet; | ||
19 | import io.atomix.copycat.server.session.ServerSession; | 21 | import io.atomix.copycat.server.session.ServerSession; |
20 | import io.atomix.copycat.server.Commit; | 22 | import io.atomix.copycat.server.Commit; |
21 | import io.atomix.copycat.server.Snapshottable; | 23 | import io.atomix.copycat.server.Snapshottable; |
... | @@ -287,10 +289,10 @@ public class AtomixLeaderElectorState extends ResourceStateMachine | ... | @@ -287,10 +289,10 @@ public class AtomixLeaderElectorState extends ResourceStateMachine |
287 | public Set<String> electedTopics(Commit<? extends GetElectedTopics> commit) { | 289 | public Set<String> electedTopics(Commit<? extends GetElectedTopics> commit) { |
288 | try { | 290 | try { |
289 | NodeId nodeId = commit.operation().nodeId(); | 291 | NodeId nodeId = commit.operation().nodeId(); |
290 | - return Maps.filterEntries(elections, e -> { | 292 | + return ImmutableSet.copyOf(Maps.filterEntries(elections, e -> { |
291 | Leader leader = leadership(e.getKey()).leader(); | 293 | Leader leader = leadership(e.getKey()).leader(); |
292 | return leader != null && leader.nodeId().equals(nodeId); | 294 | return leader != null && leader.nodeId().equals(nodeId); |
293 | - }).keySet(); | 295 | + }).keySet()); |
294 | } finally { | 296 | } finally { |
295 | commit.close(); | 297 | commit.close(); |
296 | } | 298 | } | ... | ... |
... | @@ -20,27 +20,18 @@ import com.google.common.collect.Lists; | ... | @@ -20,27 +20,18 @@ 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; | ||
25 | -import io.atomix.catalyst.transport.local.LocalTransport; | ||
26 | -import io.atomix.copycat.server.CopycatServer; | ||
27 | -import io.atomix.copycat.server.storage.Storage; | ||
28 | -import io.atomix.copycat.server.storage.StorageLevel; | ||
29 | -import io.atomix.manager.internal.ResourceManagerState; | ||
30 | import io.atomix.resource.ResourceType; | 23 | import io.atomix.resource.ResourceType; |
31 | - | ||
32 | import org.apache.commons.collections.keyvalue.DefaultMapEntry; | 24 | import org.apache.commons.collections.keyvalue.DefaultMapEntry; |
33 | -import org.junit.Ignore; | ||
34 | import org.junit.Test; | 25 | import org.junit.Test; |
35 | import org.onlab.util.Tools; | 26 | import org.onlab.util.Tools; |
36 | 27 | ||
37 | import java.io.File; | 28 | import java.io.File; |
38 | -import java.time.Duration; | ||
39 | import java.util.Arrays; | 29 | import java.util.Arrays; |
40 | import java.util.Collection; | 30 | import java.util.Collection; |
41 | import java.util.Comparator; | 31 | import java.util.Comparator; |
42 | import java.util.List; | 32 | import java.util.List; |
43 | import java.util.Map; | 33 | import java.util.Map; |
34 | +import java.util.concurrent.atomic.AtomicInteger; | ||
44 | 35 | ||
45 | import static org.junit.Assert.assertEquals; | 36 | import static org.junit.Assert.assertEquals; |
46 | import static org.junit.Assert.assertFalse; | 37 | import static org.junit.Assert.assertFalse; |
... | @@ -49,7 +40,6 @@ import static org.junit.Assert.assertTrue; | ... | @@ -49,7 +40,6 @@ import static org.junit.Assert.assertTrue; |
49 | /** | 40 | /** |
50 | * Tests the {@link AsyncConsistentSetMultimap}. | 41 | * Tests the {@link AsyncConsistentSetMultimap}. |
51 | */ | 42 | */ |
52 | -@Ignore | ||
53 | public class AsyncConsistentSetMultimapTest extends AtomixTestBase { | 43 | public class AsyncConsistentSetMultimapTest extends AtomixTestBase { |
54 | private final File testDir = Files.createTempDir(); | 44 | private final File testDir = Files.createTempDir(); |
55 | private final String keyOne = "hello"; | 45 | private final String keyOne = "hello"; |
... | @@ -66,6 +56,7 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase { | ... | @@ -66,6 +56,7 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase { |
66 | valueTwo, | 56 | valueTwo, |
67 | valueThree, | 57 | valueThree, |
68 | valueFour); | 58 | valueFour); |
59 | + private final AtomicInteger port = new AtomicInteger(49200); | ||
69 | 60 | ||
70 | @Override | 61 | @Override |
71 | protected ResourceType resourceType() { | 62 | protected ResourceType resourceType() { |
... | @@ -411,7 +402,6 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase { | ... | @@ -411,7 +402,6 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase { |
411 | clearTests(); | 402 | clearTests(); |
412 | } | 403 | } |
413 | 404 | ||
414 | - | ||
415 | private AsyncConsistentSetMultimap createResource(int clusterSize) { | 405 | private AsyncConsistentSetMultimap createResource(int clusterSize) { |
416 | try { | 406 | try { |
417 | createCopycatServers(clusterSize); | 407 | createCopycatServers(clusterSize); |
... | @@ -424,24 +414,6 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase { | ... | @@ -424,24 +414,6 @@ public class AsyncConsistentSetMultimapTest extends AtomixTestBase { |
424 | } | 414 | } |
425 | } | 415 | } |
426 | 416 | ||
427 | - @Override | ||
428 | - protected CopycatServer createCopycatServer(Address address) { | ||
429 | - CopycatServer server = CopycatServer.builder(address) | ||
430 | - .withTransport(new LocalTransport(registry)) | ||
431 | - .withStorage(Storage.builder() | ||
432 | - .withStorageLevel(StorageLevel.MEMORY) | ||
433 | - .withDirectory(testDir + "/" + address.port()) | ||
434 | - .build()) | ||
435 | - .withStateMachine(ResourceManagerState::new) | ||
436 | - .withSerializer(serializer.clone()) | ||
437 | - .withHeartbeatInterval(Duration.ofMillis(25)) | ||
438 | - .withElectionTimeout(Duration.ofMillis(50)) | ||
439 | - .withSessionTimeout(Duration.ofMillis(100)) | ||
440 | - .build(); | ||
441 | - copycatServers.add(server); | ||
442 | - return server; | ||
443 | - } | ||
444 | - | ||
445 | /** | 417 | /** |
446 | * Returns two arrays contain the same set of elements, | 418 | * Returns two arrays contain the same set of elements, |
447 | * regardless of order. | 419 | * regardless of order. | ... | ... |
... | @@ -15,19 +15,9 @@ | ... | @@ -15,19 +15,9 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.store.primitives.resources.impl; | 16 | package org.onosproject.store.primitives.resources.impl; |
17 | 17 | ||
18 | +import com.google.common.base.Throwables; | ||
19 | +import com.google.common.collect.Sets; | ||
18 | import io.atomix.resource.ResourceType; | 20 | import io.atomix.resource.ResourceType; |
19 | -import static org.hamcrest.Matchers.*; | ||
20 | -import static org.junit.Assert.*; | ||
21 | - | ||
22 | -import java.util.Arrays; | ||
23 | -import java.util.ConcurrentModificationException; | ||
24 | -import java.util.List; | ||
25 | -import java.util.concurrent.ArrayBlockingQueue; | ||
26 | -import java.util.concurrent.BlockingQueue; | ||
27 | -import java.util.concurrent.CompletionException; | ||
28 | -import java.util.stream.Collectors; | ||
29 | - | ||
30 | -import org.junit.Ignore; | ||
31 | import org.junit.Test; | 21 | import org.junit.Test; |
32 | import org.onlab.util.Tools; | 22 | import org.onlab.util.Tools; |
33 | import org.onosproject.store.primitives.MapUpdate; | 23 | import org.onosproject.store.primitives.MapUpdate; |
... | @@ -37,13 +27,27 @@ import org.onosproject.store.service.MapEventListener; | ... | @@ -37,13 +27,27 @@ import org.onosproject.store.service.MapEventListener; |
37 | import org.onosproject.store.service.MapTransaction; | 27 | import org.onosproject.store.service.MapTransaction; |
38 | import org.onosproject.store.service.Versioned; | 28 | import org.onosproject.store.service.Versioned; |
39 | 29 | ||
40 | -import com.google.common.base.Throwables; | 30 | +import java.util.Arrays; |
41 | -import com.google.common.collect.Sets; | 31 | +import java.util.ConcurrentModificationException; |
32 | +import java.util.List; | ||
33 | +import java.util.concurrent.ArrayBlockingQueue; | ||
34 | +import java.util.concurrent.BlockingQueue; | ||
35 | +import java.util.concurrent.CompletionException; | ||
36 | +import java.util.stream.Collectors; | ||
37 | + | ||
38 | +import static org.hamcrest.Matchers.is; | ||
39 | +import static org.junit.Assert.assertArrayEquals; | ||
40 | +import static org.junit.Assert.assertEquals; | ||
41 | +import static org.junit.Assert.assertFalse; | ||
42 | +import static org.junit.Assert.assertNotNull; | ||
43 | +import static org.junit.Assert.assertNull; | ||
44 | +import static org.junit.Assert.assertThat; | ||
45 | +import static org.junit.Assert.assertTrue; | ||
46 | +import static org.junit.Assert.fail; | ||
42 | 47 | ||
43 | /** | 48 | /** |
44 | * Unit tests for {@link AtomixConsistentMap}. | 49 | * Unit tests for {@link AtomixConsistentMap}. |
45 | */ | 50 | */ |
46 | -@Ignore | ||
47 | public class AtomixConsistentMapTest extends AtomixTestBase { | 51 | public class AtomixConsistentMapTest extends AtomixTestBase { |
48 | 52 | ||
49 | @Override | 53 | @Override | ... | ... |
... | @@ -20,7 +20,6 @@ import java.util.Queue; | ... | @@ -20,7 +20,6 @@ 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; | ||
24 | import org.junit.Test; | 23 | import org.junit.Test; |
25 | 24 | ||
26 | import static org.junit.Assert.*; | 25 | import static org.junit.Assert.*; |
... | @@ -36,7 +35,6 @@ import io.atomix.resource.ResourceType; | ... | @@ -36,7 +35,6 @@ import io.atomix.resource.ResourceType; |
36 | /** | 35 | /** |
37 | * Unit tests for {@link AtomixLeaderElector}. | 36 | * Unit tests for {@link AtomixLeaderElector}. |
38 | */ | 37 | */ |
39 | -@Ignore | ||
40 | public class AtomixLeaderElectorTest extends AtomixTestBase { | 38 | public class AtomixLeaderElectorTest extends AtomixTestBase { |
41 | 39 | ||
42 | NodeId node1 = new NodeId("node1"); | 40 | NodeId node1 = new NodeId("node1"); | ... | ... |
... | @@ -15,19 +15,18 @@ | ... | @@ -15,19 +15,18 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.store.primitives.resources.impl; | 16 | package org.onosproject.store.primitives.resources.impl; |
17 | 17 | ||
18 | -import static org.junit.Assert.*; | ||
19 | - | ||
20 | -import org.junit.Ignore; | ||
21 | -import org.junit.Test; | ||
22 | - | ||
23 | import io.atomix.Atomix; | 18 | import io.atomix.Atomix; |
24 | import io.atomix.resource.ResourceType; | 19 | import io.atomix.resource.ResourceType; |
25 | import io.atomix.variables.DistributedLong; | 20 | import io.atomix.variables.DistributedLong; |
21 | +import org.junit.Test; | ||
22 | + | ||
23 | +import static org.junit.Assert.assertEquals; | ||
24 | +import static org.junit.Assert.assertFalse; | ||
25 | +import static org.junit.Assert.assertTrue; | ||
26 | 26 | ||
27 | -/** | 27 | +/**git s |
28 | * Unit tests for {@link AtomixCounter}. | 28 | * Unit tests for {@link AtomixCounter}. |
29 | */ | 29 | */ |
30 | -@Ignore | ||
31 | public class AtomixLongTest extends AtomixTestBase { | 30 | public class AtomixLongTest extends AtomixTestBase { |
32 | 31 | ||
33 | @Override | 32 | @Override | ... | ... |
... | @@ -15,17 +15,22 @@ | ... | @@ -15,17 +15,22 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.store.primitives.resources.impl; | 16 | package org.onosproject.store.primitives.resources.impl; |
17 | 17 | ||
18 | +import com.google.common.util.concurrent.Uninterruptibles; | ||
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.local.LocalServerRegistry; |
22 | -import io.atomix.catalyst.transport.local.LocalTransport; | 23 | +import io.atomix.catalyst.transport.netty.NettyTransport; |
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.internal.ResourceManagerState; |
28 | import io.atomix.resource.ResourceType; | 29 | import io.atomix.resource.ResourceType; |
30 | +import org.junit.After; | ||
31 | +import org.junit.Before; | ||
32 | +import org.onlab.junit.TestTools; | ||
33 | +import org.onosproject.store.primitives.impl.CatalystSerializers; | ||
29 | 34 | ||
30 | import java.io.File; | 35 | import java.io.File; |
31 | import java.io.IOException; | 36 | import java.io.IOException; |
... | @@ -35,12 +40,7 @@ import java.util.ArrayList; | ... | @@ -35,12 +40,7 @@ import java.util.ArrayList; |
35 | import java.util.List; | 40 | import java.util.List; |
36 | import java.util.concurrent.CompletableFuture; | 41 | import java.util.concurrent.CompletableFuture; |
37 | import java.util.concurrent.CountDownLatch; | 42 | import java.util.concurrent.CountDownLatch; |
38 | - | 43 | +import java.util.concurrent.atomic.AtomicInteger; |
39 | -import org.junit.After; | ||
40 | -import org.junit.Before; | ||
41 | -import org.onosproject.store.primitives.impl.CatalystSerializers; | ||
42 | - | ||
43 | -import com.google.common.util.concurrent.Uninterruptibles; | ||
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Base class for various Atomix* tests. | 46 | * Base class for various Atomix* tests. |
... | @@ -48,7 +48,7 @@ import com.google.common.util.concurrent.Uninterruptibles; | ... | @@ -48,7 +48,7 @@ import com.google.common.util.concurrent.Uninterruptibles; |
48 | public abstract class AtomixTestBase { | 48 | public abstract class AtomixTestBase { |
49 | private static final File TEST_DIR = new File("target/test-logs"); | 49 | private static final File TEST_DIR = new File("target/test-logs"); |
50 | protected LocalServerRegistry registry; | 50 | protected LocalServerRegistry registry; |
51 | - protected int port; | 51 | + protected final AtomicInteger port = new AtomicInteger(49200); |
52 | protected List<Address> members; | 52 | protected List<Address> members; |
53 | protected List<CopycatClient> copycatClients = new ArrayList<>(); | 53 | protected List<CopycatClient> copycatClients = new ArrayList<>(); |
54 | protected List<CopycatServer> copycatServers = new ArrayList<>(); | 54 | protected List<CopycatServer> copycatServers = new ArrayList<>(); |
... | @@ -69,7 +69,8 @@ public abstract class AtomixTestBase { | ... | @@ -69,7 +69,8 @@ public abstract class AtomixTestBase { |
69 | * @return The next server address. | 69 | * @return The next server address. |
70 | */ | 70 | */ |
71 | private Address nextAddress() { | 71 | private Address nextAddress() { |
72 | - Address address = new Address("localhost", port++); | 72 | + Address address = new Address("127.0.0.1", |
73 | + TestTools.findAvailablePort(port.getAndIncrement())); | ||
73 | members.add(address); | 74 | members.add(address); |
74 | return address; | 75 | return address; |
75 | } | 76 | } |
... | @@ -82,13 +83,16 @@ public abstract class AtomixTestBase { | ... | @@ -82,13 +83,16 @@ public abstract class AtomixTestBase { |
82 | List<CopycatServer> servers = new ArrayList<>(); | 83 | List<CopycatServer> servers = new ArrayList<>(); |
83 | 84 | ||
84 | List<Address> members = new ArrayList<>(); | 85 | List<Address> members = new ArrayList<>(); |
85 | - for (int i = 0; i < nodes; i++) { | ||
86 | - members.add(nextAddress()); | ||
87 | - } | ||
88 | 86 | ||
89 | for (int i = 0; i < nodes; i++) { | 87 | for (int i = 0; i < nodes; i++) { |
90 | - CopycatServer server = createCopycatServer(members.get(i)); | 88 | + Address address = nextAddress(); |
91 | - server.bootstrap(members).thenRun(latch::countDown); | 89 | + members.add(address); |
90 | + CopycatServer server = createCopycatServer(address); | ||
91 | + if (members.size() <= 1) { | ||
92 | + server.bootstrap().thenRun(latch::countDown).join(); | ||
93 | + } else { | ||
94 | + server.join(members).thenRun(latch::countDown); | ||
95 | + } | ||
92 | servers.add(server); | 96 | servers.add(server); |
93 | } | 97 | } |
94 | 98 | ||
... | @@ -102,10 +106,9 @@ public abstract class AtomixTestBase { | ... | @@ -102,10 +106,9 @@ public abstract class AtomixTestBase { |
102 | */ | 106 | */ |
103 | protected CopycatServer createCopycatServer(Address address) { | 107 | protected CopycatServer createCopycatServer(Address address) { |
104 | CopycatServer server = CopycatServer.builder(address) | 108 | CopycatServer server = CopycatServer.builder(address) |
105 | - .withTransport(new LocalTransport(registry)) | 109 | + .withTransport(NettyTransport.builder().withThreads(1).build()) |
106 | .withStorage(Storage.builder() | 110 | .withStorage(Storage.builder() |
107 | - .withStorageLevel(StorageLevel.DISK) | 111 | + .withStorageLevel(StorageLevel.MEMORY) |
108 | - .withDirectory(TEST_DIR + "/" + address.port()) | ||
109 | .build()) | 112 | .build()) |
110 | .withStateMachine(ResourceManagerState::new) | 113 | .withStateMachine(ResourceManagerState::new) |
111 | .withSerializer(serializer.clone()) | 114 | .withSerializer(serializer.clone()) |
... | @@ -122,7 +125,6 @@ public abstract class AtomixTestBase { | ... | @@ -122,7 +125,6 @@ public abstract class AtomixTestBase { |
122 | public void clearTests() throws Exception { | 125 | public void clearTests() throws Exception { |
123 | registry = new LocalServerRegistry(); | 126 | registry = new LocalServerRegistry(); |
124 | members = new ArrayList<>(); | 127 | members = new ArrayList<>(); |
125 | - port = 5000; | ||
126 | 128 | ||
127 | CompletableFuture<Void> closeClients = | 129 | CompletableFuture<Void> closeClients = |
128 | CompletableFuture.allOf(atomixClients.stream() | 130 | CompletableFuture.allOf(atomixClients.stream() |
... | @@ -165,7 +167,7 @@ public abstract class AtomixTestBase { | ... | @@ -165,7 +167,7 @@ public abstract class AtomixTestBase { |
165 | protected AtomixClient createAtomixClient() { | 167 | protected AtomixClient createAtomixClient() { |
166 | CountDownLatch latch = new CountDownLatch(1); | 168 | CountDownLatch latch = new CountDownLatch(1); |
167 | AtomixClient client = AtomixClient.builder() | 169 | AtomixClient client = AtomixClient.builder() |
168 | - .withTransport(new LocalTransport(registry)) | 170 | + .withTransport(NettyTransport.builder().withThreads(1).build()) |
169 | .withSerializer(serializer.clone()) | 171 | .withSerializer(serializer.clone()) |
170 | .build(); | 172 | .build(); |
171 | client.connect(members).thenRun(latch::countDown); | 173 | client.connect(members).thenRun(latch::countDown); | ... | ... |
... | @@ -762,6 +762,15 @@ remote_jar ( | ... | @@ -762,6 +762,15 @@ remote_jar ( |
762 | ) | 762 | ) |
763 | 763 | ||
764 | remote_jar ( | 764 | remote_jar ( |
765 | + name = 'catalyst-concurrent', | ||
766 | + out = 'catalyst-concurrent-1.1.1.jar', | ||
767 | + url = 'mvn:io.atomix.catalyst:catalyst-concurrent:jar:1.1.1', | ||
768 | + sha1 = 'a7f3499b9815d83f65137abe0146238e447514c7', | ||
769 | + maven_coords = 'io.atomix.catalyst:catalyst-concurrent:1.1.1', | ||
770 | + visibility = [ 'PUBLIC' ], | ||
771 | +) | ||
772 | + | ||
773 | +remote_jar ( | ||
765 | name = 'netty-transport-native-epoll', | 774 | name = 'netty-transport-native-epoll', |
766 | out = 'netty-transport-native-epoll-4.0.36.Final.jar', | 775 | out = 'netty-transport-native-epoll-4.0.36.Final.jar', |
767 | url = 'mvn:io.netty:netty-transport-native-epoll:jar:4.0.36.Final', | 776 | url = 'mvn:io.netty:netty-transport-native-epoll:jar:4.0.36.Final', |
... | @@ -771,6 +780,24 @@ remote_jar ( | ... | @@ -771,6 +780,24 @@ remote_jar ( |
771 | ) | 780 | ) |
772 | 781 | ||
773 | remote_jar ( | 782 | remote_jar ( |
783 | + name = 'catalyst-netty', | ||
784 | + out = 'catalyst-netty-1.1.1.jar', | ||
785 | + url = 'mvn:io.atomix.catalyst:catalyst-netty:jar:1.1.1', | ||
786 | + sha1 = '8e9e5e6d8fdf01be26aa8a8eb07f762f5f4d4eb4', | ||
787 | + maven_coords = 'io.atomix.catalyst:catalyst-netty:1.1.1', | ||
788 | + visibility = [ 'PUBLIC' ], | ||
789 | +) | ||
790 | + | ||
791 | +remote_jar ( | ||
792 | + name = 'catalyst-transport', | ||
793 | + out = 'catalyst-transport-1.1.1.jar', | ||
794 | + url = 'mvn:io.atomix.catalyst:catalyst-transport:jar:1.1.1', | ||
795 | + sha1 = '2b38cb9ee3b5817b017072a886006461824d00c6', | ||
796 | + maven_coords = 'io.atomix.catalyst:catalyst-transport:1.1.1', | ||
797 | + visibility = [ 'PUBLIC' ], | ||
798 | +) | ||
799 | + | ||
800 | +remote_jar ( | ||
774 | name = 'objenesis', | 801 | name = 'objenesis', |
775 | out = 'objenesis-2.2.jar', | 802 | out = 'objenesis-2.2.jar', |
776 | url = 'mvn:org.objenesis:objenesis:jar:2.2', | 803 | url = 'mvn:org.objenesis:objenesis:jar:2.2', | ... | ... |
... | @@ -156,7 +156,10 @@ | ... | @@ -156,7 +156,10 @@ |
156 | "netty-common": "mvn:io.netty:netty-common:4.0.36.Final", | 156 | "netty-common": "mvn:io.netty:netty-common:4.0.36.Final", |
157 | "netty-handler": "mvn:io.netty:netty-handler:4.0.36.Final", | 157 | "netty-handler": "mvn:io.netty:netty-handler:4.0.36.Final", |
158 | "netty-transport": "mvn:io.netty:netty-transport:4.0.36.Final", | 158 | "netty-transport": "mvn:io.netty:netty-transport:4.0.36.Final", |
159 | + "catalyst-concurrent": "mvn:io.atomix.catalyst:catalyst-concurrent:1.1.1", | ||
159 | "netty-transport-native-epoll": "mvn:io.netty:netty-transport-native-epoll:4.0.36.Final", | 160 | "netty-transport-native-epoll": "mvn:io.netty:netty-transport-native-epoll:4.0.36.Final", |
161 | + "catalyst-netty": "mvn:io.atomix.catalyst:catalyst-netty:1.1.1", | ||
162 | + "catalyst-transport": "mvn:io.atomix.catalyst:catalyst-transport:1.1.1", | ||
160 | "objenesis": "mvn:org.objenesis:objenesis:2.2", | 163 | "objenesis": "mvn:org.objenesis:objenesis:2.2", |
161 | "openflowj": "mvn:org.onosproject:openflowj:0.9.4.onos", | 164 | "openflowj": "mvn:org.onosproject:openflowj:0.9.4.onos", |
162 | "org.apache.felix.scr": "mvn:org.apache.felix:org.apache.felix.scr:1.8.2", | 165 | "org.apache.felix.scr": "mvn:org.apache.felix:org.apache.felix.scr:1.8.2", | ... | ... |
-
Please register or login to post a comment