Search in sources :

Example 1 with DataTunnelStatusHandler

use of org.apache.drill.exec.ops.DataTunnelStatusHandler in project drill by apache.

the class RuntimeFilterSink method route.

private void route(RuntimeFilterWritable srcRuntimeFilterWritable) {
    BitData.RuntimeFilterBDef runtimeFilterB = srcRuntimeFilterWritable.getRuntimeFilterBDef();
    int joinMajorId = runtimeFilterB.getMajorFragmentId();
    UserBitShared.QueryId queryId = runtimeFilterB.getQueryId();
    List<String> probeFields = runtimeFilterB.getProbeFieldsList();
    List<Integer> sizeInBytes = runtimeFilterB.getBloomFilterSizeInBytesList();
    long rfIdentifier = runtimeFilterB.getRfIdentifier();
    DrillBuf[] data = srcRuntimeFilterWritable.getData();
    List<CoordinationProtos.DrillbitEndpoint> scanNodeEps = joinMjId2probeScanEps.get(joinMajorId);
    int scanNodeSize = scanNodeEps.size();
    srcRuntimeFilterWritable.retainBuffers(scanNodeSize - 1);
    int scanNodeMjId = joinMjId2ScanMjId.get(joinMajorId);
    for (int minorId = 0; minorId < scanNodeEps.size(); minorId++) {
        BitData.RuntimeFilterBDef.Builder builder = BitData.RuntimeFilterBDef.newBuilder();
        for (String probeField : probeFields) {
            builder.addProbeFields(probeField);
        }
        BitData.RuntimeFilterBDef runtimeFilterBDef = builder.setQueryId(queryId).setMajorFragmentId(scanNodeMjId).setMinorFragmentId(minorId).setToForeman(false).setRfIdentifier(rfIdentifier).addAllBloomFilterSizeInBytes(sizeInBytes).build();
        RuntimeFilterWritable runtimeFilterWritable = new RuntimeFilterWritable(runtimeFilterBDef, data);
        CoordinationProtos.DrillbitEndpoint drillbitEndpoint = scanNodeEps.get(minorId);
        DataTunnel dataTunnel = drillbitContext.getDataConnectionsPool().getTunnel(drillbitEndpoint);
        Consumer<RpcException> exceptionConsumer = new Consumer<RpcException>() {

            @Override
            public void accept(final RpcException e) {
                logger.warn("fail to broadcast a runtime filter to the probe side scan node", e);
            }

            @Override
            public void interrupt(final InterruptedException e) {
                logger.warn("fail to broadcast a runtime filter to the probe side scan node", e);
            }
        };
        RpcOutcomeListener<BitData.AckWithCredit> statusHandler = new DataTunnelStatusHandler(exceptionConsumer, sendingAccountor);
        AccountingDataTunnel accountingDataTunnel = new AccountingDataTunnel(dataTunnel, sendingAccountor, statusHandler);
        accountingDataTunnel.sendRuntimeFilter(runtimeFilterWritable);
    }
}
Also used : AccountingDataTunnel(org.apache.drill.exec.ops.AccountingDataTunnel) Consumer(org.apache.drill.exec.ops.Consumer) RpcException(org.apache.drill.exec.rpc.RpcException) DrillBuf(io.netty.buffer.DrillBuf) AccountingDataTunnel(org.apache.drill.exec.ops.AccountingDataTunnel) DataTunnel(org.apache.drill.exec.rpc.data.DataTunnel) CoordinationProtos(org.apache.drill.exec.proto.CoordinationProtos) DataTunnelStatusHandler(org.apache.drill.exec.ops.DataTunnelStatusHandler) BitData(org.apache.drill.exec.proto.BitData) UserBitShared(org.apache.drill.exec.proto.UserBitShared)

Aggregations

DrillBuf (io.netty.buffer.DrillBuf)1 AccountingDataTunnel (org.apache.drill.exec.ops.AccountingDataTunnel)1 Consumer (org.apache.drill.exec.ops.Consumer)1 DataTunnelStatusHandler (org.apache.drill.exec.ops.DataTunnelStatusHandler)1 BitData (org.apache.drill.exec.proto.BitData)1 CoordinationProtos (org.apache.drill.exec.proto.CoordinationProtos)1 UserBitShared (org.apache.drill.exec.proto.UserBitShared)1 RpcException (org.apache.drill.exec.rpc.RpcException)1 DataTunnel (org.apache.drill.exec.rpc.data.DataTunnel)1