Skip to content
Snippets Groups Projects
Commit be1fff9d authored by Gregor Maier's avatar Gregor Maier
Browse files

BSC-3926. Set switch's connectedSince when the switch is actually connected. Set to null otherwise.

parent 869dd7d0
No related branches found
No related tags found
No related merge requests found
......@@ -95,7 +95,8 @@ public abstract class OFSwitchBase implements IOFSwitch {
protected IFloodlightProviderService floodlightProvider;
protected IThreadPoolService threadPool;
protected IDebugCounterService debugCounters;
protected Date connectedSince;
// FIXME: Don't use java.util.Date
protected volatile Date connectedSince;
/* Switch features from initial featuresReply */
protected int capabilities;
......@@ -170,7 +171,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
public OFSwitchBase() {
this.stringId = null;
this.attributes = new ConcurrentHashMap<Object, Object>();
this.connectedSince = new Date();
this.connectedSince = null;
this.transactionIdSource = new AtomicInteger();
this.connected = false;
this.statsFutureMap = new ConcurrentHashMap<Integer,OFStatisticsFuture>();
......@@ -1094,6 +1095,10 @@ public abstract class OFSwitchBase implements IOFSwitch {
@JsonIgnore
public void setConnected(boolean connected) {
// No lock needed since we use volatile
if (connected && this.connectedSince == null)
this.connectedSince = new Date();
else if (!connected)
this.connectedSince = null;
this.connected = connected;
}
......
......@@ -92,6 +92,8 @@ public class ControllerSwitchesResource extends ServerResource {
}
public long getConnectedSince() {
if (sw.getConnectedSince() == null)
return 0;
return sw.getConnectedSince().getTime();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment