org.apache.karaf.cellar.core.Node.getPort()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(76)

本文整理了Java中org.apache.karaf.cellar.core.Node.getPort()方法的一些代码示例,展示了Node.getPort()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getPort()方法的具体详情如下:
包路径:org.apache.karaf.cellar.core.Node
类名称:Node
方法名:getPort

Node.getPort介绍

[英]Get the port number of the node.
[中]获取节点的端口号。

代码示例

代码示例来源:origin: org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast

@Override
public TabularData getNodes() throws Exception {
  CompositeType nodeType = new CompositeType("Node", "Karaf Cellar cluster node",
      new String[]{ "id", "alias", "hostname", "port", "local" },
      new String[]{ "ID of the node", "Alias of the node", "Hostname of the node", "Port number of the node", "Flag defining if the node is local" },
      new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN });
  TabularType tableType = new TabularType("Nodes", "Table of all Karaf Cellar nodes", nodeType, new String[]{ "id" });
  TabularData table = new TabularDataSupport(tableType);
  Set<Node> nodes = clusterManager.listNodes();
  for (Node node : nodes) {
    boolean local = (node.equals(clusterManager.getNode()));
    CompositeData data = new CompositeDataSupport(nodeType,
        new String[]{ "id", "alias", "hostname", "port", "local" },
        new Object[]{ node.getId(), node.getAlias(), node.getHost(), node.getPort(), local });
    table.put(data);
  }
  return table;
}

代码示例来源:origin: apache/karaf-cellar

@Override
public TabularData getNodes() throws Exception {
  CompositeType nodeType = new CompositeType("Node", "Karaf Cellar cluster node",
      new String[]{ "id", "alias", "hostname", "port", "local" },
      new String[]{ "ID of the node", "Alias of the node", "Hostname of the node", "Port number of the node", "Flag defining if the node is local" },
      new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN });
  TabularType tableType = new TabularType("Nodes", "Table of all Karaf Cellar nodes", nodeType, new String[]{ "id" });
  TabularData table = new TabularDataSupport(tableType);
  Set<Node> nodes = clusterManager.listNodes();
  for (Node node : nodes) {
    boolean local = (node.equals(clusterManager.getNode()));
    CompositeData data = new CompositeDataSupport(nodeType,
        new String[]{ "id", "alias", "hostname", "port", "local" },
        new Object[]{ node.getId(), node.getAlias(), node.getHost(), node.getPort(), local });
    table.put(data);
  }
  return table;
}

代码示例来源:origin: apache/karaf-cellar

@Override
protected Object doExecute() throws Exception {
  Set<Node> nodes = clusterManager.listNodes();
  if (nodes != null && !nodes.isEmpty()) {
    ShellTable table = new ShellTable();
    table.column(" ");
    table.column("Id");
    table.column("Alias");
    table.column("Host Name");
    table.column("Port");
    for (Node node : nodes) {
      String local = "";
      if (node.equals(clusterManager.getNode()))
        local = "x";
      table.addRow().addContent(local, node.getId(), node.getAlias(), node.getHost(), node.getPort());
    }
    table.print(System.out);
  } else {
    System.err.println("No node found in the cluster");
  }
  return null;
}

相关文章

微信公众号

最新文章

更多