Simplest Enterprise Continuous Integration Solutions

Sunday, August 14, 2011

Java MultiThreads on Windows


Java MultiThreads wrapped as a Windows service with below directory structure:
MultiThreads-windows-x86-32\
                           \InstallMultiThreadsService.bat
                           \MultiThreads.jar
                           \MultiThreadsConsole.bat
                           \UninstallMultiThreadsService.bat
                           \wrapper.exe
                           \conf\
                                \wrapper.conf
                           \lib\
                               \commons-io-2.0.1.jar
                               \libweapper.so
                               \wrapper.dll
                               \wrapper.jar
                               \wrappertest.jar
                               \yamlbean-1.0.jar
                           \logs
                           \receiveInputsFromYamls\
                           \invokeMultiThreadExecutions\

MultiThreads.jar which listens yaml format file as inputs from  MultiThreads\receiveInputsFromYamls, and execute the executions with outputs to MultiThreads\invokeMultiThreadExecutions\ in Java multithreads mode.

yaml format file inputs content:
name: task1
command: execute_something

MultiThreads-windows-x86-32\conf\wrapper.conf content:

 #********************************************************************

 # Wrapper Properties

 #********************************************************************

 # Java Application

 wrapper.java.command=java

 # Java Main class

 wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp

 # Java Classpath (include wrapper.jar)  Add class path elements as

 #  needed starting from 1
 wrapper.java.classpath.1=lib/wrapper.jar
 wrapper.java.classpath.2=MultiThreads.jar
 # Java Library Path (location of Wrapper.DLL or libwrapper.so)
 wrapper.java.library.path.1=lib
# Java Bits.  On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
wrapper.java.additional.auto_bits=TRUE
 # Initial Java Heap Size (in MB)
 wrapper.java.initmemory=256
 # Maximum Java Heap Size (in MB)
 wrapper.java.maxmemory=512
 # Application parameters.  Add parameters as needed starting from 1
 wrapper.app.parameter.1=com.acme.multithreads.MultiTheads
 #********************************************************************
 # Wrapper Logging Properties
 #********************************************************************
# Enables Debug output from the Wrapper.
# wrapper.debug=TRUE
 # Format of output for the console.  (See docs for formats)
 wrapper.console.format=PM
 # Log Level for console output.  (See docs for log levels)
 wrapper.console.loglevel=INFO
 # Format of output for the log file.  (See docs for formats)
 wrapper.logfile.format=LPTM
 # Log file to use for wrapper output logging.
 wrapper.logfile=logs/wrapper.log
 # Log Level for log file output.  (See docs for log levels)
 wrapper.logfile.loglevel=INFO
 # Maximum size that the log file will be allowed to grow to before
 #  the log is rolled. Size is specified in bytes.  The default value
 #  of 0, disables log rolling.  May abbreviate with the 'k' (kb) or
 #  'm' (mb) suffix.  For example: 10m = 10 megabytes.
 wrapper.logfile.maxsize=10m
 # Maximum number of rolled log files which will be allowed before old
 #  files are deleted.  The default value of 0 implies no limit.
 wrapper.logfile.maxfiles=10
 # Log Level for sys/event log output.  (See docs for log levels)
 wrapper.syslog.loglevel=ERROR
 #********************************************************************
 # Wrapper NT Service Properties
 #********************************************************************
 # WARNING - Do not modify any of these properties when an application
 #  using this configuration file has been installed as a service.
 #  Please uninstall the service before modifying this section.  The
 #  service can then be reinstalled.
 # Name of the service
wrapper.ntservice.name=MultiThreads
 # Display name of the service
wrapper.ntservice.displayname=MultiThreads Service
 # Description of the service
wrapper.ntservice.description=MultiThreads Service
 # Service dependencies.  Add dependencies as needed starting from 1
 wrapper.ntservice.dependency.1=
 # Mode in which the service is installed.  AUTO_START or DEMAND_START
 wrapper.ntservice.starttype=AUTO_START
 # Priority at which
  the service is run.  NORMAL, LOW, HIGH, or
 #  REALTIME
 wrapper.ntservice.process_priority=NORMAL
 # Allow the service to interact with the desktop.
 wrapper.ntservice.interactive=false
 #****************************************************************
 # Wrapper Linux/Unix Service Properties
 #****************************************************************
 wrapper.daemonize=TRUE

Run as Windows service mode
  • MultiThreads\UninstallMultiThreads.bat
  • MultiThreads\InstallMultiThreads.bat
  • net start MultiThreads
Run as console mode
  • MultiThreads\MultiThreads.bat

Saturday, August 13, 2011

Enterprise Linux - Autofs Automounting

Implementing an automount to NFS /home directory when user login to NIS client.
  • NFS Client
Make sure netfs, nfslock, portmap are installed and daemons are running.
[root@linux64-client1 ~]# chkconfig nfslock on
[root@linux64-client1 ~]# service nfslock start 
Starting NFS statd:                                        [  OK  ]
[root@linux64-client1 ~]# chkconfig portmap on
[root@linux64-client1 ~]# service portmap start
Starting portmapper:                                       [  OK  ]
[root@linux64-client1 ~]# chkconfig netfs on
[root@linux64-client1 ~]# service netfs start
Mounting other filesystems:                                [  OK  ]
[root@linux64-client1 ~]# mv /home /home.save
[root@linux64-client1 ~]# mkdir /home
Manual mount
[root@linux64-client1 ~]# mount 10.3.20.100:/home /home
[root@linux64-client1 ~]# umount /home
Configure autofs automount
[root@linux64-client1 ~]# cat /etc/auto.master
/home   /etc/auto.home
[root@linux64-client1 ~]# cat /etc/auto.home
*   -fstype=nfs,soft,intr,rsize=8192,wsize=8192,nosuid,tcp 10.3.20.100:/home/&
[root@linux64-client1 ~]# chkconfig autofs on
[root@linux64-client1 ~]# service autofs restart
Stopping automount:                                        [  OK  ]
Starting automount:                                        [  OK  ]
[root@linux64-client1 ~]#


After doing this, you won’t be able to see the contents of the /home directory on linux64-server as user root. This is because by default NFS activates the root squash feature, which disables this user from having privileged access to directories on remote NFS servers.