本文整理汇总了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);
}
示例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()));
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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.");
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}