Home » Author Archives: Tomasz Nurkiewicz (page 8)

Author Archives: Tomasz Nurkiewicz

Java EE developer, Scala enthusiast. Enjoying data analysis and visualization. Strongly believes in the power of testing and automation.

Probability distribution for programmers

scala-logo

This is one of these very simple programming puzzles I came across recently: given a function returning random integers from 0 to 4 inclusive with equal probability, write a function returning random integers from 0 to 6 inclusive. Of course the solution should also return equally distributed numbers. So let’s start from an input function sample definition:       ...

Read More »

@Cacheable overhead in Spring

spring-interview-questions-answers

Spring 3.1 introduced great caching abstraction layer. Finally we can abandon all home-grown aspects, decorators and code polluting our business logic related to caching.                   Since then we can simply annotate heavyweight methods and let Spring and AOP machinery do the work: @Cacheable("books") public Book findBook(ISBN isbn) {...} "books" is a cache ...

Read More »

Forcing Tomcat to log through SLF4J/Logback

apache-tomcat-logo

So you have your executable web application in JAR with bundled Tomcat (make sure to read that one first). However there are these annoying Tomcat logs at the beginning, independent from our application logs and not customizable:                 Nov 24, 2012 11:44:02 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-8080"] Nov 24, 2012 11:44:02 ...

Read More »

Standalone web application with executable Tomcat

apache-tomcat-logo

When it comes to deploying your application, simplicity is the biggest advantage. You’ll understand that especially when project evolves and needs some changes in the environment. Packaging up your whole application in one, standalone and self-sufficient JAR seems like a good idea, especially compared to installing and upgrading Tomcat in target environment. In the past I would typically include Tomcat ...

Read More »

Parallelization of a simple use case explained

scala-logo

Some time ago a friend of mine asked me about the possibilities of speeding up the following process: they are generating some data in two stages, reading from a database and processing the results. Reading takes approximately 70% of time and processing takes the remaining 30%. Unfortunately they cannot simply load the whole data into memory, thus they split reading ...

Read More »

Non-blocking I/O – discovering Akka

akka-logo

Here comes the time to follow some good practices when implementing actors. One of the most important rules we should follow is avoiding any blocking input/output operations, polling, busy waiting, sleeping, etc. Simply put, actor while handling a message should only depend on CPU and if it doesn’t need CPU cycles it should immediately return from receive and let other ...

Read More »

Two actors – discovering Akka

akka-logo

Hope you are having fun so far, but our application has serious performance defect. After measuring response times of the RandomOrgRandom class we developed in the previous part we will notice something really disturbing (the chart represents response times of subsequent invocations in milliseconds): In turns out that regularly response time (time to return one random number) is greater by ...

Read More »

Remote actors – discovering Akka

scala-logo

Assume our test application became a huge success and slowly a single server is not capable of handling growing traffic. We are faced with two choices: replacing our server with a better one (scaling up) or buying a second one and building a cluster (scaling out). We’ve chosen to build a cluster as it’s easier to scale in the future. ...

Read More »

become/unbecome – discovering Akka

akka-logo

Sometimes our actor needs to react differently based on its internal state. Typically receiving some specific message causes the state transition which, in turns, changes the way subsequent messages should be handled. Another message restores the original state and thus – the way messages were handled before. In the previous article we implemented RandomOrgBuffer actor based on waitingForResponse flag. It ...

Read More »

Request and response – discovering Akka

akka-logo

In the previous part we implemented our first actor and sent message to it. Unfortunately actor was incapable of returning any result of processing this message, which rendered him rather useless. In this episode we will learn how to send reply message to the sender and how to integrate synchronous, blocking API with (by definition) asynchronous system based on message ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close