fix compile errors
diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
index d6098af..3592fbc 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
@@ -1450,6 +1450,7 @@
// this method is only called after netty has processed all
// pending messages
log.debug("removeSwitch: {}", sw);
+ swStore.update(sw.getStringId(), SwitchState.INACTIVE, DM_OPERATION.UPDATE);
if (!this.activeSwitches.remove(sw.getId(), sw) || !sw.isConnected()) {
log.debug("Not removing switch {}; already removed", sw);
return;
@@ -1459,6 +1460,7 @@
// from slave controllers. Then we need to move this cancelation
// to switch disconnect
sw.cancelAllStatisticsReplies();
+
// FIXME: I think there's a race condition if we call updateInactiveSwitchInfo
// here if role support is enabled. In that case if the switch is being
@@ -1470,7 +1472,7 @@
// of the switch state that's written to storage.
updateInactiveSwitchInfo(sw);
- swStore.update(sw.getStringId(), SwitchState.ACTIVE, DM_OPERATION.UPDATE);
+
SwitchUpdate update = new SwitchUpdate(sw, SwitchUpdateType.REMOVED);
try {
this.updates.put(update);
@@ -2059,6 +2061,7 @@
this.roleChanger = new RoleChanger();
initVendorMessages();
this.systemStartTime = System.currentTimeMillis();
+ this.swStore = new SwitchStorageImpl();
this.swStore.init("");
}
diff --git a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
index 789f3ba..f6bd103 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
@@ -3,6 +3,11 @@
import java.util.Collection;
import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.commons.configuration.BaseConfiguration;
+import org.apache.commons.configuration.Configuration;
import org.openflow.protocol.OFPhysicalPort;
import com.thinkaurelius.titan.core.TitanException;
@@ -16,6 +21,7 @@
public class SwitchStorageImpl implements ISwitchStorage {
public TitanGraph graph;
+ protected static Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
@Override
public void update(String dpid, SwitchState state, DM_OPERATION op) {
@@ -44,9 +50,11 @@
if ((sw = graph.getVertices("dpid",dpid).iterator().next()) != null) {
sw.setProperty("state",state);
graph.stopTransaction(Conclusion.SUCCESS);
+ log.trace("SwitchStorage:setSTatus dpid:{} state: {} done", dpid, state);
}
} catch (TitanException e) {
// TODO: handle exceptions
+ log.trace("SwitchStorage:setSTatus dpid:{} state: {} failed", dpid, state);
}
@@ -58,6 +66,7 @@
Vertex sw;
try {
if ((sw = graph.getVertices("dpid",dpid).iterator().next()) != null) {
+ log.trace("SwitchStorage:addPort dpid:{} port:{}", dpid, port);
// TODO: Check if port exists
Vertex p = graph.addVertex(null);
p.setProperty("type","port");
@@ -72,6 +81,7 @@
}
} catch (TitanException e) {
// TODO: handle exceptions
+ log.trace("SwitchStorage:addPort dpid:{} port:{}", dpid, port);
}
}
@@ -97,11 +107,14 @@
@Override
public void addSwitch(String dpid) {
+ log.trace("SwitchStorage:addSwitch(): dpid {} ", dpid);
+
try {
if (graph.getVertices("dpid",dpid).iterator().hasNext()) {
/*
* Do nothing or throw exception?
*/
+ log.trace("SwitchStorage:addSwitch dpid:{} already exists", dpid);
} else {
Vertex sw = graph.addVertex(null);
@@ -109,11 +122,13 @@
sw.setProperty("dpid", dpid);
sw.setProperty("state",SwitchState.ACTIVE);
graph.stopTransaction(Conclusion.SUCCESS);
+ log.trace("SwitchStorage:addSwitch dpid:{} added", dpid);
}
} catch (TitanException e) {
/*
* retry till we succeed?
*/
+ log.trace("SwitchStorage:addSwitch dpid:{} failed", dpid);
}
@@ -133,14 +148,17 @@
try {
if ((sw = graph.getVertices("dpid",dpid).iterator().next()) != null) {
// TODO: Check if port exists
+ log.trace("SwitchStorage:deletePort dpid:{} port:{}", dpid, port);
Vertex p = sw.query().direction(Direction.OUT).labels("on").has("number",port).vertices().iterator().next();
if (p != null) {
+ log.trace("SwitchStorage:deletePort dpid:{} port:{} found and deleted", dpid, port);
graph.removeVertex(p);
graph.stopTransaction(Conclusion.SUCCESS);
}
}
} catch (TitanException e) {
// TODO: handle exceptions
+ log.trace("SwitchStorage:deletePort dpid:{} port:{} failed", dpid, port);
}
}
@@ -159,7 +177,9 @@
@Override
public void init(String conf) {
//TODO extract the DB location from conf
- String db = "/tmp/netmap";
+ Configuration db = new BaseConfiguration();
+ db.setProperty("storage,backend","local");
+ db.setProperty("storage.directory","/tmp/netmap");
graph = TitanFactory.open(db);
graph.createKeyIndex("dpid", Vertex.class);
graph.createKeyIndex("type", Vertex.class);
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
index 4e19013..6f7c9b7 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
@@ -1868,6 +1868,7 @@
}
// Initialize the link storage connector to the network map
+ this.linkStore = new LinkStorageImplStubs();
this.linkStore.init("");
ScheduledExecutorService ses = threadPool.getScheduledExecutor();