Class JMXDriverConnectionWrapper

All Implemented Interfaces:
Serializable, AutoCloseable, JPPFAdminMBean, JPPFDriverAdminMBean

public class JMXDriverConnectionWrapper extends JMXConnectionWrapper implements JPPFDriverAdminMBean
Driver-specific JMX connection wrapper, implementing a user-friendly interface for the monitoring and management of a JPPF driver. Note that this class implements the interface JPPFDriverAdminMBean.
Author:
Laurent Cohen
See Also:
  • Constructor Details

    • JMXDriverConnectionWrapper

      public JMXDriverConnectionWrapper()
      Initialize a local connection to the MBean server.
    • JMXDriverConnectionWrapper

      public JMXDriverConnectionWrapper(MBeanServerConnection mbeanServer)
      Initialize a local connection to the MBean server.
      Parameters:
      mbeanServer - a connection to the mbean server to use.
    • JMXDriverConnectionWrapper

      public JMXDriverConnectionWrapper(String host, int port)
      Initialize a plain (non-secure) connection to the remote MBean server.
      Parameters:
      host - the host the server is running on.
      port - the port used by the server.
    • JMXDriverConnectionWrapper

      public JMXDriverConnectionWrapper(String host, int port, boolean secure)
      Initialize the connection to the remote MBean server.
      Parameters:
      host - the host the server is running on.
      port - the port used by the server.
      secure - specifies whether the connection should be established over SSL/TLS.
  • Method Details

    • nbNodes

      public Integer nbNodes() throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Get the number of nodes attached to the driver. Note that this method is equivalent to calling nbNodes(null).
      Specified by:
      nbNodes in interface JPPFDriverAdminMBean
      Returns:
      the number of nodes, or -1 if information on the nodes could not be retrieved. The returned number does not include peer drivers.
      Throws:
      Exception - if any error occurs.
    • nbNodes

      public Integer nbNodes(NodeSelector selector) throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Get the number of nodes attached to the driver that satisfy the specified selector.
      Specified by:
      nbNodes in interface JPPFDriverAdminMBean
      Parameters:
      selector - specifies which nodes shouyld be counted. If null, then NodeSelector.ALL_NODES will be used.
      Returns:
      the number of nodes, or -1 if information on the nodes could not be retrieved. The returned number does not include peer drivers.
      Throws:
      Exception - if any error occurs.
    • nodesInformation

      public Collection<JPPFManagementInfo> nodesInformation() throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Request the JMX connection information for all the nodes attached to the server. Note that this method is equivalent to calling nodesInformation(null, false).
      Specified by:
      nodesInformation in interface JPPFDriverAdminMBean
      Returns:
      a collection of JPPFManagementInfo instances, or null if information on the nodes could not be retrieved.
      Throws:
      Exception - if any error occurs.
    • nodesInformation

      public Collection<JPPFManagementInfo> nodesInformation(NodeSelector selector) throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Request the JMX connection information for all the nodes attached to the server which satisfy the specified selector. Note that this method is equivalent to calling nodesInformation(selector, false).
      Specified by:
      nodesInformation in interface JPPFDriverAdminMBean
      Parameters:
      selector - specifies which nodes shouyld be counted. If null, then NodeSelector.ALL_NODES will be used.
      Returns:
      a collection of JPPFManagementInfo instances, or null if information on the nodes could not be retrieved.
      Throws:
      Exception - if any error occurs.
    • nodesInformation

      public Collection<JPPFManagementInfo> nodesInformation(NodeSelector selector, boolean includePeers) throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Request the JMX connection information for all the nodes attached to the server which satisfy the specified selector.
      Specified by:
      nodesInformation in interface JPPFDriverAdminMBean
      Parameters:
      selector - specifies which nodes shouyld be counted. If null, then NodeSelector.ALL_NODES will be used.
      includePeers - whether peer drivers should be counted as nodes and included.
      Returns:
      a collection of JPPFManagementInfo instances, or null if information on the nodes could not be retrieved.
      Throws:
      Exception - if any error occurs.
    • statistics

      public JPPFStatistics statistics() throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Get the latest statistics snapshot from the JPPF driver.
      Specified by:
      statistics in interface JPPFDriverAdminMBean
      Returns:
      a JPPFStatistics instance.
      Throws:
      Exception - if any error occurs.
    • restartShutdown

      public String restartShutdown(Long shutdownDelay, Long restartDelay) throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Perform a shutdown or restart of the server.
      Specified by:
      restartShutdown in interface JPPFDriverAdminMBean
      Parameters:
      shutdownDelay - the delay before shutting down the server, once the command is received.
      restartDelay - the delay before restarting, once the server is shutdown. If it is < 0, no restart occurs.
      Returns:
      an acknowledgement message.
      Throws:
      Exception - if any error occurs.
    • changeLoadBalancerSettings

      public String changeLoadBalancerSettings(String algorithm, Map<Object,Object> parameters) throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Change the bundle size tuning settings.
      Specified by:
      changeLoadBalancerSettings in interface JPPFDriverAdminMBean
      Parameters:
      algorithm - the name opf the load-balancing algorithm to set.
      parameters - the algorithm's parameters.
      Returns:
      an acknowledgement or error message.
      Throws:
      Exception - if an error occurred while updating the settings.
    • loadBalancerInformation

      public LoadBalancingInformation loadBalancerInformation() throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Obtain the current load-balancing settings.
      Specified by:
      loadBalancerInformation in interface JPPFDriverAdminMBean
      Returns:
      an instance of LoadBalancingInformation.
      Throws:
      Exception - if an error occurred while fetching the settings.
    • cancelJob

      public void cancelJob(String jobId) throws Exception
      Cancel the job with the specified id.
      Parameters:
      jobId - the id of the job to cancel.
      Throws:
      Exception - if any error occurs.
    • suspendJob

      public void suspendJob(String jobId, Boolean requeue) throws Exception
      Suspend the job with the specified id.
      Parameters:
      jobId - the id of the job to suspend.
      requeue - true if the sub-jobs running on each node should be canceled and requeued, false if they should be left to execute until completion.
      Throws:
      Exception - if any error occurs.
    • resumeJob

      public void resumeJob(String jobId) throws Exception
      Resume the job with the specified id.
      Parameters:
      jobId - the id of the job to resume.
      Throws:
      Exception - if any error occurs.
    • updateMaxNodes

      public void updateMaxNodes(String jobId, Integer maxNodes) throws Exception
      Update the maximum number of nodes a node can run on.
      Parameters:
      jobId - the id of the job to update.
      maxNodes - the new maximum number of nodes for the job.
      Throws:
      Exception - if any error occurs.
    • updateJobPriority

      public void updateJobPriority(String jobId, Integer newPriority) throws Exception
      Update the priority of a job.
      Parameters:
      jobId - the id of the job to update.
      newPriority - the new priority of the job.
      Throws:
      Exception - if any error occurs.
    • getJobInformation

      public JobInformation getJobInformation(String jobId) throws Exception
      Get an object describing the job with the specified id.
      Parameters:
      jobId - the id of the job to get information about.
      Returns:
      an instance of JobInformation.
      Throws:
      Exception - if any error occurs.
    • getNodeInformation

      public NodeJobInformation[] getNodeInformation(String jobId) throws Exception
      Get a list of objects describing the nodes to which the whole or part of a job was dispatched.
      Parameters:
      jobId - the id of the job for which to find node information.
      Returns:
      an array of NodeManagementInfo, JobInformation instances.
      Throws:
      Exception - if any error occurs.
    • resetStatistics

      public void resetStatistics() throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Reset this server's statistics. This method triggers a reset() event via the JPPFDriverStatsManager instance.
      Specified by:
      resetStatistics in interface JPPFDriverAdminMBean
      Throws:
      Exception - if any error occurs.
    • systemInformation

      public JPPFSystemInformation systemInformation() throws Exception
      Description copied from interface: JPPFAdminMBean
      Get detailed information about the node's JVM properties, environment variables and runtime information such as memory usage and available processors.
      Specified by:
      systemInformation in interface JPPFAdminMBean
      Overrides:
      systemInformation in class JMXConnectionWrapper
      Returns:
      a JPPFSystemInformation instance.
      Throws:
      Exception - if any error occurs.
    • nbIdleNodes

      public Integer nbIdleNodes() throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Get the number of nodes currently idle. Note that this method is equivalent to calling nbIdleNodes(null).
      Specified by:
      nbIdleNodes in interface JPPFDriverAdminMBean
      Returns:
      the number of idle nodes, or -1 if information on the nodes could not be retrieved. The returned number does not include peer drivers.
      Throws:
      Exception - if any error occurs.
    • nbIdleNodes

      public Integer nbIdleNodes(NodeSelector selector) throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Get the number of idle nodes attached to the driver that satisfy the specified selector.
      Specified by:
      nbIdleNodes in interface JPPFDriverAdminMBean
      Parameters:
      selector - specifies which nodes should be counted. If null, then NodeSelector.ALL_NODES will be used.
      Returns:
      the number of idle nodes, or -1 if information on the nodes could not be retrieved. The returned number does not include peer drivers.
      Throws:
      Exception - if any error occurs.
    • nbIdleNodes

      public Integer nbIdleNodes(NodeSelector selector, boolean includePeers) throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Get the number of idle nodes attached to the driver that satisfy the specified selector.
      Specified by:
      nbIdleNodes in interface JPPFDriverAdminMBean
      Parameters:
      selector - specifies which nodes should be counted. If null, then NodeSelector.ALL_NODES will be used.
      includePeers - whether peer drivers should be counted as nodes and included.
      Returns:
      the number of idle nodes, or -1 if information on the nodes could not be retrieved. The returned number does not include peer drivers.
      Throws:
      Exception - if any error occurs.
    • idleNodesInformation

      public Collection<JPPFManagementInfo> idleNodesInformation() throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Request the JMX connection information for all the idle nodes attached to the server. Note that this method is equivalent to calling idleNodesInformation(null).
      Specified by:
      idleNodesInformation in interface JPPFDriverAdminMBean
      Returns:
      a collection of JPPFManagementInfo instances, or null if information on the nodes could not be retrieved.
      Throws:
      Exception - if any error occurs.
    • idleNodesInformation

      public Collection<JPPFManagementInfo> idleNodesInformation(NodeSelector selector) throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Request the JMX connection information for all the idle nodes attached to the server which satisfy the specified selector.
      Specified by:
      idleNodesInformation in interface JPPFDriverAdminMBean
      Parameters:
      selector - specifies which nodes shouyld be counted. If null, then NodeSelector.ALL_NODES will be used.
      Returns:
      a collection of JPPFManagementInfo instances, or null if information on the nodes could not be retrieved.
      Throws:
      Exception - if any error occurs.
    • toggleActiveState

      public void toggleActiveState(NodeSelector selector) throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Toggle the activate state of the specified nodes. Nodes in 'active' state will be deactivated, nodes in 'inactive' state will be activated.
      Specified by:
      toggleActiveState in interface JPPFDriverAdminMBean
      Parameters:
      selector - determines which nodes will be activated or deactivated. If null, then NodeSelector.ALL_NODES will be used.
      Throws:
      Exception - if any error occurs.
    • getActiveState

      public Map<String,Boolean> getActiveState(NodeSelector selector) throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Get the active states of the nodes specified vith a NodeSelector.
      Specified by:
      getActiveState in interface JPPFDriverAdminMBean
      Parameters:
      selector - specifies for which nodes to retrieve the active states. If null, then NodeSelector.ALL_NODES will be used.
      Returns:
      a mmaping of node uuids to their active state.
      Throws:
      Exception - if any error occurs.
    • setActiveState

      public void setActiveState(NodeSelector selector, boolean active) throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Set the active state of the specified nodes.
      Specified by:
      setActiveState in interface JPPFDriverAdminMBean
      Parameters:
      selector - determines which nodes will be activated or deactivated. If null, then NodeSelector.ALL_NODES will be used.
      active - specifies the activer state to set on the selected nodes.
      Throws:
      Exception - if any error occurs.
    • setBroadcasting

      public void setBroadcasting(boolean broadcasting) throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Activate or deactivate the broadcasting of the driver's connection information. if the broadcast is already in the desired state, this method has no effect.
      Specified by:
      setBroadcasting in interface JPPFDriverAdminMBean
      Parameters:
      broadcasting - true to activate the broadcast, false to deactivate it.
      Throws:
      Exception - if any error occurs.
    • getBroadcasting

      public boolean getBroadcasting() throws Exception
      Description copied from interface: JPPFDriverAdminMBean
      Determine whether the driver is broadcasting or not.
      Specified by:
      getBroadcasting in interface JPPFDriverAdminMBean
      Returns:
      true if the broadcasting service is on, false if it is off.
      Throws:
      Exception - if any error occurs.
    • registerForwardingNotificationListener

      public String registerForwardingNotificationListener(NodeSelector selector, String mBeanName, NotificationListener listener, NotificationFilter filter, Object handback) throws Exception
      Register a notification listener which will receive notifications from the specified MBean on the selected nodes.
      Parameters:
      selector - determines which nodes will be selected.
      mBeanName - the name of the MBean from which to receive notificaztions from the selected nodes.
      listener - the listener to register.
      filter - the notification filter.
      handback - the handback object.
      Returns:
      the id of the registered listener, to use with unregisterForwardingNotificationListener(String).
      Throws:
      Exception - if any error occurs.
    • unregisterForwardingNotificationListener

      public void unregisterForwardingNotificationListener(String listenerID) throws Exception
      Unregister a previously registered forwarding notification listeners.
      Parameters:
      listenerID - the id of a listener previously registered with registerForwardingNotificationListener(NodeSelector,String,NotificationListener,NotificationFilter,Object).
      Throws:
      Exception - if the listener with this id was not found or if any other error occurss.
    • unregisterAllForwardingNotificationListeners

      public List<String> unregisterAllForwardingNotificationListeners() throws Exception
      Uneregister all previously registered forwarding notification listener.
      Returns:
      a list of the ids of the listeners that were unregistered, if any. This list may be empty but never null.
      Throws:
      Exception - if any error occurs.
    • forwardInvoke

      public Map<String,Object> forwardInvoke(NodeSelector selector, String name, String methodName, Object[] params, String[] signature) throws Exception
      Deprecated.
      Invoke a method on the specified MBean of all nodes attached to the driver.
      Parameters:
      selector - a filter on the nodes attached tot he driver, determines the nodes to which this method applies.
      name - the name of the MBean.
      methodName - the name of the method to invoke.
      params - the method parameter values.
      signature - the types of the method parameters.
      Returns:
      a mapping of node uuids to the result of invoking the MBean method on the corresponding node. Each result may be an exception.
      Additionally, each result may be null, in particular if the invoked method has a void return type.
      Throws:
      Exception - if the invocation failed.
    • forwardInvoke

      public Map<String,Object> forwardInvoke(NodeSelector selector, String name, String methodName) throws Exception
      Deprecated.
      use getForwarder().forwardInvoke(selector, name, methodName) instead. Thsis method always returns null.
      Convenience method to invoke an MBean method that has no parameter.
      This is equivalent to calling forwardInvoke(selector, name, methodName, (Object[]) null, (String[]) null).
      Parameters:
      selector - a filter on the nodes attached to the driver, determines the nodes to which this method applies.
      name - the name of the node MBean to invoke.
      methodName - the name of the method to invoke.
      Returns:
      a mapping of node uuids to the result of invoking the MBean method on the corresponding node. Each result may be an exception.
      Additionally, each result may be null, in particular if the invoked method has a void return type.
      Throws:
      Exception - if the invocation failed.
    • forwardGetAttribute

      public Map<String,Object> forwardGetAttribute(NodeSelector selector, String name, String attribute) throws Exception
      Deprecated.
      use getForwarder().forwardGetAttribute(selector, name, attribute) instead. Thsis method always returns null.
      Get the value of an attribute of the specified MBean for each specified node.
      Parameters:
      selector - a filter on the nodes attached tot he driver, determines the nodes to which this method applies.
      name - the name of the MBean to invoke for each node.
      attribute - the name of the MBean attribute to read.
      Returns:
      a mapping of node uuids to the result of getting the MBean attribute on the corresponding node. Each result may be an exception.
      Throws:
      Exception - if the invocation failed.
    • forwardSetAttribute

      public Map<String,Object> forwardSetAttribute(NodeSelector selector, String name, String attribute, Object value) throws Exception
      Deprecated.
      use getForwarder().forwardSetAttribute(selector, name, attribute, value) instead. Thsis method always returns null.
      Set the value of an attribute of the specified MBean on the specified nodes attached to the driver.
      Parameters:
      selector - a filter on the nodes attached to the driver, determines the nodes to which this method applies.
      name - the name of the MBean to invoke for each node.
      attribute - the name of the MBean attribute to set.
      value - the value to set on the attribute.
      Returns:
      a mapping of node uuids to an eventual exception resulting from setting the MBean attribute on the corresponding node. This map may be empty if no exception was raised.
      Throws:
      Exception - if the invocation failed.
    • getForwarder

      public NodeForwardingMBean getForwarder() throws Exception
      This convenience method creates a proxy to the driver's mbean which forwards requests to its nodes. It is equivalent to calling the more cumbersome getProxy(NodeForwardingMBean.MBEAN_NAME, NodeForwardingMBean.class).
      Returns:
      an instance of NodeForwardingMBean.
      Throws:
      Exception - if a proxy could not be created for any reason.
      Since:
      4.2
    • getNodeForwarder

      public JPPFNodeForwardingMBean getNodeForwarder() throws Exception
      Deprecated.
      use getForwarder() instead. Thsis method always returns null.
      This convenience method creates a proxy to the driver's mbean which forwards requests to its nodes. It is equivalent to calling the more cumbersome getProxy(JPPFNodeForwardingMBean.MBEAN_NAME, JPPFNodeForwardingMBean.class).
      Returns:
      an instance of JPPFNodeForwardingMBean.
      Throws:
      Exception - if a proxy could not be created for any reason.
      Since:
      4.2
    • getJobManager

      public DriverJobManagementMBean getJobManager() throws Exception
      This convenience method creates a proxy to the driver's mbean which manages and monitors jobs. It is equivalent to calling the more cumbersome getProxy(DriverJobManagementMBean.MBEAN_NAME, DriverJobManagementMBean.class).
      Returns:
      an instance of DriverJobManagementMBean.
      Throws:
      Exception - if a proxy could not be created for any reason.
      Since:
      4.2
    • getPersistedJobsManager

      public PersistedJobsManagerMBean getPersistedJobsManager() throws Exception
      This convenience method creates a proxy to the driver's mbean which manages persisted jobs. It is equivalent to calling the more cumbersome getProxy(PersistedJobsManagerMBean.MBEAN_NAME, PersistedJobsManagerMBean.class).
      Returns:
      an instance of PersistedJobsManagerMBean.
      Throws:
      Exception - if a proxy could not be created for any reason.
    • getLoadBalancerPersistenceManagement

      public LoadBalancerPersistenceManagement getLoadBalancerPersistenceManagement() throws Exception
      This convenience method creates a proxy to the driver's mbean that manages the load-balancers persisted states. It is equivalent to calling the more cumbersome getProxy(LoadBalancerPersistenceManagerMBean.MBEAN_NAME, LoadBalancerPersistenceManagerMBean.class).
      Returns:
      an instance of PersistedJobsManagerMBean.
      Throws:
      Exception - if a proxy could not be created for any reason.
      Since:
      6.0
    • getDiagnosticsProxy

      public DiagnosticsMBean getDiagnosticsProxy() throws Exception
      Description copied from class: JMXConnectionWrapper
      Get a proxy to the diagnostics/JVM health MBean.
      Overrides:
      getDiagnosticsProxy in class JMXConnectionWrapper
      Returns:
      a DiagnosticsMBean instance.
      Throws:
      Exception - if any error occurs.
    • getJobDependencyManager

      public JobDependencyManagerMBean getJobDependencyManager() throws Exception
      Get a proxy to the dependency manager MBean in the driver. This is a shortcut method for getProxy(JobDependencyManagerMBean.MBEAN_NAME, JobDependencyManagerMBean.class).
      Returns:
      an instance of an implementation of the JobDependencyManagerMBean interface.
      Throws:
      Exception - if any error occurs.
      Since:
      6.2
    • getMBeanForwarder

      public <E extends AbstractMBeanForwarder> E getMBeanForwarder(Class<?> mbeanInterface) throws Exception
      Create a forwarding proxy for the specified node MBean.
      Type Parameters:
      E - the type of mbean interface.
      Parameters:
      mbeanInterface - the class of the node MBean nterface.
      Returns:
      a forwarding proxy to the specified MBean.
      Throws:
      Exception - if any error occurs.
      Since:
      6.2