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;
}
}
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);
}
}
Aggregations