Monday, August 16, 2010

Deploying Resources - OGSA-DAI/CXF/Linux/Ant/Tomcat/mysql

A random post on deploying the resources. :)

Set an OGSADAI_HOME environment variable
export OGSADAI_HOME=/home/pradeeban/ogsa-dai/ogsa-dai/trunk/release-scripts/ogsa-dai/cxf/build/ogsadai-4.1-cxf-2.2.6-src/build/ogsadai-4.1-cxf-2.2.6-bin


Checking for too long path issue
After setting the environment using, make sure that your classpath hasn't exceeded the maximum allowed length. If it had exceeded, as a quick fix, you can consider moving your OGSADAI_HOME to somewhere upwards towards the root directory.

Creating a sample MySQL database 'ogsadai' using ogsa-dai's createTestMySQLDB class with the table 'littleblackbook' and 10000 entries.

java -host -port 3306 -database ogsadai -username mysqlUser -password 123456 -rootusername ogsadairootuser -rootpassword ogsadairootpassword

java -cp $CLASSPATH:/home/pradeeban/ogsa-dai/third-party/dependencies/mysql/mysql-connector/5.0.4/mysql-connector-java-5.0.4-bin.jar:/home/pradeeban/gsoc2010/data/build/lib/ogsadai-4.1-sampledata-1.0.jar -host localhost -port 3306 -database ogsadai -username root -password root -rootusername root -rootpassword root
MySQL Settings:
    MySQLHostName:           localhost
    MySQLPortNumber:         3306
    MySQLDatabaseName:       ogsadai
    MySQLUserName:           root
    MySQLPassword:           root
    NameOfTableToCreate:     littleblackbook
    NumberOfRowsToCreate:    10000
    MySQLRootUserName:       root
    MySQLRootPassword:       root
Opening connection to MySQL system database
Creating 'ogsadai' database in MySQL if it does not already exist
Creating user 'root' with password 'root' in MySQL if it does not already exist
User 'root' already exists within MySQL
Dropping table if it already exists
Creating littleblackbook table in database
Preparing insert statement
Adding 10000 entries to 'littleblackbook' .............
Test database created successfully!

Deploying the database to ogsa-dai
DeployResource deployMySQL MySQLResource jdbc:mysql://localhost:3306/ogsadai Login permit MySQLResource ANY
DeployResource deployMySQL MySQLResource jdbc:mysql://localhost:3306/ogsadai Login permit MySQLResource ANY ogsadai root

getVersion method
java -cp $CLASSPATH:/home/pradeeban/gsoc2010/core/client/build/lib/ogsadai-4.1-client-1.0.jar:/home/pradeeban/gsoc2010/core/common/build/lib/ogsadai-4.1-common-1.0.jar:/home/pradeeban/gsoc2010/core/clientserver/build/lib/ogsadai-4.1-clientserver-1.0.jar -u http://localhost:8080/dai/services/ -c getVersion

java -cp $CLASSPATH:/home/pradeeban/gsoc2010/core/client/build/lib/ogsadai-4.1-client-1.0.jar:/home/pradeeban/gsoc2010/core/common/build/lib/ogsadai-4.1-common-1.0.jar:/home/pradeeban/gsoc2010/core/clientserver/build/lib/ogsadai-4.1-clientserver-1.0.jar -u http://localhost:8080/dai/services/ -c getVersion

java -u http://localhost:8080/dai/services/ -c getVersion

How to show the server version
java -u http://localhost:8080/dai/services/ -c listResources

java -cp $CLASSPATH:/home/pradeeban/gsoc2010/core/client/build/lib/ogsadai-4.1-client-1.0.jar:/home/pradeeban/gsoc2010/core/common/build/lib/ogsadai-4.1-common-1.0.jar:/home/pradeeban/gsoc2010/core/clientserver/build/lib/ogsadai-4.1-clientserver-1.0.jar -u http://localhost:8080/dai/services/ -c listResources

java -cp client/build/lib/ogsadai-4.1-client-1.0.jar:common/build/lib/ogsadai-4.1-common-1.0.jar:clientserver/build/lib/ogsadai-4.1-clientserver-1.0.jar -u http://localhost:8080/dai/services/ -c listResources

java -cp client/build/lib/ogsadai-4.1-client-1.0.jar:common/build/lib/ogsadai-4.1-common-1.0.jar:clientserver/build/lib/ogsadai-4.1-clientserver-1.0.jar -u http://localhost:8080/dai/services/ -r MySQLDataResource -t -c getLifetime

DB Query
pradeeban@pradeeban-laptop:~/ogsa-dai/ogsa-dai/trunk/extensions/basic/client$ ant jar
pradeeban@pradeeban-laptop:~/ogsa-dai/ogsa-dai/trunk/extensions/relational/client$ ant jar

DeployResource deployMySQL MySQLResource jdbc:mysql://localhost:3306/ogsadai Login permit MySQLResource ANY
DeployResource deployMySQL MySQLResource jdbc:mysql://localhost:3306/ogsadai Login permit MySQLResource ANY ogsadai root

Deploy the above DeployResource script with:
ant -Dtomcat.dir=$CATALINA_HOME -Dconfig.file=mySQLResourceConfig.txt configure

java -cp /home/pradeeban/ogsa-dai/ogsa-dai/trunk/extensions/relational/client/build/lib/ogsadai-4.1-relational-client-1.0.jar:/home/pradeeban/gsoc2010/core/client/build/lib/ogsadai-4.1-client-1.0.jar:/home/pradeeban/gsoc2010/core/common/build/lib/ogsadai-4.1-common-1.0.jar:/home/pradeeban/gsoc2010/core/clientserver/build/lib/ogsadai-4.1-clientserver-1.0.jar -u http://localhost:8080/dai/services -d MySQLResource -q "SELECT * FROM littleblackbook WHERE id <  10"
*DRER ID: DataRequestExecutionResource
Data Resource ID: MySQLResource
Base Services URL: http://localhost:8080/dai/services
SQL-Query: SELECT * FROM littleblackbook WHERE id <  10

Wrapping up GSoC 2010

CXF Release Build
After a fix for a missing module in revision 1314, CXF release-build was successful in the test server.

Test Server
Version 1317 and 1318 focused on fixing some bugs in the test code. In 1319,  Base64 tests were done, using org.apache.cxf.common.util.Base64Utilit as the implementation of Base 64 encoding for OGSA-DAI for cxf based layer [1]. The default Base64 implementation of OGSA-DAI is, org.apache.axis.encoding.Base64, as defined in Base64 class of OGSA-DAI.

Conversion of char[] to string, and mapping the encode and decode methods of Base64Utility, is handled by presentation/cxf/client/src/main/java/uk/org/ogsadai/client/toolkit/presentation/cxf/ from the version 1322. This fixes the cxf base64 tests. Further, Base64Mapper interface will be in the core/common module, and  ogsadai.common.Base64 will have method public static synchronized void registerBase64Class(Base64Mapper mapper). Decode encode operations will use the instance of the interface, instead of the implementation itself. After 1322, cxf/server tests depend on the cxf/client module too. Hence adding it as a dependency in ant jarUnitTests for cxf/server in 1323. These changes made all the 13 tests of cxf/server module to run successfully [2], almost completing the development of the CXF - SOAP based layer for OGSA-DAI.

With the client toolkit for cxf, the pencils down date reached. Though we will continue with our projects, the changes we did to the code base after 16th of August 1900 UTC will not be counted as work under Google Summer of Code 2010.

ReSTful Layer CXF/JAX-RS
Version 1300 starts the presentation/rest for the ReSTful layer based on CXF/JAX-RS. XXXResource classes define the CRUDs, where the CRUD methods call XXX classes, the classes that calls the lower level implementation further. 1398 becomes the initial implementation of DataRequestExecutionResource for CXF-JAX/RS presentation layer. 

1399 provides a Simple ReST Server implementation. 1402 Lists resources for ReST resource types, while 1403 Gets and Deletes resources with the given resource ids. 1404 Sets the Lifetime, from the Request Service. ReST layer specific exceptions need to be written, and current error handling is very primitive for ReSTful layer.

CXF/JAX-RS Release Script
Commits 1406 and 1407 starts the release script of the ReSTful layer at trunk/release-scripts/ogsa-dai/rest, based on cxf/jax-rs. Needs more changes, and this script is still evolving. This becomes my final commit that comes under Google Summer of Code 2010 (Tonight 1900 UTC was the firm-pencils-down date).

Patches that cover my contribution towards the timeline can be retrieved by executing the below lines from the trunk.
svn diff -r 994:1407 presentation/cxf > gsoc2010.diff
svn diff -r 1274:1407 presentation/rest > gsoc2010Rest.diff
svn diff -r 1261:1407 release-scripts/ogsa-dai/cxf > gsoc2010Release.diff
svn diff -r 1406:1407 release-scripts/ogsa-dai/rest > gsoc2010ReSTRelease.diff
As the code is committed itself into trunk, the patches is practically not necessary, apart from the Google's requirements or for records.

Considering the modules, presentation/cxf, presentation/rest, release-scripts/ogsa-dai/cxf, and release-scripts/ogsa-dai/rest contain the code written during this Summer of Code. 1407 becomes the last commit that was done during the Summer, hence the later commits won't be counted for Google Summer of Code. 

The generated tarball of code for the code submission to Google can be downloaded from here.

Sunday, August 15, 2010

Summer of Love 2010 with OGSA-DAI

OGSA-DAI, a name that became the highlight of the year 2010. When we reach the climax of Google Summer of Code, I have to mention that it has become one of the sweetest memories of my 2010. Working with OGSA-DAI team is an amazing experience. We discuss about almost everything over the irc. It varies from Web Services to Neural Networks, Sri Lankan tea to Colombian Coffee, and Databases to Grid Computing. Apart from the scope of the Summer of Code project, I am pretty sure that Michal (my GSoC 2010 mate in OGSA-DAI) and I were able to gain a considerable amount of knowledge on OGSA-DAI as well as the technologies that are used. The super-friendly environment of OGSA-DAI team is one of the best learning platforms that I have experienced, During the last few months, while working with the presentation layers, I was also able to play with the code base, and experiment with it. 

Developing a presentation layer for OGSA-DAI is a challenging, but an interesting task to do. I started to write an article on how to write a presentation layer for OGSA-DAI, soon after I completed developing the SOAP based layer, which I later found more SOAP and CXF biased, when I started working with the ReSTful layer, which made me postpone releasing the article, as it obviously needs further modification. Officially Google Summer of Code completes by tomorrow, and of course, that just completes the direct involvement of Google. After taking a short break for my final exams, I will be back to OGSA-DAI on 6th of September. A compatible community is always a great motivation for a FOSS developer. With a strong community, OGSA-DAI becomes an ideal project for someone who is passionate on Software Development. 

At this moment, I should thank my mentors Ally Hume and Bartosz Dobrzelecki for the great support and motivation they offered throughout the project. My Special thanks goes to Mario Antonioletti for his constructive thoughts and help when I first applied to GSoC, as well as his encouragement throughout the project timeline. My sincere thanks to Mike Jackson for providing help in setting up the tests and release builds in the server, effectively managing the project. I should also thank Neil Chue Hong for administrating Google Summer of Code this year, providing updates and assistance to students and mentors from OMII-UK. Thoughts of the core team members Charaka Palansuriya, Carlos Buil Aranda, Tilaye Alemu, and Amy Krause were always fascinating and highly motivating, and the OGSA-DAI family is really a nice environment to work with. OGSA-DAI is a team with strong bonds, and we all love the cute hexapus!