HIGUCHI Yuta | ed49ef7 | 2013-06-12 11:34:10 -0700 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.core.internal; |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 2 | |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 3 | import net.onrc.onos.graph.GraphDBOperation; |
HIGUCHI Yuta | 2051490 | 2013-06-12 11:24:16 -0700 | [diff] [blame] | 4 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject; |
| 5 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject; |
| 6 | import net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoSwitchService; |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 7 | |
Pankaj Berde | 6201614 | 2013-04-09 15:35:50 -0700 | [diff] [blame] | 8 | import org.slf4j.Logger; |
| 9 | import org.slf4j.LoggerFactory; |
| 10 | |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 11 | public class TopoSwitchServiceImpl implements ITopoSwitchService { |
Yuta HIGUCHI | 67a7a3e | 2014-01-03 14:51:34 -0800 | [diff] [blame] | 12 | |
Toshio Koide | 63622ea | 2013-06-13 13:34:28 -0700 | [diff] [blame] | 13 | private GraphDBOperation op; |
Yuta HIGUCHI | 6ac8d18 | 2013-10-22 15:24:56 -0700 | [diff] [blame] | 14 | protected final static Logger log = LoggerFactory.getLogger(TopoSwitchServiceImpl.class); |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 15 | |
Toshio Koide | 63622ea | 2013-06-13 13:34:28 -0700 | [diff] [blame] | 16 | public TopoSwitchServiceImpl(String conf) { |
Toshio Koide | bfe9b92 | 2013-06-18 10:56:05 -0700 | [diff] [blame] | 17 | op = new GraphDBOperation(conf); |
Toshio Koide | 63622ea | 2013-06-13 13:34:28 -0700 | [diff] [blame] | 18 | } |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 19 | |
Toshio Koide | 63622ea | 2013-06-13 13:34:28 -0700 | [diff] [blame] | 20 | public TopoSwitchServiceImpl() { |
Pavlin Radoslavov | 0eac86d | 2013-10-18 18:40:16 -0700 | [diff] [blame] | 21 | this(""); |
Toshio Koide | 63622ea | 2013-06-13 13:34:28 -0700 | [diff] [blame] | 22 | } |
Yuta HIGUCHI | 67a7a3e | 2014-01-03 14:51:34 -0800 | [diff] [blame] | 23 | |
| 24 | @Override |
| 25 | protected void finalize() { |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 26 | close(); |
| 27 | } |
Yuta HIGUCHI | 67a7a3e | 2014-01-03 14:51:34 -0800 | [diff] [blame] | 28 | |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 29 | @Override |
| 30 | public void close() { |
Toshio Koide | 63622ea | 2013-06-13 13:34:28 -0700 | [diff] [blame] | 31 | op.close(); |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 32 | } |
Yuta HIGUCHI | 67a7a3e | 2014-01-03 14:51:34 -0800 | [diff] [blame] | 33 | |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 34 | @Override |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 35 | public Iterable<ISwitchObject> getActiveSwitches() { |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 36 | // TODO Auto-generated method stub |
Toshio Koide | 63622ea | 2013-06-13 13:34:28 -0700 | [diff] [blame] | 37 | op.close(); //Commit to ensure we see latest data |
| 38 | return op.getActiveSwitches(); |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | @Override |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 42 | public Iterable<ISwitchObject> getAllSwitches() { |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 43 | // TODO Auto-generated method stub |
Toshio Koide | 63622ea | 2013-06-13 13:34:28 -0700 | [diff] [blame] | 44 | op.close(); //Commit to ensure we see latest data |
| 45 | return op.getAllSwitches(); |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | @Override |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 49 | public Iterable<ISwitchObject> getInactiveSwitches() { |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 50 | // TODO Auto-generated method stub |
Toshio Koide | 63622ea | 2013-06-13 13:34:28 -0700 | [diff] [blame] | 51 | op.close(); //Commit to ensure we see latest data |
| 52 | return op.getInactiveSwitches(); |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | @Override |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 56 | public Iterable<IPortObject> getPortsOnSwitch(String dpid) { |
Jonathan Hart | 9a21e0d | 2013-11-14 15:09:09 -0800 | [diff] [blame] | 57 | op.close(); //Commit to ensure we see latest data |
| 58 | ISwitchObject switchObject = op.searchSwitch(dpid); |
| 59 | if (switchObject != null) { |
| 60 | return switchObject.getPorts(); |
| 61 | } |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 62 | return null; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public IPortObject getPortOnSwitch(String dpid, short port_num) { |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 67 | // TODO Auto-generated method stub |
| 68 | return null; |
Yuta HIGUCHI | 67a7a3e | 2014-01-03 14:51:34 -0800 | [diff] [blame] | 69 | } |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 70 | } |