use of org.apache.hadoop.hive.metastore.IMetaStoreSchemaInfo in project hive by apache.
the class TestSchemaToolForMetastore method testSchemaInit.
/**
* Test schema initialization
*/
@Test
public void testSchemaInit() throws Exception {
IMetaStoreSchemaInfo metastoreSchemaInfo = MetaStoreSchemaInfoFactory.get(conf, System.getProperty("test.tmp.dir", "target/tmp"), "derby");
schemaTool.doInit(metastoreSchemaInfo.getHiveSchemaVersion());
schemaTool.verifySchemaVersion();
}
use of org.apache.hadoop.hive.metastore.IMetaStoreSchemaInfo in project hive by apache.
the class TestTxnDbUtil method prepDb.
/**
* Prepares the metastore database for unit tests.
* Runs the latest init schema against the database configured in the CONNECT_URL_KEY param.
* Ignores any duplication (table, index etc.) So it can be called multiple times for the same database.
* @param conf Metastore configuration
* @throws Exception Initialization failure
*/
public static synchronized void prepDb(Configuration conf) throws Exception {
LOG.info("Creating transactional tables");
Connection conn = null;
Statement stmt = null;
try {
conn = getConnection(conf);
String s = conn.getMetaData().getDatabaseProductName();
DatabaseProduct dbProduct = determineDatabaseProduct(s, conf);
stmt = conn.createStatement();
if (checkDbPrepared(stmt)) {
return;
}
String schemaRootPath = getSchemaRootPath();
IMetaStoreSchemaInfo metaStoreSchemaInfo = MetaStoreSchemaInfoFactory.get(conf, schemaRootPath, dbProduct.getHiveSchemaPostfix());
String initFile = metaStoreSchemaInfo.generateInitFileName(null);
try (InputStream is = new FileInputStream(metaStoreSchemaInfo.getMetaStoreScriptDir() + File.separator + initFile)) {
LOG.info("Reinitializing the metastore db with {} on the database {}", initFile, MetastoreConf.getVar(conf, ConfVars.CONNECT_URL_KEY));
importSQL(stmt, is);
}
} catch (SQLException e) {
try {
if (conn != null) {
conn.rollback();
}
} catch (SQLException re) {
LOG.error("Error rolling back: " + re.getMessage());
}
// This might be a deadlock, if so, let's retry
if (e instanceof SQLTransactionRollbackException && deadlockCnt++ < 5) {
LOG.warn("Caught deadlock, retrying db creation");
prepDb(conf);
} else {
throw e;
}
} finally {
deadlockCnt = 0;
closeResources(conn, stmt, null);
}
}
use of org.apache.hadoop.hive.metastore.IMetaStoreSchemaInfo in project hive by apache.
the class TestSchemaTool method testSchemaInit.
/**
* Test schema initialization
* @throws Exception
*/
public void testSchemaInit() throws Exception {
IMetaStoreSchemaInfo metastoreSchemaInfo = MetaStoreSchemaInfoFactory.get(hiveConf, System.getProperty("test.tmp.dir", "target/tmp"), "derby");
schemaTool.doInit(metastoreSchemaInfo.getHiveSchemaVersion());
schemaTool.verifySchemaVersion();
}
use of org.apache.hadoop.hive.metastore.IMetaStoreSchemaInfo in project hive by apache.
the class TestSchemaToolForMetastore method testSchemaInit.
/**
* Test schema initialization
*/
@Test
public void testSchemaInit() throws Exception {
IMetaStoreSchemaInfo metastoreSchemaInfo = MetaStoreSchemaInfoFactory.get(conf, System.getProperty("test.tmp.dir", "target/tmp"), "derby");
execute(new SchemaToolTaskInit(), "-initSchemaTo " + metastoreSchemaInfo.getHiveSchemaVersion());
schemaTool.verifySchemaVersion();
}
Aggregations