com.ibm.broker.config.proxy

Class LocalBrokerUtilities

  • java.lang.Object
    • com.ibm.broker.config.proxy.LocalBrokerUtilities


  • public class LocalBrokerUtilities
    extends java.lang.Object

    A collection of static utilities for querying and configuring local brokers and Message Broker runtime installations.

    com.ibm.broker.config.proxy.LocalBrokerUtilities

    Responsibilities A collection of static utilities for querying and configuring local brokers and Message Broker runtime installations.
    Internal Collaborators None
     Change Activity:
     -------- ----------- -------------   ------------------------------------
     Reason:  Date:       Originator:     Comments:
     -------- ----------- -------------   ------------------------------------
     55019    2009-06-22  HDMPL           v7 Release
     61433    2011-06-23  HDCAB           v8 Release
                                          - added getAllLocalBrokerInstallations()
                                          - added getNumberOfLocalBrokerInstallations()
     
     
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static void cacheBroker(java.lang.String brokerName)
      Pre-loads configuration information for the broker with the supplied name, for use by subsequent LocalBrokerUtilities method invocations.
      static void clearCache()
      Removes any information that the IBM Integration API (CMP) application has cached relating to local brokers.
      static java.util.HashMap<java.lang.String,java.util.Vector<java.lang.String>> getAllLocalBrokerInstallLocations()
      Returns a HashMap that describes the installation locations of all the IBM Integration Bus and WebSphere Message Broker installations on the local machine.
      static java.lang.String getBrokerHAEnabledWorkPath(java.lang.String brokerName)
      Returns the shared work-path for a multi-instance broker that is enabled for high availability support.
      static int getLocalBrokerFAD(java.lang.String brokerName)
      Returns the value of the formats and data (FAD) level for the broker with the supplied name.
      static java.util.HashMap<java.lang.String,java.lang.String> getLocalBrokerInstallLocations()
      Returns a HashMap that describes the first installation locations of all the IBM Integration Bus and WebSphere Message Broker versions on the local machine.
      static java.lang.String[] getLocalBrokerNames()
      Returns a String array containing the names of all the brokers that have been defined on the current machine.
      static java.lang.String[] getLocalBrokerNames(int minFAD, int maxFAD)
      Returns a String array containing the names of all the brokers within the supplied formats and data (FAD) range, that have been defined on the local machine.
      static int getLocalBrokerPID(java.lang.String brokerName)
      Returns the process identifier (PID) of the local broker with the supplied name.
      static java.lang.String getLocalBrokerQueueManagerName(java.lang.String brokerName)
      Returns the queue manager associated with the locally defined broker of the supplied name.
      static boolean getLocalBrokerWebAdminEnabled(java.lang.String brokerName)
      Returns true if the web administration server is enabled for the locally defined broker of the supplied name.
      static java.lang.String getLocalBrokerWebAdminPort(java.lang.String brokerName)
      Returns the httpconnector webadmin port associated with the locally defined broker of the supplied name.
      static java.lang.String getLocalBrokerWebAdminUri(java.lang.String brokerName)
      Returns the full web URI associated with the locally defined broker of the supplied name.
      static java.lang.String getLocalBrokerWindowsRegistryPath()
      Returns the value of the Windows registry path root, which holds all of the configuration information for all brokers on a Windows system.
      static java.lang.String getLocalBrokerWorkpath(java.lang.String brokerName)
      Returns the value of any non-default workpath for the broker with the supplied name.
      static int getNumberOfLocalBrokerInstallLocations()
      Returns the total number of IBM Integration Bus and WebSphere Message Broker installations on the local machine.
      static java.lang.String getVersionFromFAD(int fadLevel)
      Returns a version identifier given a supplied FAD level.
      static boolean isBrokerHAEnabled(java.lang.String brokerName)
      Returns a boolean value that indicates whether the broker is configured as multi-instance (for high availability support).
      static boolean isHABrokerQMgrInActiveMode(java.lang.String brokerName)
      Returns a boolean value that indicates whether a multi-instance broker is running in Active mode
      static boolean isHABrokerQMgrInStandByMode(java.lang.String brokerName)
      Returns a boolean value that indicates whether a multi-instance broker is running in Standby mode
      static boolean isHABrokerStartedAsMQService(java.lang.String brokerName)
      Returns true if a multi-instance broker will start as an MQ Service .
      static void saveLocalBrokerRegistry(java.lang.String brokerName, java.util.zip.ZipOutputStream zos)
      Writes to the supplied ZipOutputStream a copy of the registry that describes the configuration of the broker with the supplied name.
      static void setBrokerHAEnabledWorkPath(java.lang.String brokerName, java.lang.String newHAWorkPath)
      Sets the value of the shared workpath for the multi-instance broker with the supplied name.
      static void setLocalBrokerWorkpath(java.lang.String brokerName, java.lang.String newWorkPath)
      Sets the value of the workpath for the broker with the supplied name.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LocalBrokerUtilities

        public LocalBrokerUtilities()
    • Method Detail

      • getLocalBrokerNames

        public static java.lang.String[] getLocalBrokerNames()
                                                      throws ConfigManagerProxyLoggedException
        Returns a String array containing the names of all the brokers that have been defined on the current machine. All brokers of at least V7.0 are returned. If no local brokers are found, the array will contain no elements.
        Returns:
        String[] each element containing a broker name
        Throws:
        ConfigManagerProxyLoggedException - if the list of brokers could not be read
      • getLocalBrokerNames

        public static java.lang.String[] getLocalBrokerNames(int minFAD,
                                                             int maxFAD)
                                                      throws ConfigManagerProxyLoggedException
        Returns a String array containing the names of all the brokers within the supplied formats and data (FAD) range, that have been defined on the local machine. FAD levels typically correspond to major versions of IBM Integration Bus: FAD 8 = IIB 10; FAD 7 = IIB 9; FAD 6 = WMB 8.0; FAD 5 = WMB 7.0. For example, getLocalBrokerNames(6, -1) will return the names of all locally defined brokers of at least FAD 6 (version 8.0). If no local brokers are found that are within the supplied FAD range, the array will contain no elements.
        Parameters:
        minFAD - Minimum FAD level of brokers to return. Use -1 to signify no minimum FAD limit.
        maxFAD - Maximum FAD level of brokers to return. Use -1 to signify no maximum FAD limit.
        Returns:
        String[] each element containing a broker name
        Throws:
        ConfigManagerProxyLoggedException - if the list of brokers could not be read
      • getLocalBrokerWorkpath

        public static java.lang.String getLocalBrokerWorkpath(java.lang.String brokerName)
                                                       throws java.io.IOException
        Returns the value of any non-default workpath for the broker with the supplied name. This is the directory in the local filesystem that holds trace information and is the value supplied to the -w parameter of mqsicreatebroker.

        If the value of the workpath is the installation-wide default, null is returned. If a broker of the supplied name cannot be found, an IO exception will be thrown. The broker need not be running in order for this method to succeed.

        Parameters:
        brokerName - name of a locally defined broker
        Returns:
        String workPath location for the broker
        Throws:
        java.io.IOException - if the broker's configuration could not be read
      • setLocalBrokerWorkpath

        public static void setLocalBrokerWorkpath(java.lang.String brokerName,
                                                  java.lang.String newWorkPath)
                                           throws java.io.IOException
        Sets the value of the workpath for the broker with the supplied name. This is the directory in the local filesystem that holds trace information and is the value supplied to the -w parameter of mqsicreatebroker. If a broker of the supplied name cannot be found, an IO exception will be thrown. The broker need not be running in order for this method to succeed.
        Parameters:
        brokerName - name of a locally defined broker
        newWorkPath - new workpath
        Throws:
        java.io.IOException - if the broker's configuration could not be written
      • getLocalBrokerWindowsRegistryPath

        public static java.lang.String getLocalBrokerWindowsRegistryPath()
                                                                  throws java.io.IOException
        Returns the value of the Windows registry path root, which holds all of the configuration information for all brokers on a Windows system. This is the the value of the MQSI_DEVELOPMENT variable, if set and valid, or SOFTWARE\\IBM\\WebSphereMQIntegrator\\2 for 32-bit Windows or SOFTWARE\\Wow6432Node\\IBM\\WebSphereMQIntegrator\\2 for 64-bit Windows for non-administrator users.

        If this method is called on non-Windows platforms or the windows registry cannot be located, null is returned.

        Throws:
        java.io.IOException - if the broker's configuration could not be read
      • clearCache

        public static void clearCache()
        Removes any information that the IBM Integration API (CMP) application has cached relating to local brokers. Information stored in the broker registry typically does not change, and the LocalBrokerUtilities class caches much of this information in order to improve performance. This means that multiple method calls will return identical information, even if the information from the registry changes. However, calling this method guarantees that the next method call to a LocalBrokerUtilities method relating to the supplied broker name will come directly from the broker registry.
      • cacheBroker

        public static void cacheBroker(java.lang.String brokerName)
        Pre-loads configuration information for the broker with the supplied name, for use by subsequent LocalBrokerUtilities method invocations. This method can be used to improve performance of subsequent calls to the LocalBrokerUtilities methods, although it means that the methods will return out-of-date information if the broker's configuration changes within the lifetime of this application. Use clearCache() to remove any cached configuration.

        If a broker of the supplied name cannot be found, this method does nothing.

        Parameters:
        brokerName - Name of the broker whose configuration is to be cached.
      • getLocalBrokerFAD

        public static int getLocalBrokerFAD(java.lang.String brokerName)
                                     throws java.io.IOException
        Returns the value of the formats and data (FAD) level for the broker with the supplied name. FAD levels typically correspond to major versions of IBM Integration Bus : FAD 7 = IIB 9; FAD 6 = WMB 8.0; FAD 5 = WMB 7.0; FAD 4 = WMB 6.1; FAD 3 = WMB 6.0. Use getVersionFromFAD() to convert FAD levels into more readily recognisable version identifiers.

        If a broker of the supplied name cannot be found, an IOException will be thrown. The broker need not be running in order for this method to succeed.

        Parameters:
        brokerName - name of a locally defined broker
        Returns:
        int FAD level
        Throws:
        java.io.IOException - if the broker's configuration could not be read or if the broker does not exist.
      • getVersionFromFAD

        public static java.lang.String getVersionFromFAD(int fadLevel)
        Returns a version identifier given a supplied FAD level. After using getLocalBrokerFAD(String) to discover a local broker's format and data (FAD) level, this method can be used to convert that int into a version identifier that is more readily recognisable.

        The format of the returned string is "V.R.M.F" which denotes the version identifier for brokers of the supplied FAD. Right-most characters will be omitted if the supplied FAD can correspond to more than one level. For example, if fadLevel is '8' the returned String is "10.0", as this FAD can be used to describe brokers at any 10.x.x.x version.

        If the supplied FAD does not correspond to a level known by this level of IBM Integration API (CMP), this method returns the empty string.

        For more detailed version information, connect to the broker and use BrokerProxy.getBrokerVersion() or BrokerProxy.getBrokerLongVersion().

        Parameters:
        fadLevel - int describing a FAD level
        Returns:
        String version identifier, or the empty string
      • getLocalBrokerQueueManagerName

        public static java.lang.String getLocalBrokerQueueManagerName(java.lang.String brokerName)
                                                               throws java.io.IOException
        Returns the queue manager associated with the locally defined broker of the supplied name.

        If a broker of the supplied name cannot be found, an IOException will be thrown. The broker need not be running in order for this method to succeed.

        Parameters:
        brokerName - name of a locally defined broker
        Returns:
        String queue manager name
        Throws:
        java.io.IOException - if the broker's configuration could not be read or if the broker does not exist.
      • getLocalBrokerWebAdminPort

        public static java.lang.String getLocalBrokerWebAdminPort(java.lang.String brokerName)
                                                           throws java.io.IOException
        Returns the httpconnector webadmin port associated with the locally defined broker of the supplied name.

        If a broker of the supplied name cannot be found, an IOException will be thrown. The broker need not be running in order for this method to succeed.

        Parameters:
        brokerName - name of a locally defined broker
        Returns:
        String port number that is used for http connection
        Throws:
        java.io.IOException - if the broker's configuration could not be read or if the broker does not exist.
      • getLocalBrokerWebAdminUri

        public static java.lang.String getLocalBrokerWebAdminUri(java.lang.String brokerName)
                                                          throws java.io.IOException
        Returns the full web URI associated with the locally defined broker of the supplied name.

        If a broker of the supplied name cannot be found, an IOException will be thrown. The broker need not be running in order for this method to succeed.

        Parameters:
        brokerName - name of a locally defined broker
        Returns:
        String uri that the broker will use for configuration.
        Throws:
        java.io.IOException - if the broker's configuration could not be read or if the broker does not exist.
      • getLocalBrokerWebAdminEnabled

        public static boolean getLocalBrokerWebAdminEnabled(java.lang.String brokerName)
                                                     throws java.io.IOException
        Returns true if the web administration server is enabled for the locally defined broker of the supplied name.

        If a broker of the supplied name cannot be found, an IOException will be thrown. The broker need not be running in order for this method to succeed.

        Parameters:
        brokerName - name of a locally defined broker
        Returns:
        boolean true if the web administration server is enabled, false otherwise.
        Throws:
        java.io.IOException - if the broker's configuration could not be read or if the broker does not exist.
      • isHABrokerStartedAsMQService

        public static boolean isHABrokerStartedAsMQService(java.lang.String brokerName)
                                                    throws java.io.IOException
        Returns true if a multi-instance broker will start as an MQ Service . Otherwise returns false.
        Parameters:
        brokerName - name of a locally defined broker
        Returns:
        boolean . True = will start as an MQ Service
        Throws:
        java.io.IOException - if the broker's configuration could not be read or if the broker does not exist.
      • getLocalBrokerPID

        public static int getLocalBrokerPID(java.lang.String brokerName)
                                     throws java.io.IOException
        Returns the process identifier (PID) of the local broker with the supplied name. This method can be used to detect whether a broker is running without attempting to connect to it, as this method returns 0 if the broker is not running.

        This method returns the PID of the broker's controlling process ("bipbroker"). If this process terminates uncleanly, this method might then return a non-zero value even though the broker is no longer running. For additional confirmation that the broker is running, you could correlate the returned PID with tasklist (on Windows) or ps (on UNIX) to ensure that a process with the returned PID is still running, and has a task name of "bipbroker".

        The broker need not be running in order for this method to succeed. However, if a broker of the supplied name cannot be found, an IOException will be thrown.

        Parameters:
        brokerName - name of a locally defined broker
        Returns:
        int Process ID, or 0 if the broker is not running.
        Throws:
        java.io.IOException - if the broker's configuration could not be read or if the broker does not exist.
      • saveLocalBrokerRegistry

        public static void saveLocalBrokerRegistry(java.lang.String brokerName,
                                                   java.util.zip.ZipOutputStream zos)
                                            throws java.io.IOException
        Writes to the supplied ZipOutputStream a copy of the registry that describes the configuration of the broker with the supplied name.

        If the method is called from a Windows platform, the data is written as a single file in the Windows Registry Editor 5.0 .reg format. The name of the file is the value of brokerName with a ".reg" file extension. On all other platforms, the registry data is copied into the Zip file as a set of files, the structure matching the /var/mqsi/registry/BROKERNAME format that the broker uses.

        The output stream is left open on exit from this method.

        If a broker of the supplied name cannot be found, an IOException will be thrown. The broker need not be running in order for this method to succeed.

        Parameters:
        brokerName - name of a locally defined broker
        zos - ZipOutputStream to which the registry will be written.
        Throws:
        java.io.IOException - if the broker's configuration could not be read from the registry or written to the ZipOutputStream.
      • getAllLocalBrokerInstallLocations

        public static java.util.HashMap<java.lang.String,java.util.Vector<java.lang.String>> getAllLocalBrokerInstallLocations()
                                                                                                                        throws java.io.IOException
        Returns a HashMap that describes the installation locations of all the IBM Integration Bus and WebSphere Message Broker installations on the local machine. Each element of the returned hashtable describes one or more Message Broker runtime installations. The key is the instance name, typically the version identifier (e.g. "7.0.0.0") and the value is the install location for that instance (e.g. "C:\Program Files\IBM\MQSI\7.0"). If Message Broker is not installed, or if the method is called from a z/OS platform, the HashMap will contain no values.

        This installation information is discovered on demand from the local filesystem and is not cached. Frequent calls to this method might impact performance.

        Returns:
        HashMap> that describes the installed runtimes.
        Throws:
        java.io.IOException - if the list of install locations could not be read.
      • getLocalBrokerInstallLocations

        public static java.util.HashMap<java.lang.String,java.lang.String> getLocalBrokerInstallLocations()
                                                                                                   throws java.io.IOException
        Returns a HashMap that describes the first installation locations of all the IBM Integration Bus and WebSphere Message Broker versions on the local machine. Each element of the returned hashtable describes a single Message Broker runtime installation. The key is the instance name, typically the version identifier (e.g. "7.0.0.0") and the value is the install location for that instance (e.g. "C:\Program Files\IBM\MQSI\7.0"). If Message Broker is not installed, or if the method is called from a z/OS platform, the HashMap will contain no values. If multiple installs exist for a single version then the getAllLocalBrokerInstallLocations() method should be used.

        This installation information is discovered on demand from the local filesystem and is not cached. Frequent calls to this method might impact performance.

        Returns:
        HashMap that describes the installed runtimes.
        Throws:
        java.io.IOException - if the list of install locations could not be read.
      • getNumberOfLocalBrokerInstallLocations

        public static int getNumberOfLocalBrokerInstallLocations()
                                                          throws java.io.IOException
        Returns the total number of IBM Integration Bus and WebSphere Message Broker installations on the local machine.
        Returns:
        int the total number of IBM Integration Bus and WebSphere Message Broker installs
        Throws:
        java.io.IOException - if the list of install locations could not be read.
      • isBrokerHAEnabled

        public static boolean isBrokerHAEnabled(java.lang.String brokerName)
                                         throws java.io.IOException
        Returns a boolean value that indicates whether the broker is configured as multi-instance (for high availability support).
        Parameters:
        brokerName - name of a locally defined broker
        Returns:
        boolean true only if the broker is configured for multi-instance operation
        Throws:
        java.io.IOException - if the list of install locations could not be read.
      • isHABrokerQMgrInActiveMode

        public static boolean isHABrokerQMgrInActiveMode(java.lang.String brokerName)
                                                  throws java.io.IOException
        Returns a boolean value that indicates whether a multi-instance broker is running in Active mode
        Parameters:
        brokerName - name of a locally defined broker
        Returns:
        boolean true only if the broker is configured for multi-instance operation AND that the broker is currently active.
        Throws:
        java.io.IOException - if the list of install locations could not be read.
      • isHABrokerQMgrInStandByMode

        public static boolean isHABrokerQMgrInStandByMode(java.lang.String brokerName)
                                                   throws java.io.IOException
        Returns a boolean value that indicates whether a multi-instance broker is running in Standby mode
        Parameters:
        brokerName - name of a locally defined broker
        Returns:
        boolean true only if the broker is configured for multi-instance operation AND that the broker is currently in standby mode.
        Throws:
        java.io.IOException - if the list of install locations could not be read.
      • getBrokerHAEnabledWorkPath

        public static java.lang.String getBrokerHAEnabledWorkPath(java.lang.String brokerName)
                                                           throws java.io.IOException
        Returns the shared work-path for a multi-instance broker that is enabled for high availability support.
        Parameters:
        brokerName - name of a locally defined broker
        Returns:
        String shared work-path for the multi-instance broker
        Throws:
        java.io.IOException - if the list of install locations could not be read.
      • setBrokerHAEnabledWorkPath

        public static void setBrokerHAEnabledWorkPath(java.lang.String brokerName,
                                                      java.lang.String newHAWorkPath)
                                               throws java.io.IOException
        Sets the value of the shared workpath for the multi-instance broker with the supplied name. This is the property in the local registry that holds a value of the path to the shared registry that was specified using the -e parameter of mqsicreatebroker. If a broker of the supplied name cannot be found, an IO exception will be thrown. The broker need not be running in order for this method to succeed.
        Parameters:
        brokerName - name of a locally defined broker instance
        newHAWorkPath - new shared workpath for the multi-instance broker
        Throws:
        java.io.IOException - if the broker's configuration could not be written