use of org.cerberus.crud.entity.SessionCounter in project cerberus-source by cerberustesting.
the class ReadCerberusDetailInformation method processRequest.
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
JSONObject jsonResponse = new JSONObject();
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
ExecutionUUID euuid = appContext.getBean(ExecutionUUID.class);
SessionCounter sc = appContext.getBean(SessionCounter.class);
Infos infos = new Infos();
try {
jsonResponse.put("simultaneous_execution", euuid.size());
JSONArray executionArray = new JSONArray();
for (Object ex : euuid.getExecutionUUIDList().values()) {
TestCaseExecution execution = (TestCaseExecution) ex;
JSONObject object = new JSONObject();
object.put("id", execution.getId());
object.put("test", execution.getTest());
object.put("testcase", execution.getTestCase());
object.put("system", execution.getApplicationObj().getSystem());
object.put("application", execution.getApplication());
object.put("environment", execution.getEnvironmentData());
object.put("country", execution.getCountry());
object.put("robotIP", execution.getSeleniumIP());
object.put("tag", execution.getTag());
object.put("start", new Timestamp(execution.getStart()));
executionArray.put(object);
}
jsonResponse.put("simultaneous_execution_list", executionArray);
jsonResponse.put("simultaneous_session", sc.getTotalActiveSession());
jsonResponse.put("active_users", sc.getActiveUsers());
cerberusDatabaseInformation = appContext.getBean(ICerberusInformationDAO.class);
AnswerItem ans = cerberusDatabaseInformation.getDatabaseInformation();
HashMap<String, String> cerberusInformation = (HashMap<String, String>) ans.getItem();
// Database Informations.
jsonResponse.put("DatabaseProductName", cerberusInformation.get("DatabaseProductName"));
jsonResponse.put("DatabaseProductVersion", cerberusInformation.get("DatabaseProductVersion"));
jsonResponse.put("DatabaseMajorVersion", cerberusInformation.get("DatabaseMajorVersion"));
jsonResponse.put("DatabaseMinorVersion", cerberusInformation.get("DatabaseMinorVersion"));
jsonResponse.put("DriverName", cerberusInformation.get("DriverName"));
jsonResponse.put("DriverVersion", cerberusInformation.get("DriverVersion"));
jsonResponse.put("DriverMajorVersion", cerberusInformation.get("DriverMajorVersion"));
jsonResponse.put("DriverMinorVersion", cerberusInformation.get("DriverMinorVersion"));
jsonResponse.put("JDBCMajorVersion", cerberusInformation.get("JDBCMajorVersion"));
jsonResponse.put("JDBCMinorVersion", cerberusInformation.get("JDBCMinorVersion"));
// Cerberus Informations.
jsonResponse.put("projectName", infos.getProjectName());
jsonResponse.put("projectVersion", infos.getProjectVersion());
jsonResponse.put("environment", System.getProperty("org.cerberus.environment"));
databaseVersionService = appContext.getBean(IDatabaseVersioningService.class);
jsonResponse.put("databaseCerberusTargetVersion", databaseVersionService.getSQLScript().size());
myVersionService = appContext.getBean(IMyVersionService.class);
if (myVersionService.findMyVersionByKey("database") != null) {
jsonResponse.put("databaseCerberusCurrentVersion", myVersionService.findMyVersionByKey("database").getValue());
} else {
jsonResponse.put("databaseCerberusCurrentVersion", "0");
}
// JAVA Informations.
jsonResponse.put("javaVersion", System.getProperty("java.version"));
Runtime instance = Runtime.getRuntime();
int mb = 1024 * 1024;
jsonResponse.put("javaFreeMemory", instance.freeMemory() / mb);
jsonResponse.put("javaTotalMemory", instance.totalMemory() / mb);
jsonResponse.put("javaUsedMemory", (instance.totalMemory() - instance.freeMemory()) / mb);
jsonResponse.put("javaMaxMemory", instance.maxMemory() / mb);
String str1 = getServletContext().getServerInfo();
jsonResponse.put("applicationServerInfo", str1);
} catch (JSONException ex) {
LOG.warn(ex);
}
response.setContentType("application/json");
response.getWriter().print(jsonResponse.toString());
}
Aggregations