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