@SuppressWarnings("nls") private void initialize() { LOG.debug("ObjectStore, initialize called"); // if this method fails, PersistenceManagerProvider will retry for the configured number of times // before giving up pm = PersistenceManagerProvider.getPersistenceManager(); LOG.info("RawStore: {}, with PersistenceManager: {}" + " created in the thread with id: {}", this, pm, Thread.currentThread().getId()); try { String productName = MetaStoreDirectSql.getProductName(pm); sqlGenerator = new SQLGenerator(DatabaseProduct.determineDatabaseProduct(productName), conf); } catch (SQLException e) { LOG.error("error trying to figure out the database product", e); throw new RuntimeException(e); } isInitialized = pm != null; if (isInitialized) { dbType = determineDatabaseProduct(); expressionProxy = createExpressionProxy(conf); if (MetastoreConf.getBoolVar(getConf(), ConfVars.TRY_DIRECT_SQL)) { String schema = PersistenceManagerProvider.getProperty("javax.jdo.mapping.Schema"); schema = org.apache.commons.lang.StringUtils.defaultIfBlank(schema, null); directSql = new MetaStoreDirectSql(pm, conf, schema); } } }
if (isConfigEnabled && directSql == null) { dbType = determineDatabaseProduct(); directSql = new MetaStoreDirectSql(pm, getConf(), "");
@SuppressWarnings("nls") private void initialize(Properties dsProps) { LOG.info("ObjectStore, initialize called"); prop = dsProps; pm = getPersistenceManager(); isInitialized = pm != null; if (isInitialized) { directSql = new MetaStoreDirectSql(pm); } return; }
@SuppressWarnings("nls") private void initialize(Properties dsProps) { LOG.info("ObjectStore, initialize called"); prop = dsProps; pm = getPersistenceManager(); isInitialized = pm != null; if (isInitialized) { expressionProxy = createExpressionProxy(hiveConf); directSql = new MetaStoreDirectSql(pm, hiveConf); } LOG.debug("RawStore: " + this + ", with PersistenceManager: " + pm + " created in the thread with id: " + Thread.currentThread().getId()); }
@SuppressWarnings("nls") private void initialize(Properties dsProps) { LOG.info("ObjectStore, initialize called"); prop = dsProps; pm = getPersistenceManager(); isInitialized = pm != null; if (isInitialized) { expressionProxy = createExpressionProxy(hiveConf); directSql = new MetaStoreDirectSql(pm, hiveConf); } LOG.debug("RawStore: " + this + ", with PersistenceManager: " + pm + " created in the thread with id: " + Thread.currentThread().getId()); }
/** * private helper to do initialization routine, so we can retry if needed if it fails. * @param dsProps */ private void initializeHelper(Properties dsProps) { LOG.info("ObjectStore, initialize called"); prop = dsProps; pm = getPersistenceManager(); try { String productName = MetaStoreDirectSql.getProductName(pm); sqlGenerator = new SQLGenerator(DatabaseProduct.determineDatabaseProduct(productName), conf); } catch (SQLException e) { LOG.error("error trying to figure out the database product", e); throw new RuntimeException(e); } isInitialized = pm != null; if (isInitialized) { dbType = determineDatabaseProduct(); expressionProxy = createExpressionProxy(conf); if (MetastoreConf.getBoolVar(getConf(), ConfVars.TRY_DIRECT_SQL)) { String schema = prop.getProperty("javax.jdo.mapping.Schema"); schema = org.apache.commons.lang.StringUtils.defaultIfBlank(schema, null); directSql = new MetaStoreDirectSql(pm, conf, schema); } } LOG.debug("RawStore: {}, with PersistenceManager: {}" + " created in the thread with id: {}", this, pm, Thread.currentThread().getId()); }
public GetHelper(String catalogName, String dbName, String tblName, boolean allowSql, boolean allowJdo) throws MetaException { assert allowSql || allowJdo; this.allowJdo = allowJdo; this.catName = (catalogName != null) ? normalizeIdentifier(catalogName) : null; this.dbName = (dbName != null) ? normalizeIdentifier(dbName) : null; if (tblName != null) { this.tblName = normalizeIdentifier(tblName); } else { // tblName can be null in cases of Helper being used at a higher // abstraction level, such as with datbases this.tblName = null; this.table = null; } this.doTrace = LOG.isDebugEnabled(); this.isInTxn = isActiveTransaction(); // SQL usage inside a larger transaction (e.g. droptable) may not be desirable because // some databases (e.g. Postgres) abort the entire transaction when any query fails, so // the fallback from failed SQL to JDO is not possible. boolean isConfigEnabled = MetastoreConf.getBoolVar(getConf(), ConfVars.TRY_DIRECT_SQL) && (MetastoreConf.getBoolVar(getConf(), ConfVars.TRY_DIRECT_SQL_DDL) || !isInTxn); if (isConfigEnabled && directSql == null) { dbType = determineDatabaseProduct(); directSql = new MetaStoreDirectSql(pm, getConf(), ""); } if (!allowJdo && isConfigEnabled && !directSql.isCompatibleDatastore()) { throw new MetaException("SQL is not operational"); // test path; SQL is enabled and broken. } this.doUseDirectSql = allowSql && isConfigEnabled && directSql.isCompatibleDatastore(); }