2 * Copyright 2015 Open Networking Laboratory
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onosproject.ovsdb.controller.driver;
19 import org.onlab.packet.IpAddress;
20 import org.onlab.packet.TpPort;
21 import org.onosproject.ovsdb.controller.OvsdbClientService;
22 import org.onosproject.ovsdb.controller.OvsdbController;
23 import org.onosproject.ovsdb.controller.OvsdbEventListener;
24 import org.onosproject.ovsdb.controller.OvsdbNodeId;
25 import org.onosproject.ovsdb.controller.OvsdbNodeListener;
27 import java.util.ArrayList;
28 import java.util.Arrays;
29 import java.util.List;
30 import java.util.concurrent.ConcurrentHashMap;
33 * Test Adapter for OvsdbController.
35 public class OvsdbControllerAdapter implements OvsdbController {
36 protected ConcurrentHashMap<OvsdbNodeId, OvsdbClientServiceAdapter> ovsdbClients =
37 new ConcurrentHashMap<OvsdbNodeId, OvsdbClientServiceAdapter>();
40 public void addNodeListener(OvsdbNodeListener listener) {
45 public void removeNodeListener(OvsdbNodeListener listener) {
50 public void addOvsdbEventListener(OvsdbEventListener listener) {
55 public void removeOvsdbEventListener(OvsdbEventListener listener) {
60 public List<OvsdbNodeId> getNodeIds() {
62 return new ArrayList<OvsdbNodeId>(Arrays.asList(
63 new OvsdbNodeId(IpAddress.valueOf("127.0.0.1"), port)));
67 public OvsdbClientService getOvsdbClient(OvsdbNodeId nodeId) {
68 return ovsdbClients.get(nodeId);
72 public void connect(IpAddress ip, TpPort port) {