本文整理了Java中org.apache.karaf.cellar.core.Node.getAlias()
方法的一些代码示例,展示了Node.getAlias()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getAlias()
方法的具体详情如下:
包路径:org.apache.karaf.cellar.core.Node
类名称:Node
方法名:getAlias
[英]Get the alias of the node.
[中]获取节点的别名。
代码示例来源:origin: apache/karaf-cellar
@Override
public String getAlias(String id) throws Exception {
Node node = clusterManager.findNodeById(id);
if (node != null) {
return node.getAlias();
}
return null;
}
代码示例来源:origin: org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast
@Override
public String getAlias(String id) throws Exception {
Node node = clusterManager.findNodeById(id);
if (node != null) {
return node.getAlias();
}
return null;
}
代码示例来源:origin: apache/karaf-cellar
@Override
protected Object doExecute() throws Exception {
if (idLookup != null) {
Node node = clusterManager.findNodeById(idLookup);
System.out.println(node.getAlias());
return null;
}
if (aliasLookup != null) {
Node node = clusterManager.findNodeByAlias(aliasLookup);
System.out.println(node.getId());
return null;
}
if (alias != null) {
if (clusterManager.findNodeByAlias(alias) != null) {
System.err.println("Alias " + alias + " already exists");
return null;
}
clusterManager.setNodeAlias(alias);
} else {
Node node = clusterManager.getNode();
if (node.getAlias() == null) {
System.out.println("");
} else {
System.out.println(node.getAlias());
}
}
return null;
}
代码示例来源:origin: apache/karaf-cellar
String nodeName = node.getAlias();
if (nodeName == null) {
nodeName = node.getId();
代码示例来源:origin: apache/karaf-cellar
Set<Node> nodes = endpointDescription.getNodes();
for (Node node : nodes) {
String nodeName = node.getAlias();
if (nodeName == null) {
nodeName = node.getId();
代码示例来源:origin: org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast
@Override
public TabularData getGroups() throws Exception {
Set<Group> allGroups = groupManager.listAllGroups();
CompositeType groupType = new CompositeType("Group", "Karaf Cellar cluster group",
new String[]{ "name", "members"},
new String[]{ "Name of the cluster group", "Members of the cluster group" },
new OpenType[]{ SimpleType.STRING, SimpleType.STRING });
TabularType tableType = new TabularType("Groups", "Table of all Karaf Cellar groups", groupType,
new String[]{ "name" });
TabularData table = new TabularDataSupport(tableType);
for (Group group : allGroups) {
StringBuffer members = new StringBuffer();
for (Node node : group.getNodes()) {
// display only up and running nodes in the cluster
if (clusterManager.findNodeById(node.getId()) != null) {
if (node.getAlias() != null) {
members.append(node.getAlias());
} else {
members.append(node.getId());
}
members.append(" ");
}
}
CompositeData data = new CompositeDataSupport(groupType,
new String[]{ "name", "members" },
new Object[]{ group.getName(), members.toString() });
table.put(data);
}
return table;
}
代码示例来源:origin: apache/karaf-cellar
@Override
public TabularData getGroups() throws Exception {
Set<Group> allGroups = groupManager.listAllGroups();
CompositeType groupType = new CompositeType("Group", "Karaf Cellar cluster group",
new String[]{ "name", "members"},
new String[]{ "Name of the cluster group", "Members of the cluster group" },
new OpenType[]{ SimpleType.STRING, SimpleType.STRING });
TabularType tableType = new TabularType("Groups", "Table of all Karaf Cellar groups", groupType,
new String[]{ "name" });
TabularData table = new TabularDataSupport(tableType);
for (Group group : allGroups) {
StringBuffer members = new StringBuffer();
for (Node node : group.getNodes()) {
// display only up and running nodes in the cluster
if (clusterManager.findNodeById(node.getId()) != null) {
if (node.getAlias() != null) {
members.append(node.getAlias());
} else {
members.append(node.getId());
}
members.append(" ");
}
}
CompositeData data = new CompositeDataSupport(groupType,
new String[]{ "name", "members" },
new Object[]{ group.getName(), members.toString() });
table.put(data);
}
return table;
}
代码示例来源:origin: apache/karaf-cellar
GetLogResult result = results.get(node);
Map<String, String> loggers = result.getLoggers();
String nodeName = node.getAlias();
if (nodeName == null) {
nodeName = node.getId();
代码示例来源: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: org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast
@Override
public TabularData consumerStatus() throws Exception {
ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
command.setStatus(null);
Map<Node, ConsumerSwitchResult> results = executionContext.execute(command);
CompositeType compositeType = new CompositeType("Event Consumer", "Karaf Cellar cluster event consumer",
new String[]{"node", "status", "local"},
new String[]{"Node hosting event consumer", "Current status of the event consumer", "True if the node is local"},
new OpenType[]{SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
TabularType tableType = new TabularType("Event Consumers", "Table of Karaf Cellar cluster event consumers",
compositeType, new String[]{"node"});
TabularDataSupport table = new TabularDataSupport(tableType);
for (Node node : results.keySet()) {
boolean local = (node.equals(clusterManager.getNode()));
ConsumerSwitchResult consumerSwitchResult = results.get(node);
String nodeName = node.getAlias();
if (nodeName == null) {
nodeName = node.getId();
}
CompositeDataSupport data = new CompositeDataSupport(compositeType,
new String[]{"node", "status", "local"},
new Object[]{nodeName, consumerSwitchResult.getStatus(), local});
table.put(data);
}
return table;
}
代码示例来源:origin: org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast
String handler = handlerEntry.getKey();
String status = handlerEntry.getValue();
String nodeName = node.getAlias();
if (nodeName == null) {
nodeName = node.getId();
代码示例来源:origin: org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast
@Override
public TabularData producerStatus() throws Exception {
ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
command.setStatus(null);
Map<Node, ProducerSwitchResult> results = executionContext.execute(command);
CompositeType compositeType = new CompositeType("Event Producer", "Karaf Cellar cluster event producer",
new String[]{"node", "status", "local"},
new String[]{"Node hosting event producer", "Current status of the event producer", "True if the node is local"},
new OpenType[]{SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
TabularType tableType = new TabularType("Event Producers", "Table of Karaf Cellar cluster event producers",
compositeType, new String[]{"node"});
TabularDataSupport table = new TabularDataSupport(tableType);
for (Node node : results.keySet()) {
boolean local = (node.equals(clusterManager.getNode()));
ProducerSwitchResult producerSwitchResult = results.get(node);
String nodeName = node.getAlias();
if (nodeName == null) {
nodeName = node.getId();
}
CompositeDataSupport data = new CompositeDataSupport(compositeType,
new String[]{"node", "status", "local"},
new Object[]{nodeName, producerSwitchResult.getStatus(), 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
String handler = handlerEntry.getKey();
String status = handlerEntry.getValue();
String nodeName = node.getAlias();
if (nodeName == null) {
nodeName = node.getId();
代码示例来源:origin: apache/karaf-cellar
@Override
public TabularData consumerStatus() throws Exception {
ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
command.setStatus(null);
Map<Node, ConsumerSwitchResult> results = executionContext.execute(command);
CompositeType compositeType = new CompositeType("Event Consumer", "Karaf Cellar cluster event consumer",
new String[]{"node", "status", "local"},
new String[]{"Node hosting event consumer", "Current status of the event consumer", "True if the node is local"},
new OpenType[]{SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
TabularType tableType = new TabularType("Event Consumers", "Table of Karaf Cellar cluster event consumers",
compositeType, new String[]{"node"});
TabularDataSupport table = new TabularDataSupport(tableType);
for (Node node : results.keySet()) {
boolean local = (node.equals(clusterManager.getNode()));
ConsumerSwitchResult consumerSwitchResult = results.get(node);
String nodeName = node.getAlias();
if (nodeName == null) {
nodeName = node.getId();
}
CompositeDataSupport data = new CompositeDataSupport(compositeType,
new String[]{"node", "status", "local"},
new Object[]{nodeName, consumerSwitchResult.getStatus(), local});
table.put(data);
}
return table;
}
代码示例来源:origin: apache/karaf-cellar
@Override
public TabularData producerStatus() throws Exception {
ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
command.setStatus(null);
Map<Node, ProducerSwitchResult> results = executionContext.execute(command);
CompositeType compositeType = new CompositeType("Event Producer", "Karaf Cellar cluster event producer",
new String[]{"node", "status", "local"},
new String[]{"Node hosting event producer", "Current status of the event producer", "True if the node is local"},
new OpenType[]{SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
TabularType tableType = new TabularType("Event Producers", "Table of Karaf Cellar cluster event producers",
compositeType, new String[]{"node"});
TabularDataSupport table = new TabularDataSupport(tableType);
for (Node node : results.keySet()) {
boolean local = (node.equals(clusterManager.getNode()));
ProducerSwitchResult producerSwitchResult = results.get(node);
String nodeName = node.getAlias();
if (nodeName == null) {
nodeName = node.getId();
}
CompositeDataSupport data = new CompositeDataSupport(compositeType,
new String[]{"node", "status", "local"},
new Object[]{nodeName, producerSwitchResult.getStatus(), local});
table.put(data);
}
return table;
}
代码示例来源:origin: apache/karaf-cellar
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
StringsCompleter delegate = new StringsCompleter();
try {
for (Node node : clusterManager.listNodes()) {
if (acceptsNode(node)) {
if (addId()) {
String id = node.getId();
if (delegate.getStrings() != null && !delegate.getStrings().contains(id)) {
delegate.getStrings().add(id);
}
}
if (addAlias()) {
String alias = node.getAlias();
if (delegate.getStrings() != null && !delegate.getStrings().contains(alias)) {
delegate.getStrings().add(alias);
}
}
}
}
} catch (Exception e) {
// Ignore
}
return delegate.complete(session, commandLine, candidates);
}
代码示例来源:origin: org.apache.karaf.cellar/org.apache.karaf.cellar.core
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
StringsCompleter delegate = new StringsCompleter();
try {
for (Node node : clusterManager.listNodes()) {
if (acceptsNode(node)) {
if (addId()) {
String id = node.getId();
if (delegate.getStrings() != null && !delegate.getStrings().contains(id)) {
delegate.getStrings().add(id);
}
}
if (addAlias()) {
String alias = node.getAlias();
if (delegate.getStrings() != null && !delegate.getStrings().contains(alias)) {
delegate.getStrings().add(alias);
}
}
}
}
} catch (Exception e) {
// Ignore
}
return delegate.complete(session, commandLine, candidates);
}
代码示例来源: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;
}
代码示例来源:origin: apache/karaf-cellar
@Override
public void doAppend(PaxLoggingEvent event) {
Map<ClusterLogKey, ClusterLogRecord> clusterLog = clusterManager.getMap(LOG_MAP);
ClusterLogRecord record = new ClusterLogRecord();
ClusterLogKey key = new ClusterLogKey();
Node node = clusterManager.getNode();
key.setNodeId(node.getId());
key.setNodeAlias(node.getAlias());
key.setTimeStamp(event.getTimeStamp());
key.setId(clusterManager.generateId());
record.setFQNOfLoggerClass(event.getFQNOfLoggerClass());
record.setLevel(event.getLevel().toString());
record.setLoggerName(event.getLoggerName());
record.setMessage(event.getMessage());
record.setRenderedMessage(event.getRenderedMessage());
record.setThreadName(event.getThreadName());
record.setThrowableStringRep(event.getThrowableStrRep());
clusterLog.put(key, record);
}
内容来源于网络,如有侵权,请联系作者删除!