}
private void compact(final ServerName sn, final HRegionInfo hri,
final boolean major, final byte [] family)
throws IOException {
HRegionInterface rs =
this.connection.getHRegionConnection(sn.getHostname(), sn.getPort());
if (family != null) {
try {
rs.compactRegion(hri, major, family);
} catch (IOException ioe) {
String notFoundMsg = "java.lang.NoSuchMethodException: org.apache.hadoop.hbase.ipc.HRegionInterface."
+ "compactRegion(org.apache.hadoop.hbase.HRegionInfo, boolean, [B)";
if (ioe.getMessage().contains(notFoundMsg)) {
throw new IOException("per-column family compaction not supported on this version "
+ "of the HBase server. You may still compact at the table or region level by "
+ "omitting the column family name. Alternatively, you can upgrade the HBase server");
}
throw ioe;
}
} else {
rs.compactRegion(hri, major);
}
}