Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.core.internal; |
| 2 | |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 3 | import net.floodlightcontroller.core.INetMapTopologyObjects.IPortObject; |
Pankaj Berde | 1e2f731 | 2013-02-15 08:25:31 -0800 | [diff] [blame] | 4 | import net.floodlightcontroller.core.INetMapTopologyObjects.ISwitchObject; |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 5 | import net.floodlightcontroller.core.INetMapTopologyService.ITopoSwitchService; |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 6 | import net.onrc.onos.util.GraphDBConnection; |
| 7 | import net.onrc.onos.util.GraphDBConnection.Transaction; |
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 | |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 14 | private GraphDBConnection conn; |
| 15 | protected static Logger log = LoggerFactory.getLogger(TopoSwitchServiceImpl.class); |
| 16 | |
| 17 | |
| 18 | public void finalize() { |
| 19 | close(); |
| 20 | } |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 21 | |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 22 | @Override |
| 23 | public void close() { |
Pankaj Berde | 6201614 | 2013-04-09 15:35:50 -0700 | [diff] [blame] | 24 | |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 25 | conn.close(); |
| 26 | } |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 27 | |
| 28 | @Override |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 29 | public Iterable<ISwitchObject> getActiveSwitches() { |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 30 | // TODO Auto-generated method stub |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 31 | conn = GraphDBConnection.getInstance("/tmp/cassandra.titan"); |
Jonathan Hart | e6e9187 | 2013-04-13 11:10:32 -0700 | [diff] [blame^] | 32 | conn.close(); //Commit to ensure we see latest data |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 33 | return conn.utils().getActiveSwitches(conn); |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | @Override |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 37 | public Iterable<ISwitchObject> getAllSwitches() { |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 38 | // TODO Auto-generated method stub |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 39 | conn = GraphDBConnection.getInstance("/tmp/cassandra.titan"); |
Jonathan Hart | e6e9187 | 2013-04-13 11:10:32 -0700 | [diff] [blame^] | 40 | conn.close(); //Commit to ensure we see latest data |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 41 | return conn.utils().getAllSwitches(conn); |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | @Override |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 45 | public Iterable<ISwitchObject> getInactiveSwitches() { |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 46 | // TODO Auto-generated method stub |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 47 | conn = GraphDBConnection.getInstance("/tmp/cassandra.titan"); |
Jonathan Hart | e6e9187 | 2013-04-13 11:10:32 -0700 | [diff] [blame^] | 48 | conn.close(); //Commit to ensure we see latest data |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 49 | return conn.utils().getInactiveSwitches(conn); |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | @Override |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 53 | public Iterable<IPortObject> getPortsOnSwitch(String dpid) { |
| 54 | // TODO Auto-generated method stub |
| 55 | return null; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public IPortObject getPortOnSwitch(String dpid, short port_num) { |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 60 | // TODO Auto-generated method stub |
| 61 | return null; |
Pankaj Berde | d18c762 | 2013-02-04 10:28:35 -0800 | [diff] [blame] | 62 | } |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 63 | } |