Search in sources :

Example 1 with LocatedTablet

use of org.apache.kudu.client.LocatedTablet in project drill by apache.

the class KuduGroupScan method init.

private void init() {
    String tableName = kuduScanSpec.getTableName();
    Collection<DrillbitEndpoint> endpoints = storagePlugin.getContext().getBits();
    Map<String, DrillbitEndpoint> endpointMap = Maps.newHashMap();
    for (DrillbitEndpoint endpoint : endpoints) {
        endpointMap.put(endpoint.getAddress(), endpoint);
    }
    try {
        List<LocatedTablet> locations = storagePlugin.getClient().openTable(tableName).getTabletsLocations(10000);
        for (LocatedTablet tablet : locations) {
            KuduWork work = new KuduWork(tablet.getPartition().getPartitionKeyStart(), tablet.getPartition().getPartitionKeyEnd());
            for (Replica replica : tablet.getReplicas()) {
                String host = replica.getRpcHost();
                DrillbitEndpoint ep = endpointMap.get(host);
                if (ep != null) {
                    work.getByteMap().add(ep, DEFAULT_TABLET_SIZE);
                }
            }
            kuduWorkList.add(work);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) LocatedTablet(org.apache.kudu.client.LocatedTablet) Replica(org.apache.kudu.client.LocatedTablet.Replica) ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)1 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)1 LocatedTablet (org.apache.kudu.client.LocatedTablet)1 Replica (org.apache.kudu.client.LocatedTablet.Replica)1