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


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


Partitioning facility PMI client programming

This section describes how to subscribe to the partitioning facility (WPF) PMI statistics. For additional information describing how to enable this infrastructure, see the management section.

To include reportTransactionComplete(....) in the application, see the partitioned stateless session bean (PSSB) programming section.


Subscribe partitioning facility PMI statistics using WPFJMX MBean

Instead of using the wpfadmin tool, you can also use WPFJMX MBean to subscribe partitioning facility PMI. The following section describes ways to get the MBean instance.


Subscribe partitioning facility PMI statistics using Java code

Here is an example of how to subscribe and unsubscribe partitioning facility PMI statistics using Java™ code. You can modify them to change statistics types, ranges, etc.

package com.ibm.websphere.wpf.jmx;

import java.util.Properties;
import java.util.Set;

import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.ReflectionException;

import com.ibm.websphere.management.AdminClient;
import com.ibm.websphere.management.AdminClientFactory;
import com.ibm.websphere.management.exception.ConnectorException;

/**
 * Creates a node scoped resource.xml entry for a DB2 XA datasource.
 * The datasource created is for CMP use.
 * 
 * You need following to run with the classpath 
 * $WAS_HOME\lib\admin.jar;
 * $WAS_HOME\lib\wasjmx.jar;
 * $WAS_HOME\lib\wasx.jar
 */
public class PMIJMXSample {

    /**
     * Main method.
     * arg[0] is the connection type, such as SOAP.
     * arg[1] is the connection host, such as localhost.
     * arg[2] is the connections port, such as 8879
     * arg[3] is the optional process. Default is Deployment Manager
     */
    public static void main(String[] args)
        throws
            MalformedObjectNameException,
            ConnectorException,
            MBeanException,
            ReflectionException,
            InstanceNotFoundException {

        System.out.println("Sample starts");

        // Initialize the AdminClient.
        String connectorType = args[0];
        String connectorHost = args[1];
        String connectorPort = args[2];

        String jmxServer = "Deployment Manager";
        if (args.length >= 4) {
            jmxServer = args[3];
        }

        Properties adminProps = new Properties();
        adminProps.setProperty(AdminClient.CONNECTOR_TYPE, connectorType);
        adminProps.setProperty(AdminClient.CONNECTOR_HOST, connectorHost);
        adminProps.setProperty(AdminClient.CONNECTOR_PORT, connectorPort);
        AdminClient adminClient = AdminClientFactory.createAdminClient(adminProps);

        ObjectName queryName = new ObjectName("WebSphere:type=WPF,process=" 
        + jmxServer + ",*");

        ObjectName wpfJMX = null;
        Set s = adminClient.queryNames(queryName, null);
        if (!s.isEmpty()) {
            wpfJMX = (ObjectName) s.iterator().next();
        }
        else {
            System.out.println("WPF JMX MBean was not found");
            System.exit(0);
        }

        String subscribeWPFPMIName = "subscribeWPFPMI";
        String[] subscribeSignatures =
            new String[] {
                "java.lang.String",
                "java.lang.String",
                "java.lang.Integer",
                "java.lang.Integer",
                "java.lang.Integer",
                "java.lang.Integer" };
        Object[] subscribeParams =
            new Object[] {
                "WPFKeyBasedPartitionSample",
                "WPFKeyBasedPartition",
                new Integer(0),
                new Integer(1),
                new Integer(5),
                new Integer(60000)};

        // invoke the subscribeWPFPMI method
        Long id = (Long) adminClient.invoke(wpfJMX, subscribeWPFPMIName, 
        subscribeParams, subscribeSignatures);

        System.out.println("Subscription ID is " + id);

        String unsubscribeWPFPMIName = "unsubscribeWPFPMI";
        String[] unsubscribeSignatures = new String[] { "java.lang.Long" };
        Object[] unsubscribeParams = new Object[] { id };

        // invoke the unsubscribeWPFPMI method

        adminClient.invoke(wpfJMX, unsubscribeWPFPMIName, unsubscribeParams, 
        unsubscribeSignatures);

    }

}


Subscribe partitioning facility PMI statistics using Jacl code

Users can write a jacl script and then use the following to subscribe to partitioning facility PMI statistics.

wsamdin -f JACL_FILE

The following shows a Jacl example of subscribing and unsubscribing partitioning facility PMI:

# Jacl script to show how to subscribe and unsubscribe WPF PMI

# get WPF Mbean
set wpf [lindex [$AdminControl queryNames "type=WPF,process=Deployment Manager,*"] 
0]puts $wpf

# subscribe WPF PMI
set id [$AdminControl invoke $wpf subscribeWPFPMI "WPFKeyBasedPartitionSample 
WPFKeyBasedPartition 0 1 5 60000"]
puts $id        

# unsubscribe WPF PMI
$AdminControl invoke $wpf unsubscribeWPFPMI $id


Subscribe partitioning facility PMI statistics using Jython code

Users can write a jython script and then use the following command to subscribe to partitioning facility PMI statistics.

wsamdin -lang jython -f JYTHON_FILE

Following is a jython example of subscribing and unsubscribing partitioning facility PMI.

# Jython script to show how to subscribe and unsubscribe WPF PMI

# get WPF Mbean
strObjectName=AdminControl.queryNames("type=WPF,process=Deployment Manager,*")
objectName = AdminControl.makeObjectName(strObjectName)
wpf = TypedProxy.makeProxy(AdminControl, objectName, 
"com.ibm.websphere.wpf.jmx.WPFJMX")

# subscribe WPF PMI
id = wpf.subscribeWPFPMI("WPFKeyBasedPartitionSample", "WPFKeyBasedPartition",
0, 1, 5, 60000)
print id        

# unsubscribe WPF PMI
wpf.unsubscribeWPFPMI(id)


Parent topic:

Partitioning facility programming


Related concepts

Partitioning facility programming