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 2014/02/19 16:03:01 UTC

[3/3] git commit: TAJO-530: Fix warnings in tajo-catalog. (jaehwa)

TAJO-530: Fix warnings in tajo-catalog. (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/413a4b3f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tajo/tree/413a4b3f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tajo/diff/413a4b3f

Branch: refs/heads/master
Commit: 413a4b3fc9bdfa49f4d58d9414f58c30a169c5ab
Parents: c586227
Author: blrunner <jh...@gruter.com>
Authored: Thu Feb 20 00:02:46 2014 +0900
Committer: blrunner <jh...@gruter.com>
Committed: Thu Feb 20 00:02:46 2014 +0900

----------------------------------------------------------------------
 CHANGES.txt                                     |    2 +
 .../org/apache/tajo/catalog/CatalogUtil.java    |   70 +-
 .../org/apache/tajo/catalog/FunctionDesc.java   |   16 +-
 .../java/org/apache/tajo/catalog/Options.java   |   11 +-
 .../java/org/apache/tajo/catalog/Schema.java    |   20 +-
 .../java/org/apache/tajo/catalog/SortSpec.java  |    6 +
 .../java/org/apache/tajo/catalog/TableDesc.java |    5 +
 .../tajo/catalog/json/TableMetaAdapter.java     |    8 +-
 .../tajo/catalog/partition/PartitionDesc.java   |   18 +
 .../catalog/partition/PartitionMethodDesc.java  |    6 +
 .../apache/tajo/catalog/statistics/StatSet.java |   21 +-
 .../tajo/catalog/store/HCatalogStore.java       |  240 ++--
 .../catalog/store/HCatalogStoreClientPool.java  |   26 +-
 .../apache/tajo/catalog/store/HCatalogUtil.java |   39 +-
 .../org/apache/tajo/catalog/CatalogServer.java  |   97 +-
 .../tajo/catalog/store/AbstractDBStore.java     | 1140 +++++++++++-------
 .../apache/tajo/catalog/store/CatalogStore.java |   57 +-
 .../apache/tajo/catalog/store/DerbyStore.java   |  368 +++---
 .../org/apache/tajo/catalog/store/MemStore.java |   71 +-
 .../apache/tajo/catalog/store/MySQLStore.java   |  208 ++--
 .../tajo/engine/planner/global/DataChannel.java |    3 +-
 .../planner/logical/TableSubQueryNode.java      |    9 +-
 .../engine/planner/physical/SeqScanExec.java    |    3 +-
 .../apache/tajo/engine/utils/SchemaUtil.java    |    9 +
 .../apache/tajo/engine/eval/ExprTestBase.java   |    3 +-
 25 files changed, 1443 insertions(+), 1013 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 8ecc7a2..af59b4c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -449,6 +449,8 @@ Release 0.8.0 - unreleased
 
   TASKS
 
+    TAJO-530: Fix warnings in tajo-catalog. (jaehwa)
+
     TAJO-532: Fix warnings in tajo-common. (jinho)
 
     TAJO-520: Move tajo-core-storage to tajo-storage. (jinho)

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java
index 95bd83d..9f143ac 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java
@@ -26,11 +26,7 @@ import org.apache.tajo.catalog.proto.CatalogProtos.SchemaProto;
 import org.apache.tajo.catalog.proto.CatalogProtos.TableDescProto;
 import org.apache.tajo.common.TajoDataTypes.DataType;
 
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.Statement;
-import java.sql.PreparedStatement;
-import java.sql.Wrapper;
+import java.sql.*;
 import java.util.Collection;
 
 import static org.apache.tajo.catalog.proto.CatalogProtos.StoreType;
@@ -157,21 +153,55 @@ public class CatalogUtil {
     return sb.toString();
   }
 
-  public static void closeSQLWrapper(Wrapper... wrapper) {
-    if(wrapper == null) return;
-
-    for(Wrapper w : wrapper){
-      try{
-        if(w instanceof Statement){
-          ((Statement)w).close();
-        } else if(w instanceof PreparedStatement){
-            ((PreparedStatement)w).close();
-        } else if(w instanceof ResultSet){
-          ((ResultSet)w).close();
-        } else if(w instanceof Connection){
-          ((Connection)w).close();
-        }
-      } catch (Exception e){}
+  public static void closeQuietly(Connection conn) {
+    try {
+      if (conn != null)
+        conn.close();
+    } catch (SQLException se) {
+    }
+  }
+
+  public static void closeQuietly(Statement stmt)  {
+    try {
+      if (stmt != null)
+        stmt.close();
+    } catch (SQLException se) {
+    }
+  }
+
+  public static void closeQuietly(ResultSet res) {
+    try {
+      if (res != null)
+        res.close();
+    } catch (SQLException se) {
+    }
+  }
+
+  public static void closeQuietly(Connection conn, Statement stmt)  {
+    try {
+      closeQuietly(stmt);
+    } finally {
+      closeQuietly(conn);
+    }
+  }
+
+  public static void closeQuietly(Connection conn, ResultSet res) {
+    try {
+      closeQuietly(res);
+    } finally {
+      closeQuietly(conn);
+    }
+  }
+
+  public static void closeQuietly(Connection conn, Statement stmt, ResultSet res) {
+    try {
+      closeQuietly(res);
+    } finally {
+      try {
+        closeQuietly(stmt);
+      } finally {
+        closeQuietly(conn);
+      }
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/FunctionDesc.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/FunctionDesc.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/FunctionDesc.java
index 084d97c..0ef8497 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/FunctionDesc.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/FunctionDesc.java
@@ -208,13 +208,17 @@ public class FunctionDesc implements ProtoObject<FunctionDescProto>, Cloneable,
   }
 
   public static String dataTypesToStr(List<DataType> parameterTypesList) {
-    String result = "";
-    String prefix = "";
-    for(DataType eachType: parameterTypesList) {
-      result += prefix + eachType.getType().toString();
-      prefix = ",";
+    StringBuilder result = new StringBuilder();
+    for (int i = 0; i < parameterTypesList.size(); i++) {
+      DataType eachType = parameterTypesList.get(i);
+
+      if (i > 0) {
+        result.append(",");
+      }
+      result.append(eachType.getType().toString());
+
     }
 
-    return result;
+    return result.toString();
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Options.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Options.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Options.java
index e770b11..c6f9a77 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Options.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Options.java
@@ -18,6 +18,7 @@
 
 package org.apache.tajo.catalog;
 
+import com.google.common.base.Objects;
 import com.google.gson.annotations.Expose;
 import org.apache.tajo.catalog.json.CatalogGsonHelper;
 import org.apache.tajo.catalog.proto.CatalogProtos.KeyValueProto;
@@ -98,8 +99,14 @@ public class Options implements ProtoObject<KeyValueSetProto>, Cloneable, GsonOb
 	public String delete(String key) {
 		return keyVals.remove(key);
 	}
-	
-	@Override
+
+  @Override
+  public int hashCode() {
+    return Objects.hashCode(keyVals);
+
+  }
+
+    @Override
 	public boolean equals(Object object) {
 		if(object instanceof Options) {
 			Options other = (Options)object;

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java
index f253151..5f1e8d7 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java
@@ -18,12 +18,14 @@
 
 package org.apache.tajo.catalog;
 
+import com.google.common.base.Objects;
 import com.google.common.collect.ImmutableList;
 import com.google.gson.annotations.Expose;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.tajo.catalog.exception.AlreadyExistsFieldException;
 import org.apache.tajo.catalog.json.CatalogGsonHelper;
+import org.apache.tajo.catalog.proto.CatalogProtos;
 import org.apache.tajo.catalog.proto.CatalogProtos.ColumnProto;
 import org.apache.tajo.catalog.proto.CatalogProtos.SchemaProto;
 import org.apache.tajo.common.ProtoObject;
@@ -279,6 +281,11 @@ public class Schema implements ProtoObject<SchemaProto>, Cloneable, GsonObject {
   }
 
   @Override
+  public int hashCode() {
+    return Objects.hashCode(fields, fieldsByQualifiedName, fieldsByName);
+  }
+
+  @Override
 	public boolean equals(Object o) {
 		if (o instanceof Schema) {
 		  Schema other = (Schema) o;
@@ -288,8 +295,15 @@ public class Schema implements ProtoObject<SchemaProto>, Cloneable, GsonObject {
 	}
 	
   @Override
-  public Object clone() {
-    Schema schema = new Schema(toArray());
+  public Object clone() throws CloneNotSupportedException {
+    Schema schema = null;
+
+    schema = (Schema) super.clone();
+    schema.builder = CatalogProtos.SchemaProto.newBuilder();
+    schema.init();
+    for(Column column: this.fields) {
+      schema.addColumn(column);
+    }
     return schema;
   }
 
@@ -311,7 +325,7 @@ public class Schema implements ProtoObject<SchemaProto>, Cloneable, GsonObject {
 	  for(Column col : fields) {
 	    sb.append(col);
 	    if (i < fields.size() - 1) {
-	      sb.append(", ");
+	      sb.append(",");
 	    }
 	    i++;
 	  }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/SortSpec.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/SortSpec.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/SortSpec.java
index 5cc0de1..3ef73d5 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/SortSpec.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/SortSpec.java
@@ -18,6 +18,7 @@
 
 package org.apache.tajo.catalog;
 
+import com.google.common.base.Objects;
 import com.google.gson.annotations.Expose;
 import org.apache.tajo.catalog.json.CatalogGsonHelper;
 import org.apache.tajo.common.ProtoObject;
@@ -85,6 +86,11 @@ public class SortSpec implements Cloneable, GsonObject, ProtoObject<SortSpecProt
   }
 
   @Override
+  public int hashCode() {
+    return Objects.hashCode(Objects.hashCode(sortKey), ascending, nullFirst);
+  }
+
+  @Override
   public boolean equals(Object object) {
     if (object instanceof SortSpec) {
       SortSpec other = (SortSpec) object;

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/TableDesc.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/TableDesc.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/TableDesc.java
index 1b0a9fe..153d5f0 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/TableDesc.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/TableDesc.java
@@ -18,6 +18,7 @@
 
 package org.apache.tajo.catalog;
 
+import com.google.common.base.Objects;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.annotations.Expose;
@@ -140,6 +141,10 @@ public class TableDesc implements ProtoObject<TableDescProto>, GsonObject, Clone
     this.partitionMethodDesc = partitionMethodDesc;
   }
 
+  public int hashCode() {
+    return Objects.hashCode(tableName, schema, meta, uri, stats, partitionMethodDesc);
+  }
+
   public boolean equals(Object object) {
     if(object instanceof TableDesc) {
       TableDesc other = (TableDesc) object;

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/json/TableMetaAdapter.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/json/TableMetaAdapter.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/json/TableMetaAdapter.java
index ce42bea..b3f788e 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/json/TableMetaAdapter.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/json/TableMetaAdapter.java
@@ -18,9 +18,9 @@
 
 package org.apache.tajo.catalog.json;
 
+import com.google.common.base.Preconditions;
 import com.google.gson.*;
 import org.apache.tajo.catalog.Options;
-import org.apache.tajo.catalog.Schema;
 import org.apache.tajo.catalog.TableMeta;
 import org.apache.tajo.catalog.proto.CatalogProtos;
 import org.apache.tajo.json.GsonSerDerAdapter;
@@ -32,13 +32,17 @@ public class TableMetaAdapter implements GsonSerDerAdapter<TableMeta> {
 	@Override
 	public TableMeta deserialize(JsonElement json, Type typeOfT,
 			JsonDeserializationContext context) throws JsonParseException {
+    Preconditions.checkNotNull(json);
 		JsonObject jsonObject = json.getAsJsonObject();
 
     CatalogProtos.StoreType type = CatalogProtos.StoreType.valueOf(jsonObject.get("store").getAsString());
 
     Options options = null;
-    if (jsonObject.has("options")) {
+    if (jsonObject.get("options") != null) {
       options = context.deserialize(jsonObject.get("options"), Options.class);
+    } else {
+      throw new JsonParseException("Options not found in json");
+
     }
 		return new TableMeta(type, options);
 	}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/partition/PartitionDesc.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/partition/PartitionDesc.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/partition/PartitionDesc.java
index f7c1342..e89ee72 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/partition/PartitionDesc.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/partition/PartitionDesc.java
@@ -18,6 +18,7 @@
 
 package org.apache.tajo.catalog.partition;
 
+import com.google.common.base.Objects;
 import com.google.gson.annotations.Expose;
 import org.apache.tajo.catalog.json.CatalogGsonHelper;
 import org.apache.tajo.catalog.proto.CatalogProtos;
@@ -104,6 +105,10 @@ public class PartitionDesc implements ProtoObject<CatalogProtos.PartitionDescPro
     this.path = path;
   }
 
+  public int hashCode() {
+    return Objects.hashCode(tableId, partitionName, ordinalPosition, partitionValue, path);
+  }
+
   public boolean equals(Object o) {
     if (o instanceof PartitionDesc) {
       PartitionDesc another = (PartitionDesc) o;
@@ -160,4 +165,17 @@ public class PartitionDesc implements ProtoObject<CatalogProtos.PartitionDescPro
   public static PartitionDesc fromJson(String strVal) {
     return strVal != null ? CatalogGsonHelper.fromJson(strVal, PartitionDesc.class) : null;
   }
+
+  public Object clone() throws CloneNotSupportedException {
+    PartitionDesc desc = (PartitionDesc) super.clone();
+    desc.builder = CatalogProtos.PartitionDescProto.newBuilder();
+    desc.tableId = tableId;
+    desc.partitionName = partitionName;
+    desc.ordinalPosition = ordinalPosition;
+    desc.partitionValue = partitionValue;
+    desc.path = path;
+
+    return desc;
+  }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/partition/PartitionMethodDesc.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/partition/PartitionMethodDesc.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/partition/PartitionMethodDesc.java
index d4a2c3e..4a8123a 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/partition/PartitionMethodDesc.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/partition/PartitionMethodDesc.java
@@ -18,6 +18,7 @@
 
 package org.apache.tajo.catalog.partition;
 
+import com.google.common.base.Objects;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.annotations.Expose;
@@ -102,6 +103,11 @@ public class PartitionMethodDesc implements ProtoObject<CatalogProtos.PartitionM
   }
 
   @Override
+  public int hashCode() {
+    return Objects.hashCode(tableId, partitionType, expression, expressionSchema);
+  }
+
+  @Override
   public CatalogProtos.PartitionMethodProto getProto() {
     if(builder == null) {
       builder = CatalogProtos.PartitionMethodProto.newBuilder();

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/StatSet.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/StatSet.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/StatSet.java
index f8d24b0..9c95a1d 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/StatSet.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/StatSet.java
@@ -18,9 +18,11 @@
 
 package org.apache.tajo.catalog.statistics;
 
+import com.google.common.base.Objects;
 import com.google.common.collect.Maps;
 import com.google.gson.annotations.Expose;
 import org.apache.tajo.catalog.json.CatalogGsonHelper;
+import org.apache.tajo.catalog.proto.CatalogProtos;
 import org.apache.tajo.catalog.proto.CatalogProtos.StatProto;
 import org.apache.tajo.catalog.proto.CatalogProtos.StatSetProto;
 import org.apache.tajo.catalog.proto.CatalogProtos.StatSetProtoOrBuilder;
@@ -67,7 +69,11 @@ public class StatSet implements ProtoObject<StatSetProto>, Cloneable {
     initStats();
     return stats.values();
   }
-  
+
+  public int hashCode() {
+    return Objects.hashCode(viaProto, stats);
+  }
+
   public boolean equals(Object obj) {
     if (obj instanceof StatSet) {
       StatSet other = (StatSet) obj;
@@ -83,7 +89,18 @@ public class StatSet implements ProtoObject<StatSetProto>, Cloneable {
   }
   
   public Object clone() throws CloneNotSupportedException {
-    return new StatSet(this.getProto());
+    StatSet statSet = (StatSet) super.clone();
+    statSet.builder = CatalogProtos.StatSetProto.newBuilder();
+    statSet.viaProto = viaProto;
+
+    statSet.stats = Maps.newHashMap();
+    for (Entry<StatType, Stat> entry : stats.entrySet()) {
+      StatType type = (StatType)entry.getKey();
+      Stat stat = (Stat)entry.getValue().clone();
+      statSet.stats.put(type, stat);
+    }
+
+    return statSet;
   }
 
   private void initStats() {

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
index f796fff..bc43f2c 100644
--- a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
+++ b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
@@ -31,6 +31,7 @@ import org.apache.hcatalog.data.schema.HCatFieldSchema;
 import org.apache.hcatalog.data.schema.HCatSchema;
 import org.apache.tajo.catalog.*;
 import org.apache.tajo.catalog.Schema;
+import org.apache.tajo.catalog.exception.CatalogException;
 import org.apache.tajo.catalog.partition.PartitionMethodDesc;
 import org.apache.tajo.catalog.proto.CatalogProtos;
 import org.apache.tajo.catalog.statistics.TableStats;
@@ -38,7 +39,10 @@ import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.exception.InternalException;
 
 import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Properties;
 
 import static org.apache.tajo.catalog.proto.CatalogProtos.PartitionType;
 
@@ -47,7 +51,7 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
 
   protected final Log LOG = LogFactory.getLog(getClass());
   protected Configuration conf;
-  private static final int CLIENT_POOL_SIZE = 5;
+  private static final int CLIENT_POOL_SIZE = 2;
   private final HCatalogStoreClientPool clientPool = new HCatalogStoreClientPool(0);
 
   public HCatalogStore(final Configuration conf)
@@ -61,7 +65,7 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
   }
 
   @Override
-  public boolean existTable(final String name) throws IOException {
+  public boolean existTable(final String name) throws CatalogException {
     boolean exist = false;
 
     String dbName = null, tableName = null;
@@ -73,8 +77,8 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
       tablePair = HCatUtil.getDbAndTableName(name);
       dbName = tablePair.first;
       tableName = tablePair.second;
-    } catch (IOException ioe) {
-      throw new InternalException("Table name is wrong.", ioe);
+    } catch (Exception ioe) {
+      throw new CatalogException("Table name is wrong.", ioe);
     }
 
     // get table
@@ -88,7 +92,7 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
       } catch (NoSuchObjectException nsoe) {
         exist = false;
       } catch (Exception e) {
-        throw new IOException(e);
+        throw new CatalogException(e);
       }
     } finally {
       client.release();
@@ -98,7 +102,7 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
   }
 
   @Override
-  public final CatalogProtos.TableDescProto getTable(final String name) throws IOException {
+  public final CatalogProtos.TableDescProto getTable(final String name) throws CatalogException {
     String dbName = null, tableName = null;
     Pair<String, String> tablePair = null;
     org.apache.hadoop.hive.ql.metadata.Table table = null;
@@ -115,8 +119,8 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
       tablePair = HCatUtil.getDbAndTableName(name);
       dbName = tablePair.first;
       tableName = tablePair.second;
-    } catch (IOException ioe) {
-      throw new InternalException("Table name is wrong.", ioe);
+    } catch (Exception ioe) {
+      throw new CatalogException("Table name is wrong.", ioe);
     }
 
     //////////////////////////////////
@@ -129,14 +133,20 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
         table = HCatUtil.getTable(client.getHiveClient(), dbName, tableName);
         path = table.getPath();
       } catch (NoSuchObjectException nsoe) {
-        throw new InternalException("Table not found. - tableName:" + name, nsoe);
+        throw new CatalogException("Table not found. - tableName:" + name, nsoe);
       } catch (Exception e) {
-        throw new IOException(e);
+        throw new CatalogException(e);
       }
 
       // convert hcatalog field schema into tajo field schema.
       schema = new org.apache.tajo.catalog.Schema();
-      HCatSchema tableSchema = HCatUtil.getTableSchemaWithPtnCols(table);
+      HCatSchema tableSchema = null;
+
+      try {
+        tableSchema = HCatUtil.getTableSchemaWithPtnCols(table);
+      } catch (IOException ioe) {
+        throw new CatalogException("Fail to get table schema. - tableName:" + name, ioe);
+      }
       List<HCatFieldSchema> fieldSchemaList = tableSchema.getFields();
       boolean isPartitionKey = false;
       for (HCatFieldSchema eachField : fieldSchemaList) {
@@ -160,9 +170,8 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
       // validate field schema.
       try {
         HCatalogUtil.validateHCatTableAndTajoSchema(tableSchema);
-      } catch (IOException e) {
-        throw new InternalException(
-            "HCatalog cannot support schema. - schema:" + tableSchema.toString(), e);
+      } catch (Exception e) {
+        throw new CatalogException("HCatalog cannot support schema. - schema:" + tableSchema.toString(), e);
       }
 
       stats = new TableStats();
@@ -181,8 +190,7 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
 
         // set file output format
         fileOutputformat = properties.getProperty("file.outputformat");
-        storeType = CatalogUtil.getStoreType(HCatalogUtil.getStoreType(fileOutputformat,
-            fieldDelimiter));
+        storeType = CatalogUtil.getStoreType(HCatalogUtil.getStoreType(fileOutputformat));
 
         if (storeType.equals(CatalogProtos.StoreType.CSV) ) {
           options.put(CVSFILE_DELIMITER, fieldDelimiter);
@@ -193,9 +201,13 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
         if(properties.getProperty("totalSize") != null) {
           totalSize = new Long(properties.getProperty("totalSize"));
         } else {
-          FileSystem fs = path.getFileSystem(conf);
-          if (fs.exists(path)) {
-            totalSize = fs.getContentSummary(path).getLength();
+          try {
+            FileSystem fs = path.getFileSystem(conf);
+            if (fs.exists(path)) {
+              totalSize = fs.getContentSummary(path).getLength();
+            }
+          } catch (IOException ioe) {
+            throw new CatalogException("Fail to get path. - path:" + path.toString(), ioe);
           }
         }
         stats.setNumBytes(totalSize);
@@ -249,26 +261,23 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
   }
 
   @Override
-  public final List<String> getAllTableNames() throws IOException {
+  public final List<String> getAllTableNames() throws CatalogException {
     List<String> dbs = null;
     List<String> tables = null;
     List<String> allTables = new ArrayList<String>();
     HCatalogStoreClientPool.HCatalogStoreClient client = null;
 
     try {
-      try {
-        client = clientPool.getClient();
-        dbs = client.getHiveClient().getAllDatabases();
-        for(String eachDB: dbs) {
-          tables = client.getHiveClient().getAllTables(eachDB);
-          for(String eachTable: tables) {
-            allTables.add(eachDB + "." + eachTable);
-          }
+      client = clientPool.getClient();
+      dbs = client.getHiveClient().getAllDatabases();
+      for(String eachDB: dbs) {
+        tables = client.getHiveClient().getAllTables(eachDB);
+        for(String eachTable: tables) {
+          allTables.add(eachDB + "." + eachTable);
         }
-      } catch (Exception e) {
-        throw new IOException(e);
       }
-
+    } catch (MetaException e) {
+      throw new CatalogException(e);
     } finally {
       client.release();
     }
@@ -276,7 +285,7 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
   }
 
   @Override
-  public final void addTable(final CatalogProtos.TableDescProto tableDesc) throws IOException {
+  public final void addTable(final CatalogProtos.TableDescProto tableDesc) throws CatalogException {
     String dbName = null, tableName = null;
     Pair<String, String> tablePair = null;
     HCatalogStoreClientPool.HCatalogStoreClient client = null;
@@ -286,88 +295,88 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
       tablePair = HCatUtil.getDbAndTableName(tableDesc.getId());
       dbName = tablePair.first;
       tableName = tablePair.second;
-    } catch (IOException ioe) {
-      throw new InternalException("Table name is wrong.", ioe);
+    } catch (Exception ioe) {
+      throw new CatalogException("Table name is wrong.", ioe);
     }
 
     try {
-      try {
-        client = clientPool.getClient();
+      client = clientPool.getClient();
 
-        org.apache.hadoop.hive.metastore.api.Table table = new org.apache.hadoop.hive.metastore.api.Table();
+      org.apache.hadoop.hive.metastore.api.Table table = new org.apache.hadoop.hive.metastore.api.Table();
 
-        table.setDbName(dbName);
-        table.setTableName(tableName);
-        // TODO: set owner
-        //table.setOwner();
+      table.setDbName(dbName);
+      table.setTableName(tableName);
+      // TODO: set owner
+      //table.setOwner();
 
-        StorageDescriptor sd = new StorageDescriptor();
+      StorageDescriptor sd = new StorageDescriptor();
 
-        // if tajo set location method, thrift client make exception as follows:
-        // Caused by: MetaException(message:java.lang.NullPointerException)
-        // If you want to modify table path, you have to modify on Hive cli.
-        //sd.setLocation(tableDesc.getPath().toString());
+      // if tajo set location method, thrift client make exception as follows:
+      // Caused by: MetaException(message:java.lang.NullPointerException)
+      // If you want to modify table path, you have to modify on Hive cli.
+      //sd.setLocation(tableDesc.getPath().toString());
 
-        // set column information
-        ArrayList<FieldSchema> cols = new ArrayList<FieldSchema>(tableDesc.getSchema().getFieldsCount());
-        for (CatalogProtos.ColumnProto col : tableDesc.getSchema().getFieldsList()) {
-          cols.add(new FieldSchema(
-              col.getColumnName(),
-              HCatalogUtil.getHiveFieldType(col.getDataType().getType().name()),
-              ""));
-        }
-        sd.setCols(cols);
-
-        sd.setCompressed(false);
-        if (tableDesc.getMeta().hasParams()) {
-          for (CatalogProtos.KeyValueProto entry: tableDesc.getMeta().getParams().getKeyvalList()) {
-            if (entry.getKey().equals("compression.codec")) {
-              sd.setCompressed(true);
-            } else if (entry.getKey().equals(CVSFILE_DELIMITER)) {
-              sd.getSerdeInfo().getParameters().put(serdeConstants.FIELD_DELIM, entry.getValue());
-            }
+      // set column information
+      ArrayList<FieldSchema> cols = new ArrayList<FieldSchema>(tableDesc.getSchema().getFieldsCount());
+      for (CatalogProtos.ColumnProto col : tableDesc.getSchema().getFieldsList()) {
+        cols.add(new FieldSchema(
+            col.getColumnName(),
+            HCatalogUtil.getHiveFieldType(col.getDataType().getType().name()),
+            ""));
+      }
+      sd.setCols(cols);
+
+      sd.setCompressed(false);
+      if (tableDesc.getMeta().hasParams()) {
+        for (CatalogProtos.KeyValueProto entry: tableDesc.getMeta().getParams().getKeyvalList()) {
+          if (entry.getKey().equals("compression.codec")) {
+            sd.setCompressed(true);
+          } else if (entry.getKey().equals(CVSFILE_DELIMITER)) {
+            sd.getSerdeInfo().getParameters().put(serdeConstants.FIELD_DELIM, entry.getValue());
           }
         }
+      }
 
-        sd.setParameters(new HashMap<String, String>());
-        sd.setSerdeInfo(new SerDeInfo());
-        sd.getSerdeInfo().setName(table.getTableName());
+      sd.setParameters(new HashMap<String, String>());
+      sd.setSerdeInfo(new SerDeInfo());
+      sd.getSerdeInfo().setName(table.getTableName());
 
-        if(tableDesc.getMeta().getStoreType().equals(CatalogProtos.StoreType.RCFILE)) {
-          sd.getSerdeInfo().setSerializationLib(org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe.class.getName());
-        } else {
-          sd.getSerdeInfo().setSerializationLib(org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe.class.getName());
-        }
+      if(tableDesc.getMeta().getStoreType().equals(CatalogProtos.StoreType.RCFILE)) {
+        sd.getSerdeInfo().setSerializationLib(org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe.class.getName());
+      } else {
+        sd.getSerdeInfo().setSerializationLib(org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe.class.getName());
+      }
 
-        sd.getSerdeInfo().setParameters(new HashMap<String, String>());
+      sd.getSerdeInfo().setParameters(new HashMap<String, String>());
 //      sd.getSerdeInfo().getParameters().put(serdeConstants.SERIALIZATION_FORMAT, "1");
 
-        if(tableDesc.getMeta().getStoreType().equals(CatalogProtos.StoreType.RCFILE)) {
-          sd.setInputFormat(org.apache.hadoop.hive.ql.io.RCFileInputFormat.class.getName());
-        } else {
-          sd.setInputFormat(org.apache.hadoop.mapred.TextInputFormat.class.getName());
-        }
+      if(tableDesc.getMeta().getStoreType().equals(CatalogProtos.StoreType.RCFILE)) {
+        sd.setInputFormat(org.apache.hadoop.hive.ql.io.RCFileInputFormat.class.getName());
+      } else {
+        sd.setInputFormat(org.apache.hadoop.mapred.TextInputFormat.class.getName());
+      }
 
-        if(tableDesc.getMeta().getStoreType().equals(CatalogProtos.StoreType.RCFILE)) {
-          sd.setOutputFormat(org.apache.hadoop.hive.ql.io.RCFileOutputFormat.class.getName());
-        } else {
-          sd.setOutputFormat(org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat.class.getName());
-        }
+      if(tableDesc.getMeta().getStoreType().equals(CatalogProtos.StoreType.RCFILE)) {
+        sd.setOutputFormat(org.apache.hadoop.hive.ql.io.RCFileOutputFormat.class.getName());
+      } else {
+        sd.setOutputFormat(org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat.class.getName());
+      }
 
-        sd.setSortCols(new ArrayList<Order>());
+      sd.setSortCols(new ArrayList<Order>());
 
-        table.setSd(sd);
-        client.getHiveClient().createTable(table);
-      } catch (Exception e) {
-        throw new IOException(e);
-      }
+      table.setSd(sd);
+      client.getHiveClient().createTable(table);
+    } catch (RuntimeException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new CatalogException(e);
     } finally {
       client.release();
     }
   }
 
   @Override
-  public final void deleteTable(final String name) throws IOException {
+  public final void deleteTable(final String name) throws CatalogException {
     String dbName = null, tableName = null;
     Pair<String, String> tablePair = null;
     HCatalogStoreClientPool.HCatalogStoreClient client = null;
@@ -377,8 +386,8 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
       tablePair = HCatUtil.getDbAndTableName(name);
       dbName = tablePair.first;
       tableName = tablePair.second;
-    } catch (IOException ioe) {
-      throw new InternalException("Table name is wrong.", ioe);
+    } catch (Exception ioe) {
+      throw new CatalogException("Table name is wrong.", ioe);
     }
 
     try {
@@ -386,120 +395,119 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
       client.getHiveClient().dropTable(dbName, tableName, false, false);
     } catch (NoSuchObjectException nsoe) {
     } catch (Exception e) {
-      throw new IOException(e);
+      throw new CatalogException(e);
     } finally {
       client.release();
     }
   }
 
   @Override
-  public void addPartitionMethod(CatalogProtos.PartitionMethodProto partitionMethodProto) throws IOException {
+  public void addPartitionMethod(CatalogProtos.PartitionMethodProto partitionMethodProto) throws CatalogException {
     // TODO - not implemented yet
   }
 
   @Override
-  public CatalogProtos.PartitionMethodProto getPartitionMethod(String tableName) throws IOException {
+  public CatalogProtos.PartitionMethodProto getPartitionMethod(String tableName) throws CatalogException {
     return null;  // TODO - not implemented yet
   }
 
   @Override
-  public boolean existPartitionMethod(String tableName) throws IOException {
+  public boolean existPartitionMethod(String tableName) throws CatalogException {
     return false;  // TODO - not implemented yet
   }
 
   @Override
-  public void delPartitionMethod(String tableName) throws IOException {
+  public void delPartitionMethod(String tableName) throws CatalogException {
     // TODO - not implemented yet
   }
 
   @Override
-  public void addPartitions(CatalogProtos.PartitionsProto partitionsProto) throws IOException {
+  public void addPartitions(CatalogProtos.PartitionsProto partitionsProto) throws CatalogException {
     // TODO - not implemented yet
   }
 
   @Override
-  public void addPartition(CatalogProtos.PartitionDescProto partitionDescProto) throws IOException {
+  public void addPartition(CatalogProtos.PartitionDescProto partitionDescProto) throws CatalogException {
     // TODO - not implemented yet
   }
 
   @Override
-  public CatalogProtos.PartitionsProto getPartitions(String tableName) throws IOException {
+  public CatalogProtos.PartitionsProto getPartitions(String tableName) throws CatalogException {
     return null; // TODO - not implemented yet
   }
 
   @Override
-  public CatalogProtos.PartitionDescProto getPartition(String partitionName) throws IOException {
+  public CatalogProtos.PartitionDescProto getPartition(String partitionName) throws CatalogException {
     return null; // TODO - not implemented yet
   }
 
   @Override
-  public void delPartition(String partitionName) throws IOException {
+  public void delPartition(String partitionName) throws CatalogException {
     // TODO - not implemented yet
   }
 
   @Override
-  public void delPartitions(String tableName) throws IOException {
+  public void delPartitions(String tableName) throws CatalogException {
     // TODO - not implemented yet
   }
 
   @Override
-  public final void addFunction(final FunctionDesc func) throws IOException {
+  public final void addFunction(final FunctionDesc func) throws CatalogException {
     // TODO - not implemented yet
   }
 
   @Override
-  public final void deleteFunction(final FunctionDesc func) throws IOException {
+  public final void deleteFunction(final FunctionDesc func) throws CatalogException {
     // TODO - not implemented yet
   }
 
   @Override
-  public final void existFunction(final FunctionDesc func) throws IOException {
+  public final void existFunction(final FunctionDesc func) throws CatalogException {
     // TODO - not implemented yet
   }
 
   @Override
-  public final List<String> getAllFunctionNames() throws IOException {
+  public final List<String> getAllFunctionNames() throws CatalogException {
     // TODO - not implemented yet
     return null;
   }
 
   @Override
-  public void delIndex(String indexName) throws IOException {
+  public void delIndex(String indexName) throws CatalogException {
     // TODO - not implemented yet
   }
 
   @Override
-  public boolean existIndex(String indexName) throws IOException {
+  public boolean existIndex(String indexName) throws CatalogException {
     // TODO - not implemented yet
     return false;
   }
 
   @Override
-  public CatalogProtos.IndexDescProto[] getIndexes(String tableName) throws IOException {
+  public CatalogProtos.IndexDescProto[] getIndexes(String tableName) throws CatalogException {
     // TODO - not implemented yet
     return null;
   }
 
   @Override
-  public void addIndex(CatalogProtos.IndexDescProto proto) throws IOException {
+  public void addIndex(CatalogProtos.IndexDescProto proto) throws CatalogException {
     // TODO - not implemented yet
   }
 
   @Override
-  public CatalogProtos.IndexDescProto getIndex(String indexName) throws IOException {
+  public CatalogProtos.IndexDescProto getIndex(String indexName) throws CatalogException {
     // TODO - not implemented yet
     return null;
   }
 
   @Override
-  public CatalogProtos.IndexDescProto getIndex(String tableName, String columnName)
-      throws IOException {
+  public CatalogProtos.IndexDescProto getIndex(String tableName, String columnName) throws CatalogException {
     // TODO - not implemented yet
     return null;
   }
 
   @Override
-  public boolean existIndex(String tableName, String columnName) {
+  public boolean existIndex(String tableName, String columnName) throws CatalogException{
     // TODO - not implemented yet
     return false;
   }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStoreClientPool.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStoreClientPool.java b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStoreClientPool.java
index 263e1dd..0a6c9b9 100644
--- a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStoreClientPool.java
+++ b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStoreClientPool.java
@@ -20,6 +20,7 @@ import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
 import org.apache.log4j.Logger;
 
 import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
  * Manages a pool of HiveMetaStoreClient connections. If the connection pool is empty
@@ -29,7 +30,7 @@ public class HCatalogStoreClientPool {
   private static final Logger LOG = Logger.getLogger(HCatalogStoreClientPool.class);
   private final ConcurrentLinkedQueue<HCatalogStoreClient> clientPool =
       new ConcurrentLinkedQueue<HCatalogStoreClient>();
-  private Boolean poolClosed = false;
+  private AtomicBoolean poolClosed = new AtomicBoolean(false);
   private final HiveConf hiveConf;
 
   /**
@@ -42,7 +43,9 @@ public class HCatalogStoreClientPool {
 
     private HCatalogStoreClient(HiveConf hiveConf) {
       try {
-        LOG.debug("Creating MetaStoreClient. Pool Size = " + clientPool.size());
+
+        LOG.info("Creating MetaStoreClient. Pool Size = " + clientPool.size());
+
         this.hiveClient = new HiveMetaStoreClient(hiveConf);
       } catch (Exception e) {
         // Turn in to an unchecked exception
@@ -69,15 +72,15 @@ public class HCatalogStoreClientPool {
       // This lock is needed to ensure proper behavior when a thread reads poolClosed
       // is false, but a call to pool.close() comes in immediately afterward.
       synchronized (poolClosed) {
-        if (poolClosed) {
+//        if (poolClosed.get()) {
           hiveClient.close();
-        } else {
+//        } else {
           // TODO: Currently the pool does not work properly because we cannot
           // reuse MetastoreClient connections. No reason to add this client back
           // to the pool. See HIVE-5181.
-          // clientPool.add(this);
-          hiveClient.close();
-        }
+//          clientPool.add(this);
+//          hiveClient.close();
+//        }
       }
     }
 
@@ -122,11 +125,6 @@ public class HCatalogStoreClientPool {
     // The pool was empty so create a new client and return that.
     if (client == null) {
       client = new HCatalogStoreClient(hiveConf);
-    } else {
-      // TODO: Due to Hive Metastore bugs, there is leftover state from previous client
-      // connections so we are unable to reuse the same connection. For now simply
-      // reconnect each time. One possible culprit is HIVE-5181.
-      client = new HCatalogStoreClient(hiveConf);
     }
     client.markInUse();
     return client;
@@ -139,10 +137,10 @@ public class HCatalogStoreClientPool {
   public void close() {
     // Ensure no more items get added to the pool once close is called.
     synchronized (poolClosed) {
-      if (poolClosed) {
+      if (poolClosed.get()) {
         return;
       }
-      poolClosed = true;
+      poolClosed.set(true);
     }
 
     HCatalogStoreClient client = null;

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogUtil.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogUtil.java b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogUtil.java
index 8310873..f2764fb 100644
--- a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogUtil.java
+++ b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogUtil.java
@@ -17,6 +17,7 @@
  */
 package org.apache.tajo.catalog.store;
 
+import com.google.common.base.Preconditions;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat;
@@ -25,23 +26,20 @@ import org.apache.hadoop.hive.serde.serdeConstants;
 import org.apache.hcatalog.common.HCatException;
 import org.apache.hcatalog.data.schema.HCatFieldSchema;
 import org.apache.hcatalog.data.schema.HCatSchema;
+import org.apache.tajo.catalog.exception.CatalogException;
 import org.apache.tajo.catalog.proto.CatalogProtos;
 import org.apache.tajo.common.TajoDataTypes;
-import org.apache.tajo.exception.InternalException;
-
-import java.io.IOException;
 
 public class HCatalogUtil {
   protected final Log LOG = LogFactory.getLog(getClass());
 
-  public static void validateHCatTableAndTajoSchema(HCatSchema tblSchema) throws InternalException {
+  public static void validateHCatTableAndTajoSchema(HCatSchema tblSchema) throws CatalogException {
     for (HCatFieldSchema hcatField : tblSchema.getFields()) {
       validateHCatFieldAndTajoSchema(hcatField);
     }
   }
 
-  private static void validateHCatFieldAndTajoSchema(HCatFieldSchema fieldSchema) throws
-      InternalException {
+  private static void validateHCatFieldAndTajoSchema(HCatFieldSchema fieldSchema) throws CatalogException {
     try {
       HCatFieldSchema.Type fieldType = fieldSchema.getType();
       switch (fieldType) {
@@ -53,15 +51,14 @@ public class HCatalogUtil {
           throw new HCatException("Tajo cannot support map field type.");
       }
     } catch (HCatException e) {
-      throw new InternalException("incompatible hcatalog types when assigning to tajo type. - " +
-          "HCatFieldSchema:" + fieldSchema, e);
+      throw new CatalogException("incompatible hcatalog types when assigning to tajo type. - " +
+          "HCatFieldSchema:" + fieldSchema);
     }
   }
 
-  public static TajoDataTypes.Type getTajoFieldType(String fieldType) throws IOException {
-    if(fieldType == null) {
-      throw new InternalException("Hive field type is null.");
-    }
+  public static TajoDataTypes.Type getTajoFieldType(String fieldType)  {
+    Preconditions.checkNotNull(fieldType);
+
     String typeStr = null;
 
     if(fieldType.equalsIgnoreCase(serdeConstants.INT_TYPE_NAME))
@@ -86,14 +83,12 @@ public class HCatalogUtil {
     try {
       return Enum.valueOf(TajoDataTypes.Type.class, typeStr);
     } catch (IllegalArgumentException iae) {
-      throw new InternalException("Cannot find a matched type aginst from '" + typeStr + "'");
+      throw new CatalogException("Cannot find a matched type aginst from '" + typeStr + "'");
     }
   }
 
-  public static String getHiveFieldType(String fieldType) throws IOException {
-    if(fieldType == null) {
-      throw new InternalException("Tajo field type is null.");
-    }
+  public static String getHiveFieldType(String fieldType) {
+    Preconditions.checkNotNull(fieldType);
     String typeStr = null;
 
     if(fieldType.equalsIgnoreCase("INT4"))
@@ -118,14 +113,12 @@ public class HCatalogUtil {
     return typeStr;
   }
 
-  public static String getStoreType(String fileFormat, String delimiter) throws IOException{
-    if(fileFormat == null) {
-      throw new InternalException("Hive file output format is null.");
-    }
+  public static String getStoreType(String fileFormat) {
+    Preconditions.checkNotNull(fileFormat);
 
     String[] fileFormatArrary = fileFormat.split("\\.");
     if(fileFormatArrary.length < 1) {
-      throw new InternalException("Hive file output format is wrong. - file output format:" + fileFormat);
+      throw new CatalogException("Hive file output format is wrong. - file output format:" + fileFormat);
     }
 
     String inputFormatClass = fileFormatArrary[fileFormatArrary.length-1];
@@ -135,7 +128,7 @@ public class HCatalogUtil {
     } else if(inputFormatClass.equals(RCFileOutputFormat.class.getSimpleName())) {
         return CatalogProtos.StoreType.RCFILE.name();
     } else {
-      throw new InternalException("Not supported file output format. - file output format:" + fileFormat);
+      throw new CatalogException("Not supported file output format. - file output format:" + fileFormat);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/413a4b3f/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 cf13a9d..dc70305 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
@@ -43,10 +43,7 @@ import org.apache.tajo.util.TUtil;
 import java.io.IOException;
 import java.lang.reflect.Constructor;
 import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -103,7 +100,12 @@ public class CatalogServer extends AbstractService {
 
     Constructor<?> cons;
     try {
-      this.conf = (TajoConf) conf;
+      if (conf instanceof TajoConf) {
+        this.conf = (TajoConf) conf;
+      } else {
+        throw new CatalogException();
+      }
+
       Class<?> storeClass = this.conf.getClass(CatalogConstants.STORE_CLASS, DerbyStore.class);
 
       LOG.info("Catalog Store Class: " + storeClass.getCanonicalName());
@@ -201,9 +203,9 @@ public class CatalogServer extends AbstractService {
         }
 
         return store.getTable(tableId);
-      } catch (IOException ioe) {
+      } catch (Exception e) {
         // TODO - handle exception
-        LOG.error(ioe);
+        LOG.error(e);
         return null;
       } finally {
         rlock.unlock();
@@ -222,8 +224,9 @@ public class CatalogServer extends AbstractService {
           builder.addTableName(iterator.next());
         }
         return builder.build();
-      } catch (IOException ioe) {
+      } catch (Exception e) {
         // TODO - handle exception
+        LOG.error(e);
         return null;
       }
     }
@@ -250,8 +253,8 @@ public class CatalogServer extends AbstractService {
           throw new AlreadyExistsTableException(proto.getId());
         }
         store.addTable(proto);
-      } catch (IOException ioe) {
-        LOG.error(ioe.getMessage(), ioe);
+      } catch (Exception e) {
+        LOG.error(e.getMessage(), e);
         return BOOL_FALSE;
       } finally {
         wlock.unlock();
@@ -272,8 +275,8 @@ public class CatalogServer extends AbstractService {
           throw new NoSuchTableException(tableId);
         }
         store.deleteTable(tableId);
-      } catch (IOException ioe) {
-        LOG.error(ioe.getMessage(), ioe);
+      } catch (Exception e) {
+        LOG.error(e.getMessage(), e);
         return BOOL_FALSE;
       } finally {
         wlock.unlock();
@@ -292,7 +295,7 @@ public class CatalogServer extends AbstractService {
         } else {
           return BOOL_FALSE;
         }
-      } catch (IOException e) {
+      } catch (Exception e) {
         LOG.error(e);
         throw new ServiceException(e);
       }
@@ -306,9 +309,9 @@ public class CatalogServer extends AbstractService {
       try {
         String tableId = name.getValue().toLowerCase();
         return store.getPartitionMethod(tableId);
-      } catch (IOException ioe) {
+      } catch (Exception e) {
         // TODO - handle exception
-        LOG.error(ioe);
+        LOG.error(e);
         return null;
       } finally {
         rlock.unlock();
@@ -323,7 +326,7 @@ public class CatalogServer extends AbstractService {
         String tableId = tableName.getValue().toLowerCase();
         return BoolProto.newBuilder().setValue(
             store.existPartitionMethod(tableId)).build();
-      } catch (IOException e) {
+      } catch (Exception e) {
         LOG.error(e);
         return BoolProto.newBuilder().setValue(false).build();
       } finally {
@@ -379,10 +382,10 @@ public class CatalogServer extends AbstractService {
           throw new AlreadyExistsIndexException(indexDesc.getName());
         }
         store.addIndex(indexDesc);
-      } catch (IOException ioe) {
-        LOG.error("ERROR : cannot add index " + indexDesc.getName(), ioe);
+      } catch (Exception e) {
+        LOG.error("ERROR : cannot add index " + indexDesc.getName(), e);
         LOG.error(indexDesc);
-        throw new ServiceException(ioe);
+        throw new ServiceException(e);
       } finally {
         rlock.unlock();
       }
@@ -398,7 +401,7 @@ public class CatalogServer extends AbstractService {
       try {
         return BoolProto.newBuilder().setValue(
             store.existIndex(indexName.getValue())).build();
-      } catch (IOException e) {
+      } catch (Exception e) {
         LOG.error(e);
         return BoolProto.newBuilder().setValue(false).build();
       } finally {
@@ -415,7 +418,7 @@ public class CatalogServer extends AbstractService {
         return BoolProto.newBuilder().setValue(
             store.existIndex(request.getTableName(),
                 request.getColumnName())).build();
-      } catch (IOException e) {
+      } catch (Exception e) {
         LOG.error(e);
         return BoolProto.newBuilder().setValue(false).build();
       } finally {
@@ -433,8 +436,8 @@ public class CatalogServer extends AbstractService {
           throw new NoSuchIndexException(indexName.getValue());
         }
         return store.getIndex(indexName.getValue());
-      } catch (IOException ioe) {
-        LOG.error("ERROR : cannot get index " + indexName, ioe);
+      } catch (Exception e) {
+        LOG.error("ERROR : cannot get index " + indexName, e);
         return null;
       } finally {
         rlock.unlock();
@@ -452,9 +455,9 @@ public class CatalogServer extends AbstractService {
               + request.getColumnName());
         }
         return store.getIndex(request.getTableName(), request.getColumnName());
-      } catch (IOException ioe) {
+      } catch (Exception e) {
         LOG.error("ERROR : cannot get index " + request.getTableName() + "."
-            + request.getColumnName(), ioe);
+            + request.getColumnName(), e);
         return null;
       } finally {
         rlock.unlock();
@@ -470,7 +473,7 @@ public class CatalogServer extends AbstractService {
           throw new NoSuchIndexException(indexName.getValue());
         }
         store.delIndex(indexName.getValue());
-      } catch (IOException e) {
+      } catch (Exception e) {
         LOG.error(e);
       } finally {
         wlock.unlock();
@@ -593,7 +596,7 @@ public class CatalogServer extends AbstractService {
     }
   }
 
-  private static class FunctionSignature implements Comparable<FunctionSignature> {
+  private static class FunctionSignature {
     private String signature;
     private FunctionType type;
     private DataType [] arguments;
@@ -637,37 +640,23 @@ public class CatalogServer extends AbstractService {
     }
 
     @Override
-    public int hashCode() {
-      return Objects.hashCode(signature, type, Objects.hashCode(arguments));
+    public boolean equals(Object o) {
+      if (this == o) {
+        return true;
+      } else if (o == null || getClass() != o.getClass()) {
+        return false;
+      } else {
+        return (signature.equals(((FunctionSignature) o).signature)
+            && type.equals(((FunctionSignature) o).type)
+            && Arrays.equals(arguments, ((FunctionSignature) o).arguments));
+      }
     }
 
     @Override
-    public int compareTo(FunctionSignature o) {
-      int signatureCmp = signature.compareTo(o.signature);
-      if (signatureCmp != 0) {
-        return signatureCmp;
-      }
-
-      int typeCmp = type.compareTo(o.type);
-      if (typeCmp != 0) {
-        return typeCmp;
-      }
-
-      int min = Math.min(arguments.length, o.arguments.length);
-      int argCmp = 0;
-      for (int i = 0; i < min; i++) {
-        if (arguments.length < min && o.arguments.length < min) {
-          argCmp = arguments[i].getType().compareTo(o.arguments[i].getType());
-
-          if (argCmp != 0) {
-            return argCmp;
-          }
-        } else {
-          argCmp = arguments.length - o.arguments.length;
-        }
-      }
-      return argCmp;
+    public int hashCode() {
+      return Objects.hashCode(signature, type, Objects.hashCode(arguments));
     }
+
   }
 
   public static void main(String[] args) throws Exception {