About Me

My photo
Working as Technical Lead in CollabNET software private limited.

Wednesday, 25 November 2009

How to take a thread dump

Yesterday, I was looking to find whether any daemon thread is running with in jboss server, which does an scheduled job.

Tried ps -efw but it didn't worked, as it's an internal thread, got some suggestions that dumpingthe jboss process will dump the name of daemon threaad and finally it worked great :)


# Find the running boss server process id.

ps -efww | grep 'java' #choose your jboss server pid.

# send thread dump signal.
kill -3 $pid

Thursday, 5 November 2009

Load Test: Lucene 2.4 VS Lucene 2.9

public class ContrivedFCTest extends TestCase {
public void testLoadTime() throws Exception {
Directory dir = FSDirectory.getDirectory(System.getProperty("java.io.tmpdir") + File.separator + "test");
IndexWriter writer = new IndexWriter (dir, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
writer.setMergeFactor(37);
writer.setUseCompoundFile(false);
for(int i = 0; i < 5000000; i++) {
Document doc = new Document();
doc.add (new Field ("field", "String" + i, Field.Store.NO, Field.Index.NOT_ANALYZED));
writer.addDocument(doc);
}
writer.close();

IndexReader reader = IndexReader.open(dir);
long start = System.currentTimeMillis();
FieldCache.DEFAULT.getStrings(reader, "field");
long end = System.currentTimeMillis();
System.out.println("load time:" + (end - start)/1000.0f + "s");
}
}

Tuesday, 3 November 2009

List ports used by java process

Below is the command to list all the ports opened by a java process

sudo netstat -tulpn |grep java