Search in sources :

Example 1 with NonNull

use of edu.umd.cs.findbugs.annotations.NonNull in project hbase by apache.

the class MetaTableAccessor method getClosestRegionInfo.

/**
   * @return Get closest metatable region row to passed <code>row</code>
   * @throws java.io.IOException
   */
@NonNull
public static HRegionInfo getClosestRegionInfo(Connection connection, @NonNull final TableName tableName, @NonNull final byte[] row) throws IOException {
    byte[] searchRow = HRegionInfo.createRegionName(tableName, row, HConstants.NINES, false);
    Scan scan = getMetaScan(connection, 1);
    scan.setReversed(true);
    scan.setStartRow(searchRow);
    try (ResultScanner resultScanner = getMetaHTable(connection).getScanner(scan)) {
        Result result = resultScanner.next();
        if (result == null) {
            throw new TableNotFoundException("Cannot find row in META " + " for table: " + tableName + ", row=" + Bytes.toStringBinary(row));
        }
        HRegionInfo regionInfo = getHRegionInfo(result);
        if (regionInfo == null) {
            throw new IOException("HRegionInfo was null or empty in Meta for " + tableName + ", row=" + Bytes.toStringBinary(row));
        }
        return regionInfo;
    }
}
Also used : ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) Scan(org.apache.hadoop.hbase.client.Scan) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) Result(org.apache.hadoop.hbase.client.Result) NonNull(edu.umd.cs.findbugs.annotations.NonNull)

Example 2 with NonNull

use of edu.umd.cs.findbugs.annotations.NonNull in project hbase by apache.

the class ReflectionUtils method invokeMethod.

/**
   * Get and invoke the target method from the given object with given parameters
   * @param obj the object to get and invoke method from
   * @param methodName the name of the method to invoke
   * @param params the parameters for the method to invoke
   * @return the return value of the method invocation
   */
@NonNull
public static Object invokeMethod(Object obj, String methodName, Object... params) {
    Method m;
    try {
        m = obj.getClass().getMethod(methodName, getParameterTypes(params));
        m.setAccessible(true);
        return m.invoke(obj, params);
    } catch (NoSuchMethodException e) {
        throw new UnsupportedOperationException("Cannot find specified method " + methodName, e);
    } catch (IllegalAccessException e) {
        throw new UnsupportedOperationException("Unable to access specified method " + methodName, e);
    } catch (IllegalArgumentException e) {
        throw new UnsupportedOperationException("Illegal arguments supplied for method " + methodName, e);
    } catch (InvocationTargetException e) {
        throw new UnsupportedOperationException("Method threw an exception for " + methodName, e);
    }
}
Also used : Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) NonNull(edu.umd.cs.findbugs.annotations.NonNull)

Aggregations

NonNull (edu.umd.cs.findbugs.annotations.NonNull)2 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Result (org.apache.hadoop.hbase.client.Result)1 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)1 Scan (org.apache.hadoop.hbase.client.Scan)1