Skip to content
Snippets Groups Projects
Commit ace82c43 authored by abat's avatar abat
Browse files

Merge into master from pull request #3770:

BSC-3926. Set switch's connectedSince when the switch is actually connected. Set to null otherwise. (https://github.com/bigswitch/bigswitchcontroller/pull/3770)
parents 42d64bca be1fff9d
No related branches found
No related tags found
No related merge requests found
......@@ -94,7 +94,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;
......@@ -169,7 +170,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>();
......@@ -1093,6 +1094,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