当前位置: 首页>>代码示例>>Java>>正文


Java StopWatch.stop方法代码示例

本文整理汇总了Java中org.apache.camel.util.StopWatch.stop方法的典型用法代码示例。如果您正苦于以下问题:Java StopWatch.stop方法的具体用法?Java StopWatch.stop怎么用?Java StopWatch.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.util.StopWatch的用法示例。


在下文中一共展示了StopWatch.stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRedeliveryErrorHandlerNoRedeliveryOnShutdown

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
public void testRedeliveryErrorHandlerNoRedeliveryOnShutdown() throws Exception {
    getMockEndpoint("mock:foo").expectedMessageCount(1);
    getMockEndpoint("mock:deadLetter").expectedMessageCount(1);
    getMockEndpoint("mock:deadLetter").setResultWaitTime(25000);

    template.sendBody("seda:foo", "Hello World");

    getMockEndpoint("mock:foo").assertIsSatisfied();

    // should not take long to stop the route
    StopWatch watch = new StopWatch();
    // sleep 3 seconds to do some redeliveries before we stop
    Thread.sleep(3000);
    log.info("==== stopping route foo ====");
    context.stopRoute("foo");
    watch.stop();

    getMockEndpoint("mock:deadLetter").assertIsSatisfied();

    log.info("OnRedelivery processor counter {}", counter.get());

    assertTrue("Should stop route faster, was " + watch.taken(), watch.taken() < 7000);
    assertTrue("Redelivery counter should be >= 2 and < 12, was: " + counter.get(), counter.get() >= 2 && counter.get() < 12);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:RedeliveryDeadLetterErrorHandlerNoRedeliveryOnShutdownTest.java

示例2: timeSplitRoutes

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
protected void timeSplitRoutes(int numberOfRequests) throws Exception {
    String[] endpoints = new String[]{"direct:splitSynchronizedAggregation", "direct:splitUnsynchronizedAggregation"};
    List<Future<File>> futures = new ArrayList<Future<File>>();
    StopWatch stopWatch = new StopWatch(false);

    for (String endpoint : endpoints) {
        stopWatch.restart();
        for (int requestIndex = 0; requestIndex < numberOfRequests; requestIndex++) {
            futures.add(template.asyncRequestBody(endpoint, null, File.class));
        }

        for (int i = 0; i < futures.size(); i++) {
            Future<File> future = futures.get(i);
            future.get();
        }
        stopWatch.stop();

        log.info(String.format("test%d.%s=%d\n", numberOfRequests, endpoint, stopWatch.taken()));
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:SplitterParallelAggregateTest.java

示例3: testVmInOutChainedTimeout

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
public void testVmInOutChainedTimeout() throws Exception {
    StopWatch watch = new StopWatch();
    
    try {
        template2.requestBody("vm:a?timeout=1000", "Hello World");
        fail("Should have thrown an exception");
    } catch (CamelExecutionException e) {
        // the chained vm caused the timeout
        ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause());
        assertEquals(200, cause.getTimeout());
    }
    
    long delta = watch.stop();

    assertTrue("Should be faster than 1 sec, was: " + delta, delta < 1100);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:VmInOutChainedTimeoutTest.java

示例4: testJmsRequestReplySharedReplyTo

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
@Test
public void testJmsRequestReplySharedReplyTo() throws Exception {
    StopWatch watch = new StopWatch();

    // shared is more slower than exclusive, due it need to use a JMS Message Selector
    // and has a receiveTimeout of 1 sec per default, so it react slower to new messages

    assertEquals("Hello A", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Shared", "A"));
    assertEquals("Hello B", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Shared", "B"));
    assertEquals("Hello C", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Shared", "C"));
    assertEquals("Hello D", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Shared", "D"));
    assertEquals("Hello E", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Shared", "E"));

    long delta = watch.stop();
    assertTrue("Should be slower than about 2 seconds, was: " + delta, delta > 2000);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:JmsRequestReplySharedReplyToTest.java

示例5: testJettyAsyncTimeout

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
@Test
public void testJettyAsyncTimeout() throws Exception {
    getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");

    StopWatch watch = new StopWatch();
    try {
        template.requestBody("http://localhost:{{port}}/myservice", null, String.class);
        fail("Should have thrown an exception");
    } catch (CamelExecutionException e) {
        log.info("Timeout hit and client got reply with failure status code");

        long taken = watch.stop();

        HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause());
        assertEquals(503, cause.getStatusCode());

        // should be approx 30-34 sec.
        assertTrue("Timeout should occur faster than " + taken, taken < 34000);
    }

    assertMockEndpointsSatisfied(2, TimeUnit.MINUTES);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:JettyAsyncDefaultContinuationTimeoutTest.java

示例6: testDisruptorVmInOutChainedTimeout

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
public void testDisruptorVmInOutChainedTimeout() throws Exception {
    StopWatch watch = new StopWatch();

    try {
        template2.requestBody("disruptor-vm:a?timeout=1000", "Hello World");
        fail("Should have thrown an exception");
    } catch (CamelExecutionException e) {
        // the chained vm caused the timeout
        ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class,
                e.getCause());
        assertEquals(200, cause.getTimeout());
    }

    long delta = watch.stop();

    assertTrue("Should be faster than 1 sec, was: " + delta, delta < 1100);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:DisruptorVmInOutChainedTimeoutTest.java

示例7: testDisruptorInOutChainedTimeout

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
@Test
public void testDisruptorInOutChainedTimeout() throws Exception {
    // time timeout after 2 sec should trigger a immediately reply
    final StopWatch watch = new StopWatch();
    try {
        template.requestBody("disruptor:a?timeout=5000", "Hello World");
        fail("Should have thrown an exception");
    } catch (CamelExecutionException e) {
        final ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class,
                e.getCause());
        assertEquals(2000, cause.getTimeout());
    }
    final long delta = watch.stop();

    assertTrue("Should be faster than 4000 millis, was: " + delta, delta < 4000);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:DisruptorInOutChainedTimeoutTest.java

示例8: stop

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
public void stop() {
    if (isStopped()) {
        logger.info(String.format("application %s was already stopped ", name));
        return;
    }

    StopWatch timingWath = new StopWatch();
    try {

        logStopingInfo();

        for (IDrinkWaterService service : services) {
            service.stop();
        }

        stopExternalServices();

        if (isUseServiceManagement()) {
            stopManagementService();
        }

        stopTokenServiceIfEnabled();

        stopDataStores();

        stopApplicationContext();

        state = ApplicationState.Stopped;
        timingWath.stop();
    } finally {
        logStoppedInfo(timingWath);
    }

}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:35,代码来源:DrinkWaterApplication.java

示例9: doResume

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
@Override
protected void doResume() throws Exception {
    try {
        EventHelper.notifyCamelContextResuming(this);

        log.info("Apache Camel " + getVersion() + " (CamelContext: " + getName() + ") is resuming");
        StopWatch watch = new StopWatch();

        // start the suspended routes (do not check for route clashes, and indicate)
        doStartOrResumeRoutes(suspendedRouteServices, false, true, true, false);

        // mark the route services as resumed (will be marked as started) as well
        for (RouteService service : suspendedRouteServices.values()) {
            if (routeSupportsSuspension(service.getId())) {
                service.resume();
            } else {
                service.start();
            }
        }

        watch.stop();
        if (log.isInfoEnabled()) {
            log.info("Resumed " + suspendedRouteServices.size() + " routes");
            log.info("Apache Camel " + getVersion() + " (CamelContext: " + getName() + ") resumed in " + TimeUtils.printDuration(watch.taken()));
        }

        // and clear the list as they have been resumed
        suspendedRouteServices.clear();

        EventHelper.notifyCamelContextResumed(this);
    } catch (Exception e) {
        EventHelper.notifyCamelContextResumeFailed(this, e);
        throw e;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:36,代码来源:DefaultCamelContext.java

示例10: waitForCompleteLatch

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
protected void waitForCompleteLatch() throws InterruptedException {
    if (latch == null) {
        fail("Should have a latch!");
    }

    StopWatch watch = new StopWatch();
    waitForCompleteLatch(resultWaitTime);
    long delta = watch.stop();
    LOG.debug("Took {} millis to complete latch", delta);

    if (resultMinimumWaitTime > 0 && delta < resultMinimumWaitTime) {
        fail("Expected minimum " + resultMinimumWaitTime
            + " millis waiting on the result, but was faster with " + delta + " millis.");
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:MockEndpoint.java

示例11: testTimerUsingStopWatch

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
public void testTimerUsingStopWatch() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result"); 
    mock.expectedMinimumMessageCount(2);

    StopWatch watch = new StopWatch();
    assertMockEndpointsSatisfied();
    long interval = watch.stop();
    
    LOG.trace("Should take approx 2000 milliseconds, was: {}", interval);
    assertTrue("Should take approx 2000 milliseconds, was: " + interval, interval >= 1700);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:TimerDrivenTimePatternConverterTest.java

示例12: testRedeliveryErrorHandlerNoRedeliveryOnShutdown

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
public void testRedeliveryErrorHandlerNoRedeliveryOnShutdown() throws Exception {
    getMockEndpoint("mock:foo").expectedMessageCount(1);

    template.sendBody("seda:foo", "Hello World");

    assertMockEndpointsSatisfied();

    // should not take long to stop the route
    StopWatch watch = new StopWatch();
    context.stopRoute("foo");
    watch.stop();

    assertTrue("Should stop route faster, was " + watch.taken(), watch.taken() < 4000);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:RedeliveryErrorHandlerNoRedeliveryOnShutdownTest.java

示例13: testSedaInOutChainedTimeout

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
public void testSedaInOutChainedTimeout() throws Exception {
    // time timeout after 2 sec should trigger a immediately reply
    StopWatch watch = new StopWatch();
    try {
        template.requestBody("seda:a?timeout=5000", "Hello World");
        fail("Should have thrown an exception");
    } catch (CamelExecutionException e) {
        ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause());
        assertEquals(2000, cause.getTimeout());
    }
    long delta = watch.stop();

    assertTrue("Should be faster than 4000 millis, was: " + delta, delta < 4000);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:SedaInOutChainedTimeoutTest.java

示例14: testJmsRequestReplyExclusiveFixedReplyTo

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
@Test
public void testJmsRequestReplyExclusiveFixedReplyTo() throws Exception {
    StopWatch watch = new StopWatch();

    assertEquals("Hello A", template.requestBody("activemq:queue:foo?replyTo=bar", "A"));
    assertEquals("Hello B", template.requestBody("activemq:queue:foo?replyTo=bar", "B"));
    assertEquals("Hello C", template.requestBody("activemq:queue:foo?replyTo=bar", "C"));
    assertEquals("Hello D", template.requestBody("activemq:queue:foo?replyTo=bar", "D"));
    assertEquals("Hello E", template.requestBody("activemq:queue:foo?replyTo=bar", "E"));

    long delta = watch.stop();
    assertTrue("Should be faster than about 4 seconds, was: " + delta, delta < 4200);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:JmsRequestReplyExclusiveReplyToComponentTest.java

示例15: testJmsRequestReplyExclusiveFixedReplyTo

import org.apache.camel.util.StopWatch; //导入方法依赖的package包/类
@Test
public void testJmsRequestReplyExclusiveFixedReplyTo() throws Exception {
    StopWatch watch = new StopWatch();

    assertEquals("Hello A", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Exclusive", "A"));
    assertEquals("Hello B", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Exclusive", "B"));
    assertEquals("Hello C", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Exclusive", "C"));
    assertEquals("Hello D", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Exclusive", "D"));
    assertEquals("Hello E", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Exclusive", "E"));

    long delta = watch.stop();
    assertTrue("Should be faster than about 4 seconds, was: " + delta, delta < 4200);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:JmsRequestReplyExclusiveReplyToTest.java


注:本文中的org.apache.camel.util.StopWatch.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。