Initial impl for NetMap service
diff --git a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
index 1be6e44..be33659 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
@@ -1,5 +1,6 @@
package net.floodlightcontroller.core.internal;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -198,8 +199,14 @@
@Override
public List<String> getActiveSwitches() {
- // TODO Auto-generated method stub
- return null;
+ // TODO Add unit test
+ List<String> switches = new ArrayList<String>();
+ for (Vertex V : graph.getVertices("type","switch")) {
+ if (V.getProperty("state").equals(SwitchState.ACTIVE.toString())) {
+ switches.add((String) V.getProperty("dpid"));
+ }
+ }
+ return switches;
}
@Override
@@ -219,4 +226,27 @@
}
}
+ @Override
+ public List<String> getAllSwitches() {
+ // TODO Auto-generated method stub
+ List<String> switches = new ArrayList<String>();
+ for (Vertex V : graph.getVertices("type","switch")) {
+ switches.add((String) V.getProperty("dpid"));
+ }
+ return switches;
+ }
+
+ @Override
+ public List<String> getInactiveSwitches() {
+ // TODO Auto-generated method stub
+ List<String> switches = new ArrayList<String>();
+ for (Vertex V : graph.getVertices("type","switch")) {
+ if (V.getProperty("state").equals(SwitchState.INACTIVE.toString())) {
+ switches.add((String) V.getProperty("dpid"));
+ }
+ }
+ return switches;
+ }
+
+
}
diff --git a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImplStubs.java b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImplStubs.java
index c281141..88f94db 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImplStubs.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImplStubs.java
@@ -111,4 +111,16 @@
}
+ @Override
+ public List<String> getAllSwitches() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<String> getInactiveSwitches() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
diff --git a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
new file mode 100644
index 0000000..99f291d
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
@@ -0,0 +1,45 @@
+package net.floodlightcontroller.core.internal;
+
+import java.util.List;
+
+import net.floodlightcontroller.core.INetMapTopologyService.ITopoSwitchService;
+
+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;
+ }
+ };
+
+ SwitchStorageImpl swStore = store.get();
+
+ @Override
+ public List<String> GetActiveSwitches() {
+ // TODO Auto-generated method stub
+ return swStore.getActiveSwitches();
+ }
+
+ @Override
+ public List<String> GetAllSwitches() {
+ // TODO Auto-generated method stub
+ return swStore.getAllSwitches();
+ }
+
+ @Override
+ public List<String> GetInactiveSwitches() {
+ // TODO Auto-generated method stub
+ return swStore.getInactiveSwitches();
+ }
+
+ @Override
+ public List<String> GetPortsOnSwitch(String dpid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}