use of org.apache.dubbo.qos.textui.TTable in project dubbo by alibaba.
the class Ls method listProvider.
public String listProvider() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("As Provider side:" + System.lineSeparator());
Collection<ProviderModel> providerModelList = ApplicationModel.allProviderModels();
TTable tTable = new TTable(new TTable.ColumnDefine[] { new TTable.ColumnDefine(TTable.Align.MIDDLE), new TTable.ColumnDefine(TTable.Align.MIDDLE) });
// Header
tTable.addRow("Provider Service Name", "PUB");
// Content
for (ProviderModel providerModel : providerModelList) {
tTable.addRow(providerModel.getServiceKey(), ServiceCheckUtils.isRegistered(providerModel) ? "Y" : "N");
}
stringBuilder.append(tTable.rendering());
return stringBuilder.toString();
}
use of org.apache.dubbo.qos.textui.TTable in project dubbo by alibaba.
the class Ready method buildUiText.
private String buildUiText(Map<String, Boolean> serviceReadyMap) {
TTable tTable = new TTable(new TTable.ColumnDefine[] { new TTable.ColumnDefine(TTable.Align.MIDDLE), new TTable.ColumnDefine(TTable.Align.MIDDLE) });
// Header
tTable.addRow("Provider Service Name", "STATUS");
for (Map.Entry<String, Boolean> entry : serviceReadyMap.entrySet()) {
String status = Boolean.TRUE.equals(entry.getValue()) ? "TRUE" : "FALSE";
tTable.addRow(entry.getKey(), status);
}
return tTable.rendering();
}
use of org.apache.dubbo.qos.textui.TTable in project dubbo by alibaba.
the class Ls method listConsumer.
public String listConsumer() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("As Consumer side:" + System.lineSeparator());
Collection<ConsumerModel> consumerModelList = ApplicationModel.allConsumerModels();
TTable tTable = new TTable(new TTable.ColumnDefine[] { new TTable.ColumnDefine(TTable.Align.MIDDLE), new TTable.ColumnDefine(TTable.Align.MIDDLE) });
// Header
tTable.addRow("Consumer Service Name", "NUM");
// TODO to calculate consumerAddressNum
for (ConsumerModel consumerModel : consumerModelList) {
tTable.addRow(consumerModel.getServiceKey(), ServiceCheckUtils.getConsumerAddressNum(consumerModel));
}
stringBuilder.append(tTable.rendering());
return stringBuilder.toString();
}
use of org.apache.dubbo.qos.textui.TTable in project dubbo by alibaba.
the class Help method mainHelp.
/*
* output main help
*/
private String mainHelp() {
final TTable tTable = new TTable(new TTable.ColumnDefine[] { new TTable.ColumnDefine(TTable.Align.RIGHT), new TTable.ColumnDefine(80, false, TTable.Align.LEFT) });
final List<Class<?>> classes = CommandHelper.getAllCommandClass();
Collections.sort(classes, new Comparator<Class<?>>() {
@Override
public int compare(Class<?> o1, Class<?> o2) {
final Integer o1s = o1.getAnnotation(Cmd.class).sort();
final Integer o2s = o2.getAnnotation(Cmd.class).sort();
return o1s.compareTo(o2s);
}
});
for (Class<?> clazz : classes) {
if (clazz.isAnnotationPresent(Cmd.class)) {
final Cmd cmd = clazz.getAnnotation(Cmd.class);
tTable.addRow(cmd.name(), cmd.summary());
}
}
return tTable.padding(1).rendering();
}
use of org.apache.dubbo.qos.textui.TTable in project dubbo by alibaba.
the class Help method commandHelp.
private String commandHelp(String commandName) {
if (!CommandHelper.hasCommand(commandName)) {
return "no such command:" + commandName;
}
Class<?> clazz = CommandHelper.getCommandClass(commandName);
final Cmd cmd = clazz.getAnnotation(Cmd.class);
final TTable tTable = new TTable(new TTable.ColumnDefine[] { new TTable.ColumnDefine(TTable.Align.RIGHT), new TTable.ColumnDefine(80, false, TTable.Align.LEFT) });
tTable.addRow("COMMAND NAME", commandName);
if (null != cmd.example()) {
tTable.addRow("EXAMPLE", drawExample(cmd));
}
return tTable.padding(1).rendering();
}
Aggregations