From b4a9f52a4efd8747c34fa9b88e898ed21976fbf1 Mon Sep 17 00:00:00 2001 From: Koji Kawamura Date: Sat, 10 Feb 2018 11:27:17 +0900 Subject: [PATCH] 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 --- .../apache/nifi/hbase/HBase_1_1_2_ClientService.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientService.java b/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientService.java index 12309d6693..cc6927bc36 100644 --- a/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientService.java +++ b/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientService.java @@ -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 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); } }