List of usage examples for java.util.concurrent.atomic AtomicIntegerArray addAndGet
public final int addAndGet(int i, int delta)
From source file:Main.java
public static void main(String[] argv) throws Exception { AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 0, 1, 2, 3 }); System.out.println(atomicIntegerArray.addAndGet(2, 10)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 0, 1, 2, 3 }); atomicIntegerArray.compareAndSet(0, 10, 20); System.out.println(atomicIntegerArray.addAndGet(2, 10)); }
From source file:com.netflix.iep.http.RxHttpTest.java
private void codeTest(int code, int attempts) throws Exception { statusCode.set(code);/*from w ww . j av a 2 s. co m*/ AtomicIntegerArray expected = copy(statusCounts); expected.addAndGet(code, attempts); rxHttp.get(uri("/empty")).toBlocking().toFuture().get(); assertEquals(expected, statusCounts); }
From source file:com.netflix.iep.http.RxHttpTest.java
@Test public void postJsonString() throws Exception { int code = 200; statusCode.set(code);//from w ww . j a v a 2 s. co m AtomicIntegerArray expected = copy(statusCounts); expected.addAndGet(code, 1); rxHttp.postJson(uri("/empty"), "{}").toBlocking().toFuture().get(); assertEquals(expected, statusCounts); }
From source file:com.netflix.iep.http.RxHttpTest.java
@Test public void putJsonString() throws Exception { int code = 200; statusCode.set(code);//from ww w . ja v a 2s. c o m AtomicIntegerArray expected = copy(statusCounts); expected.addAndGet(code, 1); rxHttp.putJson(uri("/empty"), "{}").toBlocking().toFuture().get(); assertEquals(expected, statusCounts); }
From source file:com.netflix.iep.http.RxHttpTest.java
@Test public void delete() throws Exception { int code = 200; statusCode.set(code);/*from w w w .j av a 2s . c o m*/ AtomicIntegerArray expected = copy(statusCounts); expected.addAndGet(code, 1); rxHttp.delete(uri("/empty").toString()).toBlocking().toFuture().get(); assertEquals(expected, statusCounts); }
From source file:com.netflix.iep.http.RxHttpTest.java
@Test public void head() throws Exception { int code = 200; statusCode.set(code);/*from w ww . j a v a 2s.com*/ AtomicIntegerArray expected = copy(statusCounts); expected.addAndGet(code, 1); rxHttp.submit(HttpClientRequest.<ByteBuf>create(HttpMethod.HEAD, uri("/empty").toString())).toBlocking() .toFuture().get(); assertEquals(expected, statusCounts); }
From source file:com.netflix.iep.http.RxHttpTest.java
@Test public void postWithCustomHeader() throws Exception { int code = 200; statusCode.set(code);//from ww w. j a v a 2 s . c o m AtomicIntegerArray expected = copy(statusCounts); expected.addAndGet(code, 1); rxHttp.submit(HttpClientRequest.createPost(uri("/empty").toString()).withHeader("k", "v"), "{}") .toBlocking().toFuture().get(); assertEquals(expected, statusCounts); }
From source file:com.netflix.iep.http.RxHttpTest.java
@Test public void postForm() throws Exception { int code = 200; statusCode.set(code);//from ww w . j a v a 2s .c o m AtomicIntegerArray expected = copy(statusCounts); expected.addAndGet(code, 1); final StringBuilder builder = new StringBuilder(); rxHttp.postForm(uri("/echo?foo=bar&name=John+Doe&pct=%2042%25")) .flatMap(new Func1<HttpClientResponse<ByteBuf>, Observable<ByteBuf>>() { @Override public Observable<ByteBuf> call(HttpClientResponse<ByteBuf> res) { Assert.assertEquals(200, res.getStatus().code()); return res.getContent(); } }).toBlocking().forEach(new Action1<ByteBuf>() { @Override public void call(ByteBuf byteBuf) { builder.append(byteBuf.toString(Charset.defaultCharset())); } }); assertEquals(expected, statusCounts); Assert.assertEquals("foo=bar&name=John+Doe&pct=%2042%25", builder.toString()); }
From source file:com.netflix.iep.http.RxHttpTest.java
@Test public void simplePost() throws Exception { int code = 200; statusCode.set(code);/*w w w.j a v a 2 s. co m*/ AtomicIntegerArray expected = copy(statusCounts); expected.addAndGet(code, 1); final StringBuilder builder = new StringBuilder(); rxHttp.post(uri("/echo"), "text/plain", "foo bar".getBytes()) .flatMap(new Func1<HttpClientResponse<ByteBuf>, Observable<ByteBuf>>() { @Override public Observable<ByteBuf> call(HttpClientResponse<ByteBuf> res) { Assert.assertEquals(200, res.getStatus().code()); return res.getContent(); } }).toBlocking().forEach(new Action1<ByteBuf>() { @Override public void call(ByteBuf byteBuf) { builder.append(byteBuf.toString(Charset.defaultCharset())); } }); Assert.assertEquals("foo bar", builder.toString()); assertEquals(expected, statusCounts); }