我正在使用Jenkins和JPPF进行项目。
如何获得哪个节点连接到JPPF服务器?如有可能,请给我详细的指导原则。
谢谢,

最佳答案

免责声明:JPPF开发人员在此处。

您可以使用JMX-based server management APIs监视连接到JPPF服务器的节点。您可以监视很多事情,并且可以从服务器和节点获得许多不同的信息。希望以下示例为您提供一个良好的起点:

// connect using a JMX remote connection wrapper
try (JMXDriverConnectionWrapper serverJmx = new JMXDriverConnectionWrapper("jppf_server_host", 11111)) {
  serverJmx.connectAndWait(5_000L);
  if (serverJmx.isConnected()) {
    // get summary information on all the connected nodes
    Collection<JPPFManagementInfo> nodeInfos = serverJmx.nodesInformation();
    System.out.println("there are " + nodeInfos.size() + " connected nodes:");
    for (JPPFManagementInfo info: nodeInfos) {
      System.out.println("node uuid: " + info.getUuid() + ", host is " + info.getHost());
    }

    // get detailed information on the nodes
    // the node forwarder will send the same request to all selected nodes
    // and group the results in a map where each key is a node uuid
    JPPFNodeForwardingMBean forwarder = serverJmx.getNodeForwarder();
    Map<String, Object> responses = forwarder.systemInformation(NodeSelector.ALL_NODES);
    for (Map.Entry<String, Object> response: responses.entrySet()) {
      String nodeUuid = response.getKey();
      if (response.getValue() instanceof Exception) {
        System.out.println("node with uuid = " + nodeUuid + " raised an exception:");
        ((Exception) response.getValue()).printStackTrace(System.out);
      } else {
        JPPFSystemInformation systemInfo = (JPPFSystemInformation) response.getValue();
        System.out.println("system properties for node uuid " + nodeUuid + " :");
        System.out.println(systemInfo.getSystem());
      }
    }

  } else {
    System.out.println("could not connect to jppf_server_host:11111");
  }
} catch (Exception e) {
  e.printStackTrace();
}


请注意,在相同的管理API之上构建的webstandalone管理控制台也将提供此信息。

09-13 01:05