public static HiveMetadataService newInstance(HiveConf hiveConf, SecurityContext securityContext,
Subject subject, Component hiveMetastore,
Collection<ComponentProcess> hiveMetastoreProcesses)
throws MetaException, IOException, EntityNotFoundException, PrivilegedActionException {
if (SecurityUtil.isKerberosAuthenticated(securityContext)) {
UserGroupInformation.setConfiguration(hiveConf);
UserGroupInformation.getUGIFromSubject(subject);
return new HiveMetadataService(
SecurityUtil.execute(() -> new HiveMetaStoreClient(hiveConf), securityContext, subject),
hiveConf, securityContext, subject, hiveMetastore, hiveMetastoreProcesses);
} else {
return new HiveMetadataService(new HiveMetaStoreClient(hiveConf), hiveConf, securityContext, subject,
hiveMetastore, hiveMetastoreProcesses);
}
}