Tuesday, May 6, 2014

Difference between Git and GitHub



Git is a revision control system, a tool to manage your source code history. GitHub is a hosting service for Git repositories. So they are not the same thing: Git the tool, GitHub the service for projects that uses Git. To get your code to GitHub: have look here : https://help.github.com/articles/create-a-repo


In the SVN analogy, Git replaces SVN, while GitHub replaces SourceForge

If this project of yours is new, then you can still commit to your local Git, then you can push to GitHub later on. You will need to add your GitHub repo as a 'remote repository' in your Git setup.

They seem to have something for Eclipse users : http://eclipse.github.com/

Otherwise, if you are new to Git : http://git-scm.com/book

Friday, November 26, 2010

Wsadmin updated

Example: Identifying running objects

In the WebSphere Application Server, MBeans represent running objects. You can interrogate the MBean server to see the objects it contains. Use the AdminControl object to interact with running MBeans.

* Use the queryNames command to see running MBean objects. For example:

$AdminControl queryNames *

This command returns a list of all MBean types. Depending on the server to which your scripting client attaches, this list can contain MBeans that run on different servers:

* If the client attaches to a stand-alone WebSphere Application Server, the list contains MBeans that run on that server.
* If the client attaches to a node agent, the list contains MBeans that run in the node agent and MBeans that run on all application servers on that node.
* If the client attaches to a deployment manager, the list contains MBeans that run in the deployment manager, all of the node agents communicating with that deployment manager, and all application servers on the nodes served by those node agents.

· The list that the queryNames command returns is a string representation of JMX ObjectName objects. For example:

WebSphere:cell=MyCell,name=TraceService,mbeanIdentifier=TraceService,
type=TraceService,node=MyNode,process=server1

This example represents a TraceServer object that runs in server1 on MyNode.

* The single queryNames argument represents the ObjectName object for which you are searching. The asterisk ("*") in the example means return all objects, but it is possible to be more specific. As shown in the example, ObjectName has two parts: a domain, and a list of key properties. For MBeans created by the WebSphere Application Server, the domain is WebSphere. If you do not specify a domain when you invoke queryNames, the scripting client assumes the domain is WebSphere. This means that the first example query above is equivalent to:

$AdminControl queryNames WebSphere:*

* WebSphere Application Server includes the following key properties for the ObjectName object:
* name
* type
* cell
* node
* process mbeanIdentifier

These key properties are common. There are other key properties that exist. You can use any of these key properties to narrow the scope of the queryNames command. For example:

$AdminControl queryNames WebSphere:type=Server,node=myNode,*

This example returns a list of all MBeans that represent server objects running the node myNode. The, * at the end of the ObjectName object is a JMX wildcard designation. For example, if you enter the following:

$AdminControl queryNames WebSphere:type=Server,node=myNode

you get an empty list back because the argument to queryNames is not a wildcard. There is no Server MBean running that has exactly these key properties and no others.

* If you want to see all the MBeans representing applications running on a particular node, invoke the following example:

$AdminControl queryNames WebSphere:type=Application,node=myNode,*

Example: Turning traces on and off in a server process with the wsadmin tool

The following example turns on tracing in a server process:

* Identify the object name for the TraceService MBean running in the process:

$AdminControl completeObjectName type=Server,name=server1,*

* Obtain the name of the object and set it to a variable:

set ts [$AdminControl completeObjectName type=TraceService,process=server1,*]

* Turn on traces for the server:

$AdminControl setAttribute $ts traceSpecification com.ibm.*=all=enabled

Example: Dumping threads in a server process

Use the AdminControl object to dump the Java threads of a running server.

* For example, in Jacl:

set jvm [$AdminControl completeObjectName type=JVM,process=server1,*]

$AdminControl invoke $jvm dumpThreads

This example produces a Java core file. You can use this file for problem determination.

Example: Starting a server using wsadmin

The following example starts an application server with the node specified.

* The following command starts server1 in mynode node:

$AdminControl startServer server1 mynode

Example output:

WASX7319I: The serverStartupSyncEnabled attribute is set to false. A startwill be attempted for server "server1" but the configuration information fornode "mynode" may not be current.WASX7262I: Start completed for server "server1" on node "mynode"

* The startServer command has several command syntax options. If you have Network Deployment installation, you have to use one of following:

$AdminControl startServer serverName nodeName

$AdminControl startServer serverName nodeName waitTime

* If you have an application server base installation, you can use the following syntax in addition to the previous syntax:

$AdminControl startServer serverName
$AdminControl startServer serverName waitTime


Example: Stopping a server using wsadmin

The following example stops an application server with the node specified.

* The following command stops server1 in node mynode.

$AdminControl stopServer server1 mynode

Example output:
WASX7337I: Invoked stop for server "server1" Waiting for stop completion.
WASX7264I: Stop completed for server "server1" on node "mynode"

* The stop command has serveral command syntaxes.

If you have Network Deployment installation, use the one of following command syntax:

$AdminControl stopServer serverName nodeName

$AdminControl stopServer serverName nodeName immediate
If you have application server base installation, you can use the following syntax, in addition to the previous syntax:

$AdminControl stopServer serverName

$AdminControl stopServer serverName immediate

Example: Querying the server state using the wsadmin tool

The following example queries the server state.

* Identify the server and assign it to the server variable.

set server [$AdminControl completeObjectName cell=mycell,node=mynode,name=server1,type=Server,*]

This command returns the server MBean that matches the partial object name string.


Example output:
WebSphere:cell=mycell,name=server1,mbeanIdentifier=server.xml#Server_1,
type=Server,node=mynode,process=server1,processType=ManagedProcess

* Query for the state attribute.

$AdminControl getAttribute $server state

The getAttribute command returns the value of a single attribute.

Example output:
STARTED

Example: Starting a listener port using wsadmin

The following example starts a listener port on an application server.

* Identify the listener port MBeans for the application server and assign it to the lPorts variable.

set lPorts [$AdminControl queryNames type=ListenerPort,cell=mycell,node=mynode,process=server1,*]


This command returns a list of listener port MBeans.

Example output: WebSphere:cell=mycell,name=ListenerPort,mbeanIdentifier=server.xml#ListenerPort_1,

type=ListenerPort,node=mynode,process=server1

WebSphere:cell=mycell,name=listenerPort,mbeanIdentifier=ListenerPort,type=server.xml#ListenerPort_2,

node=mynode,process=server1

* Start the listener port if it is not started with the following example:·

foreach lPort $lPorts

{ set state [$AdminControl getAttribute $lport started]

if {$state == "false"} {

$AdminControl invoke $lPort start

}

}
This piece of Jacl code loops through the listener port MBeans. For each listener port MBean, get the attribute value for the started attribute. If the attribute value is set to false, then start the listener port by invoking the start operation on the MBean.

Example: Testing data source connection using wsadmin

The following example tests a dataSource, to ensure a connection to the database.

* Identify the DataSourceCfgHelper MBean and assign it to the dshelper variable.

set dshelper [$AdminControl queryNames type=DataSourceCfgHelper,process=server1*]

Example output:

WebSphere:cell=mycell,name=DataSourceCfgHelper,mbeanIdentifier=DataSourceCfgHelper,

type=DataSourceCfgHelper,node=mynode,process=server1

* Test the connection.

$AdminControl invoke $dshelper testConnectionToDataSource "COM.ibm.db2.jdbc.DB2XADataSource dbuser1 dbpwd1 {{databaseName jtest1}} c:/sqllib/java12/db \"\" \"\""

This example command invokes the testConnectionToDataSource operation on the MBean, passing in the classname, userid, password, database name, JDBC driver class path, language, and country.

Example output:

DSRA8025I: Successfully connected to DataSource

Example: Starting an application using wsadmin

The following example starts an application:

* Identify the application manager MBean for the server where the application resides and assign it the appManager variable.

set appManager [$AdminControl queryNames cell=mycell,node=mynode,type=ApplicationManager,process=server1,*]

This command returns the application manager MBean.


Example output:

WebSphere:cell=mycell,name=ApplicationManager,mbeanIdentifier=ApplicationManager,

type=ApplicationManager,node=mynode,process=server1

* Start the application.

$AdminControl invoke $appManager startApplication myApplication

This command invokes the startApplication operation on the MBean, passing in the application name to start.

Example: Stopping running applications on a server using wsadmin

The following example stops all running applications on a server:

* Identify the application manager MBean for the server where the application resides, and assign it to the appManager variable.

set appManager [$AdminControl queryNames cell=mycell,node=mynode,type=ApplicationManager,process=server1,*]

This command returns the application manager MBean.

Example output: WebSphere:cell=mycell,name=ApplicationManager,mbeanIdentifier=ApplicationManager,

type=ApplicationManager,node=mynode,process=server1

* Query the running applications belonging to this server and assign the result to the apps variable.

set apps [$AdminControl queryNames cell=mycell,node=mynode,type=Application,process=server1,*]

This command returns a list of application MBeans.
Example output:

WebSphere:cell=mycell,name=adminconsole,mbeanIdentifier=deployment.xml#ApplicationDeployment_1,

type=Application,node=mynode,Server=server1,process=server1,J2EEName=adminconsole

WebSphere:cell=mycell,name=filetransfer,mbeanIdentifier=deployment.xml#ApplicationDeployment_1,

type=Application,node=mynode,Server=server1,process=server1,J2EEName=filetransfer

* Stop all the running applications.

foreach app $apps

{

set appName [$AdminControl getAttribute $app name]

$AdminControl invoke $appManager stopApplication $appName

}
This command stops all the running applications by invoking the stopApplication operation on the MBean, passing in the application name to stop.

Example: Querying application state using wsadmin

The following examples queries for the presence of Application MBean to find out whether the application is running.

$AdminControl completeObjectName type=Application,name=myApplication,*

If myApplication is running, then there should be an MBean created for it. Otherwise, the command returns nothing. If myApplication is running,
the following is the example output:

WebSphere:cell=mycell,name=myApplication,mbeanIdentifier=cells/mycell/applications/myApplication.ear/deployments/myApplication/deployment.xml#ApplicationDeployment_1,
type=Application,node=mynode,Server=dmgr,process=dmgr,J2EEName=myApplication

Example: Updating the Web server plug-in configuration files using wsadmin

This examples regenerates the web serer plugin configuration file.

* Identify the web server plugin configuraiton file generator MBean and assign it to the pluginGen variable.

EX:
set pluginGen [$AdminControl completeObjectName type=PluginCfgGenerator,*]

Example output:
WebSphere:cell=pongoNetwork,name=PluginCfgGenerator,
mbeanIdentifier=PluginCfgGenerator,type=PluginCfgGenerator,node=pongoManager,
process=dmgr

* Generate the updated plugin configuration file.

EX:

$AdminControl invoke $pluginGen generate "c:/WebSphere/DeploymentManager c:/WebSphere/DeploymentManager/config mycell null null plugin-cfg.xml"
This example command assumes a Windows system install. It invokes the generate operation on the MBean, passing in the install root directory, configuration root directory, cell name, node name, server name, and output file name. To pass in null as the value of an argument, enter null as given in the example. This is provided for operation that allows null as the value of its argument and processes null differently from an empty string. In this example, both node and server are set to null. The generate operation generates plugin configuration for all the nodes and servers resided in the cell. The output file plugin-cfg.xml is created in the config root directory.

You can modify this example command to generate plugin configuration for a particular node or server by specifying the node and server names.

Friday, November 19, 2010

AIX commands you should not leave home without

Commands
Kernel

How would I know if I am running a 32-bit kernel or 64-bit kernel?
To display if the kernel is 32-bit enabled or 64-bit enabled, type:
bootinfo -K

How do I know if I am running a uniprocessor kernel or a multiprocessor kernel?
/unix is a symbolic link to the booted kernel. To find out what kernel mode is running, enter ls -l /unix and see what file /unix it links to. The following are the three possible outputs from the ls -l /unix command and their corresponding kernels:
/unix -> /usr/lib/boot/unix_up # 32 bit uniprocessor kernel
/unix -> /usr/lib/boot/unix_mp # 32 bit multiprocessor kernel
/unix -> /usr/lib/boot/unix_64 # 64 bit multiprocessor kernel

Note:
AIX 5L Version 5.3 does not support a uniprocessor kernel.
How can I change from one kernel mode to another?
During the installation process, one of the kernels, appropriate for the AIX version and the hardware in operation, is enabled by default. Let us use the method from the previous question and assume the 32-bit kernel is enabled. Let us also assume that you want to boot it up in the 64-bit kernel mode. This can be done by executing the following commands in sequence:
ln -sf /usr/lib/boot/unix_64 /unix
ln -sf /usr/lib/boot/unix_64 /usr/lib/boot/unix

bosboot -ad /dev/hdiskxx
shutdown -r

The /dev/hdiskxx directory is where the boot logical volume /dev/hd5 is located. To find out what xx is in hdiskxx, run the following command:
lslv -m hd5


Note:
In AIX 5.2, the 32-bit kernel is installed by default. In AIX 5.3, the 64-bit kernel is installed on 64-bit hardware and the 32-bit kernel is installed on 32-bit hardware by default.
Hardware
How would I know if my machine is capable of running AIX 5L Version 5.3?
AIX 5L Version 5.3 runs on all currently supported CHRP (Common Hardware Reference Platform)-based POWER hardware.
How would I know if my machine is CHRP-based?
Run the prtconf command. If it's a CHRP machine, the string chrp appears on the Model Architecture line.
How would I know if my System p machine (hardware) is 32-bit or 64-bit?
To display if the hardware is 32-bit or 64-bit, type:
bootinfo -y

How much real memory does my machine have?
To display real memory in kilobytes (KB), type one of the following:
bootinfo -r

lsattr -El sys0 -a realmem

Can my machine run the 64-bit kernel?
64-bit hardware is required to run the 64-bit kernel.
What are the values of attributes for devices in my system?
To list the current values of the attributes for the tape device, rmt0, type:
lsattr -l rmt0 -E

To list the default values of the attributes for the tape device, rmt0, type:
lsattr -l rmt0 -D

To list the possible values of the login attribute for the TTY device, tty0, type:
lsattr -l tty0 -a login -R

To display system level attributes, type:
lsattr -E -l sys0

How many processors does my system have?
To display the number of processors on your system, type:
lscfg | grep proc

How many hard disks does my system have and which ones are in use?
To display the number of hard disks on your system, type:
lspv

How do I list information about a specific physical volume?
To find details about hdisk1, for example, run the following command:
lspv hdisk1


How do I get a detailed configuration of my system?
Type the following:
lscfg

The following options provide specific information:
-p Displays platform-specific device information. The flag is applicable to AIX 4.2.1 or later.
-v Displays the VPD (Vital Product Database) found in the customized VPD object class.
For example, to display details about the tape drive, rmt0, type:
lscfg -vl rmt0

You can obtain very similar information by running the prtconf command.
How do I find out the chip type, system name, node name, model number, and so forth?
The uname command provides details about your system.
uname -p Displays the chip type of the system. For example, PowerPC.
uname -r Displays the release number of the operating system.
uname -s Displays the system name. For example, AIX.
uname -n Displays the name of the node.
uname -a Displays the system name, nodename, version, machine ID.
uname -M Displays the system model name. For example, IBM, 9114-275.
uname -v Displays the operating system version.
uname -m Displays the machine ID number of the hardware running the system.
uname -u Displays the system ID number.
AIX
What version, release, and maintenance level of AIX is running on my system?
Type one of the following:
oslevel -r

lslpp -h bos.rte

How can I determine which fileset updates are missing from a particular AIX level?
To determine which fileset updates are missing from 5300-04, for example, run the following command:
oslevel -rl 5300-04

What SP (Service Pack) is installed on my system?
To see which SP is currently installed on the system, run the oslevel -s command. Sample output for an AIX 5L Version 5.3 system, with TL4, and SP2 installed would be:
oslevel –s
5300-04-02


Is a CSP (Concluding Service Pack) installed on my system?
To see if a CSP is currently installed on the system, run the oslevel -s command. Sample output for an AIX 5L Version 5.3 system, with TL3, and CSP installed would be:
oslevel –s
5300-03-CSP


How do I create a file system?
The following command will create, within volume group testvg, a jfs file system of 10MB with mounting point /fs1:
crfs -v jfs -g testvg -a size=10M -m /fs1


The following command will create, within volume group testvg, a jfs2 file system of 10MB with mounting point /fs2 and having read only permissions:
crfs -v jfs2 -g testvg -a size=10M -p ro -m /fs2


How do I change the size of a file system?
To increase the /usr file system size by 1000000 512-byte blocks, type:
chfs -a size=+1000000 /usr

Note:
In AIX 5.3, the size of a JFS2 file system can be shrunk as well.
How do I mount a CD?
Type the following:
mount -V cdrfs -o ro /dev/cd0 /cdrom

How do I mount a file system?
The following command will mount file system /dev/fslv02 on the /test directory:
mount /dev/fslv02 /test

How do I mount all default file systems (all standard file systems in the /etc/filesystems file marked by the mount=true attribute)?
The following command will mount all such file systems:
mount {-a|all}

How do I unmount a file system?

Type the following command to unmount /test file system:
umount /test

How do I display mounted file systems?
Type the following command to display information about all currently mounted file systems:
mount

How do I remove a file system?
Type the following command to remove the /test file system:
rmfs /test

How can I defragment a file system?
The defragfs command can be used to improve or report the status of contiguous space within a file system. For example, to defragment the file system /home, use the following command:
defragfs /home

Which fileset contains a particular binary?
To show bos.acct contains /usr/bin/vmstat, type:
lslpp -w /usr/bin/vmstat

Or to show bos.perf.tools contains /usr/bin/svmon, type:
which_fileset svmon

How do I display information about installed filesets on my system?
Type the following:
lslpp -l


How do I determine if all filesets of maintenance levels are installed on my system?
Type the following:
instfix -i | grep ML

How do I determine if a fix is installed on my system?
To determine if IY24043 is installed, type:
instfix -ik IY24043

How do I install an individual fix by APAR?

To install APAR IY73748 from /dev/cd0, for example, enter the command:
instfix -k IY73748 -d /dev/cd0


How do I verify if filesets have required prerequisites and are completely installed?

To show which filesets need to be installed or corrected, type:
lppchk -v

How do I get a dump of the header of the loader section and the symbol entries in symbolic representation?
Type the following:
dump -Htv

How do I determine the amount of paging space allocated and in use?
Type the following:
lsps -a

How do I increase a paging space?
You can use the chps -s command to dynamically increase the size of a paging space. For example, if you want to increase the size of hd6 with 3 logical partitions, you issue the following command:
chps -s 3 hd6


How do I reduce a paging space?
You can use the chps -d command to dynamically reduce the size of a paging space. For example, if you want to decrease the size of hd6 with four logical partitions, you issue the following command:
chps -d 4 hd6


How would I know if my system is capable of using Simultaneous Multi-threading (SMT)?
Your system is capable of SMT if it's a POWER5-based system running AIX 5L Version 5.3.
How would I know if SMT is enabled for my system?
If you run the smtctl command without any options, it tells you if it's enabled or not.
Is SMT supported for the 32-bit kernel?
Yes, SMT is supported for both 32-bit and 64-bit kernel.
How do I enable or disable SMT?
You can enable or disable SMT by running the smtctl command. The following is the syntax:
smtctl [ -m off | on [ -w boot | now]]

The following options are available:
-m off Sets SMT mode to disabled.
-m on Sets SMT mode to enabled.
-w boot Makes the SMT mode change effective on next and subsequent reboots if you run the bosboot command before the next system reboot.
-w now Makes the SMT mode change immediately but will not persist across reboot.
If neither the -w boot or the -w now options are specified, then the mode change is made immediately. It persists across subsequent reboots if you run the bosboot command before the next system reboot.
How do I get partition-specific information and statistics?
The lparstat command provides a report of partition information and utilization statistics. This command also provides a display of Hypervisor information.
Volume groups and logical volumes
How do I know if my volume group is normal, big, or scalable?
Run the lsvg command on the volume group and look at the value for MAX PVs. The value is 32 for normal, 128 for big, and 1024 for scalable volume group.
How to create a volume group?
Use the following command, where spartition_size sets the number of megabytes (MB) in each physical partition where the partition_size is expressed in units of MB from 1 through 1024. (It's 1 through 131072 for AIX 5.3.) The partition_size variable must be equal to a power of 2 (for example: 1, 2, 4, 8). The default value for standard and big volume groups is the lowest value to remain within the limitation of 1016 physical partitions per physical volume. The default value for scalable volume groups is the lowest value to accommodate 2040 physical partitions per physical volume.
mkvg -y name_of_volume_group -s partition_size list_of_hard_disks

How can I change the characteristics of a volume group?
You use the following command to change the characteristics of a volume group:
chvg

How do I create a logical volume?
Type the following:
mklv -y name_of_logical_volume name_of_volume_group number_of_partition

How do I increase the size of a logical volume?
To increase the size of the logical volume represented by the lv05 directory by three logical partitions, for example, type:
extendlv lv05 3


How do I display all logical volumes that are part of a volume group (for example, rootvg)?
You can display all logical volumes that are part of rootvg by typing the following command:
lsvg -l rootvg

How do I list information about logical volumes?
Run the following command to display information about the logical volume lv1:
lslv lv1

How do I remove a logical volume?
You can remove the logical volume lv7 by running the following command:
rmlv lv7

The rmlv command removes only the logical volume, but does not remove other entities, such as file systems or paging spaces that were using the logical volume.
How do I mirror a logical volume?
1. mklvcopy LogicalVolumeName Numberofcopies
2. syncvg VolumeGroupName
How do I remove a copy of a logical volume?
You can use the rmlvcopy command to remove copies of logical partitions of a logical volume. To reduce the number of copies of each logical partition belonging to logical volume testlv, enter:
rmlvcopy testlv 2

Each logical partition in the logical volume now has at most two physical partitions.
Queries about volume groups
To show volume groups in the system, type:
lsvg

To show all the characteristics of rootvg, type:
lsvg rootvg

To show disks used by rootvg, type:
lsvg -p rootvg

How to add a disk to a volume group?
Type the following:
extendvg VolumeGroupName hdisk0 hdisk1 ... hdiskn

How do I find out what the maximum supported logical track group (LTG) size of my hard disk?
You can use the lquerypv command with the -M flag. The output gives the LTG size in KB. For instance, the LTG size for hdisk0 in the following example is 256 KB.
/usr/sbin/lquerypv -M hdisk0
256

You can also run the lspv command on the hard disk and look at the value for MAX REQUEST.
What does syncvg command do?
The syncvg command is used to synchronize stale physical partitions. It accepts names of logical volumes, physical volumes, or volume groups as parameters.
For example, to synchronize the physical partitions located on physical volumes hdisk6 and hdisk7, use:
syncvg -p hdisk4 hdisk5


To synchronize all physical partitions from volume group testvg, use:
syncvg -v testvg


How do I replace a disk?
1. extendvg VolumeGroupName hdisk_new
2. migratepv hdisk_bad hdisk_new
3. reducevg -d VolumeGroupName hdisk_bad
How can I clone (make a copy of ) the rootvg?
You can run the alt_disk_copy command to copy the current rootvg to an alternate disk. The following example shows how to clone the rootvg to hdisk1.
alt_disk_copy -d hdisk1

Network
How can I display or set values for network parameters?
The no command sets or displays current or next boot values for network tuning parameters.
How do I get the IP address of my machine?
Type one of the following:
ifconfig -a

host Fully_Qualified_Host_Name

For example, type host cyclop.austin.ibm.com.
How do I identify the network interfaces on my server?
Either of the following two commands will display the network interfaces:
lsdev -Cc if

ifconfig -a

To get information about one specific network interface, for example, tr0, run the command:
ifconfig tr0

How do I activate a network interface?
To activate the network interface tr0, run the command:
ifconfig tr0 up

How do I deactivate a network interface?
For example, to deactivate the network interface tr0, run the command:
ifconfig tr0 down

WebSphere Password Decoder

This utility can decode WebSphere encoded passwords.
If you have lost your password(s), use this utility to recover them.

url: http://www.sysman.nl/wasdecoder/

Tuesday, September 21, 2010

wsadmin commands

Handy wsadmin commands:

I feel jacl is much easier than jython :) . Hence here are the jacl commands


To list the installed applications:
/opt/websphere/profile1/bin/wsadmin.sh -conntype SOAP -port 8880 -username wsadmin -c '$AdminApp list'

To Uninstall the Application:
/opt/websphere/profile1/bin/wsadmin.sh -conntype SOAP -port 8880 -username wsadmin -c '$AdminApp uninstall application-xyz'

To backup the existing application:

/opt/websphere/profile1/bin/wsadmin.sh -conntype SOAP -port 8880 -username wsadmin -c '$AdminApp export utilities /tmp/utilities_backup.ear'


To Stop the application:

/opt/websphere/profile1/bin/wsadmin.sh -conntype SOAP -port 8880 -username wsadmin

wsadmin>set appManager [$AdminControl queryNames type=ApplicationManager,*]
WebSphere:name=ApplicationManager,process=xyz,platform=dynamicproxy,node=xyz,version=6.1.0.0,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=xyz,spec=1.0

wsadmin>$AdminApp list
x1
x2
wsadmin>$AdminControl invoke $appManager stopApplication x1


To Start the application:

/opt/websphere/profile1/bin/wsadmin.sh -conntype SOAP -port 8880 -username wsadmin

wsadmin>set appManager [$AdminControl queryNames type=ApplicationManager,*]
WebSphere:name=ApplicationManager,process=xyz,platform=dynamicproxy,node=xyz,version=6.1.0.0,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=xyz,spec=1.0

wsadmin>$AdminApp list
x1
x2
wsadmin>$AdminControl invoke $appManager startApplication x1


To Restart all the application:

Run this command to stop all of the running applications:

foreach app $apps {set appName [$AdminControl getAttribute $app name];
$AdminControl invoke $appManager stopApplication $appName}

Run this command to start all of the running applications:

foreach app $apps {set appName [$AdminControl getAttribute $app name];
$AdminControl invoke $appManager startApplication $appName}

Tuesday, September 14, 2010

JRockit - Understanding Threads and Locks

Understanding Threads and Locks

A running application is usually made up of one process with its own memory space. A computer is generally running several processes at the same time. For example, a word processor application process might be running alongside a media player application process. Furthermore, a process consists of many concurrently running threads. When you run a Java application, a new JVM process is started.

Each Java process has at least one application thread. Besides the threads of the running Java application, there are also Oracle JRockit JVM internal threads that take care of garbage collection or code generation.

This section contains basic information about threads and locks in the JRockit JVM. The following subjects are discussed:

* Understanding Threads
* Understanding Locks

For information about how to make so-called thread dumps, printouts of the stacks of all the threads in an application, see Using Thread Dumps. Thread dumps can be used to diagnose problems and optimize application and JVM performance.


Understanding Threads

A java application consists of one or more threads that run Java code. The entire JVM process consists of the Java threads and some JVM internal threads, for example one or more garbage collection threads, a code optimizer thread and one or more finalizer threads.

From the operating system’s point of view the Java threads are just like any application threads. Scheduling of the threads is handled by the operating system, as well as thread priorities.

Within Java, the Java threads are represented by thread objects. Each thread also has a stack, used for storing runtime data. The thread stack has a specific size. If a thread tries to store more items on the stack than the stack size allows, the thread will throw a stack overflow error.
Default Stack Size for Java Threads

This section lists the default stack sizes. You can change the thread stack size with the -Xss command line option, for example:

java -Xss:512k MyApplication

The default stack sizes differ depending upon whether you are using IA32 and X64, as shown

OS Default Stack Size
Windows IA32 64 kB
Windows IA64 320 KB
Windows x64 128 kB
Linux IA32 128 kB
Linux IA64 1024 KB
Linux x64 256 kB
Solaris/SPARC 512 KB

Default Stack Size for JVM Internal Threads

A special “system” stack size is used for JVM internal threads; for example, the garbage collection and code generation threads. The default system stack size is 256 KB on all platforms.
Note: The -Xss command line option sets the stack size of both application threads and JVM internal threads.


Understanding Locks

When threads in a process share and update the same data, their activities must be synchronized to avoid errors. In Java, this is done with the synchronized keyword, or with wait and notify. Synchronization is achieved by the use of locks, each of which is associated with an object by the JVM. For a thread to work on an object, it must have control over the lock associated with it, it must “hold” the lock. Only one thread can hold a lock at a time. If a thread tries to take a lock that is already held by another thread, then it must wait until the lock is released. When this happens, there is so called “contention” for the lock.

There are four different kinds of locks:

* Fat locks: A fat lock is a lock with a history of contention (several threads trying to take the lock simultaneously), or a lock that has been waited on (for notification).
* Thin locks: A thin lock is a lock that does not have any contention.
* Recursive locks: A recursive lock is a lock that has been taken by a thread several times without having been released.
* Lazy locks: A lazy lock is a lock that is not released when a critical section is exited. Once a lazy lock is acquired by a thread, other threads that try to acquire the lock have to ensure that the lock is, or can be, released. Lazy locks are used by default in Oracle JRockit JVM 27.6. In older releases, lazy locks are only used if you have started the JVM with the -XXlazyUnlocking option.

A thin lock can be inflated to a fat lock and a fat lock can be deflated to a thin lock. The JRockit JVM uses a complex set of heuristics to determine when to inflate a thin lock to a fat lock and when to deflate a fat lock to a thin lock.
Spinning and Sleeping

Spinning occurs when a thread that wants a specific lock continuously checks that lock to see if it is still taken, instead of yielding CPU-time to another thread.

Alternatively, a thread that tries to take a lock that is already held waits for notification from the lock and goes into a sleeping state. The thread will then wait passively for the lock to be released.
Lock Chains

Several threads can be tied up in what is called lock chains. Although they appear somewhat complex, lock chains are fairly straightforward. They can be defined as follows:

* Threads A and B form a lock chain if thread A holds a lock that thread B is trying to take. If A is not trying to take a lock, then the lock chain is “open.”
* If A->B is a lock chain, and B->C is a lock chain, then A->B->C is a more complete lock chain.
* If there is no additional thread waiting for a lock held by C, then A->B->C is a complete and open lock chain.

Lock Chain Types

The JRockit JVM analyzes the threads and forms complete lock chains. There are three possible kinds of lock chains: Open, Deadlocked and Blocked lock chains.
Open Chains

Open lock chains represent a straight dependency, thread A is waiting for B which is waiting for C, and so on. If you have long open lock chains, your application might be wasting time waiting for locks. You may then want to reconsider how locks are used for synchronization in your application.
Deadlock Chains

A deadlocked, or circular, lock chain consists of a chain of threads, in which the first thread in the chain is waiting for the last thread in the chain. In the simplest case, thread A is waiting for thread B, while thread B is waiting for thread A. Note that a deadlocked chain has no head. In thread dumps, the Oracle JRockit JVM selects an arbitrary thread to display as the first thread in the chain.

Deadlocks can never be resolved, and the application will be stuck waiting indefinitely.
Blocked Chains

A blocked lock chain is made up of a lock chain whose head thread is also part of another lock chain, which can be either open or deadlocked. For example, if thread A is waiting for thread B, thread B is waiting for thread A, and thread C is waiting for thread A, then thread A and B form a deadlocked lock chain, while thread C and thread A form a blocked lock chain.

Nice Doc from Oracle

Thursday, September 9, 2010

Plumb the IP Address (ifconfig)

'ifconfig -a' that will show you all your ports and there name, netmask and everything else you could need to knwo about the card/port.

output :
lo0: flags=1000849 mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
hme0: flags=1000843 mtu 1500 index 2
inet 163.37.178.200 netmask ffffffe0 broadcast 163.37.178.223
ether 8:0:20:aa:45:f3

[ If executed as normal user, except the "ether" information
U will get the rest as stated above]

Interpretation from above output :
(a) lo0 & hme0 are the interface names
lo0 is for internal network, hme0 is for external network
(b) numbers given after "inet" are the IP Addresses
for the corresponding Interface
(c) address specified after "ether" is the MAC/Ethernet
address for the Interface Card (only for external cards)
(d) similarly netmask & broadcast addresses are specified




So run a 'ifocnfig -a' the first result will always be 'le0' or 'lo0' forget about that one. Never worry about that. Say you got a quad fast ether net card. You'll then have 4 more results after that. Say hme0 hme1 hme2 hme3, there's your 4 ports you can use (hmex is a example could be qfex or whatever).

Say you want to change hme2 from 192.168.0.1 with netmask of 255.255.0.0 to 192.165.0.1 with a netmask of 255.255.255.0 then you would type the follow command.

ifconfig hme2 plumb up 192.165.0.1 netmask 255.255.255.0

That will change the port. I perfer to unplumb the port first to make sure the above command will work.

Ok so a full set of commands I would type to make the above changes would be.

ifconfig hme2 unplumb (this will bring down port hme2 so it's not used any more)
ifconfig -a (just to make sure the port is no longer used)
ifconfig hme2 plumb up 192.165.0.1 netmask 255.255.255.0 (this will bring port hme2 up with the IP address of 192.165.0.1 and a netmask of 255.255.255.0)
ifconfig -a (just to confirm the changes)