Search in sources :

Example 1 with RowProcessor

use of org.apache.hadoop.hbase.regionserver.RowProcessor in project hbase by apache.

the class BaseRowProcessorEndpoint method constructRowProcessorFromRequest.

@SuppressWarnings("unchecked")
RowProcessor<S, T> constructRowProcessorFromRequest(ProcessRequest request) throws IOException {
    String className = request.getRowProcessorClassName();
    Class<?> cls;
    try {
        cls = Class.forName(className);
        RowProcessor<S, T> ci = (RowProcessor<S, T>) cls.newInstance();
        if (request.hasRowProcessorInitializerMessageName()) {
            Class<?> imn = Class.forName(request.getRowProcessorInitializerMessageName()).asSubclass(Message.class);
            Method m;
            try {
                m = imn.getMethod("parseFrom", ByteString.class);
            } catch (SecurityException e) {
                throw new IOException(e);
            } catch (NoSuchMethodException e) {
                throw new IOException(e);
            }
            S s;
            try {
                s = (S) m.invoke(null, request.getRowProcessorInitializerMessage());
            } catch (IllegalArgumentException e) {
                throw new IOException(e);
            } catch (InvocationTargetException e) {
                throw new IOException(e);
            }
            ci.initialize(s);
        }
        return ci;
    } catch (ClassNotFoundException e) {
        throw new IOException(e);
    } catch (InstantiationException e) {
        throw new IOException(e);
    } catch (IllegalAccessException e) {
        throw new IOException(e);
    }
}
Also used : ByteString(com.google.protobuf.ByteString) ByteString(com.google.protobuf.ByteString) Method(java.lang.reflect.Method) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RowProcessor(org.apache.hadoop.hbase.regionserver.RowProcessor)

Aggregations

ByteString (com.google.protobuf.ByteString)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 RowProcessor (org.apache.hadoop.hbase.regionserver.RowProcessor)1