Wednesday, April 22, 2009

I love the Standalone container in Jopr (updated)


I am just working on a plugin when I have some spare cycles (I will tell you which one in a few days :-)

To test the plugin I am using the Standalone Container where I have deployed my plugin, the JMX and the platform plugin.
So when I have compiled a new version of the plugin I just copy it over and start the standalone container:

snert:rhq-agent hrupp$ bin/standalone.sh

Listening for transport dt_socket at address: 8788



Starting the plugin container.

Loading plugins

...Loaded plugin: Platforms

...Loaded plugin: JMX

...Loaded plugin: MyNewOne



Ready.

[0]:0 >


This takes 3 seconds and then I am ready to discover resources:

[0]:0 > disc s

Discovery took: 2269ms

[Resource[id=-3, type=Secret, key=service:jmx:rmi://127.0.0.1/jndi/rmi://127.0.0.1:1090/jmxconnector, name=Secret, parent=snert]]

[1]:0 >


Now I can test if my invokeOperation() method from the OperationFacet works:

[2]:-0 > set res -3

[3]:-3 > invoke getProperty name=test

[PropertySimple[id=0, name=result, value=null, override=null]]


So set the resource id to the resource I want to work with and then invoke the getProperty operation with parameter name and value test. The Operation then returned null, as the underlying resource does not know this specific value.

This all took around 10 seconds now for a round trip - you can't really do faster testing :-)

When I want to repeat those steps with an updated version of the plugin, I can save my work:

[4]:-3 > !w /tmp/foo

This creates a file and saves the commands given in it. The name of the file can later be given on the command line to just run the action as a script without any need to manually type in the commands.

There is currently one caveat: Resource ids will change in each startup so the "set" command in step 2 above will not work exactly like this.

[UPDATE]


I will work on adding variables to the find command in the standalone container which can then be passed to set -- if you want to help out contact me.


What you can do is to use $r as 2nd parameter to set after finding a single resource:

[5]:0 > find r *myFooBar*

-12: MyFooBar ( Resource[id=-3, ... )

[6]:0 > set r $r

[7]:-12 >



With this trick it is now possible to just run the container with the saved file as input again and again

$snert bin/standalone.sh /tmp/foo

2 comments:

jimma said...

Cool stuff! It can really speed up the plugin development. Where can I get this standalone container ? Is there any document to list the command which support ?
Thanks

Heiko said...

Jim,
Mazz has a link in his post: http://management-platform.blogspot.com/2009/03/mighty-embeddable-plugin-container.html

Basically: the logic itself is in the normal plugin container build (perhaps only head). And then there is a special start script in $RHQ/etc/standalone-pc/

The standalone container has a help command that explains the options.