Monday, April 29, 2013

List all used ports on a unix machine

netstat -a -t --numeric-ports -p

How to manage the hadoop services with CDH4

Show HDFS Service status

for x in `cd /etc/init.d ; ls hadoop-hdfs-*` ; do sudo service $x status ; done
 * Hadoop datanode is running
 * Hadoop namenode is running
 * Hadoop secondarynamenode is running

Show Mapreduce service status

for x in `cd /etc/init.d ; ls hadoop-0.20-mapreduce-*` ; do sudo service $x status ; done
hadoop-0.20-jobtracker is running
hadoop-0.20-tasktracker is running

Thursday, October 6, 2011

Oracle Releases A Developer Preview JDK 7 for Mac OS X

At JavaOne 2011 Oracle announced the availability of JDK 7 for Mac OS X Developer Preview.

Go to http://jdk7.java.net/macportpreview/ for the download.

A list of open issues can be found here.

I as an eclipse fanboy am also happy about the release of Eclipse Indigo SR1 which adds full Java 7 support. Go here to see what is new for Java 7 in Eclipse Indigo SR1.

To use newly installed JDK in Eclipse, you have to add the path to the JDK home manually. Start Eclipse with JDK 6, select "Installed JREs" -> "Add.."->"Standard JVM". Enter the path to the /Contents/Home folder inside the installed JDK bundle and provide a meaningful name:




Have fun while trying out the latest Java 7 features!

Saturday, July 23, 2011

Project Voldemort Version 0.9

More than one year after the 0.8.1 release, LinkedIn just released version 0.9 of it's scalable nosql database Project Voldemort.

Go here for the release notes.

Sunday, July 17, 2011

Generic Java Methods And Type Inference

To create test data in Java I often wrote things like this:
List<String> names = new ArrayList<String>();
names.add("Tick"); 
names.add("Trick");
names.add("Track");
...
Generic methods and type inference make this task a lot easier:
public static <T> List<T> newArrayList(T... entries) {
  return new ArrayList<T>(Arrays.asList(entries));
}
The following JUnit test shows how to use this code:
public class ListBuilderTest {

  @Test
  public void test() {
    List<String> l = ListBuilder.newArrayList("Tick", "Trick", "Track");
      assertThat(l.size(), equalTo(3));
      assertThat(l, hasItem("Tick"));
      assertThat(l, hasItem("Trick"));
      assertThat(l, hasItem("Track"));
    }
}

By the way: I love the JUnit 4 org.junit.matchers.JUnitMatchers.* and org.hamcrest.CoreMatchers.* Matchers :-)

Of course you do not have to implement this code yourself. You can for example use the great guava libraries.

Monday, June 6, 2011

How To Update A File In A Jar/War Archive

Sometimes you want to update a file bundled in a jar or war archive (e.g. a config file).
In this post I am going to show how to update the file config/app-conf.xml in a war called frontend.war by using the jar-command.

To list the contents of our jar archive we type the following:

jar tf frontend.war

To extract the config file from the archive, type

jar xf frontend.war config/app-conf.xml

This creates a folder named config with the file app-conf.xml inside. Now you can edit the config file. After you are done editing the file you can update the archive by typing

jar uf frontend.war config/app-conf.xml

For having a quick look at the contents of a file you can use the unzip command:

unzip -q -c frontend.war config/app-conf.xml
(the c switch redirects output to stdout, the q(uiet) switch suppresses all other output. That's all!

Sunday, May 22, 2011

How To Install The MySQL Gem On Mac OS

For my latest ruby on rails project I had to install the MySQL gem on my laptop with Mac OS 10.6.
I had some trouble with this. Finally the following command did the trick:

gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Update: For rails 3 it is advisable to use the mysql2 gem.