Reduced graph handles and thread locals
diff --git a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
index e8b1bf8..b3c31ec 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
@@ -1,39 +1,49 @@
package net.floodlightcontroller.core.internal;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import net.floodlightcontroller.core.INetMapTopologyObjects.IPortObject;
import net.floodlightcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.floodlightcontroller.core.INetMapTopologyService.ITopoSwitchService;
+import net.onrc.onos.util.GraphDBConnection;
+import net.onrc.onos.util.GraphDBConnection.Transaction;
public class TopoSwitchServiceImpl implements ITopoSwitchService {
- ThreadLocal<SwitchStorageImpl> store = new ThreadLocal<SwitchStorageImpl>() {
- @Override
- protected SwitchStorageImpl initialValue() {
- SwitchStorageImpl swStore = new SwitchStorageImpl();
- //TODO: Get the file path from global properties
- swStore.init("/tmp/cassandra.titan");
- return swStore;
- }
- };
+ private GraphDBConnection conn;
+ protected static Logger log = LoggerFactory.getLogger(TopoSwitchServiceImpl.class);
+
+
+ public void finalize() {
+ close();
+ }
- SwitchStorageImpl swStore = store.get();
+ @Override
+ public void close() {
+ conn.endTx(Transaction.COMMIT);
+ conn.close();
+ }
@Override
public Iterable<ISwitchObject> getActiveSwitches() {
// TODO Auto-generated method stub
- return swStore.getActiveSwitches();
+ conn = GraphDBConnection.getInstance("");
+ return conn.utils().getActiveSwitches(conn);
}
@Override
public Iterable<ISwitchObject> getAllSwitches() {
- // TODO Auto-generated method stub
- return swStore.getAllSwitches();
+ // TODO Auto-generated method stub
+ conn = GraphDBConnection.getInstance("");
+ return conn.utils().getAllSwitches(conn);
}
@Override
public Iterable<ISwitchObject> getInactiveSwitches() {
// TODO Auto-generated method stub
- return swStore.getInactiveSwitches();
+ conn = GraphDBConnection.getInstance("");
+ return conn.utils().getInactiveSwitches(conn);
}
@Override