Posts

Tuples in Jython

Image
Tuple Hi everyone in this post I would like to workout how does the Jython tuple can be constructed and how to display their content and their operations. WebSphere Admin must know about tuple because it is heavily used internal MBeans for storing data in them. What I have understood about Tuple data type is: A tuple is a sequence of immutable Python Objects in the Jython The  tuple content cannot be changed - only assignment that is why we don't see any other functions on them Use parenthesis () to define Here elements can be stored into a tuple with comma-separated values Tuples can contain numbers, strings, nested sub-tuples, or nothing or combination that is heterogeneous types Tuple in Jython Let me experiment and prove that all. # This script list how to use the tuple. t1=(1,2,3,4) print "integer tuple", t1 t2=(1.2,10.5,13.4) print "float tuple", t2 t3=('app1','app2','app3') print "string tuple", ...

Jython script for Server Stop, Start, restart using wsadmin

Image
Server Control from wsadmin The building blocks for this script are as follows: Get Node name  Get the Server name Get the server state Using the AdminControl stop/start/restart How to get Node Name in wsadmin using Jython? We can use the nodeName using AdminControl  with getNode method or completeObjectName querying. wsadmin>nodeName=AdminControl.getNode() wsadmin>print nodeName ubuntu-was8Node01 wsadmin>objn = AdminControl.completeObjectName('WebSphere:type=Server,*') wsadmin>print objn WebSphere:name=server1,process=server1,platform=proxy,node=ubuntu-was8Node01,j2eeType=J2EEServer,version=8.5.5.6,type=Server,mbeanIdentifier=cells/ubuntu-was8Node01Cell/nodes/ubuntu-was8Node01/servers/server1/server.xml#Server_1183121908656,cell=ubuntu-was8Node01Cell,spec=1.0,processType=UnManagedProcess wsadmin>print AdminControl.getAttribute(objn, 'nodeName') ubuntu-was8Node01 In the above interaction we have experimented in two options directl...

Invoking Jython script for wsadmin

Once you have installed WebSphere you have Jython shell built in available. Logon profile editing for environment variables In Linux bash shell is default login shell. Hence we can edit the .bash_profile or .bashrc file to get the user defined environment variables. We can define the alias for lengthy repeated tasks as shortcuts with simple shorten words. Here I have my environment setup from .bash_profile clear echo "Welcome to WebSphere 8.5.5.6" export PROFILE_HOME="/home/vagrant/IBM/WebSphere/AppServer/profiles" export WAS_HOME=/home/vagrant/IBM/WebSphere/AppServer alias wsadmin="cd /home/vagrant/IBM/WebSphere/AppServer/profiles/rplan-profile/bin/; . wsadmin.sh -lang jython" alias ll="ls -lahtr" alias cls="clear" alias dmgrbin="cd ${WAS_HOME}/profiles/rplan-profile/bin; ls -lrth" alias nodebin="cd ${WAS_HOME}/IBM/WebSphere/AppServer/profiles/rplan-profile" Invoking your wsadmin for Jython made simple w...

Latest Jython using in Thin Client WebSphere 8.5 on Vagrant Ubuntu box

How to use the latest Jython for wsadmin Today my experiment on renovating wsadmin Jython version. How to check the current Jython version? It is very simple you can try with sys module attribute version and one more thing your jdk that used for wsadmin runs on which version you can know by sys.platform. wsadmin>print sys.version 2.1 wsadmin>print sys.platform java1.6.0 Installing Jython in Thin Client Home Executing the Jython jar command in the ThinClt/lib directory : vagrant@ubuntu-was8:~/ThinClt/lib$ java -jar /vagrant/was8_5_install/jython-installer-2.7.0.jar Welcome to Jython ! You are about to install Jython version 2.7.0 (at any time, answer c to cancel the installation) For the installation process, the following languages are available: English, German Please select your language [E/g] >>> E Do you want to read the license agreement now ? [y/N] >>> N Do you accept the license agreement ? [Y/n] >>> Y The following installatio...

Setup WebSphere 8.5 on Ubuntu Vagrant box

Image
I've started working on new adventure being in the WebLogic wold had some basic knowledge on Virtuallization with Vagrant and Oracle VirtualBox begin my experiment for WebSphere installation on Ubuntu box. Prerequisites Download and install Vagrant  for Windows Download and install Oracle VirtualBox Download Installation Manager Lets Start Virtualization for WebSphere 8.5 with Vagrant Initially I started following the steps which are given Pattrick Hueper in the Vagrant Ubuntu WebSphere  8.5. Downloaded the Vagrantfiles folder using git command. git clone https://github.com/phueper/vagrantfiles.git Then followed the read me document in that. Modify the Vagrantfile It stuck saying Ubuntu box is not available so I have changed the Vagrant file  with the following line:     config.vm.box = "bento/ubuntu-14.04" and I faced issue with the private network then I modified that with the following line:     config.vm.network "private...

Jython Multi Threading in wsadmin

What is the Multi threading? Multi threading is similar to how multiple programs runs on your computer system, moreover which run at same time. When you are running multiple tasks in parallel on same CPU[machine]. More cores parallel processing allowed by your VM. The simple mapping let me tell you that if you have 1 core CPU that links to Multiple threads. Do's and Don'ts in threading Let us talk about does first here: You defined tasks which are independent of each other Physics/collision calculations in on thread, graphics in another All the threads should communicate back with the main thread which actually starts them Don'ts If you don't have clarity on multi threading then whole program would mess up! so be-careful Simple Threading examples on wsadmin The following sample is from tutorial point python examples. import threading import time exitFlag = 0 class LearnThread (threading.Thread): def __init__(self, threadID, name, counter): ...

Jython Date and time formats experiment

Basic date and time formats in Jython This is common requirement in most of our WAS administration tasks. You need the date or time formats in the following tasks: Back of the deployment units such as .war or .ear or .jar files Log file rotations Monitoring report logs with time stamps Update the Logger with time stamp Jython allow us to use time object only from Python module. other two date, datetime objects are not available in Jython. Lets experiments with the time object and its different functions in a simple script: import time timetuple=time.localtime() print "Time tuple:", timetuple print "Time tuple with loop" for t in timetuple: print t # Week of the day print "Today Weekday in short:",time.strftime('%a') print "Today Weekday in full:", time.strftime('%A') # Month of the date print "This month in short:", time.strftime('%b') print "This month in full:", time.strftime('%...