Search in sources :

Example 1 with TTable

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();
}
Also used : TTable(org.apache.dubbo.qos.textui.TTable) ProviderModel(org.apache.dubbo.rpc.model.ProviderModel)

Example 2 with TTable

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();
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) TTable(org.apache.dubbo.qos.textui.TTable)

Example 3 with TTable

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();
}
Also used : ConsumerModel(org.apache.dubbo.rpc.model.ConsumerModel) TTable(org.apache.dubbo.qos.textui.TTable)

Example 4 with TTable

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();
}
Also used : Cmd(org.apache.dubbo.qos.command.annotation.Cmd) TTable(org.apache.dubbo.qos.textui.TTable)

Example 5 with TTable

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();
}
Also used : Cmd(org.apache.dubbo.qos.command.annotation.Cmd) TTable(org.apache.dubbo.qos.textui.TTable)

Aggregations

TTable (org.apache.dubbo.qos.textui.TTable)5 Cmd (org.apache.dubbo.qos.command.annotation.Cmd)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConsumerModel (org.apache.dubbo.rpc.model.ConsumerModel)1 ProviderModel (org.apache.dubbo.rpc.model.ProviderModel)1