• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RetryOnFailure类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.jcabi.aspects.RetryOnFailure的典型用法代码示例。如果您正苦于以下问题:Java RetryOnFailure类的具体用法?Java RetryOnFailure怎么用?Java RetryOnFailure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RetryOnFailure类属于com.jcabi.aspects包,在下文中一共展示了RetryOnFailure类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getAddress

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
@RetryOnFailure(attempts = 5, delay = 1, unit = TimeUnit.MINUTES)
public Address getAddress(double lat, double lng) throws IOException {
	LatLng query = new LatLng(lat, lng);
	for (LatLng entry : addressCache.keySet()) {
		if (LatLngTool.distance(entry, query, LengthUnit.METER) < 30) {
			return addressCache.get(entry);
		}
	}

	// cannot find the place in the cache. Sleep a while and query the
	// OpenStreetMap.
	LoggerFactory.getLogger(this.getClass()).trace("Query {}", query);
	Address newAddress = nominatimClient.getAddress(lng, lat);
	addressCache.put(query, newAddress);
	return newAddress;
}
 
开发者ID:ohmage,项目名称:lifestreams,代码行数:17,代码来源:CachedOpenStreetMapClient.java


示例2: validatesHtmlDocument

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * DefaultHtmlValidator can validate HTML document.
 *
 * @throws Exception If something goes wrong inside
 */
@Test
@RetryOnFailure(verbose = false)
public void validatesHtmlDocument() throws Exception {
    MatcherAssert.assertThat(
        ValidatorBuilder.HTML.validate(
            StringUtils.join(
                "<!DOCTYPE html>",
                "<html><head><meta charset='UTF-8'>",
                "<title>hey</title></head>",
                "<body></body></html>"
            )
        ).errors(),
        Matchers.empty()
    );
}
 
开发者ID:jcabi,项目名称:jcabi-w3c,代码行数:21,代码来源:DefaultHtmlValidatorITCase.java


示例3: retriesAfterFailure

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * Repeater should retry a method that fails.
 */
@Test
public void retriesAfterFailure() {
    final AtomicInteger calls = new AtomicInteger(0);
    MatcherAssert.assertThat(
        new Callable<Boolean>() {
            @Override
            @RetryOnFailure(attempts = Tv.THREE, verbose = false)
            public Boolean call() {
                if (calls.get() < Tv.THREE - 1) {
                    calls.incrementAndGet();
                    throw new IllegalStateException();
                }
                return true;
            }
        } .call(),
        Matchers.equalTo(true)
    );
    MatcherAssert.assertThat(calls.get(), Matchers.equalTo(Tv.THREE - 1));
}
 
开发者ID:jcabi,项目名称:jcabi-aspects,代码行数:23,代码来源:RepeaterTest.java


示例4: stopsRetryingAfterNumberOfAttempts

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * Repeater should stop method retries if it exceeds a threshold.
 */
@Test(expected = IllegalStateException.class)
public void stopsRetryingAfterNumberOfAttempts() {
    final AtomicInteger calls = new AtomicInteger(0);
    new Callable<Boolean>() {
        @Override
        @RetryOnFailure(attempts = Tv.THREE, verbose = false)
        public Boolean call() {
            if (calls.get() < Tv.THREE) {
                calls.incrementAndGet();
                throw new IllegalStateException();
            }
            return true;
        }
    } .call();
}
 
开发者ID:jcabi,项目名称:jcabi-aspects,代码行数:19,代码来源:RepeaterTest.java


示例5: onlyRetryExceptionsWhichAreSpecified

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * Repeater should retry if an exception specified to be
 * retried is thrown from the method.
 */
@Test
public void onlyRetryExceptionsWhichAreSpecified() {
    final AtomicInteger calls = new AtomicInteger(0);
    MatcherAssert.assertThat(
        new Callable<Boolean>() {
            @Override
            @RetryOnFailure
                (
                    attempts = Tv.THREE,
                    types = {ArrayIndexOutOfBoundsException.class },
                    verbose = false
                )
            public Boolean call() {
                if (calls.get() < Tv.THREE - 1) {
                    calls.incrementAndGet();
                    throw new ArrayIndexOutOfBoundsException();
                }
                return true;
            }
        } .call(),
        Matchers.equalTo(true)
    );
    MatcherAssert.assertThat(calls.get(), Matchers.equalTo(Tv.THREE - 1));
}
 
开发者ID:jcabi,项目名称:jcabi-aspects,代码行数:29,代码来源:RepeaterTest.java


示例6: throwExceptionsWhichAreNotSpecifiedAsRetry

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * Repeater should throw the exception if it is
 * not specified to be retried.
 */
@Test(expected = ArrayIndexOutOfBoundsException.class)
public void throwExceptionsWhichAreNotSpecifiedAsRetry() {
    final AtomicInteger calls = new AtomicInteger(0);
    try {
        new Callable<Boolean>() {
            @Override
            @RetryOnFailure
                (
                    attempts = Tv.THREE,
                    types = {IllegalArgumentException.class },
                    verbose = false
                )
            public Boolean call() {
                if (calls.get() < Tv.THREE - 1) {
                    calls.incrementAndGet();
                    throw new ArrayIndexOutOfBoundsException();
                }
                return true;
            }
        } .call();
    } finally {
        MatcherAssert.assertThat(calls.get(), Matchers.equalTo(1));
    }
}
 
开发者ID:jcabi,项目名称:jcabi-aspects,代码行数:29,代码来源:RepeaterTest.java


示例7: retryExceptionsWhichAreSubTypesOfTheExceptionsSpecified

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * Repeater should retry even if the exception is a
 * subtype of the class specified to be retried.
 */
@Test
public void retryExceptionsWhichAreSubTypesOfTheExceptionsSpecified() {
    final AtomicInteger calls = new AtomicInteger(0);
    MatcherAssert.assertThat(
        new Callable<Boolean>() {
            @Override
            @RetryOnFailure
                (
                    attempts = Tv.THREE,
                    verbose = false,
                    types = {IndexOutOfBoundsException.class }
                )
            public Boolean call() {
                if (calls.get() < Tv.THREE - 1) {
                    calls.incrementAndGet();
                    throw new ArrayIndexOutOfBoundsException();
                }
                return true;
            }
        } .call(),
        Matchers.equalTo(true)
    );
    MatcherAssert.assertThat(calls.get(), Matchers.equalTo(Tv.THREE - 1));
}
 
开发者ID:jcabi,项目名称:jcabi-aspects,代码行数:29,代码来源:RepeaterTest.java


示例8: validatesCssDocument

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * DefaultCssValidator can validate CSS document.
 * @throws Exception If something goes wrong inside
 */
@Test
@RetryOnFailure(verbose = false)
public void validatesCssDocument() throws Exception {
    MatcherAssert.assertThat(
        ValidatorBuilder.CSS.validate("* { }").errors(),
        Matchers.empty()
    );
}
 
开发者ID:jcabi,项目名称:jcabi-w3c,代码行数:13,代码来源:DefaultCssValidatorITCase.java


示例9: reserve

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * Reserve port.
 * @return Reserved TCP port
 * @throws IOException If fails
 */
@RetryOnFailure
private static int reserve() throws IOException {
    final int reserved;
    try (final ServerSocket socket = new ServerSocket(0)) {
        reserved = socket.getLocalPort();
    }
    return reserved;
}
 
开发者ID:jcabi,项目名称:jcabi-http,代码行数:14,代码来源:MkGrizzlyContainer.java


示例10: matchesValidHtml

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * W3CMatchers can check HTML document validity.
 */
@Test
@RetryOnFailure(verbose = false)
public void matchesValidHtml() {
    MatcherAssert.assertThat(
        StringUtils.join(
            "<!DOCTYPE html>",
            "<html><head><meta charset='UTF-8'/>",
            "<title>hey</title></head>",
            "<body></body></html>"
        ),
        W3CMatchers.validHtml()
    );
}
 
开发者ID:jcabi,项目名称:jcabi-matchers,代码行数:17,代码来源:W3CMatchersTest.java


示例11: rejectsInvalidHtml

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * W3CMatchers can reject invalid HTML document.
 */
@Test
@RetryOnFailure(verbose = false)
public void rejectsInvalidHtml() {
    MatcherAssert.assertThat(
        "<blah><blaaaaaaaaa/>",
        Matchers.not(W3CMatchers.validHtml())
    );
}
 
开发者ID:jcabi,项目名称:jcabi-matchers,代码行数:12,代码来源:W3CMatchersTest.java


示例12: matchesValidCss

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * W3CMatchers can check CSS document validity.
 */
@Test
@RetryOnFailure(verbose = false)
public void matchesValidCss() {
    MatcherAssert.assertThat(
        "body { background-color:#d0e4fe; }",
        W3CMatchers.validCss()
    );
}
 
开发者ID:jcabi,项目名称:jcabi-matchers,代码行数:12,代码来源:W3CMatchersTest.java


示例13: rejectsInvalidCss

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * W3CMatchers can reject invalid CSS document.
 */
@Test
@RetryOnFailure(verbose = false)
public void rejectsInvalidCss() {
    MatcherAssert.assertThat(
        "hello { $#^@*&^$&@; }",
        Matchers.not(W3CMatchers.validCss())
    );
}
 
开发者ID:jcabi,项目名称:jcabi-matchers,代码行数:12,代码来源:W3CMatchersTest.java


示例14: port

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * Returns available port number.
 * @return Available port number
 * @throws IOException in case of IO error.
 */
@RetryOnFailure
public final int port() throws IOException {
    final ServerSocket socket = new ServerSocket();
    try  {
        socket.setReuseAddress(true);
        socket.bind(
            new InetSocketAddress("localhost", 0)
        );
        return socket.getLocalPort();
    } finally {
        socket.close();
    }
}
 
开发者ID:jcabi,项目名称:jcabi-github,代码行数:19,代码来源:RandomPort.java


示例15: next

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
@Override
@RetryOnFailure
    (
        verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS,
        ignore = NoSuchElementException.class
    )
public T next() {
    return this.origin.next();
}
 
开发者ID:jcabi,项目名称:jcabi-dynamo,代码行数:10,代码来源:ReIterator.java


示例16: fetch

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
@Override
@RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS)
public Dosage fetch(final Credentials credentials, final String table,
    final Map<String, Condition> conditions,
    final Collection<String> keys) throws IOException {
    return new ReDosage(
        this.origin.fetch(credentials, table, conditions, keys)
    );
}
 
开发者ID:jcabi,项目名称:jcabi-dynamo,代码行数:10,代码来源:ReValve.java


示例17: exec

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * Execute git with these arguments.
 * @param dir In which directory to run it
 * @param args Arguments to pass to it
 * @return Stdout
 * @checkstyle MagicNumber (2 lines)
 */
@RetryOnFailure(delay = 3000, attempts = 2)
public String exec(@NotNull final File dir, @NotNull final String... args) {
    final List<String> commands = new ArrayList<String>(args.length + 1);
    commands.add("git");
    for (final String arg : args) {
        commands.add(arg);
    }
    Logger.info(this, "%s:...", StringUtils.join(commands, " "));
    final ProcessBuilder builder = new ProcessBuilder(commands);
    builder.directory(dir);
    builder.environment().put("GIT_SSH", this.script);
    return new VerboseProcess(builder).stdout();
}
 
开发者ID:jcabi,项目名称:jcabi-heroku-maven-plugin,代码行数:21,代码来源:Git.java


示例18: ping

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * Ping it.
 */
@RetryOnFailure(attempts = 4, delay = 0, verbose = false)
public void ping() {
    throw new IllegalStateException(
        String.format(
            "ping #%d",
            this.count.incrementAndGet()
        )
    );
}
 
开发者ID:jcabi,项目名称:jcabi-aspects,代码行数:13,代码来源:Counter.java


示例19: close

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
/**
 * Close method.
 * @throws IOException If something wrong happens inside
 */
@RetryOnFailure
public void close() throws IOException {
    this.socket.close();
}
 
开发者ID:teamed,项目名称:qulice,代码行数:9,代码来源:TestSocket.java


示例20: meta

import com.jcabi.aspects.RetryOnFailure; //导入依赖的package包/类
@Override
@RetryOnFailure(verbose = false)
public ObjectMetadata meta() throws IOException {
    return this.origin.meta();
}
 
开发者ID:jcabi,项目名称:jcabi-s3,代码行数:6,代码来源:ReOcket.java



注:本文中的com.jcabi.aspects.RetryOnFailure类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VMOptionCompositeData类代码示例发布时间:2022-05-22
下一篇:
Java CountingQuietWriter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap