How to use getNbPendingExecutions method of org.cerberus.servlet.zzpublic.ManageV001 class

Best Cerberus-source code snippet using org.cerberus.servlet.zzpublic.ManageV001.getNbPendingExecutions

Source:ManageV001.java Github

copy

Full Screen

...78 if (token.equals(request.getParameter("token"))) {79 int maxIteration = parameterService.getParameterIntegerByKey("cerberus_manage_timeout", "", 300);80 int cntIteration = 0;81 int instancePendingExecutionNb = euuid.size();82 int globalPendingExecutionNb = getNbPendingExecutions(appContext);83 boolean globalActive = parameterService.getParameterBooleanByKey("cerberus_queueexecution_enable", "", true);84 if (request.getParameter("action") != null && request.getParameter("action").equals("stop")) {85 if (request.getParameter("scope") != null && request.getParameter("scope").equals("instance")) {86 /**87 * We desactivate the instance to process new execution.88 */89 executionThreadPoolService.setInstanceActive(false);90 /**91 * We loop every second until maxIteration session in92 * order to wait until no more executions are running on93 * that instance.94 */95 while (instancePendingExecutionNb > 0 && cntIteration <= maxIteration) {96 cntIteration++;97 Thread.sleep(1000);98 instancePendingExecutionNb = euuid.size();99 LOG.info("Stopping instance : Check " + cntIteration + "/" + maxIteration + " on pending executions on that instance. Still running : " + instancePendingExecutionNb);100 }101 data.put("waitedIterations", cntIteration);102 } else if (request.getParameter("scope") != null && request.getParameter("scope").equals("global")) {103 /**104 * We desactivate globally the queue processing accross105 * all instances.106 */107 parameterService.setParameter("cerberus_queueexecution_enable", "", "N");108 /**109 * We loop every second until maxIteration session in110 * order to wait until no more executions are running.111 */112 while (globalPendingExecutionNb > 0 && cntIteration <= maxIteration) {113 cntIteration++;114 Thread.sleep(1000);115 // TODO116 globalPendingExecutionNb = getNbPendingExecutions(appContext);117 LOG.info("Stopping global : Check " + cntIteration + "/" + maxIteration + " on global pending executions. Still running : " + globalPendingExecutionNb);118 }119 data.put("waitedIterations", cntIteration);120 } else {121 message += "Scope parameter 'scope' not defined.";122 }123 }124 if (request.getParameter("action") != null && request.getParameter("action").equals("start")) {125 if (request.getParameter("scope") != null && request.getParameter("scope").equals("instance")) {126 /**127 * We activate the instance to process queue and start128 * new executions.129 */130 executionThreadPoolService.setInstanceActive(true);131 try {132 // Run the Execution pool Job.133 executionThreadPoolService.executeNextInQueueAsynchroneously(false);134 } catch (CerberusException ex) {135 LOG.error("Exception triggering the ThreadPool job.", ex);136 }137 } else if (request.getParameter("scope") != null && request.getParameter("scope").equals("global")) {138 /**139 * We activate the parameter to process queue (that will140 * start new executions).141 */142 parameterService.setParameter("cerberus_queueexecution_enable", "", "Y");143 } else {144 message += "Scope parameter 'scope' not defined.";145 }146 }147 JSONObject instance = new JSONObject();148 JSONObject global = new JSONObject();149 instance.put("active", executionThreadPoolService.isInstanceActive());150 instance.put("runningExecutions", instancePendingExecutionNb);151 instance.put("readyToStop", (instancePendingExecutionNb <= 0));152 data.put("instance", instance);153 global.put("active", globalActive);154 global.put("runningExecutions", globalPendingExecutionNb);155 global.put("readyToStop", (globalPendingExecutionNb <= 0));156 data.put("global", global);157 JSONObject fsSize = new JSONObject();158 fsSize.put("cerberus_exeautomedia_path", getFSSize(parameterService.getParameterStringByKey("cerberus_exeautomedia_path", "", "/")));159 fsSize.put("cerberus_applicationobject_path", getFSSize(parameterService.getParameterStringByKey("cerberus_applicationobject_path", "", "/")));160 fsSize.put("cerberus_exemanualmedia_path", getFSSize(parameterService.getParameterStringByKey("cerberus_exemanualmedia_path", "", "/")));161 fsSize.put("cerberus_ftpfile_path", getFSSize(parameterService.getParameterStringByKey("cerberus_ftpfile_path", "", "/")));162 fsSize.put("cerberus_testdatalibcsv_path", getFSSize(parameterService.getParameterStringByKey("cerberus_testdatalibcsv_path", "", "/")));163 data.put("fileSystemSize", fsSize);164 } else {165 message = "Invalid Token";166 }167 data.put("message", message);168 } catch (JSONException | InterruptedException ex) {169 LOG.error(ex);170 }171 response.getWriter().print(data.toString());172 }173 private int getNbPendingExecutions(ApplicationContext appContext) {174 try {175 tceiqService = appContext.getBean(ITestCaseExecutionQueueService.class);176 // Getting all executions already running in the queue.177 AnswerList<TestCaseExecutionQueueToTreat> answer = tceiqService.readQueueRunning();178 List<TestCaseExecutionQueueToTreat> executionsRunning = answer.getDataList();179 return executionsRunning.size();180 } catch (CerberusException ex) {181 LOG.error(ex);182 }183 return 0;184 }185 private JSONObject getFSSize(String path) {186 JSONObject exeFS = new JSONObject();187 LOG.debug(path);...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful