java

#

23 Feb: Testing BigData projects

Writing tests that use a traditional database is hard. But writing tests in a project using Hadoop is really harder. Hadoop stacks are complex pieces of software and if you want to test your Hadoop projects, it may be a real nightmare: – many components are involved, you are not just using HBase, but HBase, Zookeeper and a DFS. – a lot of configuration is needed – cleaning the data of the previous tests relies on many…

#

15 Feb: Fitting Java and Python with JPY

There are many libraries in Java (more than 176,649 unique artifacts indexed just on Maven Central), but sometimes you can not find what you are looking for, except for a Python equivalent. In a previous project, I had to deal with custom MaxMind databases. Maxmind provides a Java library with a database reader, but does not provides a database writer. After some researches, I found one official lib in Perl, and an other (unofficial) in Python. Since,…

#

17 Oct: Advanced tools: playing with Java Native Access

This post results from a recent deep diving in the source code of Elasticsearch, which uses JNA mainly for memory management when configuring the mlockall. I will present you how to use JNA in a very simple example: how to check the user who has launched the JVM. Note Remember that when you are thinking about solution using OS native calls, you must deal and depend with platform librairies. So use it carefully and only for specific…

#

10 Oct: OS monitoring with… Java

Sometimes it may be useful to get system information like the usage of a disk or the available network interfaces. For instance, Elasticsearch use this kind of tools in order to display at startup time some infos about open file descriptors or the size of the direct memory available for the JVM. The aim is not to replace a real system monitoring agent, but to guide the user to take advantage of the product by configuring it…

26 Sep: String – Best Pratices

Never, never, never use the String constructor Whenever you want to instantiate a String object, never use its constructor but always instantiate it directly. For example: //don’t: String slow = new String(“Yet another string object”); //do String fast = “Yet another string object”; From the Javadoc: Unless an explicit copy of original is needed, use of this constructor is unnecessary since Strings are immutable. Pattern and regular expressions For performance reasons, instances of pattern (java.util.regex.Pattern) should be…