/** * The number of tasks which were executed by this executor * * @return the number of tasks executed so far */ public long getExecuted() { return executed.getCount(); }
WrappedConnection(Connection c, Database database) { super(c); this.database = database; Databases.numUses.inc(); }
/** * Increments the counter by one * * @return the update value of the counter */ public long inc() { return add(1); }
/** * Computes the average raise per given unit of time. * * @param unit the unit of time to compute the average for. * @return the average increment per given time unit */ public double getAvgPer(TimeUnit unit) { return (double) count.get() / getDuration(unit); }
@SuppressWarnings("squid:S2259") protected ListFileTreeVisitor(XMLStructuredOutput output, int limit, @Nullable String marker, @Nullable String prefix) { this.output = output; this.limit = limit; this.marker = marker; this.prefix = prefix; objectCount = new Counter(); useLimit = limit > 0; usePrefix = Strings.isFilled(prefix); if (usePrefix) { this.prefix = prefix.replace('/', '_'); } markerReached = Strings.isEmpty(marker); }
/** * Manually blocks the current thread for n seconds, to make e.g. a bulk write visible in ES. * <p> * Consider using {@link #callAfterUpdate(Runnable)} which does not block system resources. Only use this method * if absolutely necessary. * * @param seconds the number of seconds to block */ public void blockThreadForUpdate(int seconds) { blocks.inc(); Wait.seconds(seconds); }
/** * Returns the total number of unique incidents (with different locations) encountered. * * @return the total number of unique incidents so far. */ public long getNumUniqueIncidents() { return numUniqueIncidents.getCount(); } }
@Override public void handleLogMessage(LogMessage msg) { if (msg.isReceiverWouldLog()) { synchronized (messages) { messages.add(0, msg); numLogMessages.inc(); while (messages.size() > maxMsg) { messages.remove(messages.size() - 1); } } } }
/** * Returns the total number of log messages encountered. * * @return the total number of log messages so far. */ public long getNumLogMessages() { return numLogMessages.getCount(); }
@Override public Connection createConnection() throws SQLException { Databases.numConnects.inc(); return actualFactory.createConnection(); } };
/** * Returns the total number of incidents (exceptions) encountered. * * @return the total number of incidents so far. */ public long getNumIncidents() { return numIncidents.getCount(); }
@Override public void handle(Incident incident) throws Exception { synchronized (incidents) { boolean unique = true; Iterator<Incident> iter = incidents.iterator(); while (iter.hasNext()) { if (Strings.areEqual(iter.next().getLocation(), incident.getLocation())) { iter.remove(); unique = false; } } incidents.add(0, incident); numIncidents.inc(); if (unique) { numUniqueIncidents.inc(); } while (incidents.size() > maxErrors) { incidents.remove(incidents.size() - 1); } } }
public long getCount() { return objectCount.getCount(); } }
/** * Adds an action to the delay line, which ensures that it is at least delayed for one second * * @param cmd to command to be delayed */ public void callAfterUpdate(final Runnable cmd) { synchronized (oneSecondDelayLine) { if (oneSecondDelayLine.size() < 100) { delays.inc(); oneSecondDelayLine.add(new WaitingBlock(cmd)); return; } } blockThreadForUpdate(); cmd.run(); }
/** * The number of tasks which were executed by blocking the caller due to system overload conditions. * <p> * A system overload occurs if all available tasks are busy and the queue of this executor reached its limit. * * @return the number of blocking task executions so far. */ public long getBlocked() { return blocked.getCount(); }
private void executeNow(ExecutionBuilder.TaskWrapper wrapper) { wrapper.prepare(); AsyncExecutor exec = findExecutor(wrapper.category); wrapper.jobNumber = exec.executed.inc(); wrapper.durationAverage = exec.duration; if (wrapper.synchronizer != null) { scheduleTable.put(wrapper.synchronizer, System.currentTimeMillis()); } exec.execute(wrapper); }
private static CallContext initialize(boolean install, String externalFlowId) { CallContext ctx = new CallContext(); ctx.addToMDC(MDC_FLOW, externalFlowId); interactionCounter.inc(); if (install) { setCurrent(ctx); } return ctx; }