En el método getPartitions de bean de sesión sin estado particionado (PSSB), puede asignar el mismo alias de partición a varias particiones, que crea un contexto de grupo de particiones para un conjunto de particiones.
En el ejemplo siguiente (WPFPartitionGroupingSample.ear), el número de grupos de particiones es la mitad (1/2) del número de particiones. Cada grupo de particiones contiene dos particiones.
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)); } }
El archivo WPFPartitionGroupingSample.ear contiene el código fuente. D_WPFPartitionGroupingSample.ear es un archivo ear desplegado.
launchClient D_WPFPartitionGroupingSample.ear -CCBootstrapPort=9813
Se producirá el código siguiente:
IBM WebSphere Application Server, Release 6.0 J2EE Application Client Tool Copyright IBM Corp., 1997-2004 WSCL0012I: Procesando argumentos de línea de mandatos. WSCL0013I: Inicializando J2EE Application Client Environment. **************************************** ClientComponentImpl.initialize() **************************************** **************************************** ClientComponentImpl.start() **************************************** WSCL0035I: La inicialización de J2EE Application Client Environment ha finalizado. WSCL0014I: Invocando la clase de Cliente de aplicaciones com.ibm.websphere.wpf.grouping. client.WPFPartitionGroupingClient PartionAlias Context Routing Sample has 10 partitions PartionAlias Context Routing Sample has 5 alias Partition alias groups different partitions and router does WLM for each alias t hat has more than 1 partitions. This sample shows that alias context will be routed into 2 different (even and o dd) 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
¿Qué es un
alias de partición?