In der Methode getPartitions einer Partitioned Stateless Session Bean (PSSB) ordnen Sie denselben Partitionsalias mehreren Partitionen zu. Dabei wird für einen Teil von Partitionen ein Partitionsgruppenkontext erstellt.
Im folgenden Beispiel (WPFPartitionGroupingSample.ear) entspricht die Anzahl der Partitionsgruppen der Hälfte (1/2) der Partitionen. Jede Partitionsgruppe enthält zwei Partitionen:
public PartitionDefinition[] getPartitions() { try { numOfAlias=Math.round(numOfPartitions/2.0f); partitionAlias= new String[numOfAlias]; } catch(Exception e){ …… } PartitionDefinition[] rc = new PartitionDefinition[numOfPartitions]; for (int i = 1; i <= numOfPartitions; ++i) { rc[i - 1] = ivManager.createPartitionDefinition(PartitionGrouping.PARTITION_PREFIX + padZeroToString(i + "", 6)); int k= Math.round((i-1)/2.0f-0.1f)+1; rc[i-1].setPartitionAlias(PartitionGrouping.PARTITION_ALIAS + padZeroToString(k + "", 6)); } }
Die Datei WPFPartitionGroupingSample.ear enthält Quellcode. D_WPFPartitionGroupingSample.ear ist ein implementiertes Enterprise Archive (EAR).
launchClient D_WPFPartitionGroupingSample.ear -CCBootstrapPort=9813
Das Ergebnis ist der folgende Code:
IBM WebSphere Application Server Release 6.0 J2EE Application Client Tool Copyright IBM Corp., 1997-2004 WSCL0012I: Die Befehlszeilenparameter werden verarbeitet. WSCL0013I: Die Umgebung des J2EE-Anwendungsclient wird initialisiert. **************************************** ClientComponentImpl.initialize() **************************************** **************************************** ClientComponentImpl.start() **************************************** WSCL0035I: Die Initialisierung der Umgebung des J2EE-Anwendungsclient ist abgeschlossen. WSCL0014I: Die Application-Client-Klasse com.ibm.websphere.wpf.grouping. client.WPFPartitionGroupingClient wird aufgerufen. PartitionAlias Context Routing Sample has 10 partitions PartitionAlias Context Routing Sample has 5 alias Partition alias groups different partitions and router does WLM for each alias that has more than 1 partitions. This sample shows that alias context will be routed into 2 different (even and odd) partitions: 1st call: PG000008->partition=PG000008,server=clusterdevNode01/s1 2nd call: PG000008->partition=PG000008,server=clusterdevNode01/s1 3rd call: PG000008->partition=PG000008,server=clusterdevNode01/s1 Alias 1st call: PGALIAS000001->partitionAlias=PGALIAS000001,server=clusterdevNode 02/s3 Alias 2nd call: PGALIAS000001->partitionAlias=PGALIAS000001,server=clusterdevNode 02/s3 Alias 3rd call: PGALIAS000001->partitionAlias=PGALIAS000001,server=clusterdevNode 02/s3 Alias 4th call: PGALIAS000001->partitionAlias=PGALIAS000001,server=clusterdevNode 02/s3 Alias 5th call: PGALIAS000001->partitionAlias=PGALIAS000001,server=clusterdevNode 02/s3 Alias 6th call: PGALIAS000001->partitionAlias=PGALIAS000001,server=clusterdevNode 02/s3 1st call: PG000006->partition=PG000006,server=clusterdevNode01/s2 2nd call: PG000006->partition=PG000006,server=clusterdevNode01/s2 3rd call: PG000006->partition=PG000006,server=clusterdevNode01/s2 1st call: PG000010->partition=PG000010,server=clusterdevNode01/s1 2nd call: PG000010->partition=PG000010,server=clusterdevNode01/s1 3rd call: PG000010->partition=PG000010,server=clusterdevNode01/s1 Alias 1st call: PGALIAS000002->partitionAlias=PGALIAS000002,server=clusterdevNode 01/s2 Alias 2nd call: PGALIAS000002->partitionAlias=PGALIAS000002,server=clusterdevNode 01/s2 Alias 3rd call: PGALIAS000002->partitionAlias=PGALIAS000002,server=clusterdevNode 02/s3 Alias 4th call: PGALIAS000002->partitionAlias=PGALIAS000002,server=clusterdevNode 02/s3 Alias 5th call: PGALIAS000002->partitionAlias=PGALIAS000002,server=clusterdevNode 01/s2 Alias 6th call: PGALIAS000002->partitionAlias=PGALIAS000002,server=clusterdevNode 02/s3 1st call: PG000001->partition=PG000001,server=clusterdevNode02/s3 2nd call: PG000001->partition=PG000001,server=clusterdevNode02/s3 3rd call: PG000001->partition=PG000001,server=clusterdevNode02/s3 1st call: PG000002->partition=PG000002,server=clusterdevNode02/s3 2nd call: PG000002->partition=PG000002,server=clusterdevNode02/s3 3rd call: PG000002->partition=PG000002,server=clusterdevNode02/s3 Alias 1st call: PGALIAS000003->partitionAlias=PGALIAS000003,server=clusterdevNode 01/s2 Alias 2nd call: PGALIAS000003->partitionAlias=PGALIAS000003,server=clusterdevNode 01/s2 Alias 3rd call: PGALIAS000003->partitionAlias=PGALIAS000003,server=clusterdevNode 01/s2 Alias 4th call: PGALIAS000003->partitionAlias=PGALIAS000003,server=clusterdevNode 01/s2 Alias 5th call: PGALIAS000003->partitionAlias=PGALIAS000003,server=clusterdevNode 01/s2 Alias 6th call: PGALIAS000003->partitionAlias=PGALIAS000003,server=clusterdevNode 01/s2 1st call: PG000004->partition=PG000004,server=clusterdevNode01/s2 2nd call: PG000004->partition=PG000004,server=clusterdevNode01/s2 3rd call: PG000004->partition=PG000004,server=clusterdevNode01/s2 1st call: PG000007->partition=PG000007,server=clusterdevNode01/s1 2nd call: PG000007->partition=PG000007,server=clusterdevNode01/s1 3rd call: PG000007->partition=PG000007,server=clusterdevNode01/s1 Alias 1st call: PGALIAS000004->partitionAlias=PGALIAS000004,server=clusterdevNode 01/s1 Alias 2nd call: PGALIAS000004->partitionAlias=PGALIAS000004,server=clusterdevNode 01/s1 Alias 3rd call: PGALIAS000004->partitionAlias=PGALIAS000004,server=clusterdevNode 01/s1 Alias 4th call: PGALIAS000004->partitionAlias=PGALIAS000004,server=clusterdevNode 01/s1 Alias 5th call: PGALIAS000004->partitionAlias=PGALIAS000004,server=clusterdevNode 01/s1 Alias 6th call: PGALIAS000004->partitionAlias=PGALIAS000004,server=clusterdevNode 01/s1 1st call: PG000003->partition=PG000003,server=clusterdevNode02/s3 2nd call: PG000003->partition=PG000003,server=clusterdevNode02/s3 3rd call: PG000003->partition=PG000003,server=clusterdevNode02/s3 1st call: PG000005->partition=PG000005,server=clusterdevNode01/s2 2nd call: PG000005->partition=PG000005,server=clusterdevNode01/s2 3rd call: PG000005->partition=PG000005,server=clusterdevNode01/s2 Alias 1st call: PGALIAS000005->partitionAlias=PGALIAS000005,server=clusterdevNode 01/s1 Alias 2nd call: PGALIAS000005->partitionAlias=PGALIAS000005,server=clusterdevNode 01/s1 Alias 3rd call: PGALIAS000005->partitionAlias=PGALIAS000005,server=clusterdevNode 01/s1 Alias 4th call: PGALIAS000005->partitionAlias=PGALIAS000005,server=clusterdevNode 01/s1 Alias 5th call: PGALIAS000005->partitionAlias=PGALIAS000005,server=clusterdevNode 01/s1 Alias 6th call: PGALIAS000005->partitionAlias=PGALIAS000005,server=clusterdevNode 01/s1 1st call: PG000009->partition=PG000009,server=clusterdevNode01/s1 2nd call: PG000009->partition=PG000009,server=clusterdevNode01/s1 3rd call: PG000009->partition=PG000009,server=clusterdevNode01/s1 C:\hao\xd6\bin>
Related concepts
Was ist ein Partitionsalias?