Showing posts from July, 2009

Oracle query null processing and indexes


Sort tab delimited file by column 7 (numeric), 2 (alpha-numeric), 3 (numeric)

> sort -t " " -k 7,7n -k 2,2 -k 3,3n someFile > someFile.sorted

Oracle locks and blocking

Vertical JLabel


Ctrl+v, Ctrl+i to enter a tab

To grep lines from log4j error log with date and subsequent caused by:
egrep "2009.*xception|Caused by|2009.*ERROR" xxx_errorlog > ~/xxx_errorlog.exceptions

To gzip logs once daily:
while true
do ls | egrep "LockMonitor.*.log.20..-..-.." | egrep -v gz | xargs gzip
sleep 86400

To grep threads from JVM
kill -3 <jbossPid> - dumps to jboss log
jstack > <filename>

grep "tid=" thread.dump > allThreads
grep -B 1 BLOCKED thread.dump > blocked
grep -B 1 RUNNABLE thread.dump > runnable
grep -B 1 WAITING thread.dump > waiting
egrep "tid|locked" thread.dump > locks

-B 1 returns previous line
-n will prepend line numbers
Do multiple greps appending with >>, then sort


Aggregation/composition symbol goes on the 1 side of the 1..* relationship.
In Enterprise Architect (EA) draw aggregation/composition from the 1..* side towards the 1 side - seems backwards to me.
{Ordered} goes on the opposite end of aggregation/composition symbol, see UML 2 Toolkit.

Graph library and auto-routing

Processing Console input

Java Initializers

Besides static initializers, instance initializer blocks are also supported.

One use might be in an anonymous class to set daemon thread status and start the thread.

Debugging High CPU usage on J2EE app - JTOP

To debug high CPU usage on Java app, run JTOP with:

java -jar %JDK_HOME%\demo\management\JTop\JTop.jar <hostaddr>:<port>

The JVM must be started with the following options set:


Find the outlier threads

Do one of the following to get the Java PID:

ps -ef | grep java

Execute one of the following to get a thread stack dump:
kill -3 <pid>
jstack <pid> > %lt;someFile>
jconsole - connect to VM, click on Threads tab, select thread
jvisualvm - connect to VM, click thread dump button

Analyze the thread stack to see where the code is executing causing high CPU

User complaints of slow J2EE pages - log4j SMTPAppender

Performed a thread stack dump and during slow user performance and saw many threads waiting on log4j appender locks. It turned out that these were due to two separate causes: SMTPAppender backups due to a congested/slow smtp server and VMWare VMFS congestion.

Analysis revealed that the default behavior for log4j logging is synchronous. This is ensures the best chance that if the VM dies logging is likely to have been written and not lost because it was queued up in buffers.

FileAppender and ConsoleAppender extend from WriterAppender which can be set immediateFlush(false) to append asynchronously. It is reported that this might yield as much as a 20% increase in performance, however you risk losing important forensic logging if a crash occurs.

There is an AsyncAppender that can be plumbed in. It creates a queue and another thread that will asynchronously log to other appenders. This is useful for appenders like the SMTPAppender that does not extend from WriterAppender and does not have an…