Example usage for com.google.common.base Stopwatch toString

List of usage examples for com.google.common.base Stopwatch toString

Introduction

In this page you can find the example usage for com.google.common.base Stopwatch toString.

Prototype

@GwtIncompatible("String.format()")
@Override
public String toString() 

Source Link

Document

Returns a string representation of the current elapsed time.

Usage

From source file:com.tkmtwo.sarapi.ArsTemplate.java

public <T> T execute(ARServerUserCallback<T> action, String description) throws DataAccessException {

    Stopwatch sw = Stopwatch.createStarted();
    T result = execute(action);//w  w  w.  j a  v a 2 s  .c  o m
    sw.stop();

    logger.trace("Executed callback {} in {}", description, sw.toString());
    return result;
}

From source file:org.apache.brooklyn.launcher.osgi.OsgiLauncherImpl.java

@Override
public void startOsgi() {
    synchronized (reloadLock) {
        final Stopwatch startupTimer = Stopwatch.createStarted();
        LOG.debug("OsgiLauncher start");
        startPartTwo();/*from   ww  w .j a va  2  s .c  o  m*/
        startupTimer.stop();
        LOG.info("Brooklyn initialisation (part two) complete after {}", startupTimer.toString());
    }
}

From source file:de.hybris.telcotrail.storefront.filters.RequestLoggerFilter.java

@Override
public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
        final FilterChain filterChain) throws IOException, ServletException {
    if (LOG.isDebugEnabled()) {
        final String requestDetails = buildRequestDetails(request);

        if (LOG.isDebugEnabled()) {
            LOG.debug(requestDetails + "Begin");
        }//w w  w . j av a2 s  .  co m

        logCookies(request);

        final ResponseWrapper wrappedResponse = new ResponseWrapper(response);

        final Stopwatch stopwatch = Stopwatch.createStarted();
        try {
            filterChain.doFilter(request, wrappedResponse);
        } finally {
            stopwatch.stop();
            final int status = wrappedResponse.getStatus();

            if (status != 0) {
                LOG.debug(requestDetails + stopwatch.toString() + " (" + status + ")");
            } else {
                LOG.debug(requestDetails + stopwatch.toString());
            }
        }

        return;
    }

    filterChain.doFilter(request, response);
}

From source file:com.pedra.storefront.filters.RequestLoggerFilter.java

@Override
public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
        final FilterChain filterChain) throws IOException, ServletException {
    if (LOG.isDebugEnabled()) {
        final String requestDetails = buildRequestDetails(request);

        if (LOG.isDebugEnabled()) {
            LOG.debug(requestDetails + "Begin");
        }/*w  w  w .j  a va  2s.c  om*/

        logCookies(request);

        final ResponseWrapper wrappedResponse = new ResponseWrapper(response);

        final Stopwatch stopwatch = new Stopwatch();
        stopwatch.start();
        try {
            filterChain.doFilter(request, wrappedResponse);
        } finally {
            stopwatch.stop();
            final int status = wrappedResponse.getStatus();

            if (status != 0) {
                LOG.debug(requestDetails + stopwatch.toString() + " (" + status + ")");
            } else {
                LOG.debug(requestDetails + stopwatch.toString());
            }
        }

        return;
    }

    filterChain.doFilter(request, response);
}

From source file:com.vmm.storefront.filters.RequestLoggerFilter.java

@Override
public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
        final FilterChain filterChain) throws IOException, ServletException {
    if (LOG.isDebugEnabled()) {
        final String requestDetails = buildRequestDetails(request);
        writeDebugLog(requestDetails, "Begin");
        logCookies(request);//from   ww  w  .  j ava2  s .c o  m

        final ResponseWrapper wrappedResponse = new ResponseWrapper(response);

        final Stopwatch stopwatch = Stopwatch.createUnstarted();
        stopwatch.start();
        try {
            filterChain.doFilter(request, wrappedResponse);
        } finally {
            stopwatch.stop();
            final int status = wrappedResponse.getStatus();

            if (status != 0) {
                writeDebugLog(requestDetails, stopwatch.toString(), " (", String.valueOf(status), ")");
            } else {
                writeDebugLog(requestDetails, stopwatch.toString());
            }
        }

        return;
    }

    filterChain.doFilter(request, response);
}

From source file:hu.vodafone.storefront.filters.RequestLoggerFilter.java

@Override
public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
        final FilterChain filterChain) throws IOException, ServletException {
    if (LOG.isDebugEnabled()) {
        final String requestDetails = buildRequestDetails(request);

        if (LOG.isDebugEnabled()) {
            LOG.debug(requestDetails + "Begin");
        }/*from   ww w .j a va 2  s  .c o  m*/

        logCookies(request);

        final ResponseWrapper wrappedResponse = new ResponseWrapper(response);

        final Stopwatch stopwatch = Stopwatch.createUnstarted();
        stopwatch.start();
        try {
            filterChain.doFilter(request, wrappedResponse);
        } finally {
            stopwatch.stop();
            final int status = wrappedResponse.getStatus();

            if (status != 0) {
                LOG.debug(requestDetails + stopwatch.toString() + " (" + status + ")");
            } else {
                LOG.debug(requestDetails + stopwatch.toString());
            }
        }

        return;
    }

    filterChain.doFilter(request, response);
}

From source file:es.usc.citius.composit.core.composition.search.NaiveForwardServiceDiscoverer.java

public ServiceMatchNetwork<E, T> search(Signature<E> signature) {
    Set<E> availableInputs = new HashSet<E>(signature.getInputs());
    Set<E> newOutputs = new HashSet<E>(signature.getInputs());
    Set<Operation<E>> usedServices = new HashSet<Operation<E>>();
    List<Set<Operation<E>>> leveledOps = new LinkedList<Set<Operation<E>>>();

    boolean checkExpectedOutputs = !signature.getOutputs().isEmpty();
    boolean stop;

    Stopwatch timer = Stopwatch.createStarted();
    Stopwatch levelTimer = Stopwatch.createUnstarted();
    int level = 0;
    do {//from   ww  w. java  2  s . c o m
        HashSet<Operation<E>> candidates = new HashSet<Operation<E>>();
        levelTimer.start();
        candidates.addAll(discovery.findOperationsConsumingSome(newOutputs));
        log.info("(Level {}) {} potential candidates selected in {}", level++, candidates.size(),
                levelTimer.toString());
        // Remove services that cannot be invoked with the available inputs
        for (Iterator<Operation<E>> it = candidates.iterator(); it.hasNext();) {
            Operation<E> candidate = it.next();
            Set<E> matched = matcher.partialMatch(availableInputs, candidate.getSignature().getInputs())
                    .getTargetElements();
            // Invokable?
            if (matched.equals(candidate.getSignature().getInputs())) {
                // Invokable operation, check if it was used previously
                boolean isNew = usedServices.add(candidate);
                if (!isNew)
                    it.remove();
            } else {
                it.remove();
            }
        }
        log.info("\t + [{}] operations selected for this level in {}: {}", candidates.size(),
                levelTimer.toString(), candidates);

        // Collect the new outputs of the new candidates
        newOutputs = Operations.outputs(candidates);
        availableInputs.addAll(newOutputs);
        Set<E> matchedOutputs = matcher.partialMatch(availableInputs, signature.getOutputs())
                .getTargetElements();

        // Add the discovered ops
        if (!candidates.isEmpty())
            leveledOps.add(candidates);

        log.debug("\t + Available inputs: {}, new outputs: {}", availableInputs.size(), newOutputs.size());
        // Stop condition. Stop if there are no more candidates and/or expected outputs are satisfied.
        stop = (checkExpectedOutputs) ? candidates.isEmpty() || matchedOutputs.equals(signature.getOutputs())
                : candidates.isEmpty();
        levelTimer.reset();
    } while (!stop);

    // Add the source and sink operations
    Source<E> sourceOp = new Source<E>(signature.getInputs());
    Sink<E> sinkOp = new Sink<E>(signature.getOutputs());
    leveledOps.add(0, Collections.<Operation<E>>singleton(sourceOp));
    leveledOps.add(leveledOps.size(), Collections.<Operation<E>>singleton(sinkOp));
    Stopwatch networkWatch = Stopwatch.createStarted();
    // Create a service match network with the discovered services
    DirectedAcyclicSMN<E, T> matchNetwork = new DirectedAcyclicSMN<E, T>(new HashLeveledServices<E>(leveledOps),
            this.matcher);
    log.info(" > Service match network computed in {}", networkWatch.stop().toString());
    log.info("Service Match Network created with {} levels (including source and sink) and {} operations.",
            leveledOps.size(), matchNetwork.listOperations().size());
    log.info("Forward Discovery done in {}", timer.toString());
    return matchNetwork;
}

From source file:com.android.builder.core.DexByteCodeConverter.java

private void dexInProcess(@NonNull final DexProcessBuilder builder, @NonNull final DexOptions dexOptions,
        @NonNull final ProcessOutputHandler outputHandler) throws IOException, ProcessException {
    final String submission = Joiner.on(',').join(builder.getInputs());
    mLogger.info("Dexing in-process : %s", submission);
    try {/*  www.  j av  a  2s .co  m*/
        sDexExecutorService.submit(() -> {
            Stopwatch stopwatch = Stopwatch.createStarted();
            ProcessResult result = DexWrapper.run(builder, dexOptions, outputHandler);
            result.assertNormalExitValue();
            mLogger.info("Dexing %s took %s.", submission, stopwatch.toString());
            return null;
        }).get();
    } catch (Exception e) {
        throw new ProcessException(e);
    }
}

From source file:es.usc.citius.composit.core.composition.search.ForwardServiceDiscoverer.java

public ServiceMatchNetwork<E, T> search(Signature<E> signature) {
    Set<E> availableInputs = new HashSet<E>(signature.getInputs());
    Set<E> newOutputs = new HashSet<E>(signature.getInputs());
    Set<E> unmatchedOutputs = new HashSet<E>(signature.getOutputs());
    Set<Operation<E>> usedServices = new HashSet<Operation<E>>();
    Map<Operation<E>, Set<E>> unmatchedInputMap = new HashMap<Operation<E>, Set<E>>();
    List<Set<Operation<E>>> leveledOps = new LinkedList<Set<Operation<E>>>();

    boolean checkExpectedOutputs = !signature.getOutputs().isEmpty();
    boolean stop;

    Stopwatch timer = Stopwatch.createStarted();
    Stopwatch levelTimer = Stopwatch.createUnstarted();
    int level = 0;
    do {/* w ww .  j a v  a2 s .co m*/
        HashSet<Operation<E>> candidates = new HashSet<Operation<E>>();
        levelTimer.start();
        candidates.addAll(discovery.findOperationsConsumingSome(newOutputs));
        log.info("(Level {}) {} potential candidates selected in {}", level++, candidates.size(),
                levelTimer.toString());
        // Remove services that cannot be invoked with the available inputs
        for (Iterator<Operation<E>> it = candidates.iterator(); it.hasNext();) {
            Operation<E> candidate = it.next();
            // Retrieve the unmatched inputs for this operation
            Set<E> unmatchedInputs = unmatchedInputMap.get(candidate);
            if (unmatchedInputs == null) {
                unmatchedInputs = candidate.getSignature().getInputs();
            }
            // Check if the new concepts match some unmatched inputs
            Set<E> matched = matcher.partialMatch(newOutputs, unmatchedInputs).getTargetElements();

            // Don't check invokability
            if (relaxedMatchCondition) {
                // Remove only if there is no match at all
                if (matched.isEmpty()) {
                    it.remove();
                } else {
                    boolean isNew = usedServices.add(candidate);
                    if (!isNew)
                        it.remove();
                }
            } else {
                // Update the unmatchedInputs
                unmatchedInputs = Sets.newHashSet(Sets.difference(unmatchedInputs, matched));
                unmatchedInputMap.put(candidate, unmatchedInputs);
                // If there are no unmatched inputs, the service is invokable!
                if (!unmatchedInputs.isEmpty()) {
                    it.remove();
                } else {
                    // Invokable operation, check if it was used previously
                    boolean isNew = usedServices.add(candidate);
                    if (!isNew)
                        it.remove();
                }
            }
        }
        log.info("\t + [{}] operations selected for this level in {}", candidates.size(),
                levelTimer.toString());
        log.debug("\t\t Candidates: {}", candidates);

        // Collect the new outputs of the new candidates
        Set<E> nextOutputs = Operations.outputs(candidates);

        // Check unmatched outputs
        Set<E> matchedOutputs = matcher.partialMatch(Sets.union(newOutputs, nextOutputs), unmatchedOutputs)
                .getTargetElements();
        //Set<Resource> matchedOutputs = matcher.matched(newOutputs, unmatchedOutputs);
        // Update the unmatched outputs
        unmatchedOutputs = Sets.newHashSet(Sets.difference(unmatchedOutputs, matchedOutputs));

        // Update for the next iteration
        availableInputs.addAll(newOutputs);
        newOutputs = nextOutputs;

        // Add the discovered ops
        if (!candidates.isEmpty())
            leveledOps.add(candidates);

        log.debug("\t + Available inputs: {}, new outputs: {}", availableInputs.size(), newOutputs.size());
        // Stop condition. Stop if there are no more candidates and/or expected outputs are satisfied.
        stop = (checkExpectedOutputs) ? candidates.isEmpty() || unmatchedOutputs.isEmpty()
                : candidates.isEmpty();
        levelTimer.reset();
    } while (!stop);

    // Add the source and sink operations
    Source<E> sourceOp = new Source<E>(signature.getInputs());
    Sink<E> sinkOp = new Sink<E>(signature.getOutputs());
    leveledOps.add(0, Collections.<Operation<E>>singleton(sourceOp));
    leveledOps.add(leveledOps.size(), Collections.<Operation<E>>singleton(sinkOp));
    Stopwatch networkWatch = Stopwatch.createStarted();
    // Create a service match network with the discovered services
    DirectedAcyclicSMN<E, T> matchNetwork = new DirectedAcyclicSMN<E, T>(new HashLeveledServices<E>(leveledOps),
            this.matcher);
    log.info(" > Service match network computed in {}", networkWatch.stop().toString());
    log.info("Service Match Network created with {} levels (including source and sink) and {} operations.",
            leveledOps.size(), matchNetwork.listOperations().size());
    log.info("Forward Discovery done in {}", timer.toString());
    this.unmatchedInputMap = unmatchedInputMap;
    return matchNetwork;
}

From source file:com.b2international.snowowl.snomed.reasoner.server.ontology.SnomedOntologyService.java

private OWLOntology createOntology(final IRI ontologyIRI, final IRI versionIRI)
        throws OWLOntologyCreationException {
    final Stopwatch stopwatch = Stopwatch.createStarted();
    LOGGER.info(MessageFormat.format(">>> Creating ontology ''{0}''", ontologyIRI));

    OWLOntology ontology = null;/*from   ww w . j av  a  2s .  c  om*/
    final OWLOntologyID ontologyID = new OWLOntologyID(ontologyIRI, versionIRI);
    ontology = manager.getOntology(ontologyID);

    if (null != ontology) {
        LOGGER.info(MessageFormat.format("<<< Creating ontology ''{0}'' [cached] [{1}]", ontologyIRI,
                stopwatch.toString()));
        return ontology;
    }

    ontology = manager.createOntology(ontologyID);

    LOGGER.info(MessageFormat.format("<<< Creating ontology ''{0}'' [built] [{1}]", ontologyIRI,
            stopwatch.toString()));
    return ontology;
}