Sunday, March 23, 2014

how to debug a Maven project

use remote debugging

mvn exec:exec -Dexec.executable="java" -Dexec.args="-classpath %classpath -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044 com.mycompany.app.App"


Then in your eclipse, you can use remote debugging and attach the debugger to localhost:1044.

Tuesday, February 4, 2014

chkconfig replavement in Ubuntu

http://www.debuntu.org/how-to-managing-services-with-update-rc-d/

How-To: Managing Services With Update-Rc.D

Posted by chantra on July 5th, 2007
Linux services can be started, stopped and reloaded with the use of scripts stocked in /etc/init.d/.
However, during start up or when changing runlevel, those scripts are searched in /etc/rcX.d/ where X is the runlevel number.
This tutorial will explain how one can activate, deactivate or modify a service start up.
When installing a new service under debian, the default is to enable it. So for instance, if you just installed apache2 package, after you installed it, apache service will be started and so will it be upon the next reboots.
If you do not use apache all the time, you might want to disable this service from starting up upon boot up and simply start it manually when you actually need it by running this command:
# /etc/init.d/apache2 start
You could either disable this service on boot up by removing any symbolic links in /etc/rcX.d/SYYapache2 or by using update-rc.d.
The advantage of using update-rc.d is that it will take care of removing/adding any required links to /etc/init.d automatically.
Taking apache2 as an example, let's examine how /etc/rcX.d is looking like:
# ls -l /etc/rc?.d/*apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc0.d/K91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc1.d/K91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc2.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc3.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc4.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc5.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc6.d/K91apache2 -> ../init.d/apache2
As you can see, for runlevels 0, 1 and 6 there is a K at the beginning of the link, for runlevels 2, 3, 4 and 5, there is a S. Those two letters stands for Kill and Start.
On Debian and Ubuntu, runlevels 2, 3, 4 and 5 are multi-users runlevels.
Runlevel 0 is Halt.
Runlevel 1 is single user mode
Runlevel 6 is reboot

1. Removing A Service

If you want to totally disable apache2 service by hand, you would need to delete every single link in /etc/rcX.d/. Using update-rc.d it is as simple as:
# update-rc.d -f apache2 remove
The use of -f is to force the removal of the symlinks even if there is still /etc/init.d/apache2.
Note: This command will only disable the service until next time the service is upgraded. If you want to make sure the service won't be re-enabled upon upgrade, you should also type the following:
# update-rc.d apache2 stop 80 0 1 2 3 4 5 6 .

2. Adding A Service

2.1. Default Priorities

Now, if you want to re-add this service to be started on boot up, you can simply use:
# update-rc.d apache2 defaults
Adding system startup for /etc/init.d/apache2 ...
/etc/rc0.d/K20apache2 -> ../init.d/apache2
/etc/rc1.d/K20apache2 -> ../init.d/apache2
/etc/rc6.d/K20apache2 -> ../init.d/apache2
/etc/rc2.d/S20apache2 -> ../init.d/apache2
/etc/rc3.d/S20apache2 -> ../init.d/apache2
/etc/rc4.d/S20apache2 -> ../init.d/apache2
/etc/rc5.d/S20apache2 -> ../init.d/apache2

2.2. Custom Priorities

But as you can see, the default value is 20 which is pretty different than 91 ... a S20 link is started before a S91 and and K91 is kill before K20.
To force apache2 to be started with priorities 91 for both Start and Kill, we need to use the following command:
# update-rc.d apache2 defaults 91
Adding system startup for /etc/init.d/apache2 ...
/etc/rc0.d/K91apache2 -> ../init.d/apache2
/etc/rc1.d/K91apache2 -> ../init.d/apache2
/etc/rc6.d/K91apache2 -> ../init.d/apache2
/etc/rc2.d/S91apache2 -> ../init.d/apache2
/etc/rc3.d/S91apache2 -> ../init.d/apache2
/etc/rc4.d/S91apache2 -> ../init.d/apache2
/etc/rc5.d/S91apache2 -> ../init.d/apache2

2.3. Different Priorities For Start And Kill

Alternatively, if you want to set different priorities for Start than for Kill, let say Start with 20 and Kill with 80, you will need to run:
# update-rc.d apache2 defaults 20 80
Adding system startup for /etc/init.d/apache2 ...
/etc/rc0.d/K80apache2 -> ../init.d/apache2
/etc/rc1.d/K80apache2 -> ../init.d/apache2
/etc/rc6.d/K80apache2 -> ../init.d/apache2
/etc/rc2.d/S20apache2 -> ../init.d/apache2
/etc/rc3.d/S20apache2 -> ../init.d/apache2
/etc/rc4.d/S20apache2 -> ../init.d/apache2
/etc/rc5.d/S20apache2 -> ../init.d/apache2

3. Specifying Custom Runlevels

Finally, if you only want to Start and Kill on specific runlevels, like for instance starting apache with priority 20 on runlevels 2, 3, 4 and 5 and Kill with priority 80 on runlevels 0, 1 and 6:
# update-rc.d apache2 start 20 2 3 4 5 . stop 80 0 1 6 .
Adding system startup for /etc/init.d/apache2 ...
/etc/rc0.d/K80apache2 -> ../init.d/apache2
/etc/rc1.d/K80apache2 -> ../init.d/apache2
/etc/rc6.d/K80apache2 -> ../init.d/apache2
/etc/rc2.d/S20apache2 -> ../init.d/apache2
/etc/rc3.d/S20apache2 -> ../init.d/apache2
/etc/rc4.d/S20apache2 -> ../init.d/apache2
/etc/rc5.d/S20apache2 -> ../init.d/apache2
Or, to start with priority 20 for runlevel 2, 3 and 4 and priority 30 for runlevel 5 and kill with priority 80 for runlevel 0, 1 and 6:
# update-rc.d apache2 start 20 2 3 4 . start 30 5 . stop 80 0 1 6 .
Adding system startup for /etc/init.d/apache2 ...
/etc/rc0.d/K80apache2 -> ../init.d/apache2
/etc/rc1.d/K80apache2 -> ../init.d/apache2
/etc/rc6.d/K80apache2 -> ../init.d/apache2
/etc/rc2.d/S20apache2 -> ../init.d/apache2
/etc/rc3.d/S20apache2 -> ../init.d/apache2
/etc/rc4.d/S20apache2 -> ../init.d/apache2
/etc/rc5.d/S30apache2 -> ../init.d/apache2

Wednesday, January 29, 2014

Configuring Supermicro IPMI interface NIC using ipmitool

Newer Supermicro IPMI interfaces come configured by default in “failover” mode which means that the IPMI will bind to either the dedicated IPMI NIC port or share with one the the machine NIC ports.
This can cause IPMI to come up on wrong NIC and hence be inaccessible if the dedicated NIC doesn’t detect a link.
You can use ipmitool to change this behavour
First query the current setting:
ipmitool raw 0x30 0x70 0x0c 0
The result will be one of the following
0x00 = Dedicated
0x01 = Onboard / Shared
0x02 = Failover

Next to configure it you can use one of the following.
For older models:
ipmitool raw 0x30 0x70 0x0c 1 1 0
For X9 motherboards:
ipmitool raw 0x30 0x70 0x0c 1 0
References for this can be found here:
http://www.supermicro.com/support/faqs/faq.cfm?faq=9829
http://www.supermicro.com/support/faqs/faq.cfm?faq=14417

Thursday, January 23, 2014

eth* and em*

https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/appe-Consistent_Network_Device_Naming.html

Monday, January 13, 2014

Difference bewteen Pylab and pyplot

Matplotlib is the whole package; pylab is a module in matplotlib that gets installed alongsidematplotlib; and matplotlib.pyplot is a module in matplotlib.
Pyplot provides the state-machine interface to the underlying plotting library in matplotlib. This means that figures and axes are implicitly and automatically created to achieve the desired plot. For example, calling plot from pyplot will automatically create the necessary figure and axes to achieve the desired plot. Setting a title will then automatically set that title to the current axes object:
Pylab combines the pyplot functionality (for plotting) with the numpy functionality (for mathematics and for working with arrays) in a single namespace, making that namespace (or environment) even more MATLAB-like. For example, one can call the sin and cos functions just like you could in MATLAB, as well as having all the features of pyplot.
The pyplot interface is generally preferred for non-interactive plotting (i.e., scripting). Thepylab interface is convenient for interactive calculations and plotting, as it minimizes typing. Note that this is what you get if you use the ipython shell with the -pylab option, which imports everything from pylab and makes plotting fully interactive.

Monday, December 30, 2013

[CC]IPMI over LAN on Ubuntu 12.04

Doing this on two of these machines:
System Information
Manufacturer: Supermicro
Product Name: X9DBL-3F/X9DBL-iF
In the IPMI section of the BIOS, set the IP/gateway/netmask addresses. (This can also be done from inside the Linux Kernel with `ipmitool` after loading the modules.) I left all the other IPMI settings as default.
After a reboot, visit the IP of the IPMI LAN device in a browser from a separate computer. I found everything worked except console redirection (SOL – Serial Over Lan,) as indeed this has to be setup inside the Linux Kernel.
These are the steps I took to make console redirection work:
1. The first thing I did was install the tools and setup the modules.
  • Install the needed software:
sudo apt-get install ipmitool freeipmi-tools
  • Find the information about the BMC (press ‘q’ to ‘quit’ less when done):
sudo ipmi-locate | less
  • I found the information needed in the first few lines of the output as seen here:
Probing KCS device using DMIDECODE... done IPMI Version: 2.0
 IPMI locate driver: DMIDECODE
 IPMI interface: KCS
 BMC driver device:
 BMC I/O base address: 0xCA2
 Register spacing: 1
  • Add the appropriate modules into the Kernel, for the ‘ipmi_si’ one use the information found with ipmi-locate like this:
sudo modprobe ipmi_si type=kcs ports=0xCA2 regspacings=1
sudo modprobe ipmi_devintf
sudo modprobe ipmi_msghandler
sudo modprobe ipmi_poweroff
sudo modprobe ipmi_watchdog
  • Now if you “ls -ahl /dev/ipmi*” you should see an ipmi0
2. Next, we need to setup a tty and tell grub to pass options to the Kernel command to redirect it’s console to that tty.
  • Make a copy of an existing tty and edit it. I’m using vim, but use whatever editor you like:
sudo cp /etc/init/tty1.conf /etc/init/ttyS1.conf
sudo vi /etc/init/ttyS1.conf
  • Edit the file to reflect ‘ttyS1′ instead of just ‘tty1′. Also edit the last line to use a baud rate of 115200, and tell it the type  ’vt100′. Mine looks like this when done:
# ttyS1 - getty
#
# This service maintains a getty on ttyS1 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345]

stop on runlevel [!2345]

respawn
exec /sbin/getty -8 115200 ttyS1 vt100
  • We must pass “console=tty1 console=ttyS1,115200n8″ as options to the command in our boot loader that starts the kernel. Note: the order of options passed to the kernel is important, the last “console” entry defines the ‘default’ console for the kernel. For grub-pc open up /etc/default/grub with your favorite editor and with sudo permissions and change GRUB_CMDLINE_LINUX=”" line to look like this:
GRUB_CMDLINE_LINUX="console=tty1 console=ttyS1,115200n8"
  • Don’t forget to update grub after this: (I also changed ‘GRUB_HIDDEN_TIMEOUT_QUIET’ to false, and I uncommented the ‘GRUB_TERMINAL=console’ line.)
sudo update-grub
3. Now we’re pretty much ready to connect. The only problem I found was with the launch.jnlp file that the Supermicro webUI spits at you. I’ll show you the edits I made to make it work:
  • Again visit the IP pointed at your IPMI and login in to the webUI. Click the ‘Launch SOL’ button under the ‘Remote Control’ tab, choose to save the file instead of opening it in your browser’s web java application (‘IcedTea java web start’ in my case.)
  • Towards the beginning of the file, look for these lines:
<property name="jnlp.packEnabled" value="true"/>
<property name="jnlp.versionEnabled" value="true"/>
  • Copy those two lines and scroll down a little until you see the distribution you are running and paste them into the there. I did it for each distribution so I didn’t have to think about it. I ended up with entries looking like this:
<resources os="Linux" arch="x86_64">
  <property name="jnlp.packEnabled" value="true"/>
  <property name="jnlp.versionEnabled" value="true"/>
  <nativelib href="liblinux_x86_64.jar" download="eager" version="1.0.3"/>
</resources>
  • Lastly, scroll to the end of the file where you will see a list of “argument” xml tags. The one below the one that contains your IP probably contains a seemingly random string of letters, but it needs to be changed to the username you setup to login to the IPMI webUI, and the one below needs to be your password. Like this:
<argument>123.123.123.123</argument>
<argument>[username]</argument>
<argument>[password]</argument>
  • Save the file and run it and you should now be ready to sit in front of the machine remotely. Reboot the server to watch it boot up, offer you the opportunity to enter the BIOS, and then offer you a login prompt. :-)
P.S. Don’t forget to edit the factory installed users in your IPMI webUI and change their passwords and/or disable them!
EDIT 07/06/13:
Corrected the line:
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS1,115200n8"
to:
GRUB_CMDLINE_LINUX="console=tty1 console=ttyS1,115200n8"
Also,
Corrected the line:
exec /sbin/getty -8 115200 tty1 vt100
to:
exec /sbin/getty -8 115200 ttyS1 vt100
Also,
Removed the lines from ttyS1.conf pertaining to ‘containers’:
and (
          not-container or
          container CONTAINER=lxc or
          container CONTAINER=lxc-libvirt)
Everything is running smoothly after this, even when networking is turned off in the kernel.

Tuesday, September 24, 2013

mapping Probe ID to Gene ID by using R

1) in or after 2006, there should be good Probe Id to GENE id map.

2) necessary package:
Biobase,
GEOquery

3) load the GPL platform file:
gpl5425 = getGEO('GPL5425',destdir=".")
         
## get annotation table
gpl5425_ann = Table(gpl5425)

#make the rownames to be ID
rownames(gpl5425_ann) = gpl5425_ann$ID

--------------------------------------------------------------------------------
                               ID                                        GB_ACC      GENE_SYMBOL                                    
AA799301_PROBE1 AA799301_PROBE1     AA799301   LOC498225            
AA799313_PROBE1 AA799313_PROBE1     AA799313      Siat10 ST3
AA799329_PROBE1 AA799329_PROBE1     AA799329     Col10a1      
AA799331_PROBE1 AA799331_PROBE1 NM_001007634        Pelo
--------------------------------------------------------------------------------

#assume the expression data is:
gse24417

--------------------------------------------------------------------------------
            ID_REF GSM204540 GSM204503 GSM204587 GSM204994
1 NM_016986_Probe1   14.5383   15.6827   14.0196   15.0969
2 NM_016987_Probe1   12.7629   15.6014   13.1481   14.4640
3 NM_016988_Probe1   14.0954   14.0583   13.6035   14.3924
4    M27893_Probe1   12.4787   12.6605   11.6335   14.0050
5 NM_012490_Probe1    8.9914    8.2654    9.2640    6.5239
--------------------------------------------------------------------------------

rownames(gse24417) = gse24417$ID_REF

#get the probe id, with upper character
pid = toupper(gse24417$ID_REF)

#get the gene symbol id
gid = gpl5425_ann[pid,]$GENE_SYMBOL

## gid contains empty value: "" , and NA value "NA", find the index of them and delete the lines.
blank_id = which( gid == "")
na_id = which(is.na(gid))

#now combine the final data
unwanted_index = c(blank_id,na_id)

gid = gid[-unwanted_index]
gse24417 = gse24417[-unwanted_index]

gse24417$ID_REF = gid

## now remove the repeated genes