Skip to content
Snippets Groups Projects
Commit 345b3b86 authored by Saurav Das's avatar Saurav Das
Browse files

Merge branch 'master' of github.com:bigswitch/bigswitchcontroller

parents 4b98845b d2da6cc6
No related branches found
No related tags found
No related merge requests found
...@@ -211,6 +211,17 @@ public interface IFloodlightProviderService extends ...@@ -211,6 +211,17 @@ public interface IFloodlightProviderService extends
*/ */
public void setAlwaysClearFlowsOnSwAdd(boolean value); public void setAlwaysClearFlowsOnSwAdd(boolean value);
/**
* Get controller memory information
*/
public Map<String, Long> getMemory();
/**
* returns the uptime of this controller.
* @return
*/
public Long getUptime();
/** /**
* Adds an OFSwitch driver * Adds an OFSwitch driver
* @param desc The starting portion of switch's manufacturer string * @param desc The starting portion of switch's manufacturer string
......
...@@ -19,6 +19,8 @@ package net.floodlightcontroller.core.internal; ...@@ -19,6 +19,8 @@ package net.floodlightcontroller.core.internal;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedChannelException;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -199,9 +201,6 @@ public class Controller implements IFloodlightProviderService, ...@@ -199,9 +201,6 @@ public class Controller implements IFloodlightProviderService,
protected RoleChanger roleChanger; protected RoleChanger roleChanger;
protected SingletonTask roleChangeDamper; protected SingletonTask roleChangeDamper;
// Start time of the controller
protected long systemStartTime;
// Flag to always flush flow table on switch reconnect (HA or otherwise) // Flag to always flush flow table on switch reconnect (HA or otherwise)
protected boolean alwaysClearFlowsOnSwAdd = false; protected boolean alwaysClearFlowsOnSwAdd = false;
...@@ -1791,7 +1790,6 @@ public class Controller implements IFloodlightProviderService, ...@@ -1791,7 +1790,6 @@ public class Controller implements IFloodlightProviderService,
this.notifiedRole = this.role; this.notifiedRole = this.role;
this.roleChanger = new RoleChanger(this); this.roleChanger = new RoleChanger(this);
initVendorMessages(); initVendorMessages();
this.systemStartTime = System.currentTimeMillis();
String option = configParams.get("flushSwitchesOnReconnect"); String option = configParams.get("flushSwitchesOnReconnect");
...@@ -1972,7 +1970,8 @@ public class Controller implements IFloodlightProviderService, ...@@ -1972,7 +1970,8 @@ public class Controller implements IFloodlightProviderService,
@Override @Override
public long getSystemStartTime() { public long getSystemStartTime() {
return (this.systemStartTime); RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
return rb.getStartTime();
} }
@Override @Override
...@@ -1984,6 +1983,21 @@ public class Controller implements IFloodlightProviderService, ...@@ -1984,6 +1983,21 @@ public class Controller implements IFloodlightProviderService,
return this.alwaysClearFlowsOnSwAdd; return this.alwaysClearFlowsOnSwAdd;
} }
@Override
public Map<String, Long> getMemory() {
Map<String, Long> m = new HashMap<String, Long>();
Runtime runtime = Runtime.getRuntime();
m.put("total", runtime.totalMemory());
m.put("free", runtime.freeMemory());
return m;
}
@Override
public Long getUptime() {
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
return rb.getUptime();
}
@Override @Override
public void addOFSwitchDriver(String description, IOFSwitchDriver driver) { public void addOFSwitchDriver(String description, IOFSwitchDriver driver) {
IOFSwitchDriver existingDriver = switchBindingMap.get(description); IOFSwitchDriver existingDriver = switchBindingMap.get(description);
......
...@@ -23,25 +23,24 @@ import org.restlet.resource.ServerResource; ...@@ -23,25 +23,24 @@ import org.restlet.resource.ServerResource;
public class SystemUptimeResource extends ServerResource { public class SystemUptimeResource extends ServerResource {
public class UptimeRest { public class UptimeRest {
long systemUptimeMsec; long systemUptimeMsec;
public long getSystemUptimeMsec() { public long getSystemUptimeMsec() {
return systemUptimeMsec; return systemUptimeMsec;
} }
} }
@Get("json") @Get("json")
public UptimeRest retrieve() { public UptimeRest retrieve() {
IFloodlightProviderService floodlightProvider = IFloodlightProviderService floodlightProvider =
(IFloodlightProviderService)getContext().getAttributes(). (IFloodlightProviderService)getContext().getAttributes().
get(IFloodlightProviderService.class.getCanonicalName()); get(IFloodlightProviderService.class.getCanonicalName());
UptimeRest uptime = new UptimeRest(); UptimeRest uptime = new UptimeRest();
uptime.systemUptimeMsec = uptime.systemUptimeMsec = floodlightProvider.getUptime();
System.currentTimeMillis() - floodlightProvider.getSystemStartTime();
return (uptime);
return (uptime); }
}
} }
...@@ -54,4 +54,6 @@ public interface IRoutingDecision { ...@@ -54,4 +54,6 @@ public interface IRoutingDecision {
public void setMulticastInterfaces(List<SwitchPort> lspt); public void setMulticastInterfaces(List<SwitchPort> lspt);
public Integer getWildcards(); public Integer getWildcards();
public void setWildcards(Integer wildcards); public void setWildcards(Integer wildcards);
public short getHardTimeout();
public void setHardTimeout(short hardTimeout);
} }
...@@ -29,6 +29,7 @@ public class RoutingDecision implements IRoutingDecision { ...@@ -29,6 +29,7 @@ public class RoutingDecision implements IRoutingDecision {
protected RoutingAction action; protected RoutingAction action;
protected Integer wildcards; protected Integer wildcards;
protected short hardTimeout;
protected SwitchPort srcPort; protected SwitchPort srcPort;
protected IDevice srcDevice; protected IDevice srcDevice;
protected List<IDevice> destDevices; protected List<IDevice> destDevices;
...@@ -46,6 +47,7 @@ public class RoutingDecision implements IRoutingDecision { ...@@ -46,6 +47,7 @@ public class RoutingDecision implements IRoutingDecision {
Collections.synchronizedList(new ArrayList<SwitchPort>()); Collections.synchronizedList(new ArrayList<SwitchPort>());
this.action = action; this.action = action;
this.wildcards = null; this.wildcards = null;
this.hardTimeout = ForwardingBase.FLOWMOD_DEFAULT_HARD_TIMEOUT;
} }
@Override @Override
...@@ -100,6 +102,16 @@ public class RoutingDecision implements IRoutingDecision { ...@@ -100,6 +102,16 @@ public class RoutingDecision implements IRoutingDecision {
this.wildcards = wildcards; this.wildcards = wildcards;
} }
@Override
public short getHardTimeout() {
return hardTimeout;
}
@Override
public void setHardTimeout(short hardTimeout) {
this.hardTimeout = hardTimeout;
}
@Override @Override
public void addToContext(FloodlightContext cntx) { public void addToContext(FloodlightContext cntx) {
rtStore.put(cntx, IRoutingDecision.CONTEXT_DECISION, this); rtStore.put(cntx, IRoutingDecision.CONTEXT_DECISION, this);
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
package net.floodlightcontroller.core.test; package net.floodlightcontroller.core.test;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
...@@ -361,4 +363,18 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro ...@@ -361,4 +363,18 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
return null; return null;
} }
@Override
public Map<String, Long> getMemory() {
Map<String, Long> m = new HashMap<String, Long>();
Runtime runtime = Runtime.getRuntime();
m.put("total", runtime.totalMemory());
m.put("free", runtime.freeMemory());
return m;
}
@Override
public Long getUptime() {
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
return rb.getUptime();
}
} }
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