Program guide > (deprecated) Partitioning facility > Partitioning facility programming > Partition alias


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


Partition alias programming

The following two methods are added through the PartitionDefition interface:

 /** 
* This sets a string as alias name 
* 
*/ 
void setPartitionAlias(String aliasName);

 /** 
* This returns the partition alias string for this partition 
* 
* @return String 
*/ 
String getPartitionAlias();


Partition alias programming sample

Two partition alias samples are provided as programming examples. One demonstrates how partition alias works, and the other shows how it works with the mixed partition aliases and non-alias partitions in the same application. The two samples follow:


Partition alias sample

In the getPartitions() method of PSSB, partitionDefinition and setPartitionAlias are created to each partition. There is a one-to-one relation between partition and partition alias.

public PartitionDefinition[] getPartitions() {
        try {
         //1-1 between partition and alias
            numOfAlias=numOfPartitions;
          
        partitionAlias= new String[numOfAlias];
        }
        catch (Exception e) {
        …
        }
        PartitionDefinition[] rc = new PartitionDefinition[numOfPartitions];
        for (int i = 1; i
<= numOfPartitions; ++i) {
            rc[i - 1] = ivManager.createPartitionDefinition(PartitionAlias.PARTITION_PREFIX + padZeroToString(i + "", 6));            
                        rc[i-1].setPartitionAlias(PartitionAlias.PARTITION_ALIAS + padZeroToString(i + "", 6));
        } 
        return rc;
    }


In PartitionAlias_PartitionKey.java class:

public class PartitionAlias_PartitionKey {
    /**
     * return the partition string as the partition key
     * @param partition
     * @return
     */
    public static String pingAlias(String partitionAlias) {
        return partitionAlias;
    }
    /**
     * return the partition string as the partition key
     * @param partition
     * @return
     */
    public static String ping(String partition) {
        return partition;
    }

Some methods can use partition alias context while other methods can use partition context.


Mixed partition alias and non-alias partition sample

In this sample, not all partitions have corresponding aliases. Only 20% (1/5) partitions have their aliases. Partitions ending with 0 or 5 have their aliases; all other partitions do not have aliases.

public PartitionDefinition[] getPartitions() {
        try {    
          numOfAlias=numOfPartitions/5;
        partitionAlias= new String[numOfAlias];
        }
        catch (Exception e) {
        ……
        }
        PartitionDefinition[] rc = new PartitionDefinition[numOfPartitions];
        for (int i = 1; i
<= numOfPartitions; ++i) {
            rc[i - 1] = ivManager.createPartitionDefinition(MixedAliasNoAliasPartition.PARTITION_PREFIX + padZeroToString(i + "", 6));
            
            if ((i-1)%5==0){
                int k= (i-1)/5 + 1;
            rc[i-1].setPartitionAlias(MixedAliasNoAliasPartition.PARTITION_ALIAS + padZeroToString(k + "", 6));
            }
        } 
        return rc;
    }

Route can use either partition alias context if it exists or partition context. If partition alias does not exist for this partition and client request has partition alias context, client requests will receive a NO_IMPLEMENT exception, but this no-alias partition can be routed with partition context. In any application, some partitions may have their aliases, and other partitions may have not any aliases.


Parent topic:

Partition alias


Related concepts

What is a partition alias?