Java Code Geeks » Tomasz Nurkiewicz http://www.javacodegeeks.com/ Java 2 Java Developers Resource Center Tue, 21 Apr 2015 16:00:09 +0000 en-US hourly 1 http://wordpress.org/?v=4.1.1 Biological computer simulation of selfish geneshttp://www.javacodegeeks.com/2015/04/biological-computer-simulation-of-selfish-genes.html http://www.javacodegeeks.com/2015/04/biological-computer-simulation-of-selfish-genes.html#comments Mon, 06 Apr 2015 19:00:49 +0000 http://www.javacodegeeks.com/?p=38976 TL;DR: I did a computer simulation of behavior evolution of monkeys, continue reading to see how problem was stated originally in The Selfish Gene. First part shows my Java implementation, second part shows charted results and conclusions. The problem I read The Selfish Gene by Richard Dawkins recently, very wide-opening book despite being 40 years ...

 

]]>
http://www.javacodegeeks.com/2015/04/biological-computer-simulation-of-selfish-genes.html/feed/ 0
CompletableFuture can’t be interruptedhttp://www.javacodegeeks.com/2015/03/completablefuture-cant-be-interrupted.html http://www.javacodegeeks.com/2015/03/completablefuture-cant-be-interrupted.html#comments Wed, 25 Mar 2015 14:00:58 +0000 http://www.javacodegeeks.com/?p=38581 I wrote a lot about InterruptedException and interrupting threads already. In short if you call Future.cancel() not inly given Future will terminate pending get(), but also it will try to interrupt underlying thread. This is a pretty important feature that enables better thread pool utilization. I also wrote to always prefer CompletableFuture over standard Future. ...

 

]]>
http://www.javacodegeeks.com/2015/03/completablefuture-cant-be-interrupted.html/feed/ 0
Journey to idempotency and temporal decouplinghttp://www.javacodegeeks.com/2015/02/journey-to-idempotency-and-temporal-decoupling.html http://www.javacodegeeks.com/2015/02/journey-to-idempotency-and-temporal-decoupling.html#comments Sat, 28 Feb 2015 13:00:57 +0000 http://www.javacodegeeks.com/?p=37466 Idempotency in HTTP means that the same request can be performed multiple times with the same effect as if it was executed just once. If you replace current state of some resource with new one, no matter how many times you do so, in the end state will be the same as if you did ...

 

]]>
http://www.javacodegeeks.com/2015/02/journey-to-idempotency-and-temporal-decoupling.html/feed/ 0
Retry-After HTTP header in practicehttp://www.javacodegeeks.com/2015/02/retry-http-header-practice.html http://www.javacodegeeks.com/2015/02/retry-http-header-practice.html#comments Fri, 13 Feb 2015 08:00:07 +0000 http://www.javacodegeeks.com/?p=36963 Retry-After is a lesser known HTTP response header. Let me quote relevant part of RFC 2616 (HTTP 1.1 spec): 14.37 Retry-After The Retry-After response-header field can be used with a 503 (Service Unavailable) response to indicate how long the service is expected to be unavailable to the requesting client. This field MAY also be used ...

 

]]>
http://www.javacodegeeks.com/2015/02/retry-http-header-practice.html/feed/ 0
Storing months of historical metrics from Hystrix in Graphitehttp://www.javacodegeeks.com/2015/02/storing-months-historical-metrics-hystrix-graphite.html http://www.javacodegeeks.com/2015/02/storing-months-historical-metrics-hystrix-graphite.html#comments Fri, 06 Feb 2015 14:00:18 +0000 http://www.javacodegeeks.com/?p=36651 One of the killer-features of Hystrix is a low-latency, data-intensive and beautiful dashboard:                     Even though it’s just a side-effect of what Hystrix is really doing (circuit breakers, thread pools, timeouts, etc.), it tends to be the most impressive feature. In order to make it work ...

 

]]>
http://www.javacodegeeks.com/2015/02/storing-months-historical-metrics-hystrix-graphite.html/feed/ 0
Asynchronous timeouts with CompletableFuturehttp://www.javacodegeeks.com/2014/12/asynchronous-timeouts-with-completablefuture.html http://www.javacodegeeks.com/2014/12/asynchronous-timeouts-with-completablefuture.html#comments Tue, 30 Dec 2014 20:00:20 +0000 http://www.javacodegeeks.com/?p=35049 One day I was rewriting poorly implemented multi-threaded code that was blocking at some point on Future.get():                   public void serve() throws InterruptedException, ExecutionException, TimeoutException { final Future<Response> responseFuture = asyncCode(); final Response response = responseFuture.get(1, SECONDS); send(response); } private void send(Response response) { //... } This ...

 

]]>
http://www.javacodegeeks.com/2014/12/asynchronous-timeouts-with-completablefuture.html/feed/ 0
Accessing Meetup’s streaming API with RxNettyhttp://www.javacodegeeks.com/2014/12/accessing-meetups-streaming-api-with-rxnetty.html http://www.javacodegeeks.com/2014/12/accessing-meetups-streaming-api-with-rxnetty.html#comments Tue, 23 Dec 2014 11:00:17 +0000 http://www.javacodegeeks.com/?p=34439 This article will touch upon multiple subjects: reactive programming, HTTP, parsing JSON and integrating with social API. All in one use case: we will load and process new meetup.com events in real time via non-bloking RxNetty library, combining the power of Netty framework and flexibility of RxJava library. Meetup provides publicly available streaming API that ...

 

]]>
http://www.javacodegeeks.com/2014/12/accessing-meetups-streaming-api-with-rxnetty.html/feed/ 0
Hazelcast member discovery using Curator and ZooKeeperhttp://www.javacodegeeks.com/2014/12/hazelcast-member-discovery-using-curator-and-zookeeper.html http://www.javacodegeeks.com/2014/12/hazelcast-member-discovery-using-curator-and-zookeeper.html#comments Fri, 19 Dec 2014 05:00:13 +0000 http://www.javacodegeeks.com/?p=34648 At one project I was setting up Hazelcast cluster in a private cloud. Within cluster all nodes must see each other, so during bootstrapping Hazelcast will try to locate other cluster members. There is no server and all nodes are made equal. There are couple techniques of discovering members implemented in Hazelcast; unfortunately it wasn’t ...

 

]]>
http://www.javacodegeeks.com/2014/12/hazelcast-member-discovery-using-curator-and-zookeeper.html/feed/ 0
Converting between Completablefuture and Observablehttp://www.javacodegeeks.com/2014/12/converting-between-completablefuture-and-observable.html http://www.javacodegeeks.com/2014/12/converting-between-completablefuture-and-observable.html#comments Mon, 01 Dec 2014 11:00:19 +0000 http://www.javacodegeeks.com/?p=33533 CompletableFuture<T> from Java 8 is an advanced abstraction over a promise that value of type T will be available in the future. Observable<T> is quite similar, but it promises arbitrary number of items in the future, from 0 to infinity. These two representations of asynchronous results are quite similar to the point where Observable with ...

 

]]>
http://www.javacodegeeks.com/2014/12/converting-between-completablefuture-and-observable.html/feed/ 0
ExecutorService – 10 tips and trickshttp://www.javacodegeeks.com/2014/11/executorservice-10-tips-and-tricks.html http://www.javacodegeeks.com/2014/11/executorservice-10-tips-and-tricks.html#comments Mon, 24 Nov 2014 11:00:04 +0000 http://www.javacodegeeks.com/?p=33430 ExecutorService abstraction has been around since Java 5. We are talking about 2004 here. Just a quick reminder: both Java 5 and 6 are no longer supported, Java 7 won’t be in half a year. The reason I’m bringing this up is that many Java programmers still don’t fully understand how ExecutorService works. There are ...

 

]]>
http://www.javacodegeeks.com/2014/11/executorservice-10-tips-and-tricks.html/feed/ 1