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

Merge into master from pull request #183:

parents 4635a5c2 e0630717
No related branches found
No related tags found
No related merge requests found
...@@ -191,5 +191,12 @@ public interface IFloodlightProviderService extends IFloodlightService { ...@@ -191,5 +191,12 @@ public interface IFloodlightProviderService extends IFloodlightService {
* @return * @return
*/ */
public Map<String, Object> getControllerInfo(String type); public Map<String, Object> getControllerInfo(String type);
/**
* Return the controller uptime in milliseconds
* @return
*/
public long getSystemUptime();
} }
...@@ -174,6 +174,9 @@ public class Controller implements IFloodlightProviderService, ...@@ -174,6 +174,9 @@ public class Controller implements IFloodlightProviderService,
// If the controller isn't configured to support roles, then this is null. // If the controller isn't configured to support roles, then this is null.
protected Role role; protected Role role;
// Start time of the controller
protected long systemStartTime;
// Storage table names // Storage table names
protected static final String CONTROLLER_TABLE_NAME = "controller_controller"; protected static final String CONTROLLER_TABLE_NAME = "controller_controller";
protected static final String CONTROLLER_ID = "id"; protected static final String CONTROLLER_ID = "id";
...@@ -1926,6 +1929,7 @@ public class Controller implements IFloodlightProviderService, ...@@ -1926,6 +1929,7 @@ public class Controller implements IFloodlightProviderService,
setConfigParams(configParams); setConfigParams(configParams);
this.role = getInitialRole(configParams); this.role = getInitialRole(configParams);
initVendorMessages(); initVendorMessages();
this.systemStartTime = System.currentTimeMillis();
} }
/** /**
...@@ -2096,4 +2100,11 @@ public class Controller implements IFloodlightProviderService, ...@@ -2096,4 +2100,11 @@ public class Controller implements IFloodlightProviderService,
} }
} }
@Override
public long getSystemUptime() {
return (System.currentTimeMillis() - this.systemStartTime);
}
} }
...@@ -59,6 +59,7 @@ public class CoreWebRoutable implements RestletRoutable { ...@@ -59,6 +59,7 @@ public class CoreWebRoutable implements RestletRoutable {
router.attach("/controller/summary/json", ControllerSummaryResource.class); router.attach("/controller/summary/json", ControllerSummaryResource.class);
router.attach("/role/json", ControllerRoleResource.class); router.attach("/role/json", ControllerRoleResource.class);
router.attach("/health/json", HealthCheckResource.class); router.attach("/health/json", HealthCheckResource.class);
router.attach("/system/uptime/json", SystemUptimeResource.class);
return router; return router;
} }
} }
package net.floodlightcontroller.core.web;
import net.floodlightcontroller.core.IFloodlightProviderService;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
public class SystemUptimeResource extends ServerResource {
@Get("json")
public long retrieve() {
IFloodlightProviderService floodlightProvider =
(IFloodlightProviderService)getContext().getAttributes().
get(IFloodlightProviderService.class.getCanonicalName());
return floodlightProvider.getSystemUptime();
}
}
...@@ -291,4 +291,12 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro ...@@ -291,4 +291,12 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override
public long getSystemUptime() {
// TODO Auto-generated method stub
return 0;
}
} }
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