List<String> subScripts = new ArrayList<>(); String baseDir = new File(schemaTool.getMetaStoreSchemaInfo().getMetaStoreScriptDir()).getParent(); String schemaFile = new File(schemaTool.getMetaStoreSchemaInfo().getMetaStoreScriptDir(), schemaTool.getMetaStoreSchemaInfo().generateInitFileName(version)).getPath(); try {
@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); } }
@Override void execute() throws HiveMetaException { ensureToVersion(); schemaTool.testConnectionToMetastore(); System.out.println("Starting metastore schema initialization to " + toVersion); String initScriptDir = schemaTool.getMetaStoreSchemaInfo().getMetaStoreScriptDir(); String initScriptFile = schemaTool.getMetaStoreSchemaInfo().generateInitFileName(toVersion); try { System.out.println("Initialization script " + initScriptFile); if (!schemaTool.isDryRun()) { schemaTool.execSql(initScriptDir, initScriptFile); System.out.println("Initialization script completed"); } } catch (IOException e) { throw new HiveMetaException("Schema initialization FAILED! Metastore state would be inconsistent!", e); } if (validate) { schemaTool.verifySchemaVersion(); } } }
@Override void execute() throws HiveMetaException { ensureFromVersion(); if (schemaTool.getMetaStoreSchemaInfo().getHiveSchemaVersion().equals(fromVersion)) { System.out.println("No schema upgrade required from version " + fromVersion); return; } // Find the list of scripts to execute for this upgrade List<String> upgradeScripts = schemaTool.getMetaStoreSchemaInfo().getUpgradeScripts(fromVersion); schemaTool.testConnectionToMetastore(); System.out.println("Starting upgrade metastore schema from version " + fromVersion + " to " + schemaTool.getMetaStoreSchemaInfo().getHiveSchemaVersion()); String scriptDir = schemaTool.getMetaStoreSchemaInfo().getMetaStoreScriptDir(); try { for (String scriptFile : upgradeScripts) { System.out.println("Upgrade script " + scriptFile); if (!schemaTool.isDryRun()) { runPreUpgrade(scriptDir, scriptFile); schemaTool.execSql(scriptDir, scriptFile); System.out.println("Completed " + scriptFile); } } } catch (IOException e) { throw new HiveMetaException("Upgrade FAILED! Metastore state would be inconsistent !!", e); } // Revalidated the new version after upgrade schemaTool.verifySchemaVersion(); }
/** * Initialize the metastore schema * * @param toVersion * If null then current hive version is used * @throws MetaException */ public void doInit(String toVersion) throws HiveMetaException { testConnectionToMetastore(); System.out.println("Starting metastore schema initialization to " + toVersion); String initScriptDir = metaStoreSchemaInfo.getMetaStoreScriptDir(); String initScriptFile = metaStoreSchemaInfo.generateInitFileName(toVersion); try { System.out.println("Initialization script " + initScriptFile); if (!dryRun) { runBeeLine(initScriptDir, initScriptFile); System.out.println("Initialization script completed"); } } catch (IOException e) { throw new HiveMetaException("Schema initialization FAILED!" + " Metastore state would be inconsistent !!", e); } }
String baseDir = new File(metaStoreSchemaInfo.getMetaStoreScriptDir()).getParent(); String schemaFile = new File(metaStoreSchemaInfo.getMetaStoreScriptDir(), metaStoreSchemaInfo.generateInitFileName(version)).getPath(); try {
System.out.println("Starting upgrade metastore schema from version " + fromSchemaVer + " to " + metaStoreSchemaInfo.getHiveSchemaVersion()); String scriptDir = metaStoreSchemaInfo.getMetaStoreScriptDir(); try { for (String scriptFile : upgradeScripts) {