You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by bl...@apache.org on 2015/06/24 03:29:18 UTC
tajo git commit: TAJO-1642: CatalogServer need to check meta table
first. (jaehwa)
Repository: tajo
Updated Branches:
refs/heads/master 0f7ff8f01 -> b24d18f5b
TAJO-1642: CatalogServer need to check meta table first. (jaehwa)
Closes #600
Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/b24d18f5
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/b24d18f5
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/b24d18f5
Branch: refs/heads/master
Commit: b24d18f5b3cf9ed3c4a4a41bff654c965521542f
Parents: 0f7ff8f
Author: JaeHwa Jung <bl...@apache.org>
Authored: Wed Jun 24 10:27:38 2015 +0900
Committer: JaeHwa Jung <bl...@apache.org>
Committed: Wed Jun 24 10:27:38 2015 +0900
----------------------------------------------------------------------
CHANGES | 2 ++
.../tajo/catalog/store/AbstractDBStore.java | 33 +++++++++++++-------
.../catalog/store/XMLCatalogSchemaManager.java | 30 ++++++++++++++++++
3 files changed, 53 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tajo/blob/b24d18f5/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index d64022a..170b928 100644
--- a/CHANGES
+++ b/CHANGES
@@ -162,6 +162,8 @@ Release 0.11.0 - unreleased
BUG FIXES
+ TAJO-1642: CatalogServer need to check meta table first. (jaehwa)
+
TAJO-1650: TestQueryResource.testGetAllQueries() occasionally fails.
(Contributed by jinho, Committed by jaehwa)
http://git-wip-us.apache.org/repos/asf/tajo/blob/b24d18f5/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
index 7fe6ef3..34740c0 100644
--- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
+++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
@@ -80,6 +80,10 @@ public abstract class AbstractDBStore extends CatalogConstants implements Catalo
return catalogSchemaManager.isInitialized(getConnection());
}
+ protected boolean catalogAlreadyExists() throws CatalogException {
+ return catalogSchemaManager.catalogAlreadyExists(getConnection());
+ }
+
protected void createBaseTable() throws CatalogException {
createDatabaseDependants();
@@ -142,22 +146,27 @@ public abstract class AbstractDBStore extends CatalogConstants implements Catalo
}
try {
- if (isInitialized()) {
- LOG.info("The base tables of CatalogServer already is initialized.");
+ if (catalogAlreadyExists()) {
+ LOG.info("The meta table of CatalogServer already is created.");
verifySchemaVersion();
} else {
- try {
- createBaseTable();
- LOG.info("The base tables of CatalogServer are created.");
- } catch (CatalogException ce) {
+ if (isInitialized()) {
+ LOG.info("The base tables of CatalogServer already is initialized.");
+ verifySchemaVersion();
+ } else {
try {
- dropBaseTable();
- } catch (Throwable t) {
- LOG.error(t, t);
+ createBaseTable();
+ LOG.info("The base tables of CatalogServer are created.");
+ } catch (CatalogException ce) {
+ try {
+ dropBaseTable();
+ } catch (Throwable t) {
+ LOG.error(t, t);
+ }
+ throw ce;
}
- throw ce;
}
- }
+ }
} catch (Exception se) {
throw new CatalogException("Cannot initialize the persistent storage of Catalog", se);
}
@@ -245,7 +254,7 @@ public abstract class AbstractDBStore extends CatalogConstants implements Catalo
LOG.error("| You might downgrade or upgrade Apache Tajo. Downgrading or upgrading |");
LOG.error("| Tajo without migration process is only available in some versions. |");
LOG.error("| In order to learn how to migration Apache Tajo instance, |");
- LOG.error("| please refer http://s.apache.org/0_8_migration. |");
+ LOG.error("| please refer http://tajo.apache.org/docs/current/backup_and_restore/catalog.html |");
LOG.error("=========================================================================");
throw new CatalogException("Migration Needed. Please refer http://s.apache.org/0_8_migration.");
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/b24d18f5/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/XMLCatalogSchemaManager.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/XMLCatalogSchemaManager.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/XMLCatalogSchemaManager.java
index 1ea812c..9173cb8 100644
--- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/XMLCatalogSchemaManager.java
+++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/XMLCatalogSchemaManager.java
@@ -51,9 +51,11 @@ import javax.xml.stream.XMLStreamReader;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.tajo.catalog.CatalogConstants;
import org.apache.tajo.catalog.CatalogUtil;
import org.apache.tajo.catalog.exception.CatalogException;
import org.apache.tajo.catalog.store.object.*;
+import org.apache.tajo.util.TUtil;
public class XMLCatalogSchemaManager {
protected final Log LOG = LogFactory.getLog(getClass());
@@ -344,6 +346,34 @@ public class XMLCatalogSchemaManager {
CatalogUtil.closeQuietly(stmt);
}
+ public boolean catalogAlreadyExists(Connection conn) throws CatalogException {
+ boolean result = false;
+ try {
+ List<String> constants = TUtil.newList();
+ constants.add(CatalogConstants.TB_META);
+ constants.add(CatalogConstants.TB_SPACES);
+ constants.add(CatalogConstants.TB_DATABASES);
+ constants.add(CatalogConstants.TB_TABLES);
+ constants.add(CatalogConstants.TB_COLUMNS);
+ constants.add(CatalogConstants.TB_OPTIONS);
+ constants.add(CatalogConstants.TB_INDEXES);
+ constants.add(CatalogConstants.TB_STATISTICS);
+ constants.add(CatalogConstants.TB_PARTITION_METHODS);
+ constants.add(CatalogConstants.TB_PARTTIONS);
+ constants.add(CatalogConstants.TB_PARTTION_KEYS);
+
+ for (String constant : constants) {
+ if (checkExistence(conn, DatabaseObjectType.TABLE, constant)) {
+ return true;
+ }
+ }
+
+ } catch (SQLException e) {
+ throw new CatalogException(e.getMessage(), e);
+ }
+ return result;
+ }
+
public boolean isInitialized(Connection conn) throws CatalogException {
if (!isLoaded()) {
throw new CatalogException("Database schema files are not loaded.");