Friday, May 15, 2015

Integration Of Maui with TORQUE.

Maui is open source cluster scheduler for cluster and is written in C.TORQUE is open source resource manager,originally known as PBS.It is purely written in C. It manages both job and node.It provides simple scheduler.But default scheduler is not customizable.Maui is customizable and provides various algorithms and policies (for example Fairshare,backfill etc.)
While integrating maui with torque we have to specify some option at the time of installation of maui.
This options are listed below.
--prefix=< location where you want to install architecture independent file.>
--exec-prefix=<location where you want to install architecture dependent file.>
--with-pbs=<location where pbs lib directory  is located.>
--with-spooldir= <location where you want to maintain config files,logs and stat directory.>

Suppose location for installing architecture dependent as well as independent files is /opt/maui then  and suppose TORQUE is installed at location /opt/torque and I am using maui-3.2.6p20 for installation.Following are the steps for installation.
1)tar -xvf  maui-3.2.6p20.tar.gz
2)cd  maui-3.2.6p20
3)./configure --prefix=/opt/maui --exec-prefix=/opt/maui --with-pbs=/opt/torque press enter.
5)make install

And maui is integrated with TORQUE.


How to allow root user to submit and run job in TORQUE.

By default TORQUE(Tera scale open source resource and queue manager) does not allow root user to submit and run the job.But you can change this behavior,using following command.
1)type qmgr
You will get something like this on screen.
Max open servers: 4 
2)Now enter following command line.
Qmgr: qmgr -c 's s acl_roots+=root@*'


Creating user with authentication in mongodb.

1.Start mongodb server
 ./mongod --dbpath datbaseDir  

2.Start mongo client command line interface.

3.Create admin user for all databases.
 >use admin  

4.Press CTRL+C

5.Now type
 mongo --port 27017 -u adminDatabase -p 123 --authenticationDatabase admin  

6.Now it will jump to prompt with adminDatabase user as logged in user.Now assume that you want to create new database newTest and want to create a admin user mahesh for it.Assume that mahesh must be able to add new user for database newTest.Steps are given below
 > use newTest  
 switched to db newTest  
 > db.createUser({user:"mahesh",pwd:"123",roles:[{role:"userAdmin",db:"newTest"}]})  

Now you can logged in using mahesh user.
 mongo newTest --port 27017 -u mahesh -p  

But if you try to create document using mahesh user it will show the error.
 > db.doc1.insert({"name":"shailesh"})  
     "writeError" : {  
         "code" : 13,  
         "errmsg" : "not authorized on newTest to execute command { insert: \"doc1\", documents: [ { _id: ObjectId('5555991b5102d7a82ac1daef'), name: \"shailesh\" } ], ordered: true }"  

It is because the permissions given to mahesh.Mahesh can just create new user not new collection.

7.Lets create new user on same database newTest but with read and write permissions.Logged in again with mahesh user.
 mongo newTest --port 27017 -u mahesh -p  
 > db.createUser({user:"mahesh1",pwd:"123",roles:[{role:"readWrite",db:"newTest"}]})  

Now mahesh1 can easily insert document into newTest.

Thursday, May 14, 2015

MongoDB java connectivity "Exception in thread "main" java.lang.NoClassDefFoundError: org/bson/codecs/Decoder"


MongoDB is cross platform,document based,NoSQL database.I am using mongodb 3.0.3.If u search for mongodb java driver,you will get the following link as search result.

This page is the download page for mongodb java driver.You have to select the Operating System and version for the driver.While writing this blog the driver was having 2 versions 3.0.1 and 2.13.1.I used 3.0.1.

Here is the simple java code.
 import com.mongodb.MongoClient;  
 public class mongoCon {  
      public static void main(String[] args)  
           MongoClient c1=new MongoClient("localhost",27017);  
           List<String> dbs=c1.getDatabaseNames();  
           for(String db: dbs)  

I used eclipse IDE and configured it for mongodb java driver by adding driver as external jar file.

When I execute the code it gets melt down.

It shows following error.
 Exception in thread "main" java.lang.NoClassDefFoundError: org/bson/codecs/Decoder  
   at mongo_java.mongoCon.main(  
 Caused by: java.lang.ClassNotFoundException: org.bson.codecs.Decoder  

It is because of jar file that I was using.When I opened it using archive manager there was no class file for Decoder.Even there was no folder codecs inside org/bson.

The solution is to download source code of driver and build it to get jar.
I downloaded it from
Then extract it and change directory to the extracted location and type ./gradlew.
 tar -xf mongo-java-driver-r3.0.1.tar.gz  
 cd mongo-java-driver-r3.0.1  
 ./gradlew jar  
  It will build the project and will  show "BUILD SUCCESSFUL" if everything is ok. If your network requires proxy setting just change "./gradlew jar" to
 ./gradlew -Dhttps.proxyHost= -Dhttps.proxyPort=3128 jar  
After this,you can get the jar file in mongo-java-driver directory of mongo-java-driver-r3.0.1. Just add this jar file as the external jar for your eclipse project and it will work.