Owen

About Owen

This author has not yet filled in any details.
So far Owen has created 36 blog entries.

Reminder of BOF session tonight

By |2020-10-12T08:39:49+00:00November 8, 2007|

I will be leading a Birds Of a Feather session at Qcon tonight at 7:15 in the City room of the Westin hotel in San Francisco. Attendees will build a simple fault-tolerant, linearly scalable application using OpenSpaces and the GigaSpacesXAP platform. ...

Freedom to Work and Play (The end)

By |2020-10-12T08:39:58+00:00November 8, 2007|

Holy good news Batman! GigaSpaces is now *free* to use for startups!!!! No. Really. This is exciting because you now can get a full XAP license with all the bells and whistles to use forever. (as long as you do not earn more than 5 million dolla...

Well, what do you know?

By |2020-10-12T07:02:32+00:00November 3, 2007|

"Always make decisions based on what you know..." A few years ago I received this excellent advice from a very successful businesswoman I worked for and I have tried to always follow it. When I drive in a car in Manhattan I always look at the traf...

SBA –all over the world!

By |2020-10-12T07:04:31+00:00October 22, 2007|

Wow!

This Fellow seems to really like GigaSpaces and SBA!!

Check out his blog here.

I wonder where he got his material for the blog...?

I guess the influence of SBA on the architect is felt worldwide.

: )

It does my heart proud to see more and more the path of the parallel and co-located rising up to meet the feet of the technologists who seek it.

Owen.

Belated hats off to Julian Browne

By |2020-10-12T08:44:01+00:00October 19, 2007|

One of my favorite success stories involving SBA Space-Based-Architecture is the OrderProcessing system implemented at Virgin Mobile a couple of years ago. Rather than speak at great lengths about it myself, I want to tip my hat to Julian Browne who did a nice job of blogging about his introduction to SBA here.

Thanks Julian for a terrific writeup on your SBA initiation.

BTW Julian: If you see this... how long exactly *was* the Virgin Mobile system down when it last crashed and recovered thanks to the resiliency of the SBA you chose? (I have heard a couple of different numbers)

For the rest of you - learn more about SBA and GigaSpaces here

Owen.

Routing Information Effectively : Divide and Conquer!

By |2020-10-12T07:24:22+00:00October 17, 2007|







RoutingExample.java


Divide and Conquer:

In the pursuit of colocation and affinity the architect/developer must articulate
what the criteria is for routing the information in the system to the best place.
With GigaSpaces,
this means establishing a routing value that will instruct the
proxy how to route the instance of the object in question.
Here I propose a pattern to direct the routing value and allow
for increased
topology transparency within the deployment environment.

Firstly: it is important to specify a dedicated property rather than reuse an
existing one as the runtime routing value needs to be flexible.

Secondly: many times utilizing a primitive is desired by the designer of a system
and once
this is done, a null-equivalent is required to allow for wide-ranging
queries accross multiple partitions. I take the opportunity here to specify a
common routing value
for numerics expressed initially as a String to be parsed as
a
float or int or double etc by the associated java.lang.Float etc... type.

The pattern specifies the use of a Routable
interface (which must be implemented
by any Object seeking to be routed) and a SpaceRoutingHelper utility that is clever
enough to route Routables to the appropriate partition without change of code ie:
'transparently' regardless of whether there is one or 99 partitions in the Space.

Here is the Routable
interface:
package gslabs.util;

/**
* Created by IntelliJ IDEA.
* User: owen
* Date: 5-Jun-2007
* Time: 12:25:12 PM
*/

public interface Routable {
public static final String DEFAULT_NUMERIC_NULL_VALUE="-9999";
public void setRoutingFieldValue(int val);
public int getRoutingFieldValue();
}


Here is the SpaceRoutingHelper:
package gslabs.util;

import com.j_spaces.core.IJSpace;
import com.j_spaces.core.cluster.ClusterPolicy;
import com.j_spaces.core.admin.IRemoteJSpaceAdmin;


/**
* Created by IntelliJ IDEA.
* User: owen
* Date: 5-Jun-2007
* Time: 12:09:12 PM
*/

public class SpaceRoutingHelper {
IJSpace space =
null;
public int NUMBER_PARTITIONS = 1;

/**
*
@param val The Routable Object to be used with a partitioned Space
*
@param seed The provided value that will determine the target partition (if left null, target partition is
* determined randomly)
*
@return The prepared version of the Routable Object with the routingField specified
*/

public Routable prepareRoutable(Routable val, Object seed) {
if (space == null) {
throw new IllegalStateException("Cannot Route Routable: target space = null");
}
int router = 0;
if (seed == null) {
router = (
int) System.nanoTime() % NUMBER_PARTITIONS;
}
else {
router = seed.hashCode() % NUMBER_PARTITIONS;
}
val.setRoutingFieldValue(router);
return val;
}

public void setSpace(IJSpace space) {
this.space = space;
if (space != null) {
try {
IRemoteJSpaceAdmin spaceAdmin = (IRemoteJSpaceAdmin) space.getAdmin();
ClusterPolicy cpolicy = spaceAdmin.getClusterPolicy();
if(cpolicy!=null){
java.util.List l = cpolicy.m_AllClusterMemberList;
if (l.size() > 1) {
int partitionValue = 1;
try {
partitionValue = cpolicy.m_ReplicationGroups.size();
if (partitionValue == 0) {
//no replicationGroups, so #partitions == size of space names
partitionValue = l.size();
}
}
catch (NullPointerException npe) {
//no replicationGroups, so #partitions == size of space names
partitionValue = l.size();
}
NUMBER_PARTITIONS = partitionValue;
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
}

Example:

The following service writes Offers to the space. In doing so the decision of
how to route the various instances is made using the SpaceRoutingHelper. This
means that without changing the code, the application can be deployed against a
cluster of any number of spaces or a single embedded space.

Additionally, I will show the use of the Routable.DEFAULT_NUMERIC_NULL_VALUE.
****

package os.example.trading;

import org.openspaces.events.adapter.SpaceDataEvent;
import org.openspaces.core.GigaSpace;
import os.example.trading.common;
import java.math.BigDecimal;
import gslabs.util.SpaceRoutingHelper;

/**
*
<p>A simple bean that is run within a Spring context that acts
* as the processing unit context as well (when executed within a
* processing unit container).
*
*
<p>Is handed SpaceDataEvents from a polling container.<br />
* This removes the need to use space.take and space.write in the code.
*
*
<p>The SQLQuery for the polling container is defined in the pu.xml.
*/

public class MarketMakerWorker {

gsutil.SpaceRoutingHelper router =
new SpaceRoutingHelper();
private float lastPrice_NASD,lastPrice_NYSE,lastPrice_AMEX;
private GigaSpace space;
private float highPrice, lowPrice;

public MarketMakerWorker(GigaSpace space, float highPrice, float lowPrice){
this.space = space;
this.highPrice = highPrice;
this.lowPrice = lowPrice;
/*
IT IS NECESSARY TO PREPARE THE SpaceRoutingHelper by passing it a
reference to the Space. Using this reference it determines the total
number of partitions and routes the Routables properly.
*/

router.setSpace(space.getSpace());
}
/**
* This method is called any time the matching event is produced by the space.
*
<p>The OpenSpaces PollingEventContainer will automagically call this method.
*
@param data The data source of the event defined for this bean.
* In this example, the Stock object is evidence of a change in the market
* price for this instrument.
* [The return value is written to the space by the Spring container]
*/

@SpaceDataEvent
public Offer dataProcessed( Stock data) {
Offer offer =
null;
if((data.getCurrentPrice().compareTo(new BigDecimal(highPrice))>0)){
offer =
new Offer();
//bogus code used to set various criteria for demo purposes...
offer.setNumberOfShares(((System.nanoTime()%
50)*1000)+500);
offer.setOfferID(
""+new java.sql.Date(
System.currentTimeMillis())+
"_"+data.getSymbol()+"_sell");
offer.setPrice(data.getCurrentPrice());
offer.setSymbol(data.getSymbol());
offer.setSell(Offer.IS_SELL_TRUE);

/*
NOTICE THE USE OF THE SpaceRoutingHelper and the decision to
Specify an affinity between the (data) Stock object and the
resulting Offer object. If desired, volume of shares could be
used in conjunction with Stock symbol to provide a finer-grained
partitioning strategy.
*/

offer = (Offer) router.prepareRoutable(
offer,
new Integer(data.getRoutingFieldValue()));
}
else if((data.getCurrentPrice().compareTo(
new BigDecimal(lowPrice))<0)){
offer =
new Offer();
//bogus code used to set various criteria for demo purposes...
offer.setNumberOfShares(((System.nanoTime()%
50)*1000)+500);
offer.setOfferID(
""+new java.sql.Date(System.currentTimeMillis())+"_"+data.getSymbol()+"_sell");
offer.setPrice(data.getCurrentPrice());
offer.setSymbol(data.getSymbol());
offer.setSell(Offer.IS_SELL_FALSE);
/*
NOTICE THE USE OF THE SpaceRoutingHelper and the decision to
Specify an affinity between the (data) Stock object and the
resulting Offer object. If desired, volume of shares could be
used in conjunction with Stock symbol to provide a finer-grained
partitioning strategy.
*/

offer = (Offer) router.prepareRoutable(offer,
new Integer(data.getRoutingFieldValue()));
}
return offer;
}

public float getLastAMEXPrice(){
return lastPrice_AMEX;
}
public float getLastNASDPrice(){
return lastPrice_NASD;
}
public float getLastNYSEPrice(){
return lastPrice_NYSE;
}
}


The following
class definition requires several OpenSpaces-specific annotations
to play nicely with that framework - these will be demonstrated - in addition, I
will show the placement of the routingFieldValue and the exposure of several
primitive fields.

package os.example.trading.common;
import com.gigaspaces.annotation.pojo.SpaceId;
import com.gigaspaces.annotation.pojo.SpaceProperty;
import com.gigaspaces.annotation.pojo.SpaceRouting;
import java.math.BigDecimal;
/**
* Created by IntelliJ IDEA.
* User: owen
* Date: Oct 9, 2007
* Time: 3:46:00 PM
*/

public class Offer implements gslabs.util.Routable{
private String offerID;
private String symbol;
private long numberOfShares;
private BigDecimal price;
private int isSell;
public static final int IS_SELL_FALSE=0;
public static final int IS_SELL_TRUE=1;
private int routingFieldValue;

public void setRoutingFieldValue(int val) {
routingFieldValue = val;
}

@SpaceProperty(nullValue=Routable.DEFAULT_NUMERIC_NULL_VALUE)
@SpaceRouting
public int getRoutingFieldValue() {
return routingFieldValue;
}

@SpaceId
public String getOfferID() {
return offerID;
}

public void setOfferID(String offerID) {
this.offerID = offerID;
}

public String getSymbol() {
return symbol;
}

public void setSymbol(String symbol) {
this.symbol = symbol;
}

@SpaceProperty(nullValue=Routable.DEFAULT_NUMERIC_NULL_VALUE)
public long getNumberOfShares() {
return numberOfShares;
}

public void setNumberOfShares(long numberOfShares) {
this.numberOfShares = numberOfShares;
}

public BigDecimal getPrice() {
return price;
}

public void setPrice(BigDecimal price) {
this.price = price;
}

@SpaceProperty(nullValue=Routable.DEFAULT_NUMERIC_NULL_VALUE)
public int getSell() {
return isSell;
}

public void setSell(int sell) {
isSell = sell;
}
}


OSGI in my future

By |2020-10-12T07:26:23+00:00September 21, 2007|

I ran across this little discussion regarding the future of Spring and OSGI. Seems the whole management of services, scaling of applications thing is getting some attention.

I am warming up to Spring (hmm that is a great book/article title!) and now with the integration of low-latency, high-throughput service-oriented applications managed via an OSGI-based infrastructure, the world of distributed programming is getting more interesting.

Seems I am going to have to delve into OSGI next.

Another acronym for my collection.

Cheers,

Owen.

Revamped the screencast to include a scrollbar and pause button!

By |2020-10-12T07:26:39+00:00September 11, 2007|

Hi all,

In light of the new features described in my last post and the fact that the earlier screencast was nigh unusable due to it being not pause-able, I have created a newer one that shows the generation of projects with the original scripts and default style templates, and then with the new Custom Properties combined with Custom Templates.

It is my hope this will encourage more successful use of this tool and of the OpenSpaces platform.

Note that the webcast moves very quickly so you may want to ready the pause button to catch all the details.

Yes you can!

You can watch the webcast by clicking the following link: projectcreator_tutorial_noSound

Remember: project-creator is *not* supported by GigaSpaces, but OpenSpaces and GigaSpaces are.

Owen.

Project Creator Version .03

By |2020-10-12T07:26:51+00:00September 11, 2007|

(My good friend Toby Found a BUG (NPE) I have since fixed it and added one more trick)

You may download the latest jar from any of the links referring to it.
Such as this one here

(I only have the latest copy available and all links point to the same one)

Note the src.jar is similarly updated and can be found here


Added features:

For those of you who want to add additional files and get really fancy - and in anticipation of supporting Spring Remoting with at least one specified Interface and a possible DAO etc... I have added the ability to do two more things with project creator. (these will no doubt again be improved upon, but for now they suffice to allow me to extend the available use-cases this tool will support)


The Two Added Features:


  1. First Feature: (Pretty Cool and useable)
    Specify the existence of a properties file called customTokens.properties and specify its directory. You specify the flag and also the relative or absolute directory containing customTokens.properties file


    example:
    -customTokens ./extraStuffGoesHere

    example:
    -customTokens c:/tmp/wrk/extraStuffGoesHere

    The contents of that properties file is a series of named tokens and their replacement values.

    NB: The tokens must all begin with @



    example:



    # the use of this file allows you to add arbitrary name-value pairs which will
    # act as replacement tokens within the massaged (template) files.
    # the massaged (template) files are limited to:
    # whatever you provide as args to :
    # -setServiceTemplateName
    # -setPUTemplateName
    # -customTemplateFileNameList (comma-separated list of files found in the -templateDir)
    # as well as the always generated:
    # build.xml
    # the sometimes generated:
    # dataObject.javasrc
    # and the various files generated by the intellij and eclipse handlers
    #to avoid name conflicts it is advised to use a prefix such as @username.THETOKEN
    # Where username is the prefix and token is the thing you care about
    # note that in your template files you will have to provide the complete matching token
    @owen.description=/* A really wild ride baby! */
    @owen.methodsig= public static void doIt(){
    @owen.attribute1=someContent
    @owen.property1=SomeContent


  2. Second Feature: (Kinda ugly and less than simple to get correct)
    Specify the existence of additional files to be used as templates (The astute will notice this was hinted at in the comments within the example customTokens.properties file above)

    It is important to note that there are several expected conditions within the project creator to enable this to work:



    1. You must specify the flag -customTemplateFileNameList followed by a comma-delimited string containing the filenames of the extra template files you wish to include

      example:
      -customTemplateFileNameList Message.javasrc_custom,readme.txt
    2. If adding additional java source files as templates: You must also specify the flag -customPackageDir and supply a single valid package into which they will *all* be placed

      example:
      -customPackageDir com.test.common.interfaces
    3. The package declaration of each of the additional java source templates should also contain this value as either hard-coded or using the following expected token: @customPackageDir
    4. The filename given to the java source template must contain the string: "javasrc" somewhere

      example:
      -customTemplateFileNameList ServiceInterface.myjavasrc_secondVersion
    5. The Resulting java Class or interface will be created using the first-half of the given template filename

      example:
      ServiceInterface.myjavasrc_secondVersion becomes ServiceInterface.java
    6. As a result of the above, the Class or Interface name specified within the java template must match the first-half of the given template filename

      example:
      public interface ServiceInterface extends Serializable{
    7. Non-Java Files specified as part of -customTemplateFileNameList will be saved into the project root directory and will be given the exact same name as provided template filename

      example:
      readme.txt becomes readme.txt and is placed in the root directory of the project



      Again, the primary reason for adding such additional functionality is for me to be able to offer additional templates and examples of such things as Spring Remoting using OpenSpaces and the use of DAO decoupling - not to mention adding additional monitoring services and their associated datatypes that will store their discovered values using the space.
      If you find this additional (restrained) flexibility useful for your purposes as well --great! But feel free to ignore it as well.

      Finally, an example of a script that uses all the above-described features:
      (latest args made available in this release are in bold)



      _____________________________________
      Example Script: createCustomStuff.cmd
      _____________________________________
      rem Personal Settings (these change according to each machine environment)
      set JAR_FILE_LOCATION=./project-creator.jar
      set OUTPUT_DIRECTORY=D:\demoProjectCreator\out
      set JAVA_HOME=c:\java\jdk1.5.0_07
      if "%JSHOMEDIR%." == "." set JSHOMEDIR=c:\GigaSpacesXAP6.0

      rem Script-specific Configuration Settings:
      set PROJECT_NAME=Worker
      if "%IDE%." == "." set IDE=-eclipse
      set SERVICE_TEMPLATE_NAME=service.javasrc_myversion
      set PU_TEMPLATE_NAME=pu.xmlsrc
      set TEMPLATE_DIR_ARG=-templateDir ./dummytemplates

      rem the following points project-creator to
      rem the directory containing customTokens.properties :

      set CUSTOM_TOKENS_ARG=-customTokens ./dummytemplates

      rem the following tells project-creator that the additional
      rem template files specified will exist in the -templateDir

      set CUSTOM_TEMPLATES_ARG=-customTemplateFileNameList Message.javasrc_custom
      set CUSTOM_PACKAGE_DIR_ARG=-customPackageDir com.test.common

      rem General Options
      rem elect to overwrite existing projects with same name:
      set OVERWRITE_OPTION=-overwrite

      call %JAVA_HOME%\bin\java -jar %JAR_FILE_LOCATION% %IDE% %OVERWRITE_OPTION% -project %PROJECT_NAME% -out %OUTPUT_DIRECTORY% -setServiceTemplateName %SERVICE_TEMPLATE_NAME% -setPUTemplateName %PU_TEMPLATE_NAME% -gigaHome %JSHOMEDIR% %TEMPLATE_DIR_ARG% %CUSTOM_TOKENS_ARG% %CUSTOM_TEMPLATES_ARG% %CUSTOM_PACKAGE_DIR_ARG%
      _____________________________________
      End Of Example Script: createCustomStuff.cmd
      _____________________________________


      Cheers,

      Owen.

version .02 Update to project-creator.jar –Make your own templates!

By |2020-10-12T07:27:07+00:00September 7, 2007|

I have made another fix to the project-creator.jar found here.

This fix allows you to specify

-templateDir X

where
X = path relative to the directory from which the script is invoked
or
X = Absolute path

example:

Let's say I want to create a new template for my data Object so that it always has a defined String property.

I create a file called "dataObject.javasrc" (because that is currently the only name available for the dataObject template file)

The file could look like this:
***

package @packageName.common;

public class @dataObjectName {

private String dummyValue;
public void setDummyValue(String val){dummyValue=val;}
public String getDummyValue(){return dummyValue};
}

***

I save that file in:
c:\tmp\openspaces\mytemplates

in c:\tmp\openspaces I have a script that looks like this: (changes from previous examples are in different font)


****
rem Personal Settings (these change according to each machine environment)
set JAR_FILE_LOCATION=./project-creator.jar
set OUTPUT_DIRECTORY=c:/tmp/openspaces/output
set JAVA_HOME=c:\java\jdk1.5.0_07
if "%JSHOMEDIR%." == "." set JSHOMEDIR=c:\GigaSpacesXAP6.0

rem Script-specific Configuration Settings:
set PROJECT_NAME=Worker
if "%IDE%." == "." set IDE=-eclipse
set SERVICE_TEMPLATE_NAME=service.javasrc_myversion
set PU_TEMPLATE_NAME=pu.xmlsrc

set TEMPLATE_DIR=-templateDir ./mytemplates


rem General Options
rem elect to overwrite existing projects with same name:
set OVERWRITE_OPTION=-overwrite

call %JAVA_HOME%\bin\java -jar %JAR_FILE_LOCATION% %IDE% %OVERWRITE_OPTION% -project %PROJECT_NAME% -out %OUTPUT_DIRECTORY% -setServiceTemplateName %SERVICE_TEMPLATE_NAME% -setPUTemplateName %PU_TEMPLATE_NAME% -gigaHome %JSHOMEDIR% %TEMPLATE_DIR%

****

If I call that script from the c:\tmp\openspaces directory all will be well and it will find my new version of the dataObject.javasrc file.

If I do not want to call it from that dir everytime, I can instead provide the arg:

set TEMPLATE_DIR=-templateDir c:/tmp/openspaces/mytemplates




and call the script from anywhere.

If the template needed for an operation is not provided in your specified TEMPLATE_DIR, projectcreator will look for it in the jar file as usual.

The template directory structure is as follows:

/%templateDir%
/%templateDir%/eclipse
/%templateDir%/intellij

All the templates are stored in the root of the templateDir except the files used for eclipse and intellij.

Some of the templates you can create must have certain names such as:

build.xml
any of the eclipse or intellij files
dataObject.javasrc

The template files used for the Service.java and pu.xml files can be given any name you like.

Within the templates you create you can currently use any of the following as replacement tokens: (consult the source code found here for more details)

@projectName (Name of the project you want to build)
@spaceName (Name of the space you want to connect to ex: MySpace)
@propertySpaceName (Name of the space with a lowercased first letter – derived from @spaceName ex: mySpace)
@varGSHome (Path to [and including] Root Directory of your XAP installation)
@spaceUrl (This is derived from the @spaceName and your choice of remote or embedded)
@packageName (You specify this as the package for your first service in this Project)
@packageDir (This is derived from the @packageName)
@serviceName (You specify this as the name of your service class)
@dataObjectName (You specify this as the name of your data class (note the package name will set to @packageName.common to ensure this class is packaged in a separate jar file for classloading purposes)

I hope this addition makes this utility even more fun to use.

Cheers,

Owen.

Project Creator Demo: tutorial (Webcast -no sound)

By |2020-10-12T07:27:16+00:00September 6, 2007|

I have created a webcast tutorial that should prove instructive to those seeking to utilize the projectcreator utility.

It demonstrates how to create the scripts, get the jar, build a simple application and run it.

It is my hope this will encourage more successful use of this tool and of the OpenSpaces platform.

Note that the webcast moves very quickly so you may want to ready the pause button to catch all the details. . . uh