use of org.apache.hadoop.hive.metastore.HiveMetaException in project hive by apache.
the class SchemaToolTaskCreateUser method execute.
@Override
void execute() throws HiveMetaException {
schemaTool.testConnectionToMetastore();
System.out.println("Starting user creation");
String scriptDir = schemaTool.getMetaStoreSchemaInfo().getMetaStoreScriptDir();
String protoCreateFile = schemaTool.getMetaStoreSchemaInfo().getCreateUserScript();
try {
File createFile = subUserAndPassword(scriptDir, protoCreateFile);
System.out.println("Creation script " + createFile.getAbsolutePath());
if (!schemaTool.isDryRun()) {
if ("oracle".equals(schemaTool.getDbType()))
oracleCreateUserHack(createFile);
else
schemaTool.execSql(createFile.getParent(), createFile.getName());
System.out.println("User creation completed");
}
} catch (IOException e) {
throw new HiveMetaException("User creation FAILED!" + " Metastore unusable !!", e);
}
}
use of org.apache.hadoop.hive.metastore.HiveMetaException in project hive by apache.
the class SchemaToolTaskMoveDatabase method execute.
@Override
void execute() throws HiveMetaException {
System.out.println(String.format("Moving database %s from catalog %s to catalog %s", dbName, fromCatName, toCatName));
Connection conn = schemaTool.getConnectionToMetastore(true);
boolean success = false;
try {
conn.setAutoCommit(false);
try (Statement stmt = conn.createStatement()) {
updateCatalogNameInTable(stmt, "DBS", "CTLG_NAME", "NAME", fromCatName, toCatName, dbName, false);
updateCatalogNameInTable(stmt, "TAB_COL_STATS", "CAT_NAME", "DB_NAME", fromCatName, toCatName, dbName, true);
updateCatalogNameInTable(stmt, "PART_COL_STATS", "CAT_NAME", "DB_NAME", fromCatName, toCatName, dbName, true);
updateCatalogNameInTable(stmt, "PARTITION_EVENTS", "CAT_NAME", "DB_NAME", fromCatName, toCatName, dbName, true);
updateCatalogNameInTable(stmt, "NOTIFICATION_LOG", "CAT_NAME", "DB_NAME", fromCatName, toCatName, dbName, true);
conn.commit();
success = true;
}
} catch (SQLException e) {
throw new HiveMetaException("Failed to move database", e);
} finally {
try {
if (!success) {
conn.rollback();
}
} catch (SQLException e) {
// Not really much we can do here.
LOG.error("Failed to rollback, everything will probably go bad from here.");
}
}
}
Aggregations