mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-17 02:11:38 +02:00
Replaced the usage of IpPrefix with IpAddress in the context of
Controller Nodes. Change-Id: Id2b25fb071bb20541db3f77b7afefe886520538e
This commit is contained in:
parent
d35961bc18
commit
444b519327
@ -22,7 +22,7 @@ import org.apache.karaf.shell.commands.Argument;
|
||||
import org.apache.karaf.shell.commands.Command;
|
||||
import org.onlab.onos.cluster.ClusterAdminService;
|
||||
import org.onlab.onos.cluster.NodeId;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
/**
|
||||
* Adds a new controller cluster node.
|
||||
@ -46,7 +46,7 @@ public class NodeAddCommand extends AbstractShellCommand {
|
||||
@Override
|
||||
protected void execute() {
|
||||
ClusterAdminService service = get(ClusterAdminService.class);
|
||||
service.addNode(new NodeId(nodeId), IpPrefix.valueOf(ip), tcpPort);
|
||||
service.addNode(new NodeId(nodeId), IpAddress.valueOf(ip), tcpPort);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.onlab.onos.cluster;
|
||||
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
/**
|
||||
* Service for administering the cluster node membership.
|
||||
@ -15,7 +15,7 @@ public interface ClusterAdminService {
|
||||
* @param tcpPort tcp listen port
|
||||
* @return newly added node
|
||||
*/
|
||||
ControllerNode addNode(NodeId nodeId, IpPrefix ip, int tcpPort);
|
||||
ControllerNode addNode(NodeId nodeId, IpAddress ip, int tcpPort);
|
||||
|
||||
/**
|
||||
* Removes the specified node from the cluster node list.
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.onlab.onos.cluster;
|
||||
|
||||
import org.onlab.onos.store.Store;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ -48,7 +48,7 @@ public interface ClusterStore extends Store<ClusterEvent, ClusterStoreDelegate>
|
||||
* @param tcpPort tcp listen port
|
||||
* @return newly added node
|
||||
*/
|
||||
ControllerNode addNode(NodeId nodeId, IpPrefix ip, int tcpPort);
|
||||
ControllerNode addNode(NodeId nodeId, IpAddress ip, int tcpPort);
|
||||
|
||||
/**
|
||||
* Removes the specified node from the inventory of cluster nodes.
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.onlab.onos.cluster;
|
||||
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
/**
|
||||
* Represents a controller instance as a member in a cluster.
|
||||
@ -33,7 +33,7 @@ public interface ControllerNode {
|
||||
*
|
||||
* @return IP address
|
||||
*/
|
||||
IpPrefix ip();
|
||||
IpAddress ip();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.onlab.onos.cluster;
|
||||
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@ -14,7 +14,7 @@ public class DefaultControllerNode implements ControllerNode {
|
||||
private static final int DEFAULT_PORT = 9876;
|
||||
|
||||
private final NodeId id;
|
||||
private final IpPrefix ip;
|
||||
private final IpAddress ip;
|
||||
private final int tcpPort;
|
||||
|
||||
// For serialization
|
||||
@ -30,7 +30,7 @@ public class DefaultControllerNode implements ControllerNode {
|
||||
* @param id instance identifier
|
||||
* @param ip instance IP address
|
||||
*/
|
||||
public DefaultControllerNode(NodeId id, IpPrefix ip) {
|
||||
public DefaultControllerNode(NodeId id, IpAddress ip) {
|
||||
this(id, ip, DEFAULT_PORT);
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ public class DefaultControllerNode implements ControllerNode {
|
||||
* @param id instance identifier
|
||||
* @param ip instance IP address
|
||||
*/
|
||||
public DefaultControllerNode(NodeId id, IpPrefix ip, int tcpPort) {
|
||||
public DefaultControllerNode(NodeId id, IpAddress ip, int tcpPort) {
|
||||
this.id = id;
|
||||
this.ip = ip;
|
||||
this.tcpPort = tcpPort;
|
||||
@ -52,7 +52,7 @@ public class DefaultControllerNode implements ControllerNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IpPrefix ip() {
|
||||
public IpAddress ip() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
||||
@ -19,9 +19,9 @@ public class ControllerNodeToNodeIdTest {
|
||||
private static final NodeId NID2 = new NodeId("bar");
|
||||
private static final NodeId NID3 = new NodeId("buz");
|
||||
|
||||
private static final IpPrefix IP1 = IpPrefix.valueOf("127.0.0.1");
|
||||
private static final IpPrefix IP2 = IpPrefix.valueOf("127.0.0.2");
|
||||
private static final IpPrefix IP3 = IpPrefix.valueOf("127.0.0.3");
|
||||
private static final IpAddress IP1 = IpAddress.valueOf("127.0.0.1");
|
||||
private static final IpAddress IP2 = IpAddress.valueOf("127.0.0.2");
|
||||
private static final IpAddress IP3 = IpAddress.valueOf("127.0.0.3");
|
||||
|
||||
private static final ControllerNode CN1 = new DefaultControllerNode(NID1, IP1);
|
||||
private static final ControllerNode CN2 = new DefaultControllerNode(NID2, IP2);
|
||||
|
@ -16,7 +16,7 @@ import org.onlab.onos.cluster.ControllerNode;
|
||||
import org.onlab.onos.cluster.NodeId;
|
||||
import org.onlab.onos.event.AbstractListenerRegistry;
|
||||
import org.onlab.onos.event.EventDeliveryService;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Set;
|
||||
@ -83,7 +83,7 @@ public class ClusterManager implements ClusterService, ClusterAdminService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ControllerNode addNode(NodeId nodeId, IpPrefix ip, int tcpPort) {
|
||||
public ControllerNode addNode(NodeId nodeId, IpAddress ip, int tcpPort) {
|
||||
checkNotNull(nodeId, INSTANCE_ID_NULL);
|
||||
checkNotNull(ip, "IP address cannot be null");
|
||||
checkArgument(tcpPort > 5000, "TCP port must be > 5000");
|
||||
|
@ -16,7 +16,7 @@ import org.onlab.onos.mastership.MastershipService;
|
||||
import org.onlab.onos.mastership.MastershipTermService;
|
||||
import org.onlab.onos.net.DeviceId;
|
||||
import org.onlab.onos.store.trivial.impl.SimpleMastershipStore;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@ -31,7 +31,7 @@ public class MastershipManagerTest {
|
||||
|
||||
private static final NodeId NID_LOCAL = new NodeId("local");
|
||||
private static final NodeId NID_OTHER = new NodeId("foo");
|
||||
private static final IpPrefix LOCALHOST = IpPrefix.valueOf("127.0.0.1");
|
||||
private static final IpAddress LOCALHOST = IpAddress.valueOf("127.0.0.1");
|
||||
private static final DeviceId DEV_MASTER = DeviceId.deviceId("of:1");
|
||||
private static final DeviceId DEV_OTHER = DeviceId.deviceId("of:2");
|
||||
|
||||
|
@ -38,7 +38,7 @@ import org.onlab.onos.net.provider.AbstractProvider;
|
||||
import org.onlab.onos.net.provider.ProviderId;
|
||||
import org.onlab.onos.store.trivial.impl.SimpleDeviceStore;
|
||||
import org.onlab.packet.ChassisId;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@ -69,7 +69,7 @@ public class DeviceManagerTest {
|
||||
private static final PortNumber P2 = PortNumber.portNumber(2);
|
||||
private static final PortNumber P3 = PortNumber.portNumber(3);
|
||||
private static final NodeId NID_LOCAL = new NodeId("local");
|
||||
private static final IpPrefix LOCALHOST = IpPrefix.valueOf("127.0.0.1");
|
||||
private static final IpAddress LOCALHOST = IpAddress.valueOf("127.0.0.1");
|
||||
|
||||
private DeviceManager mgr;
|
||||
|
||||
|
@ -8,7 +8,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.onlab.onos.cluster.DefaultControllerNode;
|
||||
import org.onlab.onos.cluster.NodeId;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -46,7 +46,7 @@ public class ClusterDefinitionStore {
|
||||
while (it.hasNext()) {
|
||||
ObjectNode nodeDef = (ObjectNode) it.next();
|
||||
nodes.add(new DefaultControllerNode(new NodeId(nodeDef.get("id").asText()),
|
||||
IpPrefix.valueOf(nodeDef.get("ip").asText()),
|
||||
IpAddress.valueOf(nodeDef.get("ip").asText()),
|
||||
nodeDef.get("tcpPort").asInt(9876)));
|
||||
}
|
||||
return nodes;
|
||||
|
@ -2,7 +2,7 @@ package org.onlab.onos.store.cluster.impl;
|
||||
|
||||
import org.onlab.onos.cluster.DefaultControllerNode;
|
||||
import org.onlab.onos.cluster.NodeId;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
// Not used right now
|
||||
/**
|
||||
@ -19,7 +19,8 @@ public interface ClusterNodesDelegate {
|
||||
* @param tcpPort node TCP listen port
|
||||
* @return the controller node
|
||||
*/
|
||||
DefaultControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort);
|
||||
DefaultControllerNode nodeDetected(NodeId nodeId, IpAddress ip,
|
||||
int tcpPort);
|
||||
|
||||
/**
|
||||
* Notifies about cluster node going offline.
|
||||
|
@ -22,7 +22,7 @@ import org.onlab.onos.cluster.NodeId;
|
||||
import org.onlab.onos.store.hz.AbsentInvalidatingLoadingCache;
|
||||
import org.onlab.onos.store.hz.AbstractHazelcastStore;
|
||||
import org.onlab.onos.store.hz.OptionalCacheLoader;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -105,7 +105,7 @@ public class DistributedClusterStore
|
||||
}
|
||||
|
||||
@Override
|
||||
public ControllerNode addNode(NodeId nodeId, IpPrefix ip, int tcpPort) {
|
||||
public ControllerNode addNode(NodeId nodeId, IpAddress ip, int tcpPort) {
|
||||
return addNode(new DefaultControllerNode(nodeId, ip, tcpPort));
|
||||
}
|
||||
|
||||
@ -127,13 +127,13 @@ public class DistributedClusterStore
|
||||
|
||||
// Creates a controller node descriptor from the Hazelcast member.
|
||||
private DefaultControllerNode node(Member member) {
|
||||
IpPrefix ip = memberAddress(member);
|
||||
IpAddress ip = memberAddress(member);
|
||||
return new DefaultControllerNode(new NodeId(ip.toString()), ip);
|
||||
}
|
||||
|
||||
private IpPrefix memberAddress(Member member) {
|
||||
private IpAddress memberAddress(Member member) {
|
||||
byte[] address = member.getSocketAddress().getAddress().getAddress();
|
||||
return IpPrefix.valueOf(address);
|
||||
return IpAddress.valueOf(address);
|
||||
}
|
||||
|
||||
// Interceptor for membership events.
|
||||
|
@ -8,7 +8,7 @@ import org.onlab.onos.cluster.DefaultControllerNode;
|
||||
import org.onlab.onos.cluster.NodeId;
|
||||
import org.onlab.onos.store.cluster.impl.ClusterNodesDelegate;
|
||||
import org.onlab.netty.NettyMessagingService;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -27,7 +27,7 @@ public class ClusterCommunicationManagerTest {
|
||||
private static final int P1 = 9881;
|
||||
private static final int P2 = 9882;
|
||||
|
||||
private static final IpPrefix IP = IpPrefix.valueOf("127.0.0.1");
|
||||
private static final IpAddress IP = IpAddress.valueOf("127.0.0.1");
|
||||
|
||||
private ClusterCommunicationManager ccm1;
|
||||
private ClusterCommunicationManager ccm2;
|
||||
@ -104,7 +104,7 @@ public class ClusterCommunicationManagerTest {
|
||||
NodeId nodeId;
|
||||
|
||||
@Override
|
||||
public DefaultControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort) {
|
||||
public DefaultControllerNode nodeDetected(NodeId nodeId, IpAddress ip, int tcpPort) {
|
||||
latch(nodeId, Op.DETECTED);
|
||||
return new DefaultControllerNode(nodeId, ip, tcpPort);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ import org.onlab.onos.store.cluster.messaging.ClusterMessage;
|
||||
import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
|
||||
import org.onlab.onos.store.cluster.messaging.MessageSubject;
|
||||
import org.onlab.packet.ChassisId;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
@ -102,12 +102,12 @@ public class GossipDeviceStoreTest {
|
||||
// local node
|
||||
private static final NodeId NID1 = new NodeId("local");
|
||||
private static final ControllerNode ONOS1 =
|
||||
new DefaultControllerNode(NID1, IpPrefix.valueOf("127.0.0.1"));
|
||||
new DefaultControllerNode(NID1, IpAddress.valueOf("127.0.0.1"));
|
||||
|
||||
// remote node
|
||||
private static final NodeId NID2 = new NodeId("remote");
|
||||
private static final ControllerNode ONOS2 =
|
||||
new DefaultControllerNode(NID2, IpPrefix.valueOf("127.0.0.2"));
|
||||
new DefaultControllerNode(NID2, IpAddress.valueOf("127.0.0.2"));
|
||||
private static final List<SparseAnnotations> NO_ANNOTATION = Collections.<SparseAnnotations>emptyList();
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@ import org.onlab.onos.store.hz.StoreManager;
|
||||
import org.onlab.onos.store.hz.StoreService;
|
||||
import org.onlab.onos.store.hz.TestStoreManager;
|
||||
import org.onlab.onos.store.serializers.KryoSerializer;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.hazelcast.config.Config;
|
||||
@ -47,7 +47,7 @@ public class DistributedMastershipStoreTest {
|
||||
private static final DeviceId DID2 = DeviceId.deviceId("of:02");
|
||||
private static final DeviceId DID3 = DeviceId.deviceId("of:03");
|
||||
|
||||
private static final IpPrefix IP = IpPrefix.valueOf("127.0.0.1");
|
||||
private static final IpAddress IP = IpAddress.valueOf("127.0.0.1");
|
||||
|
||||
private static final NodeId N1 = new NodeId("node1");
|
||||
private static final NodeId N2 = new NodeId("node2");
|
||||
|
@ -12,7 +12,7 @@ import org.onlab.onos.cluster.ControllerNode;
|
||||
import org.onlab.onos.cluster.DefaultControllerNode;
|
||||
import org.onlab.onos.cluster.NodeId;
|
||||
import org.onlab.onos.store.AbstractStore;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Set;
|
||||
@ -29,7 +29,7 @@ public class SimpleClusterStore
|
||||
extends AbstractStore<ClusterEvent, ClusterStoreDelegate>
|
||||
implements ClusterStore {
|
||||
|
||||
public static final IpPrefix LOCALHOST = IpPrefix.valueOf("127.0.0.1");
|
||||
public static final IpAddress LOCALHOST = IpAddress.valueOf("127.0.0.1");
|
||||
|
||||
private final Logger log = getLogger(getClass());
|
||||
|
||||
@ -68,7 +68,7 @@ public class SimpleClusterStore
|
||||
}
|
||||
|
||||
@Override
|
||||
public ControllerNode addNode(NodeId nodeId, IpPrefix ip, int tcpPort) {
|
||||
public ControllerNode addNode(NodeId nodeId, IpAddress ip, int tcpPort) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ import org.onlab.onos.mastership.MastershipTerm;
|
||||
import org.onlab.onos.net.DeviceId;
|
||||
import org.onlab.onos.net.MastershipRole;
|
||||
import org.onlab.onos.store.AbstractStore;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@ -45,7 +45,7 @@ public class SimpleMastershipStore
|
||||
|
||||
private final Logger log = getLogger(getClass());
|
||||
|
||||
public static final IpPrefix LOCALHOST = IpPrefix.valueOf("127.0.0.1");
|
||||
public static final IpAddress LOCALHOST = IpAddress.valueOf("127.0.0.1");
|
||||
|
||||
private ControllerNode instance =
|
||||
new DefaultControllerNode(new NodeId("local"), LOCALHOST);
|
||||
|
Loading…
x
Reference in New Issue
Block a user