org.javasimon.Split - java examples

Here are the examples of the java api org.javasimon.Split taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

116 Examples 7

19 View Complete Implementation : SimonStatement.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Measure and execute SQL operation.
 *
 * @param sql sql command
 * @param columnNames an array of column indexes indicating the columns that should be
 * returned from the inserted row
 * @return count of updated rows
 * @throws java.sql.SQLException if real calls fails
 */
@Override
public final int executeUpdate(String sql, String[] columnNames) throws SQLException {
    Split s = prepare(sql);
    try {
        return stmt.executeUpdate(sql, columnNames);
    } finally {
        finish(s);
    }
}

19 View Complete Implementation : SimonUtils.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Calls a block of code with stopwatch around and returns result.
 *
 * @param name name of the Stopwatch
 * @param callable callable block of code
 * @param <T> return type
 * @return whatever block of code returns
 * @throws Exception whatever block of code throws
 * @since 3.0
 */
public static <T> T doWithStopwatch(String name, Callable<T> callable) throws Exception {
    try (Split split = SimonManager.getStopwatch(name).start()) {
        return callable.call();
    }
}

19 View Complete Implementation : LastSplits.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Adds split to the buffer.
 *
 * @param split Split
 */
public void add(Split split) {
    synchronized (splits) {
        splits.add(split);
    }
}

19 View Complete Implementation : SimonStatement.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Measure and execute SQL operation.
 *
 * @param sql sql command
 * @return count of updated rows
 * @throws java.sql.SQLException if real calls fails
 */
@Override
public final int executeUpdate(String sql) throws SQLException {
    Split s = prepare(sql);
    try {
        return stmt.executeUpdate(sql);
    } finally {
        finish(s);
    }
}

19 View Complete Implementation : DefaultRequestReporter.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Can be overridden to decide whether {@link Split} is considered significant to be reported in the first part of the output.
 * By default all Splits with time over 5% of total request time are significant. This includes overlapping splits too, so more than
 * 20 splits can be reported.
 *
 * @param split tested Split
 * @param requestSplit Split for the whole HTTP request
 * @return true, if tested Split is significant
 */
protected boolean isSignificantSplit(Split split, Split requestSplit) {
    // is more than 5%
    return split.runningFor() > (requestSplit.runningFor() / 20);
}

19 View Complete Implementation : QuantilesCallback.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Called when there is a new split on a Stopwatch, either
 * {@link #onStopwatchStop} or {@link #onStopwatchAdd}.
 * If buckets have been initialized, the value is added to appropriate bucket.
 */
protected void onStopwatchSplit(Stopwatch stopwatch, Split split) {
    Buckets buckets = getOrCreateBuckets(stopwatch);
    if (buckets != null) {
        buckets.addValue(split.runningFor());
        buckets.log(split);
    }
}

19 View Complete Implementation : HandlerLocation.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
public void setSplit(Split split) {
    this.split = split;
}

19 View Complete Implementation : CallTreeCallback.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
@Override
public void onStopwatchStart(Split split) {
    CallTree callTree = getCallTree();
    if (callTree == null) {
        // New tree root
        callTree = initCallTree();
    }
    callTree.onStopwatchStart(split);
}

19 View Complete Implementation : TimeUtil.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
public static Split createSplit(long start, long total) {
    Split split = Split.start();
    setField(split, "start", millisToNano(start));
    setField(split, "running", false);
    setField(split, "total", total);
    return split;
}

19 View Complete Implementation : LastSplits.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Transforms this list of splits into a loggable message.
 */
public String getLogMessage(Split lastSplit) {
    return lastSplit.getStopwatch().getName() + " " + toString();
}

19 View Complete Implementation : SimonStatement.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Measure and execute SQL operation.
 *
 * @param sql sql command
 * @param columnNames an array of column indexes indicating the columns that should be
 * returned from the inserted row
 * @return <code>true</code> if the first result is a <code>ResultSet</code> object;
 *         <code>false</code> if it is an update count or there are no results
 * @throws java.sql.SQLException if real calls fails
 */
@Override
public final boolean execute(String sql, String[] columnNames) throws SQLException {
    Split s = prepare(sql);
    try {
        return stmt.execute(sql, columnNames);
    } finally {
        finish(s);
    }
}

19 View Complete Implementation : DefaultRequestReporter.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
private void buildSplitDetails(Split requestSplit, List<Split> splits, StringBuilder messageBuilder) {
    Map<String, ReporterStopwatchInfo> stopwatchInfos = new HashMap<>();
    processSplitsAndAddSignificantOnes(requestSplit, splits, messageBuilder, stopwatchInfos);
    addStopwatchSplitDistribution(messageBuilder, stopwatchInfos);
}

19 View Complete Implementation : Buckets.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Logs eventually buckets config and quantiles.
 */
public void log(Split lastSplit) {
    logTemplate.log(lastSplit, this);
}

19 View Complete Implementation : SimonStatement.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Measure and execute SQL operation.
 *
 * @param sql sql command
 * @param autoGeneratedKeys autoGeneratedKeys flag
 * @return count of updated rows
 * @throws java.sql.SQLException if real calls fails
 */
@Override
public final int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
    Split s = prepare(sql);
    try {
        return stmt.executeUpdate(sql, autoGeneratedKeys);
    } finally {
        finish(s);
    }
}

19 View Complete Implementation : CompositeCallbackImpl.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
@Override
public void onStopwatchStart(Split split) {
    for (Callback callback : callbacks) {
        callback.onStopwatchStart(split);
    }
}

19 View Complete Implementation : SimonStatement.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Measure and execute SQL operation.
 *
 * @param sql sql command
 * @return database rows and columns
 * @throws java.sql.SQLException if real calls fails
 * @see SimonResultSet
 */
@Override
public final ResultSet executeQuery(String sql) throws SQLException {
    Split s = prepare(sql);
    try {
        return new SimonResultSet(stmt.executeQuery(sql), this, prefix, s.getStopwatch().getName());
    } finally {
        finish(s);
    }
}

19 View Complete Implementation : LoggingCallback.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Logs Simon start on a specified log level.
 */
@Override
public void onStopwatchStart(Split split) {
    logger.log(level, "SIMON START: " + split.getStopwatch());
}

19 View Complete Implementation : SimonUtils.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Calls a block of code with stopwatch around, can not return any result or throw an exception
 * (use {@link #doWithStopwatch(String, java.util.concurrent.Callable)} instead).
 *
 * @param name name of the Stopwatch
 * @param runnable wrapped block of code
 * @since 3.0
 */
public static void doWithStopwatch(String name, Runnable runnable) {
    try (Split split = SimonManager.getStopwatch(name).start()) {
        runnable.run();
    }
}

19 View Complete Implementation : CallTreeCallback.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * When stopwatch corresponding to root tree node is stopped, this method is called.
 * Logs call tree when split is longer than threshold.
 *
 * @param callTree call tree to log
 * @param split stopped split
 */
public void onRootStopwatchStop(CallTree callTree, Split split) {
    callTreeLogTemplate.log(split, callTree);
    if (logThreshold != null && split.runningFor() > logThreshold) {
        split.getStopwatch().setAttribute(ATTR_NAME_LAST, callTree);
    }
    removeCallTree();
}

19 View Complete Implementation : SystemDebugCallback.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
@Override
public void onStopwatchStart(Split split) {
    out("Start split: " + split);
}

19 View Complete Implementation : LastSplits.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Log eventually this list of splits into log template
 */
public void log(Split lastSplit) {
    logTemplate.log(lastSplit, this);
}

19 View Complete Implementation : MultithreadedSleeping.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Entry point of the demo application.
 *
 * @param args command line arguments
 * @throws InterruptedException when sleep is interrupted
 */
public static void main(String[] args) throws InterruptedException {
    System.out.println("Going to run 1s sleep in " + THREADS + " threads...");
    Split realTimeSplit = Split.start();
    for (int i = 0; i < THREADS; i++) {
        new MulreplacedhreadedSleeping().start();
    }
    // here we wait for all threads to end
    latch.await();
    System.out.println("Simon: " + SimonManager.getStopwatch(NAME));
    System.out.println("Real time: " + realTimeSplit.stop());
}

19 View Complete Implementation : CallbackSkeleton.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
@Override
public void onStopwatchStart(Split split) {
}

19 View Complete Implementation : DefaultRequestReporter.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
@Override
public void reportRequest(HttpServletRequest request, Split requestSplit, List<Split> splits) {
    StringBuilder messageBuilder = new StringBuilder("Web request is too long (" + SimonUtils.presentNanoTime(requestSplit.runningFor()) + ") [" + requestSplit.getStopwatch().getNote() + "]");
    if (splits.size() > 0) {
        buildSplitDetails(requestSplit, splits, messageBuilder);
    }
    reportMessage(messageBuilder.toString());
}

19 View Complete Implementation : LastSplits.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Evaluate a function over the list of splits.
 *
 * @param <T> Function result type
 * @param function Function to evaluate
 * @return Function result, null if no splits
 */
private <T> T processFunction(SplitFunction<T> function) {
    synchronized (splits) {
        if (splits.isEmpty()) {
            return null;
        }
        for (Split split : splits) {
            function.evaluate(split);
        }
        return function.result();
    }
}

19 View Complete Implementation : SimonResultSet.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Measure next operation.
 *
 * @return {@code true} if the new current row is valid; {@code false} if there are no more rows
 * @throws java.sql.SQLException if real next operation fails
 */
@Override
public boolean next() throws SQLException {
    try (Split ignored = SimonManager.getStopwatch(stmtPrefix + ".next").start()) {
        return rset.next();
    }
}

19 View Complete Implementation : ReporterStopwatchInfo.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
public void addSplit(Split split) {
    splits.add(split);
    long runningFor = split.runningFor();
    if (maxSplit == null || runningFor > maxSplit.runningFor()) {
        maxSplit = split;
    }
    total += runningFor;
}

19 View Complete Implementation : AutoQuantilesCallback.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Called when there is a new split on a Stopwatch, either
 * {@link #onStopwatchStop} or {@link #onStopwatchAdd}.
 * If buckets have been initialized, the value is added to appropriate bucket.
 * Else if stopwatch is warming up value is added to value list.
 */
@Override
protected void onStopwatchSplit(Stopwatch stopwatch, Split split) {
    Buckets buckets = getOrCreateBuckets(stopwatch);
    long value = split.runningFor();
    if (buckets == null) {
        // Warming up
        getOrCreateBucketsValues(stopwatch).add(value);
    } else {
        // Warm
        buckets.addValue(value);
        buckets.log(split);
    }
}

19 View Complete Implementation : SimonStatement.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Measure and execute SQL operation.
 *
 * @param sql sql command
 * @param columnIndexes an array of column indexes indicating the columns that should be
 * returned from the inserted row
 * @return <code>true</code> if the first result is a <code>ResultSet</code> object;
 *         <code>false</code> if it is an update count or there are no results
 * @throws java.sql.SQLException if real calls fails
 */
@Override
public final boolean execute(String sql, int[] columnIndexes) throws SQLException {
    Split s = prepare(sql);
    try {
        return stmt.execute(sql, columnIndexes);
    } finally {
        finish(s);
    }
}

19 View Complete Implementation : CallTreeNode.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Adds a split to the current tree node.
 * In case of loops, child nodes can have many splits.
 *
 * @param split Split
 */
public void addSplit(Split split) {
    splits.add(split);
}

19 View Complete Implementation : SimonStatement.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Called after each SQL command execution. Stops concrete SQL stopwatch (started in {@link #prepare(String)}),
 * also adds time to SQL command type Simon and sets human readable SQL cmd as note.
 *
 * @param split started Stopwatch split
 */
protected final void finish(Split split) {
    if (split != null) {
        SimonManager.getStopwatch(sqlCmdLabel).addSplit(split.stop());
    }
}

19 View Complete Implementation : Buckets.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Transforms buckets and quantiles into a loggable message.
 */
public String getLogMessage(Split lastSplit) {
    return lastSplit.getStopwatch().getName() + " " + toString(true);
}

19 View Complete Implementation : SimonStatement.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Measure and execute SQL operation.
 *
 * @param sql sql command
 * @param columnIndexes an array of column indexes indicating the columns that should be
 * returned from the inserted row
 * @return count of updated rows
 * @throws java.sql.SQLException if real calls fails
 */
@Override
public final int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
    Split s = prepare(sql);
    try {
        return stmt.executeUpdate(sql, columnIndexes);
    } finally {
        finish(s);
    }
}

19 View Complete Implementation : CallTree.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * When stopwatch is started, and the root tree node is pushed into
 * the call stack, this method is called.
 * Does nothing but can be overridden for custom needs.
 *
 * @param rootNode Root tree node
 * @param split Root split
 */
public void onRootStopwatchStart(CallTreeNode rootNode, Split split) {
}

19 View Complete Implementation : SimonStatement.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Measure and execute SQL operation.
 *
 * @param sql sql command
 * @return <code>true</code> if the first result is a <code>ResultSet</code> object;
 *         <code>false</code> if it is an update count or there are no results
 * @throws java.sql.SQLException if real calls fails
 */
@Override
public final boolean execute(String sql) throws SQLException {
    Split s = prepare(sql);
    try {
        return stmt.execute(sql);
    } finally {
        finish(s);
    }
}

19 View Complete Implementation : StopwatchTimeline.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Main method used to insert the split on the timeline: <ol>
 * <li>Split start is used to determine in which time-range it should be split. A new time range may be created if needed.</li>
 * <li>Split duration is added to time range statistics.
 * </ol>
 * The split might be drop if it's too old.
 *
 * @param split Split
 */
public void addSplit(Split split) {
    final long timestamp = split.getStartMillis();
    StopwatchTimeRange timeRange;
    synchronized (this) {
        timeRange = getOrCreateTimeRange(timestamp);
    }
    if (timeRange != null) {
        // noinspection SynchronizationOnLocalVariableOrMethodParameter
        synchronized (timeRange) {
            timeRange.addSplit(timestamp, split.runningFor());
        }
    }
}

19 View Complete Implementation : SimonStatement.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Measure and execute SQL operation.
 *
 * @param sql sql command
 * @param autoGeneratedKeys autoGeneratedKeys flag
 * @return <code>true</code> if the first result is a <code>ResultSet</code> object;
 *         <code>false</code> if it is an update count or there are no results
 * @throws java.sql.SQLException if real calls fails
 */
@Override
public final boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
    Split s = prepare(sql);
    try {
        return stmt.execute(sql, autoGeneratedKeys);
    } finally {
        finish(s);
    }
}

19 View Complete Implementation : CompositeFilterCallback.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
@Override
public void onStopwatchStart(Split split) {
    Stopwatch stopwatch = split.getStopwatch();
    if (stopwatch != null && rulesApplyTo(stopwatch, Event.STOPWATCH_START, split)) {
        callback.onStopwatchStart(split);
    }
}

19 View Complete Implementation : CallTree.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * When stopwatch is stopped, and root tree node is popped from
 * call stack, this method is called.
 * Does nothing but can be overridden for custom needs, such as logging, storing...
 */
protected void onRootStopwatchStop(CallTreeNode callTreeNode, Split split) {
}

19 View Complete Implementation : CallTree.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * When stopwatch is started, a new tree node is added to the parent
 * tree node and pushed on the call stack.
 * As a result, child tree node becomes the current tree node.
 *
 * @return Current (child) tree node
 */
public CallTreeNode onStopwatchStart(Split split) {
    final String name = split.getStopwatch().getName();
    CallTreeNode currentNode;
    if (callStack.isEmpty()) {
        // Root tree node
        rootNode = new CallTreeNode(name);
        currentNode = rootNode;
        onRootStopwatchStart(currentNode, split);
    } else {
        // Child node
        currentNode = callStack.getLast().getOrAddChild(name);
    }
    callStack.addLast(currentNode);
    return currentNode;
}

19 View Complete Implementation : CallTreeNode.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Returns the total time of splits using {@link org.javasimon.Split#runningFor()}.
 *
 * @return total time of splits
 */
public long getTotal() {
    long total = 0;
    for (Split split : splits) {
        total += split.runningFor();
    }
    return total;
}

19 View Complete Implementation : SplitThresholdLogTemplate.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
@Override
protected boolean isEnabled(Split split) {
    return split.runningFor() > threshold && super.isEnabled(split);
}

19 View Complete Implementation : SimonPreparedStatement.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
/**
 * Measure and execute prepared SQL operation.
 *
 * @return database rows and columns
 * @throws java.sql.SQLException if real calls fails
 */
@Override
public final ResultSet executeQuery() throws SQLException {
    Split split = prepare();
    try {
        return new SimonResultSet(stmt.executeQuery(), this, prefix, split.getStopwatch().getName());
    } finally {
        finish(split);
    }
}

18 View Complete Implementation : BulkRestartWorkflow.java
Copyright Apache License 2.0
Author : nuxeo
@OperationMethod
public void run() {
    CloseableCoreSession session = null;
    boolean transactionStarted = false;
    Split split = SimonManager.getStopwatch(ID).start();
    try {
        session = CoreInstance.openCoreSession(null);
        // Fetching all routes
        // If the nodeId parameter is null, fetch all the workflow routes
        // with
        // the given workflowId
        String query = "Select %s from DoreplacedentRoute where (ecm:name like '%s.%%' OR  ecm:name like '%s') and ecm:currentLifeCycleState = 'running'";
        String key = "ecm:uuid";
        if (StringUtils.isEmpty(nodeId)) {
            if (StringUtils.isEmpty(workflowId)) {
                log.error("Need to specify either the workflowModelId either the nodeId to query the workflows");
                return;
            }
            query = String.format(query, key, workflowId, workflowId);
        } else {
            query = "Select %s from RouteNode  where rnode:nodeId = '%s' and ecm:currentLifeCycleState = 'suspended'";
            key = "ecm:parentId";
            if (StringUtils.isEmpty(nodeId)) {
                log.error("Need to specify either the workflowModelId either the nodeId to query the workflows");
                return;
            }
            query = String.format(query, key, nodeId);
        }
        IterableQueryResult results = session.queryAndFetch(query, "NXQL");
        List<String> routeIds = new ArrayList<>();
        for (Map<String, Serializable> result : results) {
            routeIds.add(result.get(key).toString());
        }
        results.close();
        DoreplacedentRoutingService routingService = Framework.getService(DoreplacedentRoutingService.clreplaced);
        // Batching initialization
        if (batchSize == null) {
            batchSize = DEFAULT_BATCH_SIZE;
        }
        if (!TransactionHelper.isTransactionActive()) {
            TransactionHelper.startTransaction();
            transactionStarted = true;
        }
        long routesRestartedCount = 0;
        for (String routeId : routeIds) {
            try {
                DoreplacedentModel docRoute = session.getDoreplacedent(new IdRef(routeId));
                DoreplacedentRoute route = docRoute.getAdapter(DoreplacedentRoute.clreplaced);
                List<String> relatedDocIds = route.getAttachedDoreplacedents();
                route.cancel(session);
                log.debug("Canceling workflow  " + route.getDoreplacedent().getName());
                if (reinitLifecycle) {
                    reinitLifecycle(relatedDocIds, session);
                }
                routingService.createNewInstance(workflowId, relatedDocIds, session, true);
                for (String string : relatedDocIds) {
                    log.debug("Starting workflow for " + string);
                }
                // removing old workflow instance
                session.removeDoreplacedent(route.getDoreplacedent().getRef());
                routesRestartedCount++;
                if (routesRestartedCount % batchSize == 0) {
                    session.close();
                    TransactionHelper.commitOrRollbackTransaction();
                    TransactionHelper.startTransaction();
                    session = CoreInstance.openCoreSession(null);
                }
            } catch (NuxeoException e) {
                Throwable t = unwrapException(e);
                log.error(t.getClreplaced().getSimpleName() + ": " + t.getMessage());
                log.error("Workflow with the docId '" + routeId + "' cannot be canceled. " + routesRestartedCount + " workflows have been processed.");
            }
        }
    } finally {
        if (session != null) {
            session.close();
        }
        TransactionHelper.commitOrRollbackTransaction();
        if (!transactionStarted) {
            TransactionHelper.startTransaction();
        }
        split.stop();
        log.info(split.toString());
    }
}

18 View Complete Implementation : MessageLifecycleMonitoringAction.java
Copyright Apache License 2.0
Author : researchstudio-sat
@Override
protected void doRun(final Event event, EventListener executingListener) throws Exception {
    Stopwatch stopwatchB = SimonManager.getStopwatch("messageTripB");
    Stopwatch stopwatchBC = SimonManager.getStopwatch("messageTripBC");
    Stopwatch stopwatchBCD = SimonManager.getStopwatch("messageTripBCD");
    Stopwatch stopwatchBCDE = SimonManager.getStopwatch("messageTripBCDE");
    if (event instanceof MessageSpecificEvent) {
        MessageSpecificEvent msgEvent = (MessageSpecificEvent) event;
        URI msgURI = msgEvent.getMessageURI();
        logger.debug("RECEIVED EVENT {} for uri {}", event, msgURI);
        if (event instanceof MessageDispatchStartedEvent) {
            Split splitB = stopwatchB.start();
            Split splitBC = stopwatchBC.start();
            Split splitBCD = stopwatchBCD.start();
            Split splitBCDE = stopwatchBCDE.start();
            msgSplitsB.put(msgURI.toString(), splitB);
            msgSplitsBC.put(msgURI.toString(), splitBC);
            msgSplitsBCD.put(msgURI.toString(), splitBCD);
            msgSplitsBCDE.put(msgURI.toString(), splitBCDE);
            connectionMsgUris.put(msgURI, msgEvent.getAtomURI());
        } else if (event instanceof MessageDispatchedEvent) {
            msgSplitsB.get(msgURI.toString()).stop();
        }
    } else if (event instanceof SuccessResponseEvent || event instanceof FailureResponseEvent) {
        DeliveryResponseEvent responseEvent = (DeliveryResponseEvent) event;
        if (connectionMsgUris.containsKey(responseEvent.getOriginalMessageURI())) {
            responseMsgUris.put(responseEvent.getMessage().getMessageURI(), responseEvent.getAtomURI());
        }
        if (msgSplitsBC.get(responseEvent.getOriginalMessageURI().toString()) != null) {
            logger.debug("RECEIVED RESPONSE EVENT {} for uri {}", event, responseEvent.getOriginalMessageURI());
            msgSplitsBC.get(responseEvent.getOriginalMessageURI().toString()).stop();
        }
    } else if (event instanceof MessageFromOtherAtomEvent) {
        WonMessage msg = ((MessageFromOtherAtomEvent) event).getWonMessage();
        msgSplitsBCD.get(msg.getMessageURI()).stop();
        connectionMsgUris.put(msg.getMessageURI(), msg.getRecipientAtomURI());
    } else if (event instanceof CrawlReadyEvent) {
        reportMessageSizes(connectionMsgUris, "Connection Messages");
        reportMessageSizes(responseMsgUris, "Delivery Responses");
        getEventListenerContext().getEventBus().publish(new CrawlDoneEvent());
    }
}

18 View Complete Implementation : JavaSimon.java
Copyright Apache License 2.0
Author : stevensouza
@Override
public void stop(Split split) {
    split.stop();
}

18 View Complete Implementation : JavaSimonTest.java
Copyright Apache License 2.0
Author : stevensouza
@Test
public void testStopWithException() throws Exception {
    Split mon = openMon.start(staticPart);
    openMon.stop(mon, new RuntimeException("my exception"));
    replacedertThat(mon.getStopwatch().getActive()).describedAs("The monitor should have been started").isEqualTo(0);
    replacedertThat(mon.getStopwatch().getCounter()).describedAs("The monitor should not have finished").isEqualTo(1);
}

18 View Complete Implementation : JavaSimonTest.java
Copyright Apache License 2.0
Author : stevensouza
@Test
public void testStart() throws Exception {
    Split mon = openMon.start(staticPart);
    replacedertThat(mon.getStopwatch().getActive()).describedAs("The monitor should have been started").isEqualTo(1);
    replacedertThat(mon.getStopwatch().getCounter()).describedAs("The monitor should not have finished").isEqualTo(0);
}

18 View Complete Implementation : JavaSimonTest.java
Copyright Apache License 2.0
Author : stevensouza
@Test
public void testStop() throws Exception {
    Split mon = openMon.start(staticPart);
    openMon.stop(mon);
    replacedertThat(mon.getStopwatch().getActive()).describedAs("The monitor should have been started").isEqualTo(0);
    replacedertThat(mon.getStopwatch().getCounter()).describedAs("The monitor should not have finished").isEqualTo(1);
}

18 View Complete Implementation : CallbackSkeleton.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : virgo47
@Override
public void onStopwatchAdd(Stopwatch stopwatch, Split split, StopwatchSample sample) {
}