Upgrade to Atomix 3.0-rc5
* Upgrade Raft primitives to Atomix 3.0
* Replace cluster store and messaging implementations with Atomix cluster management/messaging
* Add test scripts for installing/starting Atomix cluster
* Replace core primitives with Atomix primitives.
Change-Id: I7623653c81292a34f21b01f5f38ca11b5ef15cad
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterAdminService.java b/core/api/src/main/java/org/onosproject/cluster/ClusterAdminService.java
index d1c4325..4792a94 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterAdminService.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterAdminService.java
@@ -30,7 +30,9 @@
* instance.
*
* @param nodes set of nodes that form the cluster
+ * @deprecated since 1.14
*/
+ @Deprecated
void formCluster(Set<ControllerNode> nodes);
/**
@@ -40,7 +42,9 @@
*
* @param nodes set of nodes that form the cluster
* @param partitionSize number of nodes to compose a partition
+ * @deprecated since 1.14
*/
+ @Deprecated
void formCluster(Set<ControllerNode> nodes, int partitionSize);
/**
@@ -50,14 +54,18 @@
* @param ip node IP listen address
* @param tcpPort tcp listen port
* @return newly added node
+ * @deprecated since 1.14
*/
+ @Deprecated
ControllerNode addNode(NodeId nodeId, IpAddress ip, int tcpPort);
/**
* Removes the specified node from the cluster node list.
*
* @param nodeId controller node identifier
+ * @deprecated since 1.14
*/
+ @Deprecated
void removeNode(NodeId nodeId);
/**
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java
index c205345..8f7d960 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java
@@ -17,23 +17,20 @@
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.Objects;
import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.onosproject.net.Provided;
-import org.onosproject.net.provider.ProviderId;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Verify.verify;
-import static com.google.common.base.Charsets.UTF_8;
import com.google.common.base.MoreObjects;
-import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.common.hash.Funnel;
import com.google.common.hash.PrimitiveSink;
+import org.onosproject.net.Provided;
+import org.onosproject.net.provider.ProviderId;
+
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.base.Preconditions.checkNotNull;
/**
* Cluster metadata.
@@ -46,8 +43,8 @@
private final ProviderId providerId;
private final String name;
- private final Set<ControllerNode> nodes;
- private final Set<Partition> partitions;
+ private final ControllerNode localNode;
+ private final Set<Node> nodes;
public static final Funnel<ClusterMetadata> HASH_FUNNEL = new Funnel<ClusterMetadata>() {
@Override
@@ -60,31 +57,23 @@
private ClusterMetadata() {
providerId = null;
name = null;
+ localNode = null;
nodes = null;
- partitions = null;
}
- public ClusterMetadata(ProviderId providerId,
- String name,
- Set<ControllerNode> nodes,
- Set<Partition> partitions) {
+ public ClusterMetadata(
+ ProviderId providerId,
+ String name,
+ ControllerNode localNode,
+ Set<Node> nodes) {
this.providerId = checkNotNull(providerId);
this.name = checkNotNull(name);
+ this.localNode = localNode;
this.nodes = ImmutableSet.copyOf(checkNotNull(nodes));
- // verify that partitions are constituted from valid cluster nodes.
- boolean validPartitions = Collections2.transform(nodes, ControllerNode::id)
- .containsAll(partitions
- .stream()
- .flatMap(r -> r.getMembers().stream())
- .collect(Collectors.toSet()));
- verify(validPartitions, "Partition locations must be valid cluster nodes");
- this.partitions = ImmutableSet.copyOf(checkNotNull(partitions));
}
- public ClusterMetadata(String name,
- Set<ControllerNode> nodes,
- Set<Partition> partitions) {
- this(new ProviderId("none", "none"), name, nodes, partitions);
+ public ClusterMetadata(String name, ControllerNode localNode, Set<Node> nodes) {
+ this(new ProviderId("none", "none"), name, localNode, nodes);
}
@Override
@@ -102,20 +91,39 @@
}
/**
+ * Returns the local controller node.
+ * @return the local controller node
+ */
+ public ControllerNode getLocalNode() {
+ return localNode;
+ }
+
+ /**
* Returns the collection of {@link org.onosproject.cluster.ControllerNode nodes} that make up the cluster.
* @return cluster nodes
*/
public Collection<ControllerNode> getNodes() {
- return this.nodes;
+ return (Collection) nodes;
+ }
+
+ /**
+ * Returns the collection of storage nodes.
+ *
+ * @return the collection of storage nodes
+ */
+ public Collection<Node> getStorageNodes() {
+ return nodes;
}
/**
* Returns the collection of {@link org.onosproject.cluster.Partition partitions} that make
* up the cluster.
* @return collection of partitions.
+ * @deprecated since 1.14
*/
+ @Deprecated
public Collection<Partition> getPartitions() {
- return this.partitions;
+ return Collections.emptySet();
}
@Override
@@ -124,13 +132,12 @@
.add("providerId", providerId)
.add("name", name)
.add("nodes", nodes)
- .add("partitions", partitions)
.toString();
}
@Override
public int hashCode() {
- return Arrays.deepHashCode(new Object[] {providerId, name, nodes, partitions});
+ return Arrays.deepHashCode(new Object[] {providerId, name, nodes});
}
/*
@@ -140,7 +147,6 @@
*/
@Override
public boolean equals(Object object) {
-
if (object == null) {
return false;
}
@@ -151,9 +157,8 @@
ClusterMetadata that = (ClusterMetadata) object;
return Objects.equals(this.name, that.name) &&
+ this.localNode.equals(that.localNode) &&
Objects.equals(this.nodes.size(), that.nodes.size()) &&
- Objects.equals(this.partitions.size(), that.partitions.size()) &&
- Sets.symmetricDifference(this.nodes, that.nodes).isEmpty() &&
- Sets.symmetricDifference(this.partitions, that.partitions).isEmpty();
+ Sets.symmetricDifference(this.nodes, that.nodes).isEmpty();
}
}
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataDiff.java b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataDiff.java
index 20ce75e..acad25f 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataDiff.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataDiff.java
@@ -27,7 +27,10 @@
/**
* Utility for examining differences between two {@link ClusterMetadata metadata} values.
+ *
+ * @deprecated since 1.14
*/
+@Deprecated
public class ClusterMetadataDiff {
private final ClusterMetadata oldValue;
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterService.java b/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
index 54f23cd..69ceb64 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
@@ -44,6 +44,13 @@
Set<ControllerNode> getNodes();
/**
+ * Returns the set of consensus nodes.
+ *
+ * @return the set of consensus nodes
+ */
+ Set<Node> getConsensusNodes();
+
+ /**
* Returns the specified controller node.
*
* @param nodeId controller node identifier
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java b/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java
index dfe0b23..fdcd315 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java
@@ -37,6 +37,13 @@
ControllerNode getLocalNode();
/**
+ * Returns the set of storage nodes.
+ *
+ * @return set of storage nodes
+ */
+ Set<Node> getStorageNodes();
+
+ /**
* Returns the set of current cluster members.
*
* @return set of cluster members
diff --git a/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java b/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java
index 1d1a3ec..48932db 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java
@@ -15,12 +15,10 @@
*/
package org.onosproject.cluster;
-import org.onlab.packet.IpAddress;
-
/**
* Represents a controller instance as a member in a cluster.
*/
-public interface ControllerNode {
+public interface ControllerNode extends Node {
/** Represents the operational state of the instance. */
enum State {
@@ -60,25 +58,4 @@
}
}
- /**
- * Returns the instance identifier.
- *
- * @return instance identifier
- */
- NodeId id();
-
- /**
- * Returns the IP address of the controller instance.
- *
- * @return IP address
- */
- IpAddress ip();
-
- /**
- * Returns the TCP port on which the node listens for connections.
- *
- * @return TCP port
- */
- int tcpPort();
-
}
diff --git a/core/api/src/main/java/org/onosproject/cluster/DefaultPartition.java b/core/api/src/main/java/org/onosproject/cluster/DefaultPartition.java
index d0f2f3d..f0a73b6 100644
--- a/core/api/src/main/java/org/onosproject/cluster/DefaultPartition.java
+++ b/core/api/src/main/java/org/onosproject/cluster/DefaultPartition.java
@@ -15,8 +15,6 @@
*/
package org.onosproject.cluster;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import java.util.Collection;
import java.util.Objects;
@@ -25,13 +23,14 @@
import com.google.common.collect.Sets;
import org.onosproject.core.Version;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* Default {@link Partition} implementation.
*/
public class DefaultPartition implements Partition {
private final PartitionId id;
- private final Version version;
private final Collection<NodeId> members;
/**
@@ -39,7 +38,6 @@
*/
protected DefaultPartition() {
id = null;
- version = null;
members = null;
}
@@ -47,12 +45,10 @@
* Constructs a partition.
*
* @param id partition identifier
- * @param version partition version
* @param members partition member nodes
*/
- public DefaultPartition(PartitionId id, Version version, Collection<NodeId> members) {
+ public DefaultPartition(PartitionId id, Collection<NodeId> members) {
this.id = checkNotNull(id);
- this.version = version;
this.members = ImmutableSet.copyOf(members);
}
@@ -63,7 +59,6 @@
*/
public DefaultPartition(Partition other) {
this.id = checkNotNull(other.getId());
- this.version = checkNotNull(other.getVersion());
this.members = ImmutableSet.copyOf(other.getMembers());
}
@@ -74,7 +69,7 @@
@Override
public Version getVersion() {
- return version;
+ return null;
}
@Override
@@ -86,7 +81,6 @@
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("id", id)
- .add("version", version)
.add("members", members)
.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/cluster/Node.java b/core/api/src/main/java/org/onosproject/cluster/Node.java
new file mode 100644
index 0000000..8d6a197
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/cluster/Node.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.cluster;
+
+import org.onlab.packet.IpAddress;
+
+/**
+ * Represents a controller instance as a member in a cluster.
+ */
+public interface Node {
+
+ /**
+ * Returns the instance identifier.
+ *
+ * @return instance identifier
+ */
+ NodeId id();
+
+ /**
+ * Returns the IP address of the controller instance.
+ *
+ * @return IP address
+ */
+ IpAddress ip();
+
+ /**
+ * Returns the TCP port on which the node listens for connections.
+ *
+ * @return TCP port
+ */
+ int tcpPort();
+
+}
diff --git a/core/api/src/main/java/org/onosproject/cluster/Partition.java b/core/api/src/main/java/org/onosproject/cluster/Partition.java
index ebff406..33bc68f 100644
--- a/core/api/src/main/java/org/onosproject/cluster/Partition.java
+++ b/core/api/src/main/java/org/onosproject/cluster/Partition.java
@@ -35,7 +35,9 @@
* Returns the partition version.
*
* @return the partition version
+ * @deprecated since 1.14
*/
+ @Deprecated
Version getVersion();
/**
diff --git a/core/api/src/main/java/org/onosproject/store/primitives/PartitionService.java b/core/api/src/main/java/org/onosproject/store/primitives/PartitionService.java
index db17d1e..a392e20 100644
--- a/core/api/src/main/java/org/onosproject/store/primitives/PartitionService.java
+++ b/core/api/src/main/java/org/onosproject/store/primitives/PartitionService.java
@@ -46,7 +46,9 @@
*
* @param partitionId partition identifier
* @return set of node identifiers
+ * @deprecated since 1.14
*/
+ @Deprecated
Set<NodeId> getActiveMembersMembers(PartitionId partitionId);
/**
@@ -61,6 +63,8 @@
*
* @param partitionId partition identifier
* @return distributed primitive creator
+ * @deprecated since 1.14
*/
+ @Deprecated
DistributedPrimitiveCreator getDistributedPrimitiveCreator(PartitionId partitionId);
}
diff --git a/core/api/src/main/java/org/onosproject/store/service/PrimitiveService.java b/core/api/src/main/java/org/onosproject/store/service/PrimitiveService.java
index cc77393..030531a 100644
--- a/core/api/src/main/java/org/onosproject/store/service/PrimitiveService.java
+++ b/core/api/src/main/java/org/onosproject/store/service/PrimitiveService.java
@@ -122,6 +122,14 @@
<T> TopicBuilder<T> topicBuilder();
/**
+ * Creates a new WorkQueueBuilder.
+ *
+ * @param <E> work queue element type
+ * @return work queue builder
+ */
+ <E> WorkQueueBuilder<E> workQueueBuilder();
+
+ /**
* Creates a new transaction context builder.
*
* @return a builder for a transaction context.
diff --git a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataDiffTest.java b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataDiffTest.java
deleted file mode 100644
index f97bd6a..0000000
--- a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataDiffTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.cluster;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-import org.onosproject.core.Version;
-
-/**
- * Unit tests for ClusterMetadataDiff.
- */
-public class ClusterMetadataDiffTest {
-
- @Test
- public void testDiffNoChange() {
- PartitionId pid1 = PartitionId.from(1);
- NodeId nid1 = NodeId.nodeId("10.0.0.1");
- ControllerNode n1 = new DefaultControllerNode(nid1, IpAddress.valueOf("10.0.0.1"), 9876);
- Partition p1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1));
- ClusterMetadata md1 = new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
- ClusterMetadataDiff diff = new ClusterMetadataDiff(md1, md1);
- assertTrue(diff.nodesAdded().isEmpty());
- assertTrue(diff.nodesRemoved().isEmpty());
- assertEquals(diff.partitionDiffs().size(), 1);
- assertEquals(diff.partitionDiffs().keySet(), Sets.newHashSet(pid1));
- PartitionDiff pdiff = diff.partitionDiffs().get(pid1);
- assertFalse(pdiff.hasChanged());
- }
-
- @Test
- public void testDiffForScaleUp() {
- PartitionId pid1 = PartitionId.from(1);
- NodeId nid1 = NodeId.nodeId("10.0.0.1");
- NodeId nid2 = NodeId.nodeId("10.0.0.2");
- ControllerNode n1 = new DefaultControllerNode(nid1, IpAddress.valueOf("10.0.0.1"), 9876);
- ControllerNode n2 = new DefaultControllerNode(nid2, IpAddress.valueOf("10.0.0.2"), 9876);
- Partition p1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1));
- Partition p12 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1, nid2));
- ClusterMetadata md1 = new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
- ClusterMetadata md12 = new ClusterMetadata("foo", ImmutableSet.of(n1, n2), ImmutableSet.of(p12));
- ClusterMetadataDiff diff = new ClusterMetadataDiff(md1, md12);
- assertEquals(diff.nodesAdded(), Sets.newHashSet(n2));
- assertTrue(diff.nodesRemoved().isEmpty());
- assertEquals(diff.partitionDiffs().size(), 1);
- assertEquals(diff.partitionDiffs().keySet(), Sets.newHashSet(pid1));
- PartitionDiff pdiff = diff.partitionDiffs().get(pid1);
- assertTrue(pdiff.hasChanged());
- assertFalse(pdiff.isAdded(nid1));
- assertTrue(pdiff.isAdded(nid2));
- assertFalse(pdiff.isRemoved(nid1));
- assertFalse(pdiff.isAdded(nid1));
- }
-
- @Test
- public void testDiffForScaleDown() {
- PartitionId pid1 = PartitionId.from(1);
- NodeId nid1 = NodeId.nodeId("10.0.0.1");
- NodeId nid2 = NodeId.nodeId("10.0.0.2");
- ControllerNode n1 = new DefaultControllerNode(nid1, IpAddress.valueOf("10.0.0.1"), 9876);
- ControllerNode n2 = new DefaultControllerNode(nid2, IpAddress.valueOf("10.0.0.2"), 9876);
- Partition p1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1));
- Partition p12 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1, nid2));
- ClusterMetadata md1 = new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
- ClusterMetadata md12 = new ClusterMetadata("foo", ImmutableSet.of(n1, n2), ImmutableSet.of(p12));
- ClusterMetadataDiff diff = new ClusterMetadataDiff(md12, md1);
- assertEquals(diff.nodesRemoved(), Sets.newHashSet(nid2));
- assertTrue(diff.nodesAdded().isEmpty());
- assertEquals(diff.partitionDiffs().size(), 1);
- assertEquals(diff.partitionDiffs().keySet(), Sets.newHashSet(pid1));
- PartitionDiff pdiff = diff.partitionDiffs().get(pid1);
- assertTrue(pdiff.hasChanged());
- assertTrue(pdiff.isRemoved(nid2));
- assertFalse(pdiff.isAdded(nid2));
- assertFalse(pdiff.isRemoved(nid1));
- assertFalse(pdiff.isAdded(nid1));
- }
-}
diff --git a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataEventTest.java b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataEventTest.java
index 036839a..b176aee 100644
--- a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataEventTest.java
+++ b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataEventTest.java
@@ -19,7 +19,6 @@
import com.google.common.testing.EqualsTester;
import org.junit.Test;
import org.onlab.packet.IpAddress;
-import org.onosproject.core.Version;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@@ -38,15 +37,12 @@
new DefaultControllerNode(nid1, IpAddress.valueOf("10.0.0.1"), 9876);
private final ControllerNode n2 =
new DefaultControllerNode(nid2, IpAddress.valueOf("10.0.0.2"), 9876);
- private final Partition p1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1));
- private final Partition p2 = new DefaultPartition(pid2, Version.version("1.0.0"), ImmutableSet.of(nid1, nid2));
- private final Partition p3 = new DefaultPartition(pid2, Version.version("1.0.0"), ImmutableSet.of(nid2));
private final ClusterMetadata metadata1 =
- new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
+ new ClusterMetadata("foo", n1, ImmutableSet.of(n1));
private final ClusterMetadata metadata2 =
- new ClusterMetadata("bar", ImmutableSet.of(n1, n2), ImmutableSet.of(p1, p2));
+ new ClusterMetadata("bar", n1, ImmutableSet.of(n1, n2));
private final ClusterMetadata metadata3 =
- new ClusterMetadata("baz", ImmutableSet.of(n2), ImmutableSet.of(p3));
+ new ClusterMetadata("baz", n1, ImmutableSet.of(n2));
private final ClusterMetadataEvent event1 =
new ClusterMetadataEvent(ClusterMetadataEvent.Type.METADATA_CHANGED, metadata1, time1);
diff --git a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataServiceAdapter.java b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataServiceAdapter.java
index 443ee29..b1b46f9 100644
--- a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataServiceAdapter.java
@@ -15,10 +15,8 @@
*/
package org.onosproject.cluster;
-import org.onlab.packet.IpAddress;
-
import com.google.common.collect.Sets;
-import org.onosproject.core.Version;
+import org.onlab.packet.IpAddress;
/**
* Test adapter for the ClusterMetadata service.
@@ -29,10 +27,7 @@
public ClusterMetadata getClusterMetadata() {
final NodeId nid = new NodeId("test-node");
final IpAddress addr = IpAddress.valueOf(0);
- final Partition p = new DefaultPartition(PartitionId.from(1), Version.version("1.0.0"), Sets.newHashSet(nid));
- return new ClusterMetadata("test-cluster",
- Sets.newHashSet(new DefaultControllerNode(nid, addr)),
- Sets.newHashSet(p));
+ return new ClusterMetadata("test-cluster", new DefaultControllerNode(nid, addr), Sets.newHashSet());
}
@Override
diff --git a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataTest.java b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataTest.java
index 3d86d93..d6e2f33 100644
--- a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataTest.java
+++ b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataTest.java
@@ -19,21 +19,17 @@
import com.google.common.testing.EqualsTester;
import org.junit.Test;
import org.onlab.packet.IpAddress;
-import org.onosproject.core.Version;
import org.onosproject.net.provider.ProviderId;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertThat;
/**
* Unit tests for ClusterMetadata.
*/
public class ClusterMetadataTest {
- private final PartitionId pid1 = PartitionId.from(1);
- private final PartitionId pid2 = PartitionId.from(2);
-
private final NodeId nid1 = NodeId.nodeId("10.0.0.1");
private final NodeId nid2 = NodeId.nodeId("10.0.0.2");
@@ -42,15 +38,12 @@
private final ControllerNode n2 =
new DefaultControllerNode(nid2, IpAddress.valueOf("10.0.0.2"), 9876);
- private final Partition p1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1));
- private final Partition p2 = new DefaultPartition(pid2, Version.version("1.0.0"), ImmutableSet.of(nid1, nid2));
-
private final ClusterMetadata metadata1 =
- new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
+ new ClusterMetadata("foo", n1, ImmutableSet.of(n1));
private final ClusterMetadata sameAsMetadata1 =
- new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
+ new ClusterMetadata("foo", n1, ImmutableSet.of(n1));
private final ClusterMetadata metadata2 =
- new ClusterMetadata("bar", ImmutableSet.of(n1, n2), ImmutableSet.of(p1, p2));
+ new ClusterMetadata("bar", n1, ImmutableSet.of(n1, n2));
private final ProviderId defaultProvider =
new ProviderId("none", "none");
/**
@@ -73,9 +66,6 @@
assertThat(metadata2.getName(), is("bar"));
assertThat(metadata2.getNodes(), hasSize(2));
assertThat(metadata2.getNodes(), contains(n1, n2));
- assertThat(metadata2.getPartitions(), hasSize(2));
- assertThat(metadata2.getPartitions(), contains(p1, p2));
assertThat(metadata1.providerId(), is(defaultProvider));
-
}
}
diff --git a/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java b/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java
index bc40f67..b486132 100644
--- a/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java
@@ -46,6 +46,11 @@
}
@Override
+ public Set<Node> getConsensusNodes() {
+ return null;
+ }
+
+ @Override
public ControllerNode.State getState(NodeId nodeId) {
return null;
}
diff --git a/core/api/src/test/java/org/onosproject/cluster/DefaultPartitionTest.java b/core/api/src/test/java/org/onosproject/cluster/DefaultPartitionTest.java
index 105c94e..292c9a2 100644
--- a/core/api/src/test/java/org/onosproject/cluster/DefaultPartitionTest.java
+++ b/core/api/src/test/java/org/onosproject/cluster/DefaultPartitionTest.java
@@ -17,11 +17,9 @@
import java.util.Collection;
-import org.junit.Test;
-
import com.google.common.collect.ImmutableSet;
import com.google.common.testing.EqualsTester;
-import org.onosproject.core.Version;
+import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
@@ -44,13 +42,13 @@
PartitionId pid2 = new PartitionId(2);
PartitionId pid3 = new PartitionId(3);
- DefaultPartition partition1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(id1));
- DefaultPartition sameAsPartition1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(id1));
+ DefaultPartition partition1 = new DefaultPartition(pid1, ImmutableSet.of(id1));
+ DefaultPartition sameAsPartition1 = new DefaultPartition(pid1, ImmutableSet.of(id1));
- DefaultPartition partition2 = new DefaultPartition(pid2, Version.version("1.0.0"), ImmutableSet.of(id2));
+ DefaultPartition partition2 = new DefaultPartition(pid2, ImmutableSet.of(id2));
DefaultPartition copyOfPartition2 = new DefaultPartition(partition2);
- DefaultPartition partition3 = new DefaultPartition(pid3, Version.version("1.0.0"), ImmutableSet.of(id1, id2, id3));
+ DefaultPartition partition3 = new DefaultPartition(pid3, ImmutableSet.of(id1, id2, id3));
/**
* Checks that the default partition implementation is an immutable
diff --git a/core/api/src/test/java/org/onosproject/store/primitives/PartitionEventTest.java b/core/api/src/test/java/org/onosproject/store/primitives/PartitionEventTest.java
index abcc659..0aec80a 100644
--- a/core/api/src/test/java/org/onosproject/store/primitives/PartitionEventTest.java
+++ b/core/api/src/test/java/org/onosproject/store/primitives/PartitionEventTest.java
@@ -22,7 +22,6 @@
import org.onosproject.cluster.NodeId;
import org.onosproject.cluster.Partition;
import org.onosproject.cluster.PartitionId;
-import org.onosproject.core.Version;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@@ -42,9 +41,9 @@
private final Partition p1 =
- new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1));
+ new DefaultPartition(pid1, ImmutableSet.of(nid1));
private final Partition p2 =
- new DefaultPartition(pid2, Version.version("1.0.0"), ImmutableSet.of(nid1, nid2));
+ new DefaultPartition(pid2, ImmutableSet.of(nid1, nid2));
private final PartitionEvent event1 =
new PartitionEvent(PartitionEvent.Type.UPDATED, p1, time);
diff --git a/core/api/src/test/java/org/onosproject/store/service/CoordinationServiceAdapter.java b/core/api/src/test/java/org/onosproject/store/service/CoordinationServiceAdapter.java
index 68cb5fd..26644ee 100644
--- a/core/api/src/test/java/org/onosproject/store/service/CoordinationServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/store/service/CoordinationServiceAdapter.java
@@ -80,6 +80,11 @@
}
@Override
+ public <E> WorkQueueBuilder<E> workQueueBuilder() {
+ return null;
+ }
+
+ @Override
public TransactionContextBuilder transactionContextBuilder() {
return null;
}
diff --git a/core/api/src/test/java/org/onosproject/store/service/StorageServiceAdapter.java b/core/api/src/test/java/org/onosproject/store/service/StorageServiceAdapter.java
index ae65500..202a271 100644
--- a/core/api/src/test/java/org/onosproject/store/service/StorageServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/store/service/StorageServiceAdapter.java
@@ -75,6 +75,11 @@
}
@Override
+ public <E> WorkQueueBuilder<E> workQueueBuilder() {
+ return null;
+ }
+
+ @Override
public <E> WorkQueue<E> getWorkQueue(String name, Serializer serializer) {
return null;
}
diff --git a/core/api/src/test/java/org/onosproject/store/service/TestConsistentMap.java b/core/api/src/test/java/org/onosproject/store/service/TestConsistentMap.java
index 4e25f4d..aa08c8d 100644
--- a/core/api/src/test/java/org/onosproject/store/service/TestConsistentMap.java
+++ b/core/api/src/test/java/org/onosproject/store/service/TestConsistentMap.java
@@ -16,11 +16,11 @@
package org.onosproject.store.service;
import java.util.Collection;
-import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
@@ -45,7 +45,7 @@
private final Serializer serializer;
private TestConsistentMap(String mapName, Serializer serializer) {
- map = new HashMap<>();
+ map = new ConcurrentHashMap<>();
listeners = new LinkedList<>();
this.mapName = mapName;
this.serializer = serializer;