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

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

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

Node.getHost介绍

[英]Get the hostname of the node.
[中]获取节点的主机名。

代码示例

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

  1. public String constructLocation(String alias) {
  2. String httpHost = clusterManager.getNode().getHost();
  3. String httpPort = null;
  4. try {
  5. Configuration configuration = configurationAdmin.getConfiguration("org.ops4j.pax.web", null);
  6. if (configuration != null) {
  7. Dictionary properties = configuration.getProperties();
  8. if (properties != null) {
  9. httpPort = (String) properties.get("org.osgi.service.http.port");
  10. }
  11. }
  12. } catch (Exception e) {
  13. LOGGER.warn("CELLAR HTTP BALANCER: can't get HTTP port number from configuration", e);
  14. }
  15. if (httpPort == null)
  16. httpPort = "8181";
  17. String location = "http://" + httpHost + ":" + httpPort + alias;
  18. return location;
  19. }

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

  1. @Override
  2. public TabularData getNodes() throws Exception {
  3. CompositeType nodeType = new CompositeType("Node", "Karaf Cellar cluster node",
  4. new String[]{ "id", "alias", "hostname", "port", "local" },
  5. 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" },
  6. new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN });
  7. TabularType tableType = new TabularType("Nodes", "Table of all Karaf Cellar nodes", nodeType, new String[]{ "id" });
  8. TabularData table = new TabularDataSupport(tableType);
  9. Set<Node> nodes = clusterManager.listNodes();
  10. for (Node node : nodes) {
  11. boolean local = (node.equals(clusterManager.getNode()));
  12. CompositeData data = new CompositeDataSupport(nodeType,
  13. new String[]{ "id", "alias", "hostname", "port", "local" },
  14. new Object[]{ node.getId(), node.getAlias(), node.getHost(), node.getPort(), local });
  15. table.put(data);
  16. }
  17. return table;
  18. }

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

  1. @Override
  2. public TabularData getNodes() throws Exception {
  3. CompositeType nodeType = new CompositeType("Node", "Karaf Cellar cluster node",
  4. new String[]{ "id", "alias", "hostname", "port", "local" },
  5. 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" },
  6. new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN });
  7. TabularType tableType = new TabularType("Nodes", "Table of all Karaf Cellar nodes", nodeType, new String[]{ "id" });
  8. TabularData table = new TabularDataSupport(tableType);
  9. Set<Node> nodes = clusterManager.listNodes();
  10. for (Node node : nodes) {
  11. boolean local = (node.equals(clusterManager.getNode()));
  12. CompositeData data = new CompositeDataSupport(nodeType,
  13. new String[]{ "id", "alias", "hostname", "port", "local" },
  14. new Object[]{ node.getId(), node.getAlias(), node.getHost(), node.getPort(), local });
  15. table.put(data);
  16. }
  17. return table;
  18. }

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

  1. @Override
  2. protected Object doExecute() throws Exception {
  3. Set<Node> nodes = clusterManager.listNodes();
  4. if (nodes != null && !nodes.isEmpty()) {
  5. ShellTable table = new ShellTable();
  6. table.column(" ");
  7. table.column("Id");
  8. table.column("Alias");
  9. table.column("Host Name");
  10. table.column("Port");
  11. for (Node node : nodes) {
  12. String local = "";
  13. if (node.equals(clusterManager.getNode()))
  14. local = "x";
  15. table.addRow().addContent(local, node.getId(), node.getAlias(), node.getHost(), node.getPort());
  16. }
  17. table.print(System.out);
  18. } else {
  19. System.err.println("No node found in the cluster");
  20. }
  21. return null;
  22. }

相关文章