mirror of https://github.com/apache/nifi.git
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:
parent
b7fdb235ee
commit
b4a9f52a4e
|
@ -91,6 +91,7 @@ public class HBase_1_1_2_ClientService extends AbstractControllerService impleme
|
||||||
|
|
||||||
private volatile Connection connection;
|
private volatile Connection connection;
|
||||||
private volatile UserGroupInformation ugi;
|
private volatile UserGroupInformation ugi;
|
||||||
|
private volatile String masterAddress;
|
||||||
|
|
||||||
private List<PropertyDescriptor> properties;
|
private List<PropertyDescriptor> properties;
|
||||||
private KerberosProperties kerberosProperties;
|
private KerberosProperties kerberosProperties;
|
||||||
|
@ -212,6 +213,7 @@ public class HBase_1_1_2_ClientService extends AbstractControllerService impleme
|
||||||
final Admin admin = this.connection.getAdmin();
|
final Admin admin = this.connection.getAdmin();
|
||||||
if (admin != null) {
|
if (admin != null) {
|
||||||
admin.listTableNames();
|
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.");
|
logger.warn("Connection has not been established, could not create a transit URI. Returning null.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
final String transitUriMasterAddress = StringUtils.isEmpty(masterAddress) ? "unknown" : masterAddress;
|
||||||
final String masterAddress = connection.getAdmin().getClusterStatus().getMaster().getHostAndPort();
|
return "hbase://" + transitUriMasterAddress + "/" + tableName + (StringUtils.isEmpty(rowKey) ? "" : "/" + rowKey);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue