Thursday, December 30, 2010

CPU Utilization

Every way possible to dice CPU utiliztion on *nix.

http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html

I learned that sar is great! ( but sars is bad )

Monday, December 20, 2010

How do I do that Java 101 task again?...

I find that every new Java project I'm on, I run into a situation where I want to translate an InputStream to a String or vice versa. This is frequently in a unit test where I've read an input file or expected output file in using getClass().getResourceAsStream() and need to convert to Strings for use in my test.

It's a simple boiler plate task, yet darned if I can remember the most an effecient way to do it every time. I always re-google and always tend to refer to this one to jog my memory..

Thought I'd link out to it this time.

Wednesday, December 8, 2010

POM Search Site

I know this is obvious, but adding it I can reference in the future...

Get dependency tags for dependencies.
http://mvnrepository.com/

Friday, December 3, 2010

Hibernate shows SQL to log4j too

Log hibernate queries and more without using the show_sql = true setting in your hibernate config. This way you can see them in your log4j configured log files, not just in your STDOUT log.

# Hibernate logging
# Log everything (a lot of information, but very useful for troubleshooting)

log4j.logger.org.hibernate=FATAL
# Log all SQL DML statements as they are executed
log4j.logger.org.hibernate.SQL=DEBUG
# Log all JDBC parameters
log4j.logger.org.hibernate.type=INHERITED
# Log all SQL DDL statements as they are executed
log4j.logger.org.hibernate.tool.hbm2ddl=INHERITED
# Log the state of all entities (max 20 entities) associated with the session at flush time
log4j.logger.org.hibernate.pretty=INHERITED
# Log all second-level cache activity
log4j.logger.org.hibernate.cache=INHERITED
# Log all OSCache activity - used by Hibernate
log4j.logger.com.opensymphony.oscache=INHERITED
# Log transaction related activity
log4j.logger.org.hibernate.transaction=INHERITED
# Log all JDBC resource acquisition
log4j.logger.org.hibernate.jdbc=INHERITED
# Log all JAAS authorization requests
log4j.logger.org.hibernate.secure=INHERITED

Monday, April 19, 2010

Oracle Query Analysis

This is the best thing since sliced bread...

set autotrace on exp;
Run Some SQL!

It shows me the bottle necks in my SQL statement, where indexes might help, and give me a pretty accurate estimate on the time the statement will take to run. This is all done within a second for so.

Example output..



Elapsed: 00:00:00.01

Execution Plan
----------------------------------------------------------
Plan hash value: 1080733679

--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 21 | 2 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 21 | | |
| 2 | NESTED LOOPS | | 1 | 21 | 2 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| NG_FILES | 1 | 16 | 2 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN| PK_NG_FILES_ID | 1 | 5 | 0 (0)| 00:00:01 |
--------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

3 - filter("DATE_FILE_RECEIVED">=TIMESTAMP' 2009-12-16 00:00:00' AND
"DATE_FILE_RECEIVED"<=TIMESTAMP' 2009-12-17 00:00:00')
4 - access("NG_FILE_ID"="NG_FILE_ID")

Thursday, April 1, 2010

Linux Commands

A few commands I find myself using from time to time and don't want to forget.

To examine a large log with logj4, STDIN, STDOUT, and STDERR printouts all going to the same log file, I find it easier to comb when I can narrow down to specific type(s) of log4j level statements and show them without line breaks.

grep "^\[TRACE\|DEBUG\|INFO\|ERROR\|WARN\|FATAL\]" my.log | less -S

Also, to recursively add files in your svn working copy...

svn status | grep "^\?" | awk '{print $2}' | xargs svn add

Friday, March 26, 2010

SVN Merging : Blocking Revisions

Blocking revisions from auto merging in svn, taken from the manual.





$ cd my-calc-branch

$ svn propget svn:mergeinfo .
/trunk:1680-3305

# Let's make the metadata list r3328 as already merged.
$ svn merge -c 3328 --record-only http://svn.example.com/repos/calc/trunk

$ svn status
M .

$ svn propget svn:mergeinfo .
/trunk:1680-3305,3328

$ svn commit -m "Block r3328 from being merged to the branch."

Friday, February 19, 2010

Debug tests in maven

    If you need to configure a different port, you may pass a more detailed value. For example, the value below will use port 5334.

    mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5334" test

    Note: if you are not worried about making a connection to the debugger so that you are connected before the program reaches your breakpoint, you can change suspend=y to suspend=n, and the tests will not wait for a debugger connection