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 2013/11/18 12:45:56 UTC
git commit: TAJO-313: Support deprecated variables in
CatalogConstants. (jaehwa)
Updated Branches:
refs/heads/master 342fd47ff -> 4b12aaafc
TAJO-313: Support deprecated variables in CatalogConstants. (jaehwa)
Project: http://git-wip-us.apache.org/repos/asf/incubator-tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tajo/commit/4b12aaaf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tajo/tree/4b12aaaf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tajo/diff/4b12aaaf
Branch: refs/heads/master
Commit: 4b12aaafcee7b8849fb9147f0b5b56f0c67d2220
Parents: 342fd47
Author: blrunner <jh...@gruter.com>
Authored: Mon Nov 18 20:45:30 2013 +0900
Committer: blrunner <jh...@gruter.com>
Committed: Mon Nov 18 20:45:30 2013 +0900
----------------------------------------------------------------------
CHANGES.txt | 2 +
.../apache/tajo/catalog/CatalogConstants.java | 6 ++-
.../org/apache/tajo/catalog/CatalogServer.java | 11 ++++-
.../tajo/catalog/store/AbstractDBStore.java | 28 +++++++++++-
.../tajo/catalog/store/HCatalogStore.java | 8 +++-
.../apache/tajo/catalog/store/MySQLStore.java | 3 +-
.../tajo/catalog/TestCatalogConstants.java | 46 ++++++++++++++++++++
.../org/apache/tajo/catalog/TestDBStore.java | 6 +--
8 files changed, 102 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/4b12aaaf/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f91d2d1..d4c2048 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -65,6 +65,8 @@ Release 0.2.0 - unreleased
IMPROVEMENTS
+ TAJO-313: Support deprecated variables in CatalogConstants. (jaehwa)
+
TAJO-310: Make the DataLocation class as a separate class and move it to the tajo-core-storage package. (jihoon)
TAJO-311: Improve Hive dependency. (jaehwa)
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/4b12aaaf/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogConstants.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogConstants.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogConstants.java
index b9e6d61..4b1f794 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogConstants.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogConstants.java
@@ -23,8 +23,12 @@ public class CatalogConstants {
public static final String CONNECTION_ID = "tajo.catalog.connection.id";
public static final String CONNECTION_PASSWORD = "tajo.catalog.connection.password";
-
public static final String CATALOG_URI="tajo.catalog.uri";
+
+ public static final String DEPRECATED_CONNECTION_ID = "tajo.catalog.jdbc.connection.id";
+ public static final String DEPRECATED_CONNECTION_PASSWORD = "tajo.catalog.jdbc.connection.password";
+ public static final String DEPRECATED_CATALOG_URI="tajo.catalog.jdbc.uri";
+
public static final String TB_META = "META";
public static final String TB_TABLES = "TABLES";
public static final String TB_COLUMNS = "COLUMNS";
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/4b12aaaf/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/CatalogServer.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/CatalogServer.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/CatalogServer.java
index 21ccfaf..dc279bc 100644
--- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/CatalogServer.java
+++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/CatalogServer.java
@@ -125,8 +125,17 @@ public class CatalogServer extends AbstractService {
}
public String getCatalogServerName() {
+ String catalogUri = null;
+ if(conf.get(CatalogConstants.DEPRECATED_CATALOG_URI) != null) {
+ LOG.warn("Configuration parameter " + CatalogConstants.DEPRECATED_CATALOG_URI + " " +
+ "is deprecated. Use " + CatalogConstants.CATALOG_URI + " instead.");
+ catalogUri = conf.get(CatalogConstants.DEPRECATED_CATALOG_URI);
+ } else {
+ catalogUri = conf.get(CatalogConstants.CATALOG_URI);
+ }
+
return bindAddressStr + ", store=" + this.store.getClass().getSimpleName() + ", catalogUri="
- + conf.get(CatalogConstants.CATALOG_URI);
+ + catalogUri;
}
private void initBuiltinFunctions(List<FunctionDesc> functions)
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/4b12aaaf/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 a1e8d0d..6a76794 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
@@ -43,6 +43,8 @@ import java.util.Map.Entry;
public abstract class AbstractDBStore extends CatalogConstants implements CatalogStore {
protected final Log LOG = LogFactory.getLog(getClass());
protected Configuration conf;
+ protected String connectionId;
+ protected String connectionPassword;
protected String catalogUri;
private Connection conn;
@@ -60,7 +62,31 @@ public abstract class AbstractDBStore extends CatalogConstants implements Catalo
throws InternalException {
this.conf = conf;
- this.catalogUri = conf.get(CATALOG_URI);
+
+ if(conf.get(CatalogConstants.DEPRECATED_CATALOG_URI) != null) {
+ LOG.warn("Configuration parameter " + CatalogConstants.DEPRECATED_CATALOG_URI + " " +
+ "is deprecated. Use " + CatalogConstants.CATALOG_URI + " instead.");
+ this.catalogUri = conf.get(CatalogConstants.DEPRECATED_CATALOG_URI);
+ } else {
+ this.catalogUri = conf.get(CatalogConstants.CATALOG_URI);
+ }
+
+ if(conf.get(CatalogConstants.DEPRECATED_CONNECTION_ID) != null) {
+ LOG.warn("Configuration parameter " + CatalogConstants.DEPRECATED_CONNECTION_ID + " " +
+ "is deprecated. Use " + CatalogConstants.CONNECTION_ID + " instead.");
+ this.connectionId = conf.get(CatalogConstants.DEPRECATED_CONNECTION_ID);
+ } else {
+ this.connectionId = conf.get(CatalogConstants.CONNECTION_ID);
+ }
+
+ if(conf.get(CatalogConstants.DEPRECATED_CONNECTION_PASSWORD) != null) {
+ LOG.warn("Configuration parameter " + CatalogConstants.DEPRECATED_CONNECTION_PASSWORD + " " +
+ "is deprecated. Use " + CatalogConstants.CONNECTION_PASSWORD + " instead.");
+ this.connectionPassword = conf.get(CatalogConstants.DEPRECATED_CONNECTION_PASSWORD);
+ } else {
+ this.connectionPassword = conf.get(CatalogConstants.CONNECTION_PASSWORD);
+ }
+
String catalogDriver = getCatalogDriverName();
try {
Class.forName(getCatalogDriverName()).newInstance();
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/4b12aaaf/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
index f54990b..d8a0e98 100644
--- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
+++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
@@ -48,7 +48,13 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
public HCatalogStore(final Configuration conf)
throws InternalException {
this.conf = conf;
- this.catalogUri = conf.get(CATALOG_URI);
+ if(conf.get(CatalogConstants.DEPRECATED_CATALOG_URI) != null) {
+ LOG.warn("Configuration parameter " + CatalogConstants.DEPRECATED_CATALOG_URI + " " +
+ "is deprecated. Use " + CatalogConstants.CATALOG_URI + " instead.");
+ this.catalogUri = conf.get(CatalogConstants.DEPRECATED_CATALOG_URI);
+ } else {
+ this.catalogUri = conf.get(CatalogConstants.CATALOG_URI);
+ }
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/4b12aaaf/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MySQLStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MySQLStore.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MySQLStore.java
index 6c379f1..259d9d6 100644
--- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MySQLStore.java
+++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MySQLStore.java
@@ -42,7 +42,8 @@ public class MySQLStore extends AbstractDBStore {
}
protected Connection createConnection(Configuration conf) throws SQLException {
- Connection con = DriverManager.getConnection(getCatalogUri(), conf.get(CONNECTION_ID), conf.get(CONNECTION_PASSWORD));
+ Connection con = DriverManager.getConnection(getCatalogUri(), this.connectionId,
+ this.connectionPassword);
//TODO con.setAutoCommit(false);
return con;
}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/4b12aaaf/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalogConstants.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalogConstants.java b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalogConstants.java
new file mode 100644
index 0000000..f7b5c19
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalogConstants.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tajo.catalog;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.tajo.catalog.store.DerbyStore;
+import org.apache.tajo.conf.TajoConf;
+import org.apache.tajo.util.CommonTestingUtil;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import java.io.File;
+
+public class TestCatalogConstants extends TestDBStore {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ conf = new TajoConf();
+ Path testDir = CommonTestingUtil.getTestDir("target/test-data/TestDBSTore");
+ File absolutePath = new File(testDir.toUri());
+ conf.set(CatalogConstants.DEPRECATED_CATALOG_URI, "jdbc:derby:"+absolutePath.getAbsolutePath()+"/db;create=true");
+ LOG.info("derby repository is set to "+conf.get(CatalogConstants.DEPRECATED_CATALOG_URI));
+ store = new DerbyStore(conf);
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ store.close();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/4b12aaaf/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestDBStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestDBStore.java b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestDBStore.java
index 4ae4d5d..260b4c7 100644
--- a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestDBStore.java
+++ b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestDBStore.java
@@ -39,9 +39,9 @@ import java.io.IOException;
import static org.junit.Assert.*;
public class TestDBStore {
- private static final Log LOG = LogFactory.getLog(TestDBStore.class);
- private static Configuration conf;
- private static AbstractDBStore store;
+ protected static final Log LOG = LogFactory.getLog(TestDBStore.class);
+ protected static Configuration conf;
+ protected static AbstractDBStore store;
@BeforeClass
public static void setUp() throws Exception {