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

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

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

Node.getAlias介绍

[英]Get the alias of the node.
[中]获取节点的别名。

代码示例

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

  1. @Override
  2. public String getAlias(String id) throws Exception {
  3. Node node = clusterManager.findNodeById(id);
  4. if (node != null) {
  5. return node.getAlias();
  6. }
  7. return null;
  8. }

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

  1. @Override
  2. public String getAlias(String id) throws Exception {
  3. Node node = clusterManager.findNodeById(id);
  4. if (node != null) {
  5. return node.getAlias();
  6. }
  7. return null;
  8. }

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

  1. @Override
  2. protected Object doExecute() throws Exception {
  3. if (idLookup != null) {
  4. Node node = clusterManager.findNodeById(idLookup);
  5. System.out.println(node.getAlias());
  6. return null;
  7. }
  8. if (aliasLookup != null) {
  9. Node node = clusterManager.findNodeByAlias(aliasLookup);
  10. System.out.println(node.getId());
  11. return null;
  12. }
  13. if (alias != null) {
  14. if (clusterManager.findNodeByAlias(alias) != null) {
  15. System.err.println("Alias " + alias + " already exists");
  16. return null;
  17. }
  18. clusterManager.setNodeAlias(alias);
  19. } else {
  20. Node node = clusterManager.getNode();
  21. if (node.getAlias() == null) {
  22. System.out.println("");
  23. } else {
  24. System.out.println(node.getAlias());
  25. }
  26. }
  27. return null;
  28. }

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

  1. String nodeName = node.getAlias();
  2. if (nodeName == null) {
  3. nodeName = node.getId();

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

  1. Set<Node> nodes = endpointDescription.getNodes();
  2. for (Node node : nodes) {
  3. String nodeName = node.getAlias();
  4. if (nodeName == null) {
  5. nodeName = node.getId();

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

  1. @Override
  2. public TabularData getGroups() throws Exception {
  3. Set<Group> allGroups = groupManager.listAllGroups();
  4. CompositeType groupType = new CompositeType("Group", "Karaf Cellar cluster group",
  5. new String[]{ "name", "members"},
  6. new String[]{ "Name of the cluster group", "Members of the cluster group" },
  7. new OpenType[]{ SimpleType.STRING, SimpleType.STRING });
  8. TabularType tableType = new TabularType("Groups", "Table of all Karaf Cellar groups", groupType,
  9. new String[]{ "name" });
  10. TabularData table = new TabularDataSupport(tableType);
  11. for (Group group : allGroups) {
  12. StringBuffer members = new StringBuffer();
  13. for (Node node : group.getNodes()) {
  14. // display only up and running nodes in the cluster
  15. if (clusterManager.findNodeById(node.getId()) != null) {
  16. if (node.getAlias() != null) {
  17. members.append(node.getAlias());
  18. } else {
  19. members.append(node.getId());
  20. }
  21. members.append(" ");
  22. }
  23. }
  24. CompositeData data = new CompositeDataSupport(groupType,
  25. new String[]{ "name", "members" },
  26. new Object[]{ group.getName(), members.toString() });
  27. table.put(data);
  28. }
  29. return table;
  30. }

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

  1. @Override
  2. public TabularData getGroups() throws Exception {
  3. Set<Group> allGroups = groupManager.listAllGroups();
  4. CompositeType groupType = new CompositeType("Group", "Karaf Cellar cluster group",
  5. new String[]{ "name", "members"},
  6. new String[]{ "Name of the cluster group", "Members of the cluster group" },
  7. new OpenType[]{ SimpleType.STRING, SimpleType.STRING });
  8. TabularType tableType = new TabularType("Groups", "Table of all Karaf Cellar groups", groupType,
  9. new String[]{ "name" });
  10. TabularData table = new TabularDataSupport(tableType);
  11. for (Group group : allGroups) {
  12. StringBuffer members = new StringBuffer();
  13. for (Node node : group.getNodes()) {
  14. // display only up and running nodes in the cluster
  15. if (clusterManager.findNodeById(node.getId()) != null) {
  16. if (node.getAlias() != null) {
  17. members.append(node.getAlias());
  18. } else {
  19. members.append(node.getId());
  20. }
  21. members.append(" ");
  22. }
  23. }
  24. CompositeData data = new CompositeDataSupport(groupType,
  25. new String[]{ "name", "members" },
  26. new Object[]{ group.getName(), members.toString() });
  27. table.put(data);
  28. }
  29. return table;
  30. }

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

  1. GetLogResult result = results.get(node);
  2. Map<String, String> loggers = result.getLoggers();
  3. String nodeName = node.getAlias();
  4. if (nodeName == null) {
  5. nodeName = node.getId();

代码示例来源: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: org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast

  1. @Override
  2. public TabularData consumerStatus() throws Exception {
  3. ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
  4. command.setStatus(null);
  5. Map<Node, ConsumerSwitchResult> results = executionContext.execute(command);
  6. CompositeType compositeType = new CompositeType("Event Consumer", "Karaf Cellar cluster event consumer",
  7. new String[]{"node", "status", "local"},
  8. new String[]{"Node hosting event consumer", "Current status of the event consumer", "True if the node is local"},
  9. new OpenType[]{SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
  10. TabularType tableType = new TabularType("Event Consumers", "Table of Karaf Cellar cluster event consumers",
  11. compositeType, new String[]{"node"});
  12. TabularDataSupport table = new TabularDataSupport(tableType);
  13. for (Node node : results.keySet()) {
  14. boolean local = (node.equals(clusterManager.getNode()));
  15. ConsumerSwitchResult consumerSwitchResult = results.get(node);
  16. String nodeName = node.getAlias();
  17. if (nodeName == null) {
  18. nodeName = node.getId();
  19. }
  20. CompositeDataSupport data = new CompositeDataSupport(compositeType,
  21. new String[]{"node", "status", "local"},
  22. new Object[]{nodeName, consumerSwitchResult.getStatus(), local});
  23. table.put(data);
  24. }
  25. return table;
  26. }

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

  1. String handler = handlerEntry.getKey();
  2. String status = handlerEntry.getValue();
  3. String nodeName = node.getAlias();
  4. if (nodeName == null) {
  5. nodeName = node.getId();

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

  1. @Override
  2. public TabularData producerStatus() throws Exception {
  3. ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
  4. command.setStatus(null);
  5. Map<Node, ProducerSwitchResult> results = executionContext.execute(command);
  6. CompositeType compositeType = new CompositeType("Event Producer", "Karaf Cellar cluster event producer",
  7. new String[]{"node", "status", "local"},
  8. new String[]{"Node hosting event producer", "Current status of the event producer", "True if the node is local"},
  9. new OpenType[]{SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
  10. TabularType tableType = new TabularType("Event Producers", "Table of Karaf Cellar cluster event producers",
  11. compositeType, new String[]{"node"});
  12. TabularDataSupport table = new TabularDataSupport(tableType);
  13. for (Node node : results.keySet()) {
  14. boolean local = (node.equals(clusterManager.getNode()));
  15. ProducerSwitchResult producerSwitchResult = results.get(node);
  16. String nodeName = node.getAlias();
  17. if (nodeName == null) {
  18. nodeName = node.getId();
  19. }
  20. CompositeDataSupport data = new CompositeDataSupport(compositeType,
  21. new String[]{"node", "status", "local"},
  22. new Object[]{nodeName, producerSwitchResult.getStatus(), local});
  23. table.put(data);
  24. }
  25. return table;
  26. }

代码示例来源: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. String handler = handlerEntry.getKey();
  2. String status = handlerEntry.getValue();
  3. String nodeName = node.getAlias();
  4. if (nodeName == null) {
  5. nodeName = node.getId();

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

  1. @Override
  2. public TabularData consumerStatus() throws Exception {
  3. ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
  4. command.setStatus(null);
  5. Map<Node, ConsumerSwitchResult> results = executionContext.execute(command);
  6. CompositeType compositeType = new CompositeType("Event Consumer", "Karaf Cellar cluster event consumer",
  7. new String[]{"node", "status", "local"},
  8. new String[]{"Node hosting event consumer", "Current status of the event consumer", "True if the node is local"},
  9. new OpenType[]{SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
  10. TabularType tableType = new TabularType("Event Consumers", "Table of Karaf Cellar cluster event consumers",
  11. compositeType, new String[]{"node"});
  12. TabularDataSupport table = new TabularDataSupport(tableType);
  13. for (Node node : results.keySet()) {
  14. boolean local = (node.equals(clusterManager.getNode()));
  15. ConsumerSwitchResult consumerSwitchResult = results.get(node);
  16. String nodeName = node.getAlias();
  17. if (nodeName == null) {
  18. nodeName = node.getId();
  19. }
  20. CompositeDataSupport data = new CompositeDataSupport(compositeType,
  21. new String[]{"node", "status", "local"},
  22. new Object[]{nodeName, consumerSwitchResult.getStatus(), local});
  23. table.put(data);
  24. }
  25. return table;
  26. }

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

  1. @Override
  2. public TabularData producerStatus() throws Exception {
  3. ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
  4. command.setStatus(null);
  5. Map<Node, ProducerSwitchResult> results = executionContext.execute(command);
  6. CompositeType compositeType = new CompositeType("Event Producer", "Karaf Cellar cluster event producer",
  7. new String[]{"node", "status", "local"},
  8. new String[]{"Node hosting event producer", "Current status of the event producer", "True if the node is local"},
  9. new OpenType[]{SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
  10. TabularType tableType = new TabularType("Event Producers", "Table of Karaf Cellar cluster event producers",
  11. compositeType, new String[]{"node"});
  12. TabularDataSupport table = new TabularDataSupport(tableType);
  13. for (Node node : results.keySet()) {
  14. boolean local = (node.equals(clusterManager.getNode()));
  15. ProducerSwitchResult producerSwitchResult = results.get(node);
  16. String nodeName = node.getAlias();
  17. if (nodeName == null) {
  18. nodeName = node.getId();
  19. }
  20. CompositeDataSupport data = new CompositeDataSupport(compositeType,
  21. new String[]{"node", "status", "local"},
  22. new Object[]{nodeName, producerSwitchResult.getStatus(), local});
  23. table.put(data);
  24. }
  25. return table;
  26. }

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

  1. @Override
  2. public int complete(Session session, CommandLine commandLine, List<String> candidates) {
  3. StringsCompleter delegate = new StringsCompleter();
  4. try {
  5. for (Node node : clusterManager.listNodes()) {
  6. if (acceptsNode(node)) {
  7. if (addId()) {
  8. String id = node.getId();
  9. if (delegate.getStrings() != null && !delegate.getStrings().contains(id)) {
  10. delegate.getStrings().add(id);
  11. }
  12. }
  13. if (addAlias()) {
  14. String alias = node.getAlias();
  15. if (delegate.getStrings() != null && !delegate.getStrings().contains(alias)) {
  16. delegate.getStrings().add(alias);
  17. }
  18. }
  19. }
  20. }
  21. } catch (Exception e) {
  22. // Ignore
  23. }
  24. return delegate.complete(session, commandLine, candidates);
  25. }

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

  1. @Override
  2. public int complete(Session session, CommandLine commandLine, List<String> candidates) {
  3. StringsCompleter delegate = new StringsCompleter();
  4. try {
  5. for (Node node : clusterManager.listNodes()) {
  6. if (acceptsNode(node)) {
  7. if (addId()) {
  8. String id = node.getId();
  9. if (delegate.getStrings() != null && !delegate.getStrings().contains(id)) {
  10. delegate.getStrings().add(id);
  11. }
  12. }
  13. if (addAlias()) {
  14. String alias = node.getAlias();
  15. if (delegate.getStrings() != null && !delegate.getStrings().contains(alias)) {
  16. delegate.getStrings().add(alias);
  17. }
  18. }
  19. }
  20. }
  21. } catch (Exception e) {
  22. // Ignore
  23. }
  24. return delegate.complete(session, commandLine, candidates);
  25. }

代码示例来源: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. }

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

  1. @Override
  2. public void doAppend(PaxLoggingEvent event) {
  3. Map<ClusterLogKey, ClusterLogRecord> clusterLog = clusterManager.getMap(LOG_MAP);
  4. ClusterLogRecord record = new ClusterLogRecord();
  5. ClusterLogKey key = new ClusterLogKey();
  6. Node node = clusterManager.getNode();
  7. key.setNodeId(node.getId());
  8. key.setNodeAlias(node.getAlias());
  9. key.setTimeStamp(event.getTimeStamp());
  10. key.setId(clusterManager.generateId());
  11. record.setFQNOfLoggerClass(event.getFQNOfLoggerClass());
  12. record.setLevel(event.getLevel().toString());
  13. record.setLoggerName(event.getLoggerName());
  14. record.setMessage(event.getMessage());
  15. record.setRenderedMessage(event.getRenderedMessage());
  16. record.setThreadName(event.getThreadName());
  17. record.setThrowableStringRep(event.getThrowableStrRep());
  18. clusterLog.put(key, record);
  19. }

相关文章