mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-05-05 04:06:49 +02:00
Remove deprecated Node APIs
Change-Id: I3e235ff213fc376c02ac01eb43f72d72ab4d17f4
This commit is contained in:
parent
e1077f8ed7
commit
f632826bc2
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014-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.cli;
|
||||
|
||||
import org.apache.karaf.shell.api.action.Argument;
|
||||
import org.apache.karaf.shell.api.action.Command;
|
||||
import org.apache.karaf.shell.api.action.lifecycle.Service;
|
||||
import org.onosproject.cluster.ClusterAdminService;
|
||||
import org.onosproject.cluster.DefaultControllerNode;
|
||||
import org.onosproject.cluster.NodeId;
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
/**
|
||||
* Adds a new controller cluster node.
|
||||
*/
|
||||
@Service
|
||||
@Command(scope = "onos", name = "add-node",
|
||||
description = "Adds a new controller cluster node")
|
||||
public class NodeAddCommand extends AbstractShellCommand {
|
||||
|
||||
@Argument(index = 0, name = "nodeId", description = "Node ID",
|
||||
required = true, multiValued = false)
|
||||
String nodeId = null;
|
||||
|
||||
@Argument(index = 1, name = "ip", description = "Node IP address",
|
||||
required = true, multiValued = false)
|
||||
String ip = null;
|
||||
|
||||
@Argument(index = 2, name = "tcpPort", description = "Node TCP listen port",
|
||||
required = false, multiValued = false)
|
||||
int tcpPort = DefaultControllerNode.DEFAULT_PORT;
|
||||
|
||||
@Override
|
||||
protected void doExecute() {
|
||||
ClusterAdminService service = get(ClusterAdminService.class);
|
||||
service.addNode(new NodeId(nodeId), IpAddress.valueOf(ip), tcpPort);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014-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.cli;
|
||||
|
||||
import org.apache.karaf.shell.api.action.Argument;
|
||||
import org.apache.karaf.shell.api.action.Command;
|
||||
import org.apache.karaf.shell.api.action.lifecycle.Service;
|
||||
import org.onosproject.cluster.ClusterAdminService;
|
||||
import org.onosproject.cluster.NodeId;
|
||||
|
||||
/**
|
||||
* Removes a controller cluster node.
|
||||
*/
|
||||
@Service
|
||||
@Command(scope = "onos", name = "remove-node",
|
||||
description = "Removes a new controller cluster node")
|
||||
public class NodeRemoveCommand extends AbstractShellCommand {
|
||||
|
||||
@Argument(index = 0, name = "nodeId", description = "Node ID",
|
||||
required = true, multiValued = false)
|
||||
String nodeId = null;
|
||||
|
||||
@Override
|
||||
protected void doExecute() {
|
||||
ClusterAdminService service = get(ClusterAdminService.class);
|
||||
service.removeNode(new NodeId(nodeId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -15,59 +15,11 @@
|
||||
*/
|
||||
package org.onosproject.cluster;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.onlab.packet.IpAddress;
|
||||
|
||||
/**
|
||||
* Service for administering the cluster node membership.
|
||||
*/
|
||||
public interface ClusterAdminService extends ClusterService {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @deprecated since 1.14
|
||||
*/
|
||||
@Deprecated
|
||||
void formCluster(Set<ControllerNode> nodes);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param partitionSize number of nodes to compose a partition
|
||||
* @deprecated since 1.14
|
||||
*/
|
||||
@Deprecated
|
||||
void formCluster(Set<ControllerNode> nodes, int partitionSize);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Marks the current node as fully started or not.
|
||||
*
|
||||
|
||||
@ -16,14 +16,10 @@
|
||||
package org.onosproject.cluster.impl;
|
||||
|
||||
import org.apache.karaf.system.SystemService;
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.onosproject.cluster.ClusterAdminService;
|
||||
import org.onosproject.cluster.ClusterEvent;
|
||||
import org.onosproject.cluster.ClusterEventListener;
|
||||
import org.onosproject.cluster.ClusterMetadata;
|
||||
import org.onosproject.cluster.ClusterMetadataDiff;
|
||||
import org.onosproject.cluster.ClusterMetadataEvent;
|
||||
import org.onosproject.cluster.ClusterMetadataEventListener;
|
||||
import org.onosproject.cluster.ClusterService;
|
||||
import org.onosproject.cluster.ClusterStore;
|
||||
import org.onosproject.cluster.ClusterStoreDelegate;
|
||||
@ -43,7 +39,6 @@ import java.time.Instant;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.onosproject.security.AppGuard.checkPermission;
|
||||
import static org.onosproject.security.AppPermission.Type.CLUSTER_READ;
|
||||
@ -70,7 +65,6 @@ public class ClusterManager
|
||||
protected SystemService systemService;
|
||||
|
||||
private final AtomicReference<ClusterMetadata> currentMetadata = new AtomicReference<>();
|
||||
private final InternalClusterMetadataListener metadataListener = new InternalClusterMetadataListener();
|
||||
|
||||
@Activate
|
||||
public void activate() {
|
||||
@ -136,30 +130,6 @@ public class ClusterManager
|
||||
return store.getLastUpdatedInstant(nodeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void formCluster(Set<ControllerNode> nodes) {
|
||||
formCluster(nodes, DEFAULT_PARTITION_SIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void formCluster(Set<ControllerNode> nodes, int partitionSize) {
|
||||
log.warn("formCluster is deprecated");
|
||||
}
|
||||
|
||||
@Override
|
||||
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");
|
||||
return store.addNode(nodeId, ip, tcpPort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode(NodeId nodeId) {
|
||||
checkNotNull(nodeId, INSTANCE_ID_NULL);
|
||||
store.removeNode(nodeId);
|
||||
}
|
||||
|
||||
// Store delegate to re-post events emitted from the store.
|
||||
private class InternalStoreDelegate implements ClusterStoreDelegate {
|
||||
@Override
|
||||
@ -167,25 +137,4 @@ public class ClusterManager
|
||||
post(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes metadata by adding and removing nodes from the cluster.
|
||||
*/
|
||||
private synchronized void processMetadata(ClusterMetadata metadata) {
|
||||
try {
|
||||
ClusterMetadataDiff examiner =
|
||||
new ClusterMetadataDiff(currentMetadata.get(), metadata);
|
||||
examiner.nodesAdded().forEach(node -> addNode(node.id(), node.ip(), node.tcpPort()));
|
||||
examiner.nodesRemoved().forEach(this::removeNode);
|
||||
} finally {
|
||||
currentMetadata.set(metadata);
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalClusterMetadataListener implements ClusterMetadataEventListener {
|
||||
@Override
|
||||
public void event(ClusterMetadataEvent event) {
|
||||
processMetadata(event.subject());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user