NIFI-4866: Fixed HBase performance issue

HBase_1_1_2_ClientService performance dropped due to accessing HBase
admin upon every FlowFile transfer. Fixed that by getting master address
only once when the service is enabled and a connection is established.

This closes #2464
This commit is contained in:
Koji Kawamura 2018-02-10 11:27:17 +09:00 committed by Matt Gilman
parent b7fdb235ee
commit b4a9f52a4e
No known key found for this signature in database
GPG Key ID: DF61EC19432AEE37
1 changed files with 4 additions and 6 deletions

View File

@ -91,6 +91,7 @@ public class HBase_1_1_2_ClientService extends AbstractControllerService impleme
private volatile Connection connection;
private volatile UserGroupInformation ugi;
private volatile String masterAddress;
private List<PropertyDescriptor> properties;
private KerberosProperties kerberosProperties;
@ -212,6 +213,7 @@ public class HBase_1_1_2_ClientService extends AbstractControllerService impleme
final Admin admin = this.connection.getAdmin();
if (admin != null) {
admin.listTableNames();
masterAddress = admin.getClusterStatus().getMaster().getHostAndPort();
}
}
}
@ -549,11 +551,7 @@ public class HBase_1_1_2_ClientService extends AbstractControllerService impleme
logger.warn("Connection has not been established, could not create a transit URI. Returning null.");
return null;
}
try {
final String masterAddress = connection.getAdmin().getClusterStatus().getMaster().getHostAndPort();
return "hbase://" + masterAddress + "/" + tableName + (rowKey != null && !rowKey.isEmpty() ? "/" + rowKey : "");
} catch (IOException e) {
throw new RuntimeException("Failed to get HBase Admin interface, due to " + e, e);
}
final String transitUriMasterAddress = StringUtils.isEmpty(masterAddress) ? "unknown" : masterAddress;
return "hbase://" + transitUriMasterAddress + "/" + tableName + (StringUtils.isEmpty(rowKey) ? "" : "/" + rowKey);
}
}