Tuesday, December 21, 2010

testPool() methode -- Test Data Source from WLST command line

It was posted in oracle forum about how to test data source from wlst command line.
The script is fine and bit clear. The only concern is the output of testpool() method. It will print None unless we fetch the query and print the result. If we use default JDBC package and query “SELECT count( * ) FROM `systables`” to fetch data from default SYSTABLE the same result will be printed, unless we use fetchall() method.
Please try the below script and compare.

#!/bin/python
'''
Python Version - 2.*
@author : Jaydeb Chakraborty

?? Use WLST to test Data Source via python script

'''
from weblogic.security.internal import *
from weblogic.security.internal.encryption import *
from com.ziclix.python.sql import zxJDBC
from java.io import FileInputStream
from xml.dom import minidom
# Please put the correct path of DataSource Config xml.
doc = minidom.parse('d:/bea/Weblogic1033/user_projects/domains/weblogic1033_domain/config/jdbc/JDBC_Data_Source-0-3407-jdbc.xml')
s = doc.childNodes
t = s[0]
JDBC_DS_NAME = t.childNodes[1].firstChild.data
JDBC_URL = t.childNodes[3].childNodes[1].firstChild.data
JDBC_DRIVER = t.childNodes[3].childNodes[3].firstChild.data
JDBC_USER_NAME = t.childNodes[3].childNodes[5].childNodes[1].childNodes[3].firstChild.data
ENCRP_PASSWORD = t.childNodes[3].childNodes[7].firstChild.data

#Connect AdminServer where connection pool has been targeted
#We can keep these parameters in properties file to avoide hard coding
connect('weblogic','weblogic123','t3://localhost:7001')

#Get password of connectionpool 
encryptionService = SerializedSystemIni.getEncryptionService(".")
clearOrEncryptService = ClearOrEncryptedService(encryptionService)
pwd = ENCRP_PASSWORD
# Remove unnecessary escape characters
preppwd = pwd.replace("\\", "")
# Decrypt the password
psd=clearOrEncryptService.decrypt(preppwd)

#Connect with Database
con = zxJDBC.connect(JDBC_URL, JDBC_USER_NAME, psd, JDBC_DRIVER)
cursor = con.cursor()
result1=cursor.execute("SELECT count( * ) FROM `systables` WHERE 1")
result=cursor.fetchall()
#print number of row exist
print(result) # Print the output of "result1", the exact result you will received as you get exicuting testPool()
if result == None:
print("Check Table")
else:
print("The above number of row has been fetched")

Save this file by any name with extention .py and exicute from wlst.

Saturday, October 16, 2010

High CPU utilization of JAVA process...what is going on?

On top of one kernel space thread LWP is running and user space threads are running on top of LWP.
It may be 1:1 or one: many. I just tried out finding thread ID (LWPID) of java process. The CPU utilization of java PID was too high. Usually I use following command
ps -Leo pid,ruser,vsz,rss,state,priority,nice,time,%cpu,comm,lwp,psr,nlwp
pid = Process ID
ruser = Real user ID
vsz = virtual memory size of the process in KiB (1024-byte units).
rss = resident set size, the non-swapped physical memory that a task has used (in kiloBytes).
state = Process state
priority = kernel scheduling priority.
nice = Nice value.
time = cumulative CPU time,
%cpu = cpu utilization of the process in "##.#" format. Currently, it is the CPU time used divided by the time the process has been running (cputime/realtime ratio), expressed as a percentage. It will not add up to 100% unless you are lucky. (alias pcpu).
comm = command name (only the executable name). Modifications to the command name will not be shown. A process marked is partly dead, waiting to be fully destroyed by its parent. The output in this column may contain spaces. (alias ucmd, ucomm). See also the args format keyword, the -f option, and the c option. When specified last, this column will extend to the edge of the display. If ps can not determine display width, as when output is redirected (piped) into a file or another command, the output width is undefined. (it may be 80, unlimited, determined by the TERM variable, and so on) The COLUMNS environment variable or --cols option may be used to exactly determine the width in this case. The w or -w option may be also be used to adjust width.
lwp and nlwp = lwp (light weight process, or thread) ID of the lwp being reported and number of lwp.
psr = processor that process is currently assigned to.
I have just kept it here for my own convenience. use man to get help of command.
As it was Weblogic server and java processes were owned by weblogic user, I used “| grep weblogic” and then filter with “ grep -v ' 0.0 '” to minimize output.
The above command gives us thread ID and CPU utilization of each thread. Many ways we can accomplish this task.
Use “ps –eo user,pid,%cpu,cmd | grep java” and then “ps u –Lp ” or “top –H –p .
Now we have to search thread id in process thread dump. Before that create thread dump using “kill -3 ” or JVM specific command (JDK/Jrokit).
#jstack > threadDump.txt
OR
#jrcmd print_threads > threadDump.txt
Search lwp ID as tid in thread dump that has taken from Jrokit JVM. Use hex value of lwp ID if java process uses jdk.

Friday, October 15, 2010

Process, child process and thread in Linux

Threading in Linux is (or was!!!) bit confusing.

Before coming to the main point, we need to have clear idea about process and thread. A process is an instance of a computer program that is being sequentially executed. A single process may contain several executable programs (threads) that work together concurrently to carry out the main function of the process. Threads share global data and address space with other threads running in the same process. On the other hand processes do not share address space. Child process has a own copy of data space (VM) of the parent process. Threads can directly communicate with other threads of its process; processes must use interprocess communication to communicate with child processes. Prior to Linux kernel 2.6, Linux OS was not good for JAVA multithreaded applications.
Introduction of NPTL offers performance improvement in the area of thread creation and destruction. With the new lightweight implementation, creating threads is fast and scalable.
Administrator use LWP id finding thread activity in java application. However, there are specific command in Solaris to get PID and associated lightweight process id.

Thursday, September 30, 2010

Use VMware Server to explore Oracle Weblogic

For My system:
--------------
Created 3 VMware Instances on Windows platform
configured network adapter with Nat enabled
installed RHEL 5
installed weblogic cluster on first node and 2nd node
updated host table to communicate each other, pinged each server to test communication
exicuted wlst.sh
startNodeManager()
startserver('AdminServer')
nmConnect('weblogic','weblogic123','MyHost1','5556','vwr','/home/weblogic/Oracle/Middleware/user_projects/domains/vwr','ssl')
start('','Server')
login to anather node and started node manager
from Admin server connected node manager of 2nd server and started managed server 2

Issue:
Weblogic can not started :-> created boot.properties with new
username=weblogic
password=weblogic123
and started weblogic.....did not sarted....LDAP file issue
found one LDAP file's woner was changed to root user
changed that file to weblogic owner
started server

on 3rd server I installed apache 2.2
copied mod_wl_22.so to module folder
in httpd.conf file added following line

LoadModule weblogic_module modules/mod_wl_22.so

edited httpd-vhost.conf file

ServerName MyHost3:80

WeblogicCluster MyHost1:7003,MyHost2:7003
MatchExpression *.jsp PathPrepend /NewApp
MatchExpression *.html PathPrepend /NewApp

SetHandler weblogic-handler

started Apache with following command
./httpd -f conf/httpd.conf -k start

accessed application /NewApp

it was not connected....Issue Network Bridge was not established

configured Network adapter to NAT and enabled DHCP for all 3 host
configured VMware Network adapter with static IP from windows platform andd enabled Automatic bridge from program->vmware->vmware server-> Manage Virtual Network

Everything started working