Search in sources :

Example 1 with CipherOptionProto

use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.CipherOptionProto in project hbase by apache.

the class FanOutOneBlockAsyncDFSOutputSaslHelper method createPBHelper.

private static PBHelper createPBHelper() throws NoSuchMethodException {
    Class<?> helperClass;
    try {
        helperClass = Class.forName("org.apache.hadoop.hdfs.protocolPB.PBHelperClient");
    } catch (ClassNotFoundException e) {
        LOG.debug("No PBHelperClient class found, should be hadoop 2.7-", e);
        helperClass = org.apache.hadoop.hdfs.protocolPB.PBHelper.class;
    }
    Method convertCipherOptionsMethod = helperClass.getMethod("convertCipherOptions", List.class);
    Method convertCipherOptionProtosMethod = helperClass.getMethod("convertCipherOptionProtos", List.class);
    return new PBHelper() {

        @SuppressWarnings("unchecked")
        @Override
        public List<CipherOptionProto> convertCipherOptions(List<CipherOption> options) {
            try {
                return (List<CipherOptionProto>) convertCipherOptionsMethod.invoke(null, options);
            } catch (IllegalAccessException | InvocationTargetException e) {
                throw new RuntimeException(e);
            }
        }

        @SuppressWarnings("unchecked")
        @Override
        public List<CipherOption> convertCipherOptionProtos(List<CipherOptionProto> options) {
            try {
                return (List<CipherOption>) convertCipherOptionProtosMethod.invoke(null, options);
            } catch (IllegalAccessException | InvocationTargetException e) {
                throw new RuntimeException(e);
            }
        }
    };
}
Also used : CipherOption(org.apache.hadoop.crypto.CipherOption) Method(java.lang.reflect.Method) CipherOptionProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.CipherOptionProto) InvocationTargetException(java.lang.reflect.InvocationTargetException) List(java.util.List)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 List (java.util.List)1 CipherOption (org.apache.hadoop.crypto.CipherOption)1 CipherOptionProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.CipherOptionProto)1