Search in sources :

Example 1 with ElasticsearchNode

use of com.facebook.presto.elasticsearch.client.ElasticsearchNode in project presto by prestodb.

the class NodesSystemTable method pageSource.

@Override
public ConnectorPageSource pageSource(ConnectorTransactionHandle transaction, ConnectorSession session, TupleDomain<Integer> constraint) {
    Set<ElasticsearchNode> nodes = client.getNodes();
    BlockBuilder nodeId = VARCHAR.createBlockBuilder(null, nodes.size());
    BlockBuilder prestoAddress = VARCHAR.createBlockBuilder(null, nodes.size());
    BlockBuilder elasticsearchNodeId = VARCHAR.createBlockBuilder(null, nodes.size());
    BlockBuilder elasticsearchAddress = VARCHAR.createBlockBuilder(null, nodes.size());
    for (ElasticsearchNode node : nodes) {
        VARCHAR.writeString(nodeId, currentNode.getNodeIdentifier());
        VARCHAR.writeString(prestoAddress, currentNode.getHostAndPort().toString());
        VARCHAR.writeString(elasticsearchNodeId, node.getId());
        if (node.getAddress().isPresent()) {
            VARCHAR.writeString(elasticsearchAddress, node.getAddress().get());
        } else {
            elasticsearchAddress.appendNull();
        }
    }
    return new FixedPageSource(ImmutableList.of(new Page(nodeId.build(), prestoAddress.build(), elasticsearchNodeId.build(), elasticsearchAddress.build())));
}
Also used : ElasticsearchNode(com.facebook.presto.elasticsearch.client.ElasticsearchNode) Page(com.facebook.presto.common.Page) FixedPageSource(com.facebook.presto.spi.FixedPageSource) BlockBuilder(com.facebook.presto.common.block.BlockBuilder)

Aggregations

Page (com.facebook.presto.common.Page)1 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)1 ElasticsearchNode (com.facebook.presto.elasticsearch.client.ElasticsearchNode)1 FixedPageSource (com.facebook.presto.spi.FixedPageSource)1