public void fireBeginRunEvent() { m_threadLifeCycleListeners .apply(new Informer<ThreadLifeCycleListener>() { public void inform(ThreadLifeCycleListener l) { l.beginRun(); } }); }
public void handle(final LogReportGrinderMessage message) { m_logListeners.apply(new Informer<LogArrivedListener>() { @Override public void inform(LogArrivedListener listener) { listener.logArrived(message.getTestId(), message.getAddress(), message.getLogs()); } }); } });
public void fireBeginThreadEvent() { m_threadLifeCycleListeners .apply(new Informer<ThreadLifeCycleListener>() { public void inform(ThreadLifeCycleListener l) { l.beginThread(); } }); }
public void fireBeginShutdownEvent() { m_threadLifeCycleListeners .apply(new Informer<ThreadLifeCycleListener>() { public void inform(ThreadLifeCycleListener l) { l.beginShutdown(); } }); }
public void fireEndThreadEvent() { m_threadLifeCycleListeners .apply(new Informer<ThreadLifeCycleListener>() { public void inform(ThreadLifeCycleListener l) { l.endThread(); } }); }
@Override public void threadStarted(final ThreadContext threadContext) { m_processLifeCycleListeners.apply(new Informer<ProcessLifeCycleListener>() { @Override public void inform(final ProcessLifeCycleListener listener) { listener.threadStarted(threadContext); } }); } };
private void setInternalState(InternalState newState) { synchronized (this) { m_state = newState; } m_listeners.apply(new ListenerSupport.Informer<Listener>() { public void inform(Listener l) { l.stateChanged(); } }); }
public void fireEndRunEvent() { m_threadLifeCycleListeners .apply(new Informer<ThreadLifeCycleListener>() { public void inform(ThreadLifeCycleListener l) { l.endRun(); } }); }
@Override public void threadCreated(final ThreadContext threadContext) { m_processLifeCycleListeners.apply(new Informer<ProcessLifeCycleListener>() { @Override public void inform(final ProcessLifeCycleListener listener) { listener.threadCreated(threadContext); } }); }
private void informTestSamplingStart() { samplingLifeCycleListener.apply(new Informer<SamplingLifeCycleListener>() { @Override public void inform(SamplingLifeCycleListener listener) { try { listener.onSamplingStarted(); } catch (Exception e) { LOGGER.error("Error occurred while running sampling start listener", e); } } }); samplingLifeCycleFollowupListener.apply(new Informer<SamplingLifeCycleFollowUpListener>() { @Override public void inform(SamplingLifeCycleFollowUpListener listener) { try { listener.onSamplingStarted(); } catch (Exception e) { LOGGER.error("Error occurred while running sampling start listener", e); } } }); }
private void informTestSamplingEnd() { samplingLifeCycleListener.apply(new Informer<SamplingLifeCycleListener>() { @Override public void inform(SamplingLifeCycleListener listener) { try { listener.onSamplingEnded(); } catch (Exception e) { LOGGER.error("Error occurred while running sampling end listener", e); } } }); samplingLifeCycleFollowupListener.apply(new Informer<SamplingLifeCycleFollowUpListener>() { @Override public void inform(SamplingLifeCycleFollowUpListener listener) { try { listener.onSamplingEnded(); } catch (Exception e) { LOGGER.error("Error occurred while running sampling end listener", e); } } }); }
/** * Update agent status. */ private void update() { if (!m_newData) { return; } m_newData = false; m_listeners.apply(new ListenerSupport.Informer<Listener>() { public void inform(Listener l) { l.update(new ConcurrentHashMap<AgentIdentity, AgentStatus>(m_agentMap)); } }); }
/** * Reset all shutdown listener. */ public void resetListeners() { final ListenerSupport<AgentShutDownListener> backup = new ListenerSupport<AgentDaemon.AgentShutDownListener>(); getListeners().apply(new Informer<AgentShutDownListener>() { public void inform(AgentShutDownListener listener) { backup.add(listener); } }); backup.apply(new Informer<AgentShutDownListener>() { public void inform(AgentShutDownListener listener) { getListeners().remove(listener); } }); }
/** * Reset the model. * * <p> * This doesn't affect our internal state, just the statistics and the listeners. * </p> */ public void reset() { synchronized (m_tests) { m_tests.clear(); } m_accumulators.clear(); m_totalSampleAccumulator.zero(); m_listeners.apply(new ListenerSupport.Informer<Listener>() { public void inform(Listener l) { l.resetTests(); } }); }
private void checkExecutionErrors(ProcessReports[] processReports) { if (samplingCount == 0 && ArrayUtils.isNotEmpty(this.processReports) && ArrayUtils.isEmpty(processReports)) { getListeners().apply(new Informer<ConsoleShutdownListener>() { public void inform(ConsoleShutdownListener listener) { listener.readyToStop(StopReason.SCRIPT_ERROR); } }); } }
/** * Check if the TPS is too low. the TPS is lower than 0.001 for 1 minutes, * It emits a shutdown event to the {@link ConsoleShutdownListener} * * @param tps current TPS */ private void checkTooLowTps(double tps) { // If the tps is too low, which means the agents or scripts went wrong. if (tps < 0.001) { if (momentWhenTpsBeganToHaveVerySmall == 0) { momentWhenTpsBeganToHaveVerySmall = System.currentTimeMillis(); } else if (new Date().getTime() - momentWhenTpsBeganToHaveVerySmall >= TOO_LOW_TPS_TIME) { LOGGER.warn("Stop the test because its tps is less than 0.001 for more than {} minitue.", TOO_LOW_TPS_TIME / 60000); getListeners().apply(new Informer<ConsoleShutdownListener>() { public void inform(ConsoleShutdownListener listener) { listener.readyToStop(StopReason.TOO_LOW_TPS); } }); momentWhenTpsBeganToHaveVerySmall = 0; } } else { momentWhenTpsBeganToHaveVerySmall = 0; } }
/** * Fire sampling. * * @param sampleInterval sampling interval * @param period period */ public void fireSample(long sampleInterval, long period) { m_intervalStatistics.setValue(m_periodIndex, sampleInterval); m_cumulativeStatistics.setValue(m_periodIndex, period); m_listeners.apply(new ListenerSupport.Informer<SampleListener>() { public void inform(SampleListener l) { l.update(m_intervalStatistics, m_cumulativeStatistics); } }); m_lastSampleStatistics = m_intervalStatistics; // We create new statistics each time to ensure that // m_lastSampleStatistics is always valid and fixed. }
public void run() { do { try { if (count++ % LOG_FREQUENCY == 0) { LOGGER.info("The agent controller daemon is started."); } getAgentController().run(); getListeners().apply(new Informer<AgentControllerShutDownListener>() { public void inform(AgentControllerShutDownListener listener) { listener.shutdownAgentController(); } }); } catch (Exception e) { LOGGER.info("Agent controller daemon is crashed. {}", e.getMessage()); LOGGER.debug("The error detail is ", e); } if (isForceShutdown()) { setForceShutdown(false); break; } ThreadUtils.sleep(GrinderConstants.AGENT_CONTROLLER_RETRY_INTERVAL); } while (true); } }, "Agent Controller Thread");
public void run() { try { setAgent(new AgentImplementationEx(LOGGER, m_agentConfig)).run(getGrinderProperties()); } catch (Exception e) { LOGGER.error("While running an agent thread, an error occurred", e); } getListeners().apply(new Informer<AgentShutDownListener>() { public void inform(AgentShutDownListener listener) { listener.shutdownAgent(); } }); if (isForceShutdown()) { setForceShutdown(false); } } }
/** * Check if too many error has been occurred. If the half of total * transaction is error for the last 10 secs. It notifies the * {@link ConsoleShutdownListener} * * @param cumulativeStatistics accumulated Statistics */ private void checkTooManyError(StatisticsSet cumulativeStatistics) { StatisticsIndexMap statisticsIndexMap = getStatisticsIndexMap(); long testSum = cumulativeStatistics.getCount(statisticsIndexMap.getLongSampleIndex("timedTests")); long errors = cumulativeStatistics.getValue(statisticsIndexMap.getLongIndex("errors")); if (((double) (testSum + errors)) / 2 < errors) { if (lastMomentWhenErrorsMoreThanHalfOfTotalTPSValue == 0) { lastMomentWhenErrorsMoreThanHalfOfTotalTPSValue = System.currentTimeMillis(); } else if (isOverLowTpsThreshold()) { LOGGER.warn("Stop the test because the count of test error is more than" + " half of total tps for last {} seconds.", TOO_MANY_ERROR_TIME / 1000); getListeners().apply(new Informer<ConsoleShutdownListener>() { public void inform(ConsoleShutdownListener listener) { listener.readyToStop(StopReason.TOO_MANY_ERRORS); } }); lastMomentWhenErrorsMoreThanHalfOfTotalTPSValue = 0; } } }