Program guide > (deprecated) Partitioning facility > Partitioning facility programming > Develop partitioning facility applications with WSAD v5.1 > Use WSAD 5.1 with a new partitioned application > Add sample partitions


Deprecated feature: The partitioning facility (WPF) feature is deprecated. You can configure partitioning with WebSphere eXtreme Scale.


Update the getPartitions method


setPartitionAlias

Extended Deployment v6.0 supports partitionAlias context-based routing. After following the next step to update the getPartitions method, you can add:

 PartitionDefinition p = ivRuntime.createPartitionDefinition(pName)  

p.setPartitionAlias(pAlias) 

This will enable you to use either pName or pAlias context to do routing.

Update the getPartitions method...

    public PartitionDefinition[] getPartitions() 
    {
        ArrayList partitions = new ArrayList();
        
        // first add some key based partitions. These are static here but could
        // just as  be loaded from a database when the application starts.
        String[] keys = new String[] {"IBM", "CSCO", "SUNW", "BEAS", "ORCL", 
"MSFT", "GE"};
        for(int i = 0; i
< keys.length; ++i)
        {
            PartitionDefinition p = ivRuntime.createPartitionDefinition("K_" + 
keys[i], 
                    "KEYS", PartitionScope.K_CLUSTER);
            partitions.add(p);
        }
        // now add some partitions for our hash test. We'll have a hash space
     of 16 slots
        // thus allowing us to scale to 16 JVMs. We can  use a larger 
     number but 16
        // is sufficient for this sample.
        for(int i = 0; i
< 16; ++i)
        {
            PartitionDefinition p = ivRuntime.createPartitionDefinition
     ("H_" + i, 
                    "HASH", PartitionScope.K_CLUSTER);
            partitions.add(p);
        }
        PartitionDefinition p = ivRuntime.createPartitionDefinition
    ("SINGLETON");
        partitions.add(p);
        return (PartitionDefinition[])partitions.toArray();
    }

This method shows an example of three types of partitioning schemes.

The first scheme creates a partition per key. The keys here are stock symbols. You can load the list of stock symbols (there are usually thousands) and return partition definitions for each. The next scheme shows how partitions can be created to hash a set of keys onto a fixed set of partitions using a hashing scheme. The sample uses sixteen partitions. Finally, the last scheme shows how to make a singleton service for the cluster by giving it a single partition.

The purpose of the partition stateless session bean (PSSB) is to support the application specification of the set partitions at startup time. With each partition that is specified, the cluster member can be a potential activation member for the partition. Each cluster member normally returns the same set of partitions, and the customer can use the HA manager and its policies to determine partition placement. This scheme offers both flexibility and simplicity by separating the concerns of partition definition versus partition placement. There is no need to implement complicated application logic returning different partition sets for each cluster member. When the cluster starts, each partition is activated on one of the cluster members.


Parent topic:

Add sample partitions


Related tasks

Add sample partitions