diff options
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/cluster')
23 files changed, 0 insertions, 1614 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterAdminService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterAdminService.java deleted file mode 100644 index 47944874..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterAdminService.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * 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; - -import java.util.Set; - -/** - * Service for administering the cluster node membership. - */ -public interface ClusterAdminService { - - /** - * Forms cluster configuration based on the specified set of node - * information. This method resets and restarts the controller - * instance. - * - * @param nodes set of nodes that form the cluster - */ - void formCluster(Set<ControllerNode> nodes); - - /** - * Adds a new controller node to the cluster. - * - * @param nodeId controller node identifier - * @param ip node IP listen address - * @param tcpPort tcp listen port - * @return newly added node - */ - ControllerNode addNode(NodeId nodeId, IpAddress ip, int tcpPort); - - /** - * Removes the specified node from the cluster node list. - * - * @param nodeId controller node identifier - */ - void removeNode(NodeId nodeId); - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterEvent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterEvent.java deleted file mode 100644 index 7bdc1d7d..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterEvent.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * 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.onosproject.event.AbstractEvent; - -/** - * Describes cluster-related event. - */ -public class ClusterEvent extends AbstractEvent<ClusterEvent.Type, ControllerNode> { - - /** - * Type of cluster-related events. - */ - public enum Type { - /** - * Signifies that a new cluster instance has been administratively added. - */ - INSTANCE_ADDED, - - /** - * Signifies that a cluster instance has been administratively removed. - */ - INSTANCE_REMOVED, - - /** - * Signifies that a cluster instance became active. - */ - INSTANCE_ACTIVATED, - - /** - * Signifies that a cluster instance became inactive. - */ - INSTANCE_DEACTIVATED - } - - /** - * Creates an event of a given type and for the specified instance and the - * current time. - * - * @param type cluster event type - * @param instance cluster device subject - */ - public ClusterEvent(Type type, ControllerNode instance) { - super(type, instance); - } - - /** - * Creates an event of a given type and for the specified device and time. - * - * @param type device event type - * @param instance event device subject - * @param time occurrence time - */ - public ClusterEvent(Type type, ControllerNode instance, long time) { - super(type, instance, time); - } - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterEventListener.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterEventListener.java deleted file mode 100644 index 79ff06ec..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterEventListener.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * 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.onosproject.event.EventListener; - -/** - * Entity capable of receiving device cluster-related events. - */ -public interface ClusterEventListener extends EventListener<ClusterEvent> { -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java deleted file mode 100644 index e1eacfee..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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 java.util.Arrays; -import java.util.Collection; -import java.util.Set; -import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Verify.verifyNotNull; -import static com.google.common.base.Verify.verify; - -import com.google.common.base.MoreObjects; -import com.google.common.collect.Collections2; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Cluster metadata. - * <p> - * Metadata specifies the attributes that define a ONOS cluster and comprises the collection - * of {@link org.onosproject.cluster.ControllerNode nodes} and the collection of data - * {@link org.onosproject.cluster.Partition partitions}. - */ -public final class ClusterMetadata { - - private String name; - private Set<ControllerNode> nodes; - private Set<Partition> partitions; - - /** - * Returns a new cluster metadata builder. - * @return The cluster metadata builder. - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Returns the name of the cluster. - * - * @return cluster name - */ - public String getName() { - return this.name; - } - - /** - * 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; - } - - /** - * Returns the collection of data {@link org.onosproject.cluster.Partition partitions} that make up the cluster. - * @return collection of partitions. - */ - public Collection<Partition> getPartitions() { - return this.partitions; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(ClusterMetadata.class) - .add("name", name) - .add("nodes", nodes) - .add("partitions", partitions) - .toString(); - } - - @Override - public int hashCode() { - return Arrays.deepHashCode(new Object[] {name, nodes, partitions}); - } - - /* - * Provide a deep quality check of the meta data (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - - if (!ClusterMetadata.class.isInstance(object)) { - return false; - } - ClusterMetadata that = (ClusterMetadata) object; - - if (!this.name.equals(that.name) || this.nodes.size() != that.nodes.size() - || this.partitions.size() != that.partitions.size()) { - return false; - } - - return Sets.symmetricDifference(this.nodes, that.nodes).isEmpty() - && Sets.symmetricDifference(this.partitions, that.partitions).isEmpty(); - } - - /** - * Builder for a {@link ClusterMetadata} instance. - */ - public static class Builder { - - private final ClusterMetadata metadata; - - public Builder() { - metadata = new ClusterMetadata(); - } - - /** - * Sets the cluster name, returning the cluster metadata builder for method chaining. - * @param name cluster name - * @return this cluster metadata builder - */ - public Builder withName(String name) { - metadata.name = checkNotNull(name); - return this; - } - - /** - * Sets the collection of cluster nodes, returning the cluster metadata builder for method chaining. - * @param controllerNodes collection of cluster nodes - * @return this cluster metadata builder - */ - public Builder withControllerNodes(Collection<ControllerNode> controllerNodes) { - metadata.nodes = ImmutableSet.copyOf(checkNotNull(controllerNodes)); - return this; - } - - /** - * Sets the collection of data partitions, returning the cluster metadata builder for method chaining. - * @param partitions collection of partitions - * @return this cluster metadata builder - */ - public Builder withPartitions(Collection<Partition> partitions) { - metadata.partitions = ImmutableSet.copyOf(checkNotNull(partitions)); - return this; - } - - /** - * Builds the cluster metadata. - * @return cluster metadata - * @throws com.google.common.base.VerifyException VerifyException if the metadata is misconfigured - */ - public ClusterMetadata build() { - verifyMetadata(); - return metadata; - } - - /** - * Validates the constructed metadata for semantic correctness. - * @throws VerifyException if the metadata is misconfigured. - */ - private void verifyMetadata() { - verifyNotNull(metadata.getName(), "Cluster name must be specified"); - verifyNotNull(metadata.getNodes(), "Cluster nodes must be specified"); - verifyNotNull(metadata.getPartitions(), "Cluster partitions must be specified"); - verify(!metadata.getNodes().isEmpty(), "Cluster nodes must not be empty"); - verify(!metadata.getPartitions().isEmpty(), "Cluster nodes must not be empty"); - - // verify that partitions are constituted from valid cluster nodes. - boolean validPartitions = Collections2.transform(metadata.getNodes(), ControllerNode::id) - .containsAll(metadata.getPartitions() - .stream() - .flatMap(r -> r.getMembers().stream()) - .collect(Collectors.toSet())); - verify(validPartitions, "Partition locations must be valid cluster nodes"); - } - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataEvent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataEvent.java deleted file mode 100644 index a0f461c4..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataEvent.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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.onosproject.event.AbstractEvent; - -/** - * Describes a cluster metadata event. - */ -public class ClusterMetadataEvent extends AbstractEvent<ClusterMetadataEvent.Type, ClusterMetadata> { - - /** - * Type of cluster metadata events. - */ - public enum Type { - /** - * Signifies that the cluster metadata has changed. - */ - METADATA_CHANGED, - } - - /** - * Creates an event of a given type and for the specified metadata and the - * current time. - * - * @param type cluster metadata event type - * @param metadata cluster metadata subject - */ - public ClusterMetadataEvent(Type type, ClusterMetadata metadata) { - super(type, metadata); - } - - /** - * Creates an event of a given type and for the specified metadata and time. - * - * @param type cluster metadata event type - * @param metadata cluster metadata subject - * @param time occurrence time - */ - public ClusterMetadataEvent(Type type, ClusterMetadata metadata, long time) { - super(type, metadata, time); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataEventListener.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataEventListener.java deleted file mode 100644 index fdfaeed0..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataEventListener.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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.onosproject.event.EventListener; - -/** - * Entity capable of receiving cluster metadata related events. - */ -public interface ClusterMetadataEventListener extends EventListener<ClusterMetadataEvent> { -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataService.java deleted file mode 100644 index 25a6df63..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataService.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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; - -/** - * Service for obtaining metadata information about the cluster. - */ -public interface ClusterMetadataService { - - /** - * Returns the current cluster metadata. - * @return cluster metadata - */ - ClusterMetadata getClusterMetadata(); - - /** - * Updates the cluster metadata. - * @param metadata new metadata - */ - void setClusterMetadata(ClusterMetadata metadata); - - /** - * Returns the local controller node representing this instance. - * @return local controller node - */ - ControllerNode getLocalNode(); -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataStore.java deleted file mode 100644 index 7e83b5b5..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataStore.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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 java.util.Collection; - -import org.onosproject.store.Store; -import org.onosproject.store.service.Versioned; - -/** - * Manages persistence of cluster metadata; not intended for direct use. - */ -public interface ClusterMetadataStore extends Store<ClusterMetadataEvent, ClusterMetadataStoreDelegate> { - - /** - * Returns the cluster metadata. - * <p> - * The returned metadata is versioned to aid determining if a metadata instance is more recent than another. - * @return cluster metadata - */ - Versioned<ClusterMetadata> getClusterMetadata(); - - /** - * Updates the cluster metadata. - * @param metadata new metadata value - */ - void setClusterMetadata(ClusterMetadata metadata); - - // TODO: The below methods should move to a separate store interface that is responsible for - // tracking cluster partition operational state. - - /** - * Sets a controller node as an active member of a partition. - * <p> - * Active members are those replicas that are up to speed with the rest of the system and are - * usually capable of participating in the replica state management activities in accordance with - * the data consistency and replication protocol in use. - * @param partitionId partition identifier - * @param nodeId id of controller node - */ - void setActiveReplica(String partitionId, NodeId nodeId); - - /** - * Removes a controller node as an active member for a partition. - * <p> - * Active members are those replicas that are up to speed with the rest of the system and are - * usually capable of participating in the replica state management activities in accordance with - * the data consistency and replication protocol in use. - * @param partitionId partition identifier - * @param nodeId id of controller node - */ - void unsetActiveReplica(String partitionId, NodeId nodeId); - - /** - * Returns the collection of controller nodes that are the active replicas for a partition. - * <p> - * Active members are those replicas that are up to speed with the rest of the system and are - * usually capable of participating in the replica state management activities in accordance with - * the data consistency and replication protocol in use. - * @param partitionId partition identifier - * @return identifiers of controller nodes that are the active replicas - */ - Collection<NodeId> getActiveReplicas(String partitionId); -}
\ No newline at end of file diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataStoreDelegate.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataStoreDelegate.java deleted file mode 100644 index b56b7a24..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataStoreDelegate.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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.onosproject.store.StoreDelegate; - -/** - * Cluster metadata store delegate abstraction. - */ -public interface ClusterMetadataStoreDelegate extends StoreDelegate<ClusterMetadataEvent> { -}
\ No newline at end of file diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterService.java deleted file mode 100644 index 015a6482..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterService.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * 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 java.util.Set; - -import org.joda.time.DateTime; -import org.onosproject.event.ListenerService; - -/** - * Service for obtaining information about the individual nodes within - * the controller cluster. - */ -public interface ClusterService - extends ListenerService<ClusterEvent, ClusterEventListener> { - - /** - * Returns the local controller node. - * - * @return local controller node - */ - ControllerNode getLocalNode(); - - /** - * Returns the set of current cluster members. - * - * @return set of cluster members - */ - Set<ControllerNode> getNodes(); - - /** - * Returns the specified controller node. - * - * @param nodeId controller node identifier - * @return controller node - */ - ControllerNode getNode(NodeId nodeId); - - /** - * Returns the availability state of the specified controller node. - * - * @param nodeId controller node identifier - * @return availability state - */ - ControllerNode.State getState(NodeId nodeId); - - /** - * Returns the system time when the availability state was last updated. - * - * @param nodeId controller node identifier - * @return system time when the availability state was last updated. - */ - DateTime getLastUpdated(NodeId nodeId); - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java deleted file mode 100644 index 0481d510..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * 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.joda.time.DateTime; -import org.onlab.packet.IpAddress; -import org.onosproject.store.Store; - -import java.util.Set; - -/** - * Manages inventory of controller cluster nodes; not intended for direct use. - */ -public interface ClusterStore extends Store<ClusterEvent, ClusterStoreDelegate> { - - /** - * Returns the local controller node. - * - * @return local controller instance - */ - ControllerNode getLocalNode(); - - /** - * Returns the set of current cluster members. - * - * @return set of cluster members - */ - Set<ControllerNode> getNodes(); - - /** - * Returns the specified controller node. - * - * @param nodeId controller instance identifier - * @return controller instance - */ - ControllerNode getNode(NodeId nodeId); - - /** - * Returns the availability state of the specified controller node. - * - * @param nodeId controller instance identifier - * @return availability state - */ - ControllerNode.State getState(NodeId nodeId); - - /** - * Returns the system when the availability state was last updated. - * - * @param nodeId controller node identifier - * @return system time when the availability state was last updated. - */ - DateTime getLastUpdated(NodeId nodeId); - - /** - * Adds a new controller node to the cluster. - * - * @param nodeId controller node identifier - * @param ip node IP listen address - * @param tcpPort tcp listen port - * @return newly added node - */ - ControllerNode addNode(NodeId nodeId, IpAddress ip, int tcpPort); - - /** - * Removes the specified node from the inventory of cluster nodes. - * - * @param nodeId controller instance identifier - */ - void removeNode(NodeId nodeId); - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterStoreDelegate.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterStoreDelegate.java deleted file mode 100644 index 50d44305..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterStoreDelegate.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * 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.onosproject.store.StoreDelegate; - -/** - * Cluster store delegate abstraction. - */ -public interface ClusterStoreDelegate extends StoreDelegate<ClusterEvent> { -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java deleted file mode 100644 index 2f74ae69..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * 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 ControllerNode { - - /** Represents the operational state of the instance. */ - enum State { - /** - * Signifies that the instance is active and operating normally. - */ - ACTIVE, - - /** - * Signifies that the instance is inactive, which means either down or - * up, but not operational. - */ - INACTIVE - } - - /** - * 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/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNodeToNodeId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNodeToNodeId.java deleted file mode 100644 index 4cde8b29..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNodeToNodeId.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * 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 com.google.common.base.Function; - -/** - * Function to convert ControllerNode to NodeId. - */ -public final class ControllerNodeToNodeId - implements Function<ControllerNode, NodeId> { - - private static final ControllerNodeToNodeId INSTANCE = new ControllerNodeToNodeId(); - - @Override - public NodeId apply(ControllerNode input) { - if (input == null) { - return null; - } else { - return input.id(); - } - } - - /** - * Returns a Function to convert ControllerNode to NodeId. - * - * @return ControllerNodeToNodeId instance. - */ - public static ControllerNodeToNodeId toNodeId() { - return INSTANCE; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/DefaultControllerNode.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/DefaultControllerNode.java deleted file mode 100644 index 3787daa5..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/DefaultControllerNode.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * 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; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Default implementation of a controller instance descriptor. - */ -public class DefaultControllerNode implements ControllerNode { - - public static final int DEFAULT_PORT = 9876; - - private final NodeId id; - private final IpAddress ip; - private final int tcpPort; - - // For serialization - private DefaultControllerNode() { - this.id = null; - this.ip = null; - this.tcpPort = 0; - } - - /** - * Creates a new instance with the specified id and IP address. - * - * @param id instance identifier - * @param ip instance IP address - */ - public DefaultControllerNode(NodeId id, IpAddress ip) { - this(id, ip, DEFAULT_PORT); - } - - /** - * Creates a new instance with the specified id and IP address and TCP port. - * - * @param id instance identifier - * @param ip instance IP address - * @param tcpPort TCP port - */ - public DefaultControllerNode(NodeId id, IpAddress ip, int tcpPort) { - this.id = checkNotNull(id); - this.ip = ip; - this.tcpPort = tcpPort; - } - - @Override - public NodeId id() { - return id; - } - - @Override - public IpAddress ip() { - return ip; - } - - @Override - public int tcpPort() { - return tcpPort; - } - - @Override - public int hashCode() { - return id.hashCode(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o instanceof DefaultControllerNode) { - DefaultControllerNode that = (DefaultControllerNode) o; - return Objects.equals(this.id, that.id); - } - return false; - } - - @Override - public String toString() { - return toStringHelper(this).add("id", id) - .add("ip", ip).add("tcpPort", tcpPort).toString(); - } - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/Leadership.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/Leadership.java deleted file mode 100644 index 113e19cb..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/Leadership.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * 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 java.util.Objects; -import java.util.List; -import java.util.Optional; - -import org.joda.time.DateTime; - -import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableList; - -/** - * Abstract leadership concept. The information carried by this construct - * include the topic of contention, the {@link NodeId}s of Nodes that could - * become leader for the topic, the epoch when the term for a given leader - * began, and the system time when the term began. Note: - * <ul> - * <li>The list of NodeIds may include the current leader at index 0, and the - * rest in decreasing preference order.</li> - * <li>The epoch is the logical age of a Leadership construct, and should be - * used for comparing two Leaderships, but only of the same topic.</li> - * <li>The leader may be null if its accuracy can't be guaranteed. This applies - * to CANDIDATES_CHANGED events and candidate board contents.</li> - * </ul> - */ -public class Leadership { - - private final String topic; - private final Optional<NodeId> leader; - private final List<NodeId> candidates; - private final long epoch; - private final long electedTime; - - public Leadership(String topic, NodeId leader, long epoch, long electedTime) { - this.topic = topic; - this.leader = Optional.of(leader); - this.candidates = ImmutableList.of(leader); - this.epoch = epoch; - this.electedTime = electedTime; - } - - public Leadership(String topic, NodeId leader, List<NodeId> candidates, - long epoch, long electedTime) { - this.topic = topic; - this.leader = Optional.of(leader); - this.candidates = ImmutableList.copyOf(candidates); - this.epoch = epoch; - this.electedTime = electedTime; - } - - public Leadership(String topic, List<NodeId> candidates, - long epoch, long electedTime) { - this.topic = topic; - this.leader = Optional.empty(); - this.candidates = ImmutableList.copyOf(candidates); - this.epoch = epoch; - this.electedTime = electedTime; - } - - /** - * The topic for which this leadership applies. - * - * @return leadership topic. - */ - public String topic() { - return topic; - } - - /** - * The nodeId of leader for this topic. - * - * @return leader node. - */ - // This will return Optional<NodeId> in the future. - public NodeId leader() { - return leader.orElse(null); - } - - /** - * Returns an preference-ordered list of nodes that are in the leadership - * race for this topic. - * - * @return a list of NodeIds in priority-order, or an empty list. - */ - public List<NodeId> candidates() { - return candidates; - } - - /** - * The epoch when the leadership was assumed. - * <p> - * Comparing epochs is only appropriate for leadership events for the same - * topic. The system guarantees that for any given topic the epoch for a new - * term is higher (not necessarily by 1) than the epoch for any previous - * term. - * - * @return leadership epoch - */ - public long epoch() { - return epoch; - } - - /** - * The system time when the term started. - * <p> - * The elected time is initially set on the node coordinating - * the leader election using its local system time. Due to possible - * clock skew, relying on this value for determining event ordering - * is discouraged. Epoch is more appropriate for determining - * event ordering. - * - * @return elected time. - */ - public long electedTime() { - return electedTime; - } - - @Override - public int hashCode() { - return Objects.hash(topic, leader, candidates, epoch, electedTime); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof Leadership) { - final Leadership other = (Leadership) obj; - return Objects.equals(this.topic, other.topic) && - Objects.equals(this.leader, other.leader) && - Objects.equals(this.candidates, other.candidates) && - Objects.equals(this.epoch, other.epoch) && - Objects.equals(this.electedTime, other.electedTime); - } - return false; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this.getClass()) - .add("topic", topic) - .add("leader", leader) - .add("candidates", candidates) - .add("epoch", epoch) - .add("electedTime", new DateTime(electedTime)) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/LeadershipEvent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/LeadershipEvent.java deleted file mode 100644 index faf6dd45..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/LeadershipEvent.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * 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 java.util.Objects; - -import org.onosproject.event.AbstractEvent; - -import com.google.common.base.MoreObjects; - -/** - * Describes leadership-related event. - */ -public class LeadershipEvent extends AbstractEvent<LeadershipEvent.Type, Leadership> { - - /** - * Type of leadership-related events. - */ - public enum Type { - /** - * Signifies that the leader has been elected. The event subject is the - * new leader. - */ - LEADER_ELECTED, - - /** - * Signifies that the leader has been re-elected. The event subject is the - * leader. - */ - LEADER_REELECTED, - - /** - * Signifies that the leader has been booted and lost leadership. The - * event subject is the former leader. - */ - LEADER_BOOTED, - - /** - * Signifies that the list of candidates for leadership for a topic has - * changed. This event does not guarantee accurate leader information. - */ - CANDIDATES_CHANGED - } - - /** - * Creates an event of a given type and for the specified instance and the - * current time. - * - * @param type leadership event type - * @param leadership event subject - */ - public LeadershipEvent(Type type, Leadership leadership) { - super(type, leadership); - } - - /** - * Creates an event of a given type and for the specified subject and time. - * - * @param type leadership event type - * @param leadership event subject - * @param time occurrence time - */ - public LeadershipEvent(Type type, Leadership leadership, long time) { - super(type, leadership, time); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subject(), time()); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof LeadershipEvent) { - final LeadershipEvent other = (LeadershipEvent) obj; - return Objects.equals(this.type(), other.type()) && - Objects.equals(this.subject(), other.subject()) && - Objects.equals(this.time(), other.time()); - } - return false; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this.getClass()) - .add("type", type()) - .add("subject", subject()) - .add("time", time()) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/LeadershipEventListener.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/LeadershipEventListener.java deleted file mode 100644 index 53d84b1b..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/LeadershipEventListener.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * 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.onosproject.event.EventListener; - -/** - * Entity capable of receiving device leadership-related events. - */ -public interface LeadershipEventListener extends EventListener<LeadershipEvent> { -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/LeadershipService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/LeadershipService.java deleted file mode 100644 index 7d1f6079..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/LeadershipService.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * 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.onosproject.event.ListenerService; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CompletableFuture; - -/** - * Service for leader election. - * Leadership contests are organized around topics. A instance can join the - * leadership race for a topic or withdraw from a race it has previously joined. - * Listeners can be added to receive notifications asynchronously for various - * leadership contests. - */ -public interface LeadershipService - extends ListenerService<LeadershipEvent, LeadershipEventListener> { - - /** - * Returns the current leader for the topic. - * - * @param path topic - * @return nodeId of the leader, null if so such topic exists. - */ - NodeId getLeader(String path); - - /** - * Returns the current leadership info for the topic. - * - * @param path topic - * @return leadership info or null if so such topic exists. - */ - Leadership getLeadership(String path); - - /** - * Returns the set of topics owned by the specified node. - * - * @param nodeId node Id. - * @return set of topics for which this node is the current leader. - */ - Set<String> ownedTopics(NodeId nodeId); - - /** - * Joins the leadership contest. - * - * @param path topic for which this controller node wishes to be a leader - * @return {@code Leadership} future - */ - CompletableFuture<Leadership> runForLeadership(String path); - - /** - * Withdraws from a leadership contest. - * - * @param path topic for which this controller node no longer wishes to be a leader - * @return future that is successfully completed when withdraw is done - */ - CompletableFuture<Void> withdraw(String path); - - /** - * If the local nodeId is the leader for specified topic, this method causes it to - * step down temporarily from leadership. - * <p> - * The node will continue to be in contention for leadership and can - * potentially become the leader again if and when it becomes the highest - * priority candidate - * <p> - * If the local nodeId is not the leader, this method will make no changes and - * simply return false. - * - * @param path topic for which this controller node should give up leadership - * @return true if this node stepped down from leadership, false otherwise - */ - boolean stepdown(String path); - - /** - * Moves the specified nodeId to the top of the candidates list for the topic. - * <p> - * If the node is not a candidate for this topic, this method will be a noop. - * - * @param path leadership topic - * @param nodeId nodeId to make the top candidate - * @return true if nodeId is now the top candidate, false otherwise - */ - boolean makeTopCandidate(String path, NodeId nodeId); - - /** - * Returns the current leader board. - * - * @return mapping from topic to leadership info. - */ - Map<String, Leadership> getLeaderBoard(); - - /** - * Returns the candidates for all known topics. - * - * @return A mapping from topics to corresponding list of candidates. - */ - Map<String, List<NodeId>> getCandidates(); - - /** - * Returns the candidates for a given topic. - * - * @param path topic - * @return A lists of NodeIds, which may be empty. - */ - List<NodeId> getCandidates(String path); - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/NodeId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/NodeId.java deleted file mode 100644 index e5ab9dc8..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/NodeId.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * 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 java.util.Objects; - -/** - * Controller cluster identity. - */ -public class NodeId implements Comparable<NodeId> { - - private final String id; - - /** - * Creates a new cluster node identifier from the specified string. - * - * @param id string identifier - */ - public NodeId(String id) { - this.id = id; - } - - @Override - public int hashCode() { - return id.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof NodeId) { - final NodeId other = (NodeId) obj; - return Objects.equals(this.id, other.id); - } - return false; - } - - @Override - public String toString() { - return id; - } - - @Override - public int compareTo(NodeId that) { - return this.id.compareTo(that.id); - } - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/Partition.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/Partition.java deleted file mode 100644 index 1eca4aeb..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/Partition.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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 java.util.Arrays; -import java.util.Collection; -import java.util.Set; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * A data partition. - * <p> - * Partition represents a slice of the data space and is made up of a collection - * of {@link org.onosproject.cluster.ControllerNode nodes} - * that all maintain copies of this data. - */ -public class Partition { - - private final String name; - private final Set<NodeId> members; - - private Partition() { - name = null; - members = null; - } - - public Partition(String name, Collection<NodeId> members) { - this.name = checkNotNull(name); - this.members = ImmutableSet.copyOf(checkNotNull(members)); - } - - /** - * Returns the partition name. - * <p> - * Each partition is identified by a unique name. - * @return partition name - */ - public String getName() { - return this.name; - } - - /** - * Returns the collection of controller node identifiers that make up this partition. - * @return collection of controller node identifiers - */ - public Collection<NodeId> getMembers() { - return this.members; - } - - @Override - public int hashCode() { - return Arrays.deepHashCode(new Object[] {name, members}); - } - - @Override - public boolean equals(Object other) { - if (this == other) { - return true; - } - - if (other == null || !Partition.class.isInstance(other)) { - return false; - } - - Partition that = (Partition) other; - - if (!this.name.equals(that.name) || (this.members == null && that.members != null) - || (this.members != null && that.members == null) || this.members.size() != that.members.size()) { - return false; - } - - return Sets.symmetricDifference(this.members, that.members).isEmpty(); - } -}
\ No newline at end of file diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/RoleInfo.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/RoleInfo.java deleted file mode 100644 index 081a6ba2..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/RoleInfo.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * 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 java.util.List; -import java.util.Objects; -import java.util.Optional; - -import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableList; - -/** - * An immutable container for role information for a device, - * within the current cluster. Role attributes include current - * master and a preference-ordered list of backup nodes. - */ -public class RoleInfo { - private final Optional<NodeId> master; - private final List<NodeId> backups; - - public RoleInfo(NodeId master, List<NodeId> backups) { - this.master = Optional.ofNullable(master); - this.backups = ImmutableList.copyOf(backups); - } - - public RoleInfo() { - this.master = Optional.empty(); - this.backups = ImmutableList.of(); - } - - // This will return a Optional<NodeId> in the future. - public NodeId master() { - return master.orElseGet(() -> null); - } - - public List<NodeId> backups() { - return backups; - } - - @Override - public boolean equals(Object other) { - if (this == other) { - return true; - } - - if (!(other instanceof RoleInfo)) { - return false; - } - RoleInfo that = (RoleInfo) other; - - return Objects.equals(this.master, that.master) - && Objects.equals(this.backups, that.backups); - } - - @Override - public int hashCode() { - return Objects.hash(master, backups); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this.getClass()) - .add("master", master.orElseGet(() -> null)) - .add("backups", backups) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/package-info.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/package-info.java deleted file mode 100644 index d5ae40c2..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * 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. - */ - -/** - * Set of abstractions for dealing with controller cluster related topics. - */ -package org.onosproject.cluster; |