use of org.apache.hadoop.hive.metastore.datasource.DataSourceProvider in project hive by apache.
the class ObjectStore method getPMF.
private static synchronized PersistenceManagerFactory getPMF() {
if (pmf == null) {
Configuration conf = MetastoreConf.newMetastoreConf();
DataSourceProvider dsp = DataSourceProviderFactory.getDataSourceProvider(conf);
if (dsp == null) {
pmf = JDOHelper.getPersistenceManagerFactory(prop);
} else {
try {
DataSource ds = dsp.create(conf);
Map<Object, Object> dsProperties = new HashMap<>();
// Any preexisting datanucleus property should be passed along
dsProperties.putAll(prop);
dsProperties.put("datanucleus.ConnectionFactory", ds);
dsProperties.put("javax.jdo.PersistenceManagerFactoryClass", "org.datanucleus.api.jdo.JDOPersistenceManagerFactory");
pmf = JDOHelper.getPersistenceManagerFactory(dsProperties);
} catch (SQLException e) {
LOG.warn("Could not create PersistenceManagerFactory using " + "connection pool properties, will fall back", e);
pmf = JDOHelper.getPersistenceManagerFactory(prop);
}
}
DataStoreCache dsc = pmf.getDataStoreCache();
if (dsc != null) {
String objTypes = MetastoreConf.getVar(conf, ConfVars.CACHE_PINOBJTYPES);
LOG.info("Setting MetaStore object pin classes with hive.metastore.cache.pinobjtypes=\"{}\"", objTypes);
if (org.apache.commons.lang.StringUtils.isNotEmpty(objTypes)) {
String[] typeTokens = objTypes.toLowerCase().split(",");
for (String type : typeTokens) {
type = type.trim();
if (PINCLASSMAP.containsKey(type)) {
dsc.pinAll(true, PINCLASSMAP.get(type));
} else {
LOG.warn("{} is not one of the pinnable object types: {}", type, org.apache.commons.lang.StringUtils.join(PINCLASSMAP.keySet(), " "));
}
}
}
} else {
LOG.warn("PersistenceManagerFactory returned null DataStoreCache object. Unable to initialize object pin types defined by hive.metastore.cache.pinobjtypes");
}
}
return pmf;
}
Aggregations