Class HealthCenterFactory

java.lang.Object
com.ibm.java.diagnostics.healthcenter.api.factory.HealthCenterFactory

public class HealthCenterFactory extends Object
This is entry point into the Health Center API code. From here, you can either load a previously saved file, or connect to a running application that has the Health Center agent attached to it. By default, the Health Center agent listens on port 1972.
  • Constructor Details

    • HealthCenterFactory

      public HealthCenterFactory()
  • Method Details

    • connect

      public static HealthCenter connect(File filename) throws HealthCenterException, FileNotFoundException
      Loads a previously created Health Center .hcd file. This will not return until the file has been completely loaded. This ensures that all the data has been loaded and processed. Note. Memory restrictions are disabled when loading an hcd file
      Parameters:
      filename - - the file to load.
      Returns:
      a HealthCenter object, which provides access to all the data in the specified file.
      Throws:
      HealthCenterException
      FileNotFoundException
    • connect

      Make a connection to the current process, i.e. monitor yourself. This does not require any network ports to be opened but can be allowing other Health Center clients to also monitor the same application Health Center agent. By default, launching the agent with -Xhealthcenter will allow an inprocess connection. If you do not require any other ports to be open, specify -Xhealthcenter:level=inprocess
      Returns:
      a HealthCenter object which provides access to all the data in the specified file.
      Throws:
      HealthCenterException
      HealthCenterJMXException
      HealthCenterSSLException
    • connect

      Connects to and monitors a running application that was started with the Health Center agent attached.
      Parameters:
      props - a ConnectionProperties object, which contains details of what to connect to.
      Returns:
      a HealthCenter object which provides access to all the data in the specified file.
      Throws:
      HealthCenterException
      HealthCenterJMXException
      HealthCenterSSLException
    • connect

      Connects to and monitors a running application that was started with the Health Center agent attached.
      Parameters:
      props - a ConnectionProperties object, which contains details of what to connect to.
      autoScan - set to true if you want to connect to the first available agent.
      Returns:
      a HealthCenter object which provides access to all the data in the specified file.
      Throws:
      HealthCenterException
      HealthCenterJMXException
      HealthCenterSSLException
    • connect

      Connects to and monitors a running application that was started with the named Health Center agent attached. The name of the Health Center Agent can be found by using the scanForAgents method.
      Parameters:
      props - a ConnectionProperties object, which contains details of what to connect to.
      agentName - the name of the agent to connect to
      Returns:
      a HealthCenter object which provides access to all the data in the specified file.
      Throws:
      HealthCenterException
      HealthCenterJMXException
      HealthCenterSSLException
    • scanForPort

      public static int[] scanForPort(ConnectionProperties props, int numberOfScans, boolean stopWhenFound) throws HealthCenterException
      This method scans a group of ports for available agents that are running.
      Parameters:
      props - this object contains information such as the host to search and the starting port.
      numberOfScans - the number of ports to scan. The more scans that are made, the longer this process takes.
      stopWhenFound - setting this to true stops the scan after the first agent is found.
      Returns:
      an int array, representing ports that have Health Center agents listening on.
      Throws:
      HealthCenterException
    • scanForAgents

      public static String[] scanForAgents(ConnectionProperties props, int numberOfAgents) throws HealthCenterException
      This method returns the names of the available agents that are running on a specific connection and is mainly used when searching for multiple agents that are all connected to a single MQTT broker.
      Parameters:
      props - this object contains the hostname and port to search on
      numberOfAgents - the maximum number of agent names to return but you will get less if fewer agents are available. The larger the number, the longer this process takes. To bring back all agent names, enter 0.
      Returns:
      a String array, representing the names of the HealthCenter agents discovered.
      Throws:
      HealthCenterException
    • setMemoryRestrictionSize

      public static void setMemoryRestrictionSize(long userMemoryRestrictionSize)
      Sets the maximum amount of memory to be used by the Health Center process when connecting a .hcd file. This method must be called before connecting to the file to ensure the memory restriction is set as requested. If not called before connecting or if the value is not larger than the default of 200mb then the default is used instead.
      Parameters:
      userMemoryRestrictionSize - - the value of the memory to use, in bytes.
    • setMemoryRestictionEnabled

      public static void setMemoryRestictionEnabled(boolean enableMemoryRestriction)
      Sets whether to set memory restriction on or off. The default is ON. This value makes the Health Center process restrict the amount of memory that it uses.
      Parameters:
      enableMemoryRestriction - true or false