Search in sources :

Example 51 with Table

use of org.elasticsearch.common.Table in project elasticsearch by elastic.

the class RestTableTests method testRowOutOfBounds.

public void testRowOutOfBounds() {
    Table table = new Table();
    table.startHeaders();
    table.addCell("compare");
    table.endHeaders();
    RestTable.TableIndexComparator comparator = new RestTable.TableIndexComparator(table, Collections.singletonList(new RestTable.ColumnOrderElement("compare", false)));
    Error e = expectThrows(AssertionError.class, () -> {
        comparator.compare(0, 1);
    });
    assertEquals("Invalid comparison of indices (0, 1): Table has 0 rows.", e.getMessage());
}
Also used : Table(org.elasticsearch.common.Table)

Example 52 with Table

use of org.elasticsearch.common.Table in project elasticsearch by elastic.

the class RestTableTests method testAliasSort.

public void testAliasSort() {
    Table table = new Table();
    table.startHeaders();
    table.addCell("compare", "alias:c;");
    table.endHeaders();
    List<Integer> comparisonList = Arrays.asList(3, 1, 2);
    for (int i = 0; i < comparisonList.size(); i++) {
        table.startRow();
        table.addCell(comparisonList.get(i));
        table.endRow();
    }
    restRequest.params().put("s", "c");
    List<Integer> rowOrder = RestTable.getRowOrder(table, restRequest);
    assertEquals(Arrays.asList(1, 2, 0), rowOrder);
}
Also used : Table(org.elasticsearch.common.Table)

Example 53 with Table

use of org.elasticsearch.common.Table in project elasticsearch by elastic.

the class ExampleCatAction method getTableWithHeader.

@Override
protected Table getTableWithHeader(RestRequest request) {
    final Table table = new Table();
    table.startHeaders();
    table.addCell("test", "desc:test");
    table.endHeaders();
    return table;
}
Also used : Table(org.elasticsearch.common.Table) RestTable(org.elasticsearch.rest.action.cat.RestTable)

Example 54 with Table

use of org.elasticsearch.common.Table in project elasticsearch by elastic.

the class ExampleCatAction method doCatRequest.

@Override
protected RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
    Table table = getTableWithHeader(request);
    table.startRow();
    table.addCell(config.getTestConfig());
    table.endRow();
    return channel -> {
        try {
            channel.sendResponse(RestTable.buildResponse(table, channel));
        } catch (final Exception e) {
            channel.sendResponse(new BytesRestResponse(channel, e));
        }
    };
}
Also used : BytesRestResponse(org.elasticsearch.rest.BytesRestResponse) Settings(org.elasticsearch.common.settings.Settings) GET(org.elasticsearch.rest.RestRequest.Method.GET) AbstractCatAction(org.elasticsearch.rest.action.cat.AbstractCatAction) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) Table(org.elasticsearch.common.Table) RestController(org.elasticsearch.rest.RestController) RestTable(org.elasticsearch.rest.action.cat.RestTable) Table(org.elasticsearch.common.Table) RestTable(org.elasticsearch.rest.action.cat.RestTable) BytesRestResponse(org.elasticsearch.rest.BytesRestResponse)

Aggregations

Table (org.elasticsearch.common.Table)54 Settings (org.elasticsearch.common.settings.Settings)9 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)8 RestController (org.elasticsearch.rest.RestController)8 NodeClient (org.elasticsearch.client.node.NodeClient)7 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)7 RestRequest (org.elasticsearch.rest.RestRequest)7 GET (org.elasticsearch.rest.RestRequest.Method.GET)6 List (java.util.List)5 NodeStats (org.elasticsearch.action.admin.cluster.node.stats.NodeStats)5 NodeInfo (org.elasticsearch.action.admin.cluster.node.info.NodeInfo)4 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)4 Strings (org.elasticsearch.common.Strings)4 RestResponse (org.elasticsearch.rest.RestResponse)4 RestResponseListener (org.elasticsearch.rest.action.RestResponseListener)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ClusterStateRequest (org.elasticsearch.action.admin.cluster.state.ClusterStateRequest)3 ClusterStateResponse (org.elasticsearch.action.admin.cluster.state.ClusterStateResponse)3 MetaData (org.elasticsearch.cluster.metadata.MetaData)3