private void ensureFromVersion() throws HiveMetaException { if (fromVersion != null) { return; } // If null, then read from the metastore MetaStoreConnectionInfo connectionInfo = schemaTool.getConnectionInfo(false); fromVersion = schemaTool.getMetaStoreSchemaInfo().getMetaStoreSchemaVersion(connectionInfo); if (fromVersion == null || fromVersion.isEmpty()) { throw new HiveMetaException("Schema version not stored in the metastore. " + "Metastore schema is too old or corrupt. Try specifying the version manually"); } System.out.println("Upgrading from the version " + fromVersion); }
/** * check if the current schema version in metastore matches the Hive version */ @VisibleForTesting void verifySchemaVersion() throws HiveMetaException { // don't check version if its a dry run if (dryRun) { return; } String newSchemaVersion = metaStoreSchemaInfo.getMetaStoreSchemaVersion(getConnectionInfo(false)); // verify that the new version is added to schema assertCompatibleVersion(metaStoreSchemaInfo.getHiveSchemaVersion(), newSchemaVersion); }
@Override void execute() throws HiveMetaException { String hiveVersion = schemaTool.getMetaStoreSchemaInfo().getHiveSchemaVersion(); MetaStoreConnectionInfo connectionInfo = schemaTool.getConnectionInfo(true); String dbVersion = schemaTool.getMetaStoreSchemaInfo().getMetaStoreSchemaVersion(connectionInfo); System.out.println("Hive distribution version:\t " + hiveVersion); System.out.println("Metastore schema version:\t " + dbVersion); schemaTool.assertCompatibleVersion(hiveVersion, dbVersion); } }
boolean validateSchemaVersions() throws HiveMetaException { System.out.println("Validating schema version"); try { String hiveSchemaVersion = schemaTool.getMetaStoreSchemaInfo().getHiveSchemaVersion(); MetaStoreConnectionInfo connectionInfo = schemaTool.getConnectionInfo(false); String newSchemaVersion = schemaTool.getMetaStoreSchemaInfo().getMetaStoreSchemaVersion(connectionInfo); schemaTool.assertCompatibleVersion(hiveSchemaVersion, newSchemaVersion); } catch (HiveMetaException hme) { if (hme.getMessage().contains("Metastore schema version is not compatible") || hme.getMessage().contains("Multiple versions were found in metastore") || hme.getMessage().contains("Could not find version info in metastore VERSION table")) { System.err.println(hme.getMessage()); System.out.println("[FAIL]\n"); return false; } else { throw hme; } } System.out.println("[SUCCESS]\n"); return true; }
try { MetaStoreConnectionInfo connectionInfo = schemaTool.getConnectionInfo(false); version = schemaTool.getMetaStoreSchemaInfo().getMetaStoreSchemaVersion(connectionInfo); } catch (HiveMetaException he) { System.err.println("Failed to determine schema version from Hive Metastore DB. " + he.getMessage());
@Override void execute() throws HiveMetaException { HiveSchemaHelper.MetaStoreConnectionInfo connectionInfo = schemaTool.getConnectionInfo(true); String dbVersion = null; try { dbVersion = schemaTool.getMetaStoreSchemaInfo().getMetaStoreSchemaVersion(connectionInfo); } catch (HiveMetaException e) { LOG.info("Exception getting db version:" + e.getMessage()); LOG.info("Try to initialize db schema"); } SchemaToolTask task; if (dbVersion == null) { task = new SchemaToolTaskInit(); } else { task = new SchemaToolTaskUpgrade(); } task.setHiveSchemaTool(schemaTool); task.setCommandLineArguments(cl); task.execute(); } }
/*** * Print Hive version and schema version * @throws MetaException */ public void showInfo() throws HiveMetaException { String hiveVersion = metaStoreSchemaInfo.getHiveSchemaVersion(); String dbVersion = metaStoreSchemaInfo.getMetaStoreSchemaVersion(getConnectionInfo(true)); System.out.println("Hive distribution version:\t " + hiveVersion); System.out.println("Metastore schema version:\t " + dbVersion); assertCompatibleVersion(hiveVersion, dbVersion); }
/** * Perform metastore schema upgrade. extract the current schema version from metastore * @throws MetaException */ public void doUpgrade() throws HiveMetaException { String fromVersion = metaStoreSchemaInfo.getMetaStoreSchemaVersion(getConnectionInfo(false)); if (fromVersion == null || fromVersion.isEmpty()) { throw new HiveMetaException("Schema version not stored in the metastore. " + "Metastore schema is too old or corrupt. Try specifying the version manually"); } doUpgrade(fromVersion); }
/** * check if the current schema version in metastore matches the Hive version * @throws MetaException */ public void verifySchemaVersion() throws HiveMetaException { // don't check version if its a dry run if (dryRun) { return; } String newSchemaVersion = metaStoreSchemaInfo.getMetaStoreSchemaVersion(getConnectionInfo(false)); // verify that the new version is added to schema assertCompatibleVersion(metaStoreSchemaInfo.getHiveSchemaVersion(), newSchemaVersion); }
boolean validateSchemaVersions() throws HiveMetaException { System.out.println("Validating schema version"); try { String newSchemaVersion = metaStoreSchemaInfo.getMetaStoreSchemaVersion(getConnectionInfo(false)); assertCompatibleVersion(metaStoreSchemaInfo.getHiveSchemaVersion(), newSchemaVersion); } catch (HiveMetaException hme) { if (hme.getMessage().contains("Metastore schema version is not compatible") || hme.getMessage().contains("Multiple versions were found in metastore") || hme.getMessage().contains("Could not find version info in metastore VERSION table")) { System.err.println(hme.getMessage()); System.out.println("Failed in schema version validation."); return false; } else { throw hme; } } System.out.println("Succeeded in schema version validation."); return true; }
version = metaStoreSchemaInfo.getMetaStoreSchemaVersion(getConnectionInfo(false)); } catch (HiveMetaException he) { System.err.println("Failed to determine schema version from Hive Metastore DB. " + he.getMessage());