Search in sources :

Example 1 with PipelineAckProto

use of org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.PipelineAckProto in project hbase by apache.

the class FanOutOneBlockAsyncDFSOutputHelper method createPipelineAckStatusGetter27.

private static PipelineAckStatusGetter createPipelineAckStatusGetter27() throws NoSuchMethodException {
    Method getFlagListMethod = PipelineAckProto.class.getMethod("getFlagList");
    @SuppressWarnings("rawtypes") Class<? extends Enum> ecnClass;
    try {
        ecnClass = Class.forName("org.apache.hadoop.hdfs.protocol.datatransfer.PipelineAck$ECN").asSubclass(Enum.class);
    } catch (ClassNotFoundException e) {
        String msg = "Couldn't properly initialize the PipelineAck.ECN class. Please " + "update your WAL Provider to not make use of the 'asyncfs' provider. See " + "HBASE-16110 for more information.";
        LOG.error(msg, e);
        throw new Error(msg, e);
    }
    @SuppressWarnings("unchecked") Enum<?> disabledECN = Enum.valueOf(ecnClass, "DISABLED");
    Method getReplyMethod = PipelineAckProto.class.getMethod("getReply", int.class);
    Method combineHeaderMethod = PipelineAck.class.getMethod("combineHeader", ecnClass, Status.class);
    Method getStatusFromHeaderMethod = PipelineAck.class.getMethod("getStatusFromHeader", int.class);
    return new PipelineAckStatusGetter() {

        @Override
        public Status get(PipelineAckProto ack) {
            try {
                @SuppressWarnings("unchecked") List<Integer> flagList = (List<Integer>) getFlagListMethod.invoke(ack);
                Integer headerFlag;
                if (flagList.isEmpty()) {
                    Status reply = (Status) getReplyMethod.invoke(ack, 0);
                    headerFlag = (Integer) combineHeaderMethod.invoke(null, disabledECN, reply);
                } else {
                    headerFlag = flagList.get(0);
                }
                return (Status) getStatusFromHeaderMethod.invoke(null, headerFlag);
            } catch (IllegalAccessException | InvocationTargetException e) {
                throw new RuntimeException(e);
            }
        }
    };
}
Also used : Status(org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.Status) HdfsFileStatus(org.apache.hadoop.hdfs.protocol.HdfsFileStatus) PipelineAckProto(org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.PipelineAckProto) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 HdfsFileStatus (org.apache.hadoop.hdfs.protocol.HdfsFileStatus)1 PipelineAckProto (org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.PipelineAckProto)1 Status (org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.Status)1