Monday, September 30, 2013

Log rotation for last week files

find . -type f -name *.log -mtime +1 -mtime -8 -exec rm -f {} \;

type f =its for file
-mtime +1 = modified time greater than 1 day.
-mtime -8=modified time less than 8 days.
-exec = executes a following commands here its removal of *.log files

Wednesday, September 18, 2013

J2CA0045E: Connection not available while invoking method createOrWaitForConnection for resource jdbc/xx solution

The reason this error is coming is lack of connection pool to create connections.

Solution:

Increase the maximum connection pool size .If you are increasing the connection pool size at cluster scope remember use the below logic to set.

maxpoolsize * number of cluster members should not be greater than connection setting in database.
If above solution does not resolve then enable database trace to analyse further the PoolManager.
 

Tuesday, September 17, 2013

JVM argument to solve frequent garbage collection due to System.gc() or Runtime.gc()

System.gc() or Runtime.gc() is called in java codes to do explicit garbage collection.
Since JVM has the capability to do garbage collection on its own we should avoid the
use of sytem.gc() in our codes

If you have the below kind of lines in your gc  logs
<sys id="1" timestamp="Jul 15 12:56:26 2005" intervalms="0.000">
  <time exclusiveaccessms="0.018" />

  <tenured freebytes="821120" totalbytes="4194304" percent="19" >
    <soa freebytes="611712" totalbytes="3984896" percent="15" />
    <loa freebytes="209408" totalbytes="209408" percent="100" />
  </tenured>
  <gc type="global" id="1" totalid="1" intervalms="0.000">
    <classloadersunloaded count="0" timetakenms="0.012" />
    <refs_cleared soft="0" weak="4" phantom="0" />
    <finalization objectsqueued="6" />
    <timesms mark="3.065" sweep="0.138" compact="0.000" total="3.287" />
    <tenured freebytes="3579072" totalbytes="4194304" percent="85" >
      <soa freebytes="3369664" totalbytes="3984896" percent="84" />
      <loa freebytes="209408" totalbytes="209408" percent="100" />
    </tenured>
  </gc>
  <tenured freebytes="3579072" totalbytes="4194304" percent="85" >
    <soa freebytes="3369664" totalbytes="3984896" percent="84" />
    <loa freebytes="209408" totalbytes="209408" percent="100" />
  </tenured>

  <time totalms="3.315" />
</sys>
 
The tag <sys> meant that garbage collection is done due to System.gc() calls.
 
The intervalms is the time used to know how frequent the garbage collection 
happened for this kind.
0.00 ms represent that this is the first time gc happened due to system.gc call.

Please add the below JVM argument if you face frequent gc due to system.gc call

IBM JVM:-Xdisableexplicitgc
Sun JVM: -XX:+DisableExplicitGC