private void removeThreadGroupFromEngine(AbstractThreadGroup group) { try { StandardJMeterEngine engine = JMeterContextService.getContext().getEngine(); Field groupsField = StandardJMeterEngine.class.getDeclaredField("groups"); groupsField.setAccessible(true); List<AbstractThreadGroup> groups = (List<AbstractThreadGroup>) groupsField.get(engine); groups.remove(group); } catch (ReflectiveOperationException ex) { log.warn("Can not remove DummyThreadGroup from engine", ex); } }
private void addThreadGroupToEngine(AbstractThreadGroup group) { try { StandardJMeterEngine engine = JMeterContextService.getContext().getEngine(); Field groupsField = StandardJMeterEngine.class.getDeclaredField("groups"); groupsField.setAccessible(true); List<AbstractThreadGroup> groups = (List<AbstractThreadGroup>) groupsField.get(engine); groups.add(group); } catch (ReflectiveOperationException ex) { log.warn("Can not add DummyThreadGroup to engine", ex); } }
protected void stopTest() { if (stopTries > 30) { throw new RuntimeException("More than 30 seconds - stopping by exception"); } if (lastStopTry == time) { return; } log.info("No further RPS schedule, asking threads to stop..."); lastStopTry = time; stopTries++; if (stopTries > 10) { log.info("Tries more than 10, stop it NOW!"); StandardJMeterEngine.stopEngineNow(); } else if (stopTries > 5) { log.info("Tries more than 5, stop it!"); StandardJMeterEngine.stopEngine(); } else { JMeterContextService.getContext().getEngine().askThreadsToStop(); } }
jmThread.setThreadName("parallel " + this.getName()); jmThread.setThreadGroup(threadGroup); jmThread.setEngine(JMeterContextService.getContext().getEngine()); injectVariables(jmThread, this.getThreadContext()); jMeterThreads.add(jmThread);
private void stopTest() { stopTries++; if (JMeter.isNonGUI()) { log.info("Stopping JMeter via UDP call"); stopTestViaUDP("StopTestNow"); } else { if (stopTries > 10) { log.info("Tries more than 10, stop it NOW!"); StandardJMeterEngine.stopEngineNow(); } else if (stopTries > 5) { log.info("Tries more than 5, stop it!"); StandardJMeterEngine.stopEngine(); } else { JMeterContextService.getContext().getEngine().askThreadsToStop(); } } }
private void stopTest() { stopTries++; if (JMeter.isNonGUI()) { log.info("Stopping JMeter via UDP call"); stopTestViaUDP("StopTestNow"); } else { if (stopTries > 10) { log.info("Tries more than 10, stop it NOW!"); StandardJMeterEngine.stopEngineNow(); } else if (stopTries > 5) { log.info("Tries more than 5, stop it!"); StandardJMeterEngine.stopEngine(); } else { JMeterContextService.getContext().getEngine().askThreadsToStop(); } } }
} else { log.info("No further matches found, stopping test"); context.getEngine().askThreadsToStop();
/** * Update the worker thread jmeter context with the main thread one * @param isInit if true the context a full copy is done, if false only update is done */ private void syncContext(boolean isInit) { // jmeter context synchronisation JMeterContext current = JMeterContextService.getContext(); JMeterContext ctx = this.getThreadContext(); if (isInit) { current.setCurrentSampler(ctx.getCurrentSampler()); current.setEngine(ctx.getEngine()); current.setRestartNextLoop(ctx.isRestartNextLoop()); current.setSamplingStarted(ctx.isSamplingStarted()); current.setThread(ctx.getThread()); current.setThreadGroup(ctx.getThreadGroup()); current.setThreadNum(ctx.getThreadNum()); } current.setVariables(ctx.getVariables()); current.setPreviousResult(ctx.getPreviousResult()); //current.getSamplerContext().putAll(ctx.getSamplerContext()); }
/** * Update the worker thread jmeter context with the main thread one * @param isInit if true the context a full copy is done, if false only update is done */ private void syncContext(boolean isInit) { // jmeter context synchronisation JMeterContext current = JMeterContextService.getContext(); JMeterContext ctx = this.getThreadContext(); if (isInit) { current.setCurrentSampler(ctx.getCurrentSampler()); current.setEngine(ctx.getEngine()); current.setRestartNextLoop(ctx.isRestartNextLoop()); current.setSamplingStarted(ctx.isSamplingStarted()); current.setThread(ctx.getThread()); current.setThreadGroup(ctx.getThreadGroup()); current.setThreadNum(ctx.getThreadNum()); } current.setVariables(ctx.getVariables()); current.setPreviousResult(ctx.getPreviousResult()); //current.getSamplerContext().putAll(ctx.getSamplerContext()); }
/** * Update the worker thread jmeter context with the main thread one * @param isInit if true the context a full copy is done, if false only update is done */ private void syncContext(boolean isInit) { // jmeter context synchronisation JMeterContext current = JMeterContextService.getContext(); JMeterContext ctx = this.getThreadContext(); if (isInit) { current.setCurrentSampler(ctx.getCurrentSampler()); current.setEngine(ctx.getEngine()); current.setRestartNextLoop(ctx.isRestartNextLoop()); current.setSamplingStarted(ctx.isSamplingStarted()); current.setThread(ctx.getThread()); current.setThreadGroup(ctx.getThreadGroup()); current.setThreadNum(ctx.getThreadNum()); } current.setVariables(ctx.getVariables()); current.setPreviousResult(ctx.getPreviousResult()); //current.getSamplerContext().putAll(ctx.getSamplerContext()); } @Override