Javascript based grid operations client on github

Posted by: Billy Newport on 2010-11-29 16:46:00.0

I get asked a lot if WebSphere eXtreme Scale includes a utility to examine the contents of a grid and/or allow the grid to be manipulated. I've uploaded the first version of such a utility to my github repository today. 

https://github.com/bnewport/Samples/tree/master/jsoncrud/

I'll add the README from the project here:

This is a command line utility that allows you to work with a remote grid and examine/manipulate it. It's built around a JavaScript shell. When you start the utility then you specify the grid you want to connect to:

> jsonclient.sh -ch localhost -cp 2809 -grid Grid 

I'm assuming you've created a jsonclient.sh script to call "com.devwebsphere.jsoncrud.WXSShell". This is the main class. This will then connect to the grid and start up a JavaScript shell like this: 

Rhino 1.7 release 2 2009 03 22

js> 

At this point there is one global variable defined called 'grid'. You can use this to get instances of Maps in the remote grid. For example: 

js> personMap = grid.getMap("Person", "java.lang.String", "com.billy.Person")

 This stores a Map object instance for Person in the personMap variable. The map is stored remotely in the grid and uses a String for the key with a value using the class com.billy.Person

Lets suppose your Person looks like this:

public class Person implements Serializable 

{

String firstName;

String middleInitial;

String surname;

Date dateOfBirth;

double creditLimit;

...

}

 

The class would have getters and setters define for the attributes. You can insert a Person entry using this:

js> billy = {"firstName":"Billy", "surname":"Newport", "middleInitial":"Z", "creditLimit":"100.0"}

js> personMap.put("bn", billy)

 

This creates an entry in the map with the key "bn" and the value as shown. The value in the remote Map is a Person class instance. The JSON string above needs to have the same corresponding attributes as the Person POJO. We can modify the entry so have a different credit limit like this:

js> p = personMap.get("bn")

js> p.creditLimit = 200

js> personMap.put("bn", p)

 

We can remove the entry like this:

js> personMap.remove("bn")

 

We can invalidate the entry like this:

js> personMap.invalidate("bn")

Preparation Instructions

Add the jars to the grid classpath. Add a map called "Router" to your mapset. It is just used for routing, no data is stored in it. The client doesn't need any application classes. Once this is done then you should be able to connect to the grid and work as described above

 

 


be the first to rate this blog

About Billy Newport

Billy Newport

Billy is a Distinguished Engineer at IBM. He's been at IBM since 2001. Billy was the lead on the WorkManager/ Scheduler APIs which were later standardized by IBM and BEA and are now the subject of JSR 236 and JSR 237. Billy lead the design of the WebSphere 6.0 non blocking IO framework (channel framework) and the WebSphere 6.0 high availability/clustering (HAManager). Billy currently works on WebSphere XD and ObjectGrid. He's also the lead persistence architect and runtime availability/scaling architect for the base application server.

Before IBM, Billy worked as an independant consultant at investment banks, telcos, publishing companies and travel reservation companies. He wrote video games in C and assembler on the ZX Spectrum, Atari ST and Commodore Amiga as a teenager. He started programming on an Apple IIe when he was eleven, his first programming language was 6502 assembler.

Billys current interests are lightweight non invasive middleware, complex event processing systems and grid based OLTP frameworks.

More About Billy »

NFJS, the Magazine

2010-12-01 00:00:00.0 Issue Now Available
  • Functional Programming in Java
    by Ted Neward
  • On mini-languages and Clojure
    by Raju Gandhi
  • Testing in Scala
    by Daniel Hinojosa
  • An Introduction to Node.JS
    by James Carr
Learn More »