You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by pa...@apache.org on 2017/06/12 01:27:39 UTC

[1/4] drill git commit: DRILL-5560: Create configuration file for distribution specific configuration This closes #848

Repository: drill
Updated Branches:
  refs/heads/master 874bf6296 -> a7e298760


DRILL-5560: Create configuration file for distribution specific configuration
This closes #848


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/adb79fb5
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/adb79fb5
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/adb79fb5

Branch: refs/heads/master
Commit: adb79fb58e7ee699424d8f24c6ed76080921b579
Parents: 874bf62
Author: Padma Penumarthy <pp...@yahoo.com>
Authored: Tue May 30 10:17:48 2017 -0700
Committer: Parth Chandra <pa...@apache.org>
Committed: Sun Jun 11 17:15:27 2017 -0700

----------------------------------------------------------------------
 .../drill/common/config/CommonConstants.java     |  3 +++
 .../apache/drill/common/config/DrillConfig.java  | 19 ++++++++++++++-----
 distribution/src/resources/drill-config.sh       |  3 ++-
 3 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/adb79fb5/common/src/main/java/org/apache/drill/common/config/CommonConstants.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/config/CommonConstants.java b/common/src/main/java/org/apache/drill/common/config/CommonConstants.java
index d3d2b72..eab48d0 100644
--- a/common/src/main/java/org/apache/drill/common/config/CommonConstants.java
+++ b/common/src/main/java/org/apache/drill/common/config/CommonConstants.java
@@ -25,6 +25,9 @@ public interface CommonConstants {
   /** Module configuration files name.  (Classpath resource pathname.) */
   String DRILL_JAR_MARKER_FILE_RESOURCE_PATHNAME = "drill-module.conf";
 
+  /** Distribution Specific Override configuration file name.  (Classpath resource pathname.) */
+  String CONFIG_DISTRIBUTION_RESOURCE_PATHNAME = "drill-distrib.conf";
+
   /** Override configuration file name.  (Classpath resource pathname.) */
   String CONFIG_OVERRIDE_RESOURCE_PATHNAME = "drill-override.conf";
 

http://git-wip-us.apache.org/repos/asf/drill/blob/adb79fb5/common/src/main/java/org/apache/drill/common/config/DrillConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/config/DrillConfig.java b/common/src/main/java/org/apache/drill/common/config/DrillConfig.java
index 6828718..0d3ce9a 100644
--- a/common/src/main/java/org/apache/drill/common/config/DrillConfig.java
+++ b/common/src/main/java/org/apache/drill/common/config/DrillConfig.java
@@ -116,11 +116,9 @@ public class DrillConfig extends NestedConfig {
 
 
   /**
-   * <p>
    * DrillConfig loads up Drill configuration information. It does this utilizing a combination of classpath scanning
    * and Configuration fallbacks provided by the TypeSafe configuration library. The order of precedence is as
    * follows:
-   * </p>
    * <p>
    * Configuration values are retrieved as follows:
    * <ul>
@@ -128,6 +126,8 @@ public class DrillConfig extends NestedConfig {
    *     on the classpath, which copy is read is indeterminate.
    *     If a non-null value for overrideFileResourcePathname is provided, this
    *     is used instead of "{@code drill-override.conf}".</li>
+   * <li>Check a single copy of "drill-distrib.conf". If multiple copies are
+   *     on the classpath, which copy is read is indeterminate. </li>
    * <li>Check all copies of "{@code drill-module.conf}".  Loading order is
    *     indeterminate.</li>
    * <li>Check a single copy of "{@code drill-default.conf}".  If multiple
@@ -216,12 +216,21 @@ public class DrillConfig extends NestedConfig {
     }
     logString.append("\n");
 
-    // 3. Load any specified overrides configuration file along with any
+    final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+    // 3. Load distribution specific configuration file.
+    final URL distribConfigFileUrl = classLoader.getResource(CommonConstants.CONFIG_DISTRIBUTION_RESOURCE_PATHNAME);
+    if (null != distribConfigFileUrl ) {
+      logString.append("Distribution Specific Configuration File: ").append(distribConfigFileUrl).append("\n");
+    }
+    fallback =
+      ConfigFactory.load(CommonConstants.CONFIG_DISTRIBUTION_RESOURCE_PATHNAME).withFallback(fallback);
+
+    // 4. Load any specified overrides configuration file along with any
     //    overrides from JVM system properties (e.g., {-Dname=value").
 
     // (Per ConfigFactory.load(...)'s mention of using Thread.getContextClassLoader():)
-    final URL overrideFileUrl =
-        Thread.currentThread().getContextClassLoader().getResource(overrideFileResourcePathname);
+    final URL overrideFileUrl = classLoader.getResource(overrideFileResourcePathname);
     if (null != overrideFileUrl ) {
       logString.append("Override File: ").append(overrideFileUrl).append("\n");
     }

http://git-wip-us.apache.org/repos/asf/drill/blob/adb79fb5/distribution/src/resources/drill-config.sh
----------------------------------------------------------------------
diff --git a/distribution/src/resources/drill-config.sh b/distribution/src/resources/drill-config.sh
index 1946275..32306ee 100644
--- a/distribution/src/resources/drill-config.sh
+++ b/distribution/src/resources/drill-config.sh
@@ -260,7 +260,8 @@ fi
 # Add $DRILL_HOME/conf if the user has provided their own
 # site configuration directory.
 # Ensures we pick up the default logback.xml, etc. if the
-# user does not provide their own.
+# user does not provide their own, and that we pick up the
+# drill-distrib.conf file, if provided by the distro.
 # Also, set a variable to remember that the config dir
 # is non-default, which is needed later.
 


[2/4] drill git commit: DRILL-5541: C++ Client Crashes During Simple "Man in the Middle" Attack Test with Exploitable Write AV This closes #850

Posted by pa...@apache.org.
DRILL-5541: C++ Client Crashes During Simple "Man in the Middle" Attack Test with Exploitable Write AV
This closes #850


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/5d2eedff
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/5d2eedff
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/5d2eedff

Branch: refs/heads/master
Commit: 5d2eedff8329b687fb7a5a498971503b82260946
Parents: adb79fb
Author: Rob Wu <ro...@gmail.com>
Authored: Mon Jun 5 14:06:33 2017 -0700
Committer: Parth Chandra <pa...@apache.org>
Committed: Sun Jun 11 17:28:52 2017 -0700

----------------------------------------------------------------------
 .../client/src/clientlib/drillClientImpl.cpp    | 46 ++++++++++++++++++--
 .../client/src/clientlib/drillClientImpl.hpp    | 40 +++++++++--------
 .../native/client/src/clientlib/rpcMessage.cpp  | 12 +++++
 3 files changed, 75 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/5d2eedff/contrib/native/client/src/clientlib/drillClientImpl.cpp
----------------------------------------------------------------------
diff --git a/contrib/native/client/src/clientlib/drillClientImpl.cpp b/contrib/native/client/src/clientlib/drillClientImpl.cpp
index 0dee309..7015b5a 100644
--- a/contrib/native/client/src/clientlib/drillClientImpl.cpp
+++ b/contrib/native/client/src/clientlib/drillClientImpl.cpp
@@ -1580,6 +1580,9 @@ status_t DrillClientImpl::processPreparedStatement(AllocatedBufferPtr allocatedB
     std::map<int,DrillClientQueryHandle*>::const_iterator it=this->m_queryHandles.find(msg.m_coord_id);
     if(it!=this->m_queryHandles.end()){
         DrillClientPrepareHandle* pDrillClientPrepareHandle=static_cast<DrillClientPrepareHandle*>((*it).second);
+        if (!validateResultRPCType(pDrillClientPrepareHandle, msg)){
+            return handleQryError(QRY_COMM_ERROR, "Unexpected RPC Type for prepared statement.", pDrillClientPrepareHandle);
+        }
         exec::user::CreatePreparedStatementResp resp;
         DRILL_MT_LOG(DRILL_LOG(LOG_TRACE)  << "Received Prepared Statement Handle " << msg.m_pbody.size() << std::endl;)
         if (!resp.ParseFromArray(msg.m_pbody.data(), msg.m_pbody.size())) {
@@ -1588,7 +1591,9 @@ status_t DrillClientImpl::processPreparedStatement(AllocatedBufferPtr allocatedB
         if (resp.has_status() && resp.status() != exec::user::OK) {
             return handleQryError(QRY_FAILED, resp.error(), pDrillClientPrepareHandle);
         }
-        pDrillClientPrepareHandle->setupPreparedStatement(resp.prepared_statement());
+        if (QRY_SUCCESS != pDrillClientPrepareHandle->setupPreparedStatement(resp.prepared_statement())){
+            return handleQryError(QRY_FAILED, "Error during prepared statement setup.", pDrillClientPrepareHandle);
+        }
         pDrillClientPrepareHandle->notifyListener(pDrillClientPrepareHandle, NULL);
         DRILL_MT_LOG(DRILL_LOG(LOG_DEBUG) << "Prepared Statement handle - " << resp.prepared_statement().server_handle().DebugString() << std::endl;)
     }else{
@@ -1619,6 +1624,9 @@ status_t DrillClientImpl::processCatalogsResult(AllocatedBufferPtr allocatedBuff
     std::map<int,DrillClientQueryHandle*>::const_iterator it=this->m_queryHandles.find(msg.m_coord_id);
     if(it!=this->m_queryHandles.end()){
         DrillClientCatalogResult* pHandle=static_cast<DrillClientCatalogResult*>((*it).second);
+        if (!validateResultRPCType(pHandle, msg)){
+            return handleQryError(QRY_COMM_ERROR, "Unexpected RPC Type for getcatalogs results.", pHandle);
+        }
         exec::user::GetCatalogsResp* resp = new exec::user::GetCatalogsResp;
         pHandle->attachMetadataResult(resp);
         DRILL_MT_LOG(DRILL_LOG(LOG_TRACE)  << "Received GetCatalogs result Handle " << msg.m_pbody.size() << std::endl;)
@@ -1667,6 +1675,9 @@ status_t DrillClientImpl::processSchemasResult(AllocatedBufferPtr allocatedBuffe
     std::map<int,DrillClientQueryHandle*>::const_iterator it=this->m_queryHandles.find(msg.m_coord_id);
     if(it!=this->m_queryHandles.end()){
         DrillClientSchemaResult* pHandle=static_cast<DrillClientSchemaResult*>((*it).second);
+        if (!validateResultRPCType(pHandle, msg)){
+            return handleQryError(QRY_COMM_ERROR, "Unexpected RPC Type for getschemas results.", pHandle);
+        }
         exec::user::GetSchemasResp* resp = new exec::user::GetSchemasResp();
         pHandle->attachMetadataResult(resp);
         DRILL_MT_LOG(DRILL_LOG(LOG_TRACE)  << "Received GetSchemasResp result Handle " << msg.m_pbody.size() << std::endl;)
@@ -1715,6 +1726,9 @@ status_t DrillClientImpl::processTablesResult(AllocatedBufferPtr allocatedBuffer
     std::map<int,DrillClientQueryHandle*>::const_iterator it=this->m_queryHandles.find(msg.m_coord_id);
     if(it!=this->m_queryHandles.end()){
         DrillClientTableResult* pHandle=static_cast<DrillClientTableResult*>((*it).second);
+        if (!validateResultRPCType(pHandle, msg)){
+            return handleQryError(QRY_COMM_ERROR, "Unexpected RPC Type for gettables results.", pHandle);
+        }
         exec::user::GetTablesResp* resp =  new exec::user::GetTablesResp();
         pHandle->attachMetadataResult(resp);
         DRILL_MT_LOG(DRILL_LOG(LOG_TRACE)  << "Received GeTablesResp result Handle " << msg.m_pbody.size() << std::endl;)
@@ -1762,6 +1776,9 @@ status_t DrillClientImpl::processColumnsResult(AllocatedBufferPtr allocatedBuffe
     std::map<int,DrillClientQueryHandle*>::const_iterator it=this->m_queryHandles.find(msg.m_coord_id);
     if(it!=this->m_queryHandles.end()){
         DrillClientColumnResult* pHandle=static_cast<DrillClientColumnResult*>((*it).second);
+        if (!validateResultRPCType(pHandle, msg)){
+            return handleQryError(QRY_COMM_ERROR, "Unexpected RPC Type for getcolumns results.", pHandle);
+        }
         exec::user::GetColumnsResp* resp = new exec::user::GetColumnsResp();
         pHandle->attachMetadataResult(resp);
         DRILL_MT_LOG(DRILL_LOG(LOG_TRACE)  << "Received GetColumnsResp result Handle " << msg.m_pbody.size() << std::endl;)
@@ -1809,6 +1826,9 @@ status_t DrillClientImpl::processServerMetaResult(AllocatedBufferPtr allocatedBu
     std::map<int,DrillClientQueryHandle*>::const_iterator it=this->m_queryHandles.find(msg.m_coord_id);
     if(it!=this->m_queryHandles.end()){
         DrillClientServerMetaHandle* pHandle=static_cast<DrillClientServerMetaHandle*>((*it).second);
+        if (!validateResultRPCType(pHandle, msg)){
+            return handleQryError(QRY_COMM_ERROR, "Unexpected RPC Type for GetServerMetaResp results.", pHandle);
+        }
         exec::user::GetServerMetaResp* resp = new exec::user::GetServerMetaResp();
         DRILL_MT_LOG(DRILL_LOG(LOG_TRACE)  << "Received GetServerMetaResp result Handle " << msg.m_pbody.size() << std::endl;)
         if (!(resp->ParseFromArray(msg.m_pbody.data(), msg.m_pbody.size()))) {
@@ -1863,7 +1883,8 @@ status_t DrillClientImpl::processQueryStatusResult(exec::shared::QueryResult* qr
         case exec::shared::QueryResult_QueryState_FAILED:
             {
                 // get the error message from protobuf and handle errors
-                ret=handleQryError(ret, qr->error(0), pDrillClientQueryResult);
+                ret = (0 == qr->error_size()) ? 
+                    handleQryError(ret, "Unknown protobuf error.", pDrillClientQueryResult) : handleQryError(ret, qr->error(0), pDrillClientQueryResult);
             }
             break;
             // m_pendingRequests should be decremented when the query is
@@ -2100,6 +2121,20 @@ status_t DrillClientImpl::validateResultMessage(const rpc::InBoundRpcMessage& ms
     return QRY_SUCCESS;
 }
 
+bool DrillClientImpl::validateResultRPCType(DrillClientQueryHandle* pQueryHandle, const rpc::InBoundRpcMessage& msg) {
+    DRILL_MT_LOG(DRILL_LOG(LOG_TRACE) << "DrillClientImpl::validateResultRPCType" << std::endl;)
+    if (NULL != pQueryHandle) {
+        DRILL_MT_LOG(DRILL_LOG(LOG_DEBUG)
+            << "DrillClientImpl::validateResultRPCType: Expected RPC Type: "
+            << pQueryHandle->getExpectedRPCType()
+            << " inbound RPC Type: "
+            << msg.m_rpc_type
+            << std::endl;)
+        return (pQueryHandle->getExpectedRPCType() == msg.m_rpc_type);
+    }
+    return false;
+}
+
 /*
  * Called when there is failure in connect/send.
  */
@@ -2589,8 +2624,11 @@ status_t DrillClientPrepareHandle::setupPreparedStatement(const exec::user::Prep
     }
 
     // Copy server handle
-    this->m_preparedStatementHandle.CopyFrom(pstmt.server_handle());
-    return QRY_SUCCESS;
+    if (pstmt.has_server_handle()){
+        this->m_preparedStatementHandle.CopyFrom(pstmt.server_handle());
+        return QRY_SUCCESS;
+    }
+    return QRY_FAILURE;
 }
 
 void DrillClientPrepareHandle::clearAndDestroy(){

http://git-wip-us.apache.org/repos/asf/drill/blob/5d2eedff/contrib/native/client/src/clientlib/drillClientImpl.hpp
----------------------------------------------------------------------
diff --git a/contrib/native/client/src/clientlib/drillClientImpl.hpp b/contrib/native/client/src/clientlib/drillClientImpl.hpp
index 852233f..efa4e66 100644
--- a/contrib/native/client/src/clientlib/drillClientImpl.hpp
+++ b/contrib/native/client/src/clientlib/drillClientImpl.hpp
@@ -109,15 +109,16 @@ class DrillClientImplBase{
 class DrillClientQueryHandle{
     friend class DrillClientImpl;
     public:
-    DrillClientQueryHandle(DrillClientImpl& client, int32_t coordId, const std::string& query, void* context):
+        DrillClientQueryHandle(DrillClientImpl& client, int32_t coordId, const std::string& query, void* context, int in_expectedRPCType) :
         m_client(client),
         m_coordinationId(coordId),
         m_query(query),
-		m_status(QRY_SUCCESS),
+        m_status(QRY_SUCCESS),
         m_bCancel(false),
         m_bHasError(false),
+        m_expectedRPCType(in_expectedRPCType),
         m_pError(NULL),
-		m_pApplicationContext(context){
+        m_pApplicationContext(context){
     };
 
     virtual ~DrillClientQueryHandle(){
@@ -137,7 +138,7 @@ class DrillClientQueryHandle{
     void setQueryStatus(status_t s){ m_status = s;}
     status_t getQueryStatus() const { return m_status;}
     inline DrillClientImpl& client() const { return m_client; };
-
+    int getExpectedRPCType() const { return m_expectedRPCType; };
     inline void* getApplicationContext() const { return m_pApplicationContext; }
 
     protected:
@@ -153,7 +154,7 @@ class DrillClientQueryHandle{
     status_t m_status;
     bool m_bCancel;
     bool m_bHasError;
-
+    int m_expectedRPCType;
     const DrillClientError* m_pError;
 
     void* m_pApplicationContext;
@@ -163,9 +164,9 @@ template<typename Listener, typename ListenerValue>
 class DrillClientBaseHandle: public DrillClientQueryHandle {
     friend class DrillClientImpl;
     public:
-    DrillClientBaseHandle(DrillClientImpl& client, int32_t coordId, const std::string& query, Listener listener, void* context):
-    	DrillClientQueryHandle(client, coordId, query, context),
-		m_pApplicationListener(listener){
+        DrillClientBaseHandle(DrillClientImpl& client, int32_t coordId, const std::string& query, Listener listener, void* context, int in_expectedRPCType) :
+            DrillClientQueryHandle(client, coordId, query, context, in_expectedRPCType),
+            m_pApplicationListener(listener){
     };
 
     virtual ~DrillClientBaseHandle(){
@@ -189,7 +190,7 @@ class DrillClientQueryResult: public DrillClientBaseHandle<pfnQueryResultsListen
     friend class DrillClientImpl;
     public:
     DrillClientQueryResult(DrillClientImpl& client, int32_t coordId, const std::string& query, pfnQueryResultsListener listener, void* listenerCtx):
-    	DrillClientBaseHandle<pfnQueryResultsListener, RecordBatch*>(client, coordId, query, listener, listenerCtx),
+        DrillClientBaseHandle<pfnQueryResultsListener, RecordBatch*>(client, coordId, query, listener, listenerCtx, exec::user::QUERY_HANDLE),
         m_numBatches(0),
         m_columnDefs(new std::vector<Drill::FieldMetadata*>),
         m_bIsQueryPending(true),
@@ -288,8 +289,8 @@ class DrillClientQueryResult: public DrillClientBaseHandle<pfnQueryResultsListen
 class DrillClientPrepareHandle: public DrillClientBaseHandle<pfnPreparedStatementListener, PreparedStatement*>, public PreparedStatement {
     public:
     DrillClientPrepareHandle(DrillClientImpl& client, int32_t coordId, const std::string& query, pfnPreparedStatementListener listener, void* listenerCtx):
-    	DrillClientBaseHandle<pfnPreparedStatementListener, PreparedStatement*>(client, coordId, query, listener, listenerCtx),
-		PreparedStatement(),
+        DrillClientBaseHandle<pfnPreparedStatementListener, PreparedStatement*>(client, coordId, query, listener, listenerCtx, exec::user::PREPARED_STATEMENT),
+        PreparedStatement(),
         m_columnDefs(new std::vector<Drill::FieldMetadata*>) {
     };
 
@@ -311,8 +312,8 @@ class DrillClientPrepareHandle: public DrillClientBaseHandle<pfnPreparedStatemen
 typedef status_t (*pfnServerMetaListener)(void* ctx, const exec::user::ServerMeta* serverMeta, DrillClientError* err);
 class DrillClientServerMetaHandle: public DrillClientBaseHandle<pfnServerMetaListener, const exec::user::ServerMeta*> {
     public:
-	DrillClientServerMetaHandle(DrillClientImpl& client, int32_t coordId, pfnServerMetaListener listener, void* listenerCtx):
-    	DrillClientBaseHandle<pfnServerMetaListener, const exec::user::ServerMeta*>(client, coordId, "server meta", listener, listenerCtx) {
+    DrillClientServerMetaHandle(DrillClientImpl& client, int32_t coordId, pfnServerMetaListener listener, void* listenerCtx):
+        DrillClientBaseHandle<pfnServerMetaListener, const exec::user::ServerMeta*>(client, coordId, "server meta", listener, listenerCtx, exec::user::SERVER_META) {
     };
 
     private:
@@ -323,8 +324,8 @@ class DrillClientServerMetaHandle: public DrillClientBaseHandle<pfnServerMetaLis
 template<typename Listener, typename MetaType, typename MetaImpl, typename MetadataResult>
 class DrillClientMetadataResult: public DrillClientBaseHandle<Listener, const DrillCollection<MetaType>*> {
 public:
-    DrillClientMetadataResult(DrillClientImpl& client, int32_t coordId, const std::string& query, Listener listener, void* listenerCtx):
-    	DrillClientBaseHandle<Listener, const DrillCollection<MetaType>*>(client, coordId, query, listener, listenerCtx) {}
+    DrillClientMetadataResult(DrillClientImpl& client, int32_t coordId, const std::string& query, Listener listener, void* listenerCtx, int in_expectedRPCType) :
+        DrillClientBaseHandle<Listener, const DrillCollection<MetaType>*>(client, coordId, query, listener, listenerCtx, in_expectedRPCType) {}
 
     void attachMetadataResult(MetadataResult* result) { this->m_pMetadata.reset(result); }
 
@@ -344,28 +345,28 @@ class DrillClientCatalogResult: public DrillClientMetadataResult<Metadata::pfnCa
     friend class DrillClientImpl;
 public:
     DrillClientCatalogResult(DrillClientImpl& client, int32_t coordId, Metadata::pfnCatalogMetadataListener listener, void* listenerCtx):
-    	DrillClientMetadataResult<Metadata::pfnCatalogMetadataListener, meta::CatalogMetadata, meta::DrillCatalogMetadata, exec::user::GetCatalogsResp>(client, coordId, "getCatalog", listener, listenerCtx) {}
+        DrillClientMetadataResult<Metadata::pfnCatalogMetadataListener, meta::CatalogMetadata, meta::DrillCatalogMetadata, exec::user::GetCatalogsResp>(client, coordId, "getCatalog", listener, listenerCtx, exec::user::CATALOGS) {}
 };
 
 class DrillClientSchemaResult: public DrillClientMetadataResult<Metadata::pfnSchemaMetadataListener, meta::SchemaMetadata, meta::DrillSchemaMetadata, exec::user::GetSchemasResp> {
     friend class DrillClientImpl;
 public:
     DrillClientSchemaResult(DrillClientImpl& client, int32_t coordId, Metadata::pfnSchemaMetadataListener listener, void* listenerCtx):
-    	DrillClientMetadataResult<Metadata::pfnSchemaMetadataListener, meta::SchemaMetadata, meta::DrillSchemaMetadata, exec::user::GetSchemasResp>(client, coordId, "getSchemas", listener, listenerCtx) {}
+        DrillClientMetadataResult<Metadata::pfnSchemaMetadataListener, meta::SchemaMetadata, meta::DrillSchemaMetadata, exec::user::GetSchemasResp>(client, coordId, "getSchemas", listener, listenerCtx, exec::user::SCHEMAS) {}
 };
 
 class DrillClientTableResult: public DrillClientMetadataResult<Metadata::pfnTableMetadataListener, meta::TableMetadata, meta::DrillTableMetadata, exec::user::GetTablesResp> {
     friend class DrillClientImpl;
 public:
     DrillClientTableResult(DrillClientImpl& client, int32_t coordId, Metadata::pfnTableMetadataListener listener, void* listenerCtx):
-    	DrillClientMetadataResult<Metadata::pfnTableMetadataListener, meta::TableMetadata, meta::DrillTableMetadata, exec::user::GetTablesResp>(client, coordId, "getTables", listener, listenerCtx) {}
+        DrillClientMetadataResult<Metadata::pfnTableMetadataListener, meta::TableMetadata, meta::DrillTableMetadata, exec::user::GetTablesResp>(client, coordId, "getTables", listener, listenerCtx, exec::user::TABLES) {}
 };
 
 class DrillClientColumnResult: public DrillClientMetadataResult<Metadata::pfnColumnMetadataListener, meta::ColumnMetadata, meta::DrillColumnMetadata, exec::user::GetColumnsResp> {
     friend class DrillClientImpl;
     public:
     DrillClientColumnResult(DrillClientImpl& client, int32_t coordId, Metadata::pfnColumnMetadataListener listener, void* listenerCtx):
-    	DrillClientMetadataResult<Metadata::pfnColumnMetadataListener, meta::ColumnMetadata, meta::DrillColumnMetadata, exec::user::GetColumnsResp>(client, coordId, "getColumns", listener, listenerCtx) {}
+        DrillClientMetadataResult<Metadata::pfnColumnMetadataListener, meta::ColumnMetadata, meta::DrillColumnMetadata, exec::user::GetColumnsResp>(client, coordId, "getColumns", listener, listenerCtx, exec::user::COLUMNS) {}
 };
 
 // Length Decoder Function Pointer definition
@@ -519,6 +520,7 @@ class DrillClientImpl : public DrillClientImplBase{
         void handleRead(ByteBuf_t inBuf, const boost::system::error_code & err, size_t bytes_transferred) ;
         status_t validateDataMessage(const rpc::InBoundRpcMessage& msg, const exec::shared::QueryData& qd, std::string& valError);
         status_t validateResultMessage(const rpc::InBoundRpcMessage& msg, const exec::shared::QueryResult& qr, std::string& valError);
+        bool validateResultRPCType(DrillClientQueryHandle* pQueryHandle, const rpc::InBoundRpcMessage& msg);
         connectionStatus_t handleConnError(connectionStatus_t status, const std::string& msg);
         status_t handleQryCancellation(status_t status, DrillClientQueryResult* pQueryResult);
         status_t handleQryError(status_t status, const std::string& msg, DrillClientQueryHandle* pQueryHandle);

http://git-wip-us.apache.org/repos/asf/drill/blob/5d2eedff/contrib/native/client/src/clientlib/rpcMessage.cpp
----------------------------------------------------------------------
diff --git a/contrib/native/client/src/clientlib/rpcMessage.cpp b/contrib/native/client/src/clientlib/rpcMessage.cpp
index f64167f..87d2fdb 100644
--- a/contrib/native/client/src/clientlib/rpcMessage.cpp
+++ b/contrib/native/client/src/clientlib/rpcMessage.cpp
@@ -152,6 +152,12 @@ bool decode(const uint8_t* buf, int length, InBoundRpcMessage& msg) {
 
         assert(dbody_length == size);
         assert(msg.m_dbody==buf+currPos);
+
+        // Enforce assertion due to unexpected crashes during network error.
+        if (!((dbody_length == size) && (msg.m_dbody == (buf + currPos)))) {
+            return false;
+        }
+
 		#ifdef CODER_DEBUG
 			cerr << "Read raw body of " << dbody_length << " bytes" << endl;
 		#endif
@@ -173,6 +179,12 @@ bool decode(const uint8_t* buf, int length, InBoundRpcMessage& msg) {
 
     int endPos = cis.CurrentPosition();
     assert((endPos-startPos) == length);
+
+    // Enforce assertion due to unexpected crashes during network error.
+    if ((endPos - startPos) != length) {
+        return false;
+        
+    }
     return true;
 }
 


[4/4] drill git commit: DRILL-5545: Fix issues reported by findbugs in Async Parquet Reader. This closes #847

Posted by pa...@apache.org.
DRILL-5545: Fix issues reported by findbugs in Async Parquet Reader.
This closes #847


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/a7e29876
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/a7e29876
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/a7e29876

Branch: refs/heads/master
Commit: a7e298760f9c9efa281d61a1d2ec776139f69225
Parents: 610602e
Author: Parth Chandra <pc...@maprtech.com>
Authored: Wed May 17 16:56:13 2017 -0700
Committer: Parth Chandra <pa...@apache.org>
Committed: Sun Jun 11 17:28:53 2017 -0700

----------------------------------------------------------------------
 .../parquet/columnreaders/AsyncPageReader.java  | 118 +++++++------------
 .../parquet/columnreaders/ColumnReader.java     |  17 ++-
 .../store/parquet/columnreaders/PageReader.java |  31 ++++-
 3 files changed, 83 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/a7e29876/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/AsyncPageReader.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/AsyncPageReader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/AsyncPageReader.java
index 2e94f56..926436c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/AsyncPageReader.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/AsyncPageReader.java
@@ -39,6 +39,7 @@ import org.apache.parquet.format.Util;
 import org.apache.parquet.hadoop.metadata.CompressionCodecName;
 import org.xerial.snappy.Snappy;
 
+import java.io.EOFException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.concurrent.Callable;
@@ -86,17 +87,16 @@ class AsyncPageReader extends PageReader {
   private LinkedBlockingQueue<ReadStatus> pageQueue;
   private ConcurrentLinkedQueue<Future<Void>> asyncPageRead;
   private long totalPageValuesRead = 0;
+  private Object pageQueueSyncronize = new Object(); // Object to use to synchronize access to the page Queue.
+                                                     // FindBugs complains if we synchronize on a Concurrent Queue
 
   AsyncPageReader(ColumnReader<?> parentStatus, FileSystem fs, Path path,
       ColumnChunkMetaData columnChunkMetaData) throws ExecutionSetupException {
     super(parentStatus, fs, path, columnChunkMetaData);
-    if (threadPool == null && asyncPageRead == null) {
-      threadPool = parentColumnReader.parentReader.getOperatorContext().getScanExecutor();
-      queueSize  = parentColumnReader.parentReader.readQueueSize;
-      pageQueue = new LinkedBlockingQueue<>((int)queueSize);
-      asyncPageRead = new ConcurrentLinkedQueue<>();
-      asyncPageRead.offer(threadPool.submit(new AsyncPageReaderTask(debugName, pageQueue)));
-    }
+    threadPool = parentColumnReader.parentReader.getOperatorContext().getScanExecutor();
+    queueSize = parentColumnReader.parentReader.readQueueSize;
+    pageQueue = new LinkedBlockingQueue<>((int) queueSize);
+    asyncPageRead = new ConcurrentLinkedQueue<>();
   }
 
   @Override
@@ -105,22 +105,34 @@ class AsyncPageReader extends PageReader {
     if (columnChunkMetaData.getDictionaryPageOffset() > 0) {
       try {
         assert(columnChunkMetaData.getDictionaryPageOffset() >= dataReader.getPos() );
-        dataReader.skip(columnChunkMetaData.getDictionaryPageOffset() - dataReader.getPos());
+        long bytesToSkip = columnChunkMetaData.getDictionaryPageOffset() - dataReader.getPos();
+        while (bytesToSkip > 0) {
+          long skipped = dataReader.skip(bytesToSkip);
+          if (skipped > 0) {
+            bytesToSkip -= skipped;
+          } else {
+            // no good way to handle this. Guava uses InputStream.available to check
+            // if EOF is reached and because available is not reliable,
+            // tries to read the rest of the data.
+            DrillBuf skipBuf = dataReader.getNext((int) bytesToSkip);
+            if (skipBuf != null) {
+              skipBuf.release();
+            } else {
+              throw new EOFException("End of File reached.");
+            }
+          }
+        }
       } catch (IOException e) {
         handleAndThrowException(e, "Error Reading dictionary page.");
       }
-      // parent constructor may call this method before the thread pool is set.
-      if (threadPool == null && asyncPageRead == null) {
-        threadPool = parentColumnReader.parentReader.getOperatorContext().getScanExecutor();
-        queueSize  = parentColumnReader.parentReader.getFragmentContext().getOptions()
-            .getOption(ExecConstants.PARQUET_PAGEREADER_QUEUE_SIZE).num_val;
-        pageQueue = new LinkedBlockingQueue<ReadStatus>((int)queueSize);
-        asyncPageRead = new ConcurrentLinkedQueue<>();
-        asyncPageRead.offer(threadPool.submit(new AsyncPageReaderTask(debugName, pageQueue)));
-      }
     }
   }
 
+  @Override protected void init() throws IOException {
+    super.init();
+    asyncPageRead.offer(threadPool.submit(new AsyncPageReaderTask(debugName, pageQueue)));
+  }
+
   private DrillBuf getDecompressedPageData(ReadStatus readStatus) {
     DrillBuf data;
     boolean isDictionary = false;
@@ -146,35 +158,6 @@ class AsyncPageReader extends PageReader {
     return data;
   }
 
-  // Read and decode the dictionary and the header
-  private void readDictionaryPage( final ColumnReader<?> parentStatus) throws UserException {
-    try {
-      Stopwatch timer = Stopwatch.createStarted();
-      ReadStatus readStatus = null;
-      synchronized(pageQueue) {
-        boolean pageQueueFull = pageQueue.remainingCapacity() == 0;
-        asyncPageRead.poll().get(); // get the result of execution
-        readStatus = pageQueue.take(); // get the data if no exception has been thrown
-        assert (readStatus.pageData != null);
-        //if the queue was full before we took a page out, then there would
-        // have been no new read tasks scheduled. In that case, schedule a new read.
-        if (pageQueueFull) {
-          asyncPageRead.offer(threadPool.submit(new AsyncPageReaderTask(debugName, pageQueue)));
-        }
-      }
-      long timeBlocked = timer.elapsed(TimeUnit.NANOSECONDS);
-      stats.timeDiskScanWait.addAndGet(timeBlocked);
-      stats.timeDiskScan.addAndGet(readStatus.getDiskScanTime());
-      stats.numDictPageLoads.incrementAndGet();
-      stats.timeDictPageLoads.addAndGet(timeBlocked + readStatus.getDiskScanTime());
-      readDictionaryPageData(readStatus, parentStatus);
-    } catch (InterruptedException e) {
-      Thread.currentThread().interrupt();
-    } catch (Exception e) {
-      handleAndThrowException(e, "Error reading dictionary page.");
-    }
-  }
-
   // Read and decode the dictionary data
   private void readDictionaryPageData(final ReadStatus readStatus, final ColumnReader<?> parentStatus)
       throws UserException {
@@ -229,12 +212,11 @@ class AsyncPageReader extends PageReader {
   @Override
   protected void nextInternal() throws IOException {
     ReadStatus readStatus = null;
-    String name = parentColumnReader.columnChunkMetaData.toString();
     try {
       Stopwatch timer = Stopwatch.createStarted();
       parentColumnReader.parentReader.getOperatorContext().getStats().startWait();
       asyncPageRead.poll().get(); // get the result of execution
-      synchronized(pageQueue) {
+      synchronized (pageQueueSyncronize) {
         boolean pageQueueFull = pageQueue.remainingCapacity() == 0;
         readStatus = pageQueue.take(); // get the data if no exception has been thrown
         if (readStatus.pageData == null || readStatus == ReadStatus.EMPTY) {
@@ -259,14 +241,14 @@ class AsyncPageReader extends PageReader {
       }
       pageHeader = readStatus.getPageHeader();
 
-    // TODO - figure out if we need multiple dictionary pages, I believe it may be limited to one
-    // I think we are clobbering parts of the dictionary if there can be multiple pages of dictionary
+      // TODO - figure out if we need multiple dictionary pages, I believe it may be limited to one
+      // I think we are clobbering parts of the dictionary if there can be multiple pages of dictionary
 
       do {
         if (pageHeader.getType() == PageType.DICTIONARY_PAGE) {
           readDictionaryPageData(readStatus, parentColumnReader);
           asyncPageRead.poll().get(); // get the result of execution
-          synchronized (pageQueue) {
+          synchronized (pageQueueSyncronize) {
             boolean pageQueueFull = pageQueue.remainingCapacity() == 0;
             readStatus = pageQueue.take(); // get the data if no exception has been thrown
             if (readStatus.pageData == null || readStatus == ReadStatus.EMPTY) {
@@ -278,17 +260,18 @@ class AsyncPageReader extends PageReader {
               asyncPageRead.offer(threadPool.submit(new AsyncPageReaderTask(debugName, pageQueue)));
             }
           }
-          assert (readStatus.pageData != null);
           pageHeader = readStatus.getPageHeader();
         }
       } while (pageHeader.getType() == PageType.DICTIONARY_PAGE);
 
-    pageHeader = readStatus.getPageHeader();
-    pageData = getDecompressedPageData(readStatus);
-    assert(pageData != null);
+      pageHeader = readStatus.getPageHeader();
+      pageData = getDecompressedPageData(readStatus);
+      assert (pageData != null);
     } catch (InterruptedException e) {
       Thread.currentThread().interrupt();
-    } catch (Exception e){
+    } catch (RuntimeException e) { // Catch this explicitly to satisfy findbugs
+      handleAndThrowException(e, "Error reading page data");
+    } catch (Exception e) {
       handleAndThrowException(e, "Error reading page data");
     }
 
@@ -303,13 +286,14 @@ class AsyncPageReader extends PageReader {
         } else {
           f.get(1, TimeUnit.MILLISECONDS);
         }
+      } catch (RuntimeException e) {
+        // Do Nothing
       } catch (Exception e) {
         // Do nothing.
       }
     }
 
     //Empty the page queue
-    String name = parentColumnReader.columnChunkMetaData.toString();
     ReadStatus r;
     while (!pageQueue.isEmpty()) {
       r = null;
@@ -426,25 +410,10 @@ class AsyncPageReader extends PageReader {
       DrillBuf pageData = null;
       timer.reset();
       try {
-        long s = parent.dataReader.getPos();
         PageHeader pageHeader = Util.readPageHeader(parent.dataReader);
-        //long e = parent.dataReader.getPos();
-        //if (logger.isTraceEnabled()) {
-        //  logger.trace("[{}]: Read Page Header : ReadPos = {} : Bytes Read = {} ", name, s, e - s);
-        //}
         int compressedSize = pageHeader.getCompressed_page_size();
-        s = parent.dataReader.getPos();
         pageData = parent.dataReader.getNext(compressedSize);
         bytesRead = compressedSize;
-        //e = parent.dataReader.getPos();
-        //if (logger.isTraceEnabled()) {
-        //  DrillBuf bufStart = pageData.slice(0, compressedSize>100?100:compressedSize);
-        //  int endOffset = compressedSize>100?compressedSize-100:0;
-        //  DrillBuf bufEnd = pageData.slice(endOffset, compressedSize-endOffset);
-        //  logger
-        //      .trace("[{}]: Read Page Data : ReadPos = {} : Bytes Read = {} : Buf Start = {} : Buf End = {} ",
-        //          name, s, e - s, ByteBufUtil.hexDump(bufStart), ByteBufUtil.hexDump(bufEnd));
-        //}
 
         synchronized (parent) {
           if (pageHeader.getType() == PageType.DICTIONARY_PAGE) {
@@ -462,7 +431,10 @@ class AsyncPageReader extends PageReader {
           readStatus.setDiskScanTime(timeToRead);
           assert (totalValuesRead <= totalValuesCount);
         }
-        synchronized (queue) {
+        // You do need the synchronized block
+        // because you want the check to see if there is remaining capacity in the queue, to be
+        // synchronized
+        synchronized (parent.pageQueueSyncronize) {
           queue.put(readStatus);
           // if the queue is not full, schedule another read task immediately. If it is then the consumer
           // will schedule a new read task as soon as it removes a page from the queue.

http://git-wip-us.apache.org/repos/asf/drill/blob/a7e29876/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/ColumnReader.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/ColumnReader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/ColumnReader.java
index 98e1d78..2d8f556 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/ColumnReader.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/ColumnReader.java
@@ -99,6 +99,17 @@ public abstract class ColumnReader<V extends ValueVector> {
           new PageReader(this, parentReader.getFileSystem(), parentReader.getHadoopPath(),
               columnChunkMetaData);
     }
+    try {
+      pageReader.init();
+    } catch (IOException e) {
+      UserException ex = UserException.dataReadError(e)
+          .message("Error initializing page reader for Parquet file")
+          .pushContext("Row Group Start: ", this.columnChunkMetaData.getStartingPos())
+          .pushContext("Column: ", this.schemaElement.getName())
+          .pushContext("File: ", this.parentReader.getHadoopPath().toString() )
+          .build(logger);
+      throw ex;
+    }
     if (columnDescriptor.getType() != PrimitiveType.PrimitiveTypeName.BINARY) {
       if (columnDescriptor.getType() == PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY) {
         dataTypeLengthInBits = columnDescriptor.getTypeLength() * 8;
@@ -106,9 +117,7 @@ public abstract class ColumnReader<V extends ValueVector> {
         dataTypeLengthInBits = ParquetColumnMetadata.getTypeLengthInBits(columnDescriptor.getType());
       }
     }
-    if(threadPool == null) {
-      threadPool = parentReader.getOperatorContext().getScanDecodeExecutor();
-    }
+    threadPool = parentReader.getOperatorContext().getScanDecodeExecutor();
   }
 
   public int getRecordsReadInCurrentPass() {
@@ -218,7 +227,7 @@ public abstract class ColumnReader<V extends ValueVector> {
   public Future<Boolean> readPageAsync() {
     Future<Boolean> f = threadPool.submit(new Callable<Boolean>() {
       @Override public Boolean call() throws Exception {
-        return new Boolean(readPage());
+        return Boolean.valueOf(readPage());
       }
     });
     return f;

http://git-wip-us.apache.org/repos/asf/drill/blob/a7e29876/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/PageReader.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/PageReader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/PageReader.java
index 8a783c9..35cdb14 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/PageReader.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/PageReader.java
@@ -46,6 +46,7 @@ import org.apache.parquet.hadoop.metadata.ColumnChunkMetaData;
 import org.apache.parquet.hadoop.metadata.CompressionCodecName;
 import org.apache.parquet.schema.PrimitiveType;
 
+import java.io.EOFException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
@@ -143,10 +144,6 @@ class PageReader {
             columnChunkMetaData.getStartingPos(), columnChunkMetaData.getTotalSize(), enforceTotalSize,
             useFadvise);
       }
-      dataReader.init();
-
-      loadDictionaryIfExists(parentStatus, columnChunkMetaData, dataReader);
-
     } catch (IOException e) {
       throw new ExecutionSetupException("Error opening or reading metadata for parquet file at location: "
           + path.getName(), e);
@@ -154,11 +151,33 @@ class PageReader {
 
   }
 
+  protected void init() throws IOException{
+    dataReader.init();
+    loadDictionaryIfExists(parentColumnReader, parentColumnReader.columnChunkMetaData, dataReader);
+  }
+
   protected void loadDictionaryIfExists(final org.apache.drill.exec.store.parquet.columnreaders.ColumnReader<?> parentStatus,
       final ColumnChunkMetaData columnChunkMetaData, final DirectBufInputStream f) throws IOException {
     Stopwatch timer = Stopwatch.createUnstarted();
     if (columnChunkMetaData.getDictionaryPageOffset() > 0) {
-      dataReader.skip(columnChunkMetaData.getDictionaryPageOffset() - dataReader.getPos());
+      long bytesToSkip = columnChunkMetaData.getDictionaryPageOffset() - dataReader.getPos();
+      while (bytesToSkip > 0) {
+        long skipped = dataReader.skip(bytesToSkip);
+        if (skipped > 0) {
+          bytesToSkip -= skipped;
+        } else {
+          // no good way to handle this. Guava uses InputStream.available to check
+          // if EOF is reached and because available is not reliable,
+          // tries to read the rest of the data.
+          DrillBuf skipBuf = dataReader.getNext((int) bytesToSkip);
+          if (skipBuf != null) {
+            skipBuf.release();
+          } else {
+            throw new EOFException("End of File reachecd.");
+          }
+        }
+      }
+
       long start=dataReader.getPos();
       timer.start();
       final PageHeader pageHeader = Util.readPageHeader(f);
@@ -366,7 +385,7 @@ class PageReader {
     if (pageHeader.type == PageType.DICTIONARY_PAGE) {
       pageType = "Dictionary Page";
     }
-    logger.trace("ParquetTrace,{},{},{},{},{},{},{},{}", op, pageType.toString(),
+    logger.trace("ParquetTrace,{},{},{},{},{},{},{},{}", op, pageType,
         this.parentColumnReader.parentReader.hadoopPath,
         this.parentColumnReader.columnDescriptor.toString(), start, bytesin, bytesout, time);
 


[3/4] drill git commit: DRILL-5545: Update POM to add support for running findbugs

Posted by pa...@apache.org.
DRILL-5545: Update POM to add support for running findbugs


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/610602eb
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/610602eb
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/610602eb

Branch: refs/heads/master
Commit: 610602eb13fb883acab8bc2b73ab304896b4f0b6
Parents: 5d2eedf
Author: Parth Chandra <pc...@maprtech.com>
Authored: Tue May 23 11:04:15 2017 -0700
Committer: Parth Chandra <pa...@apache.org>
Committed: Sun Jun 11 17:28:53 2017 -0700

----------------------------------------------------------------------
 contrib/storage-hive/hive-exec-shade/pom.xml |  7 ++
 pom.xml                                      | 94 ++++++++++++++++++++++-
 2 files changed, 100 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/610602eb/contrib/storage-hive/hive-exec-shade/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/storage-hive/hive-exec-shade/pom.xml b/contrib/storage-hive/hive-exec-shade/pom.xml
index bec13fd..d9a5761 100644
--- a/contrib/storage-hive/hive-exec-shade/pom.xml
+++ b/contrib/storage-hive/hive-exec-shade/pom.xml
@@ -128,6 +128,13 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>findbugs-maven-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 </project>

http://git-wip-us.apache.org/repos/asf/drill/blob/610602eb/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 071f086..3158b42 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,6 +42,7 @@
     <mapr.release.version>5.2.1-mapr</mapr.release.version>
     <ojai.version>1.1</ojai.version>
     <kerby.version>1.0.0-RC2</kerby.version>
+    <findbugs.version>3.0.0</findbugs.version>
 
     <!--
       Currently Hive storage plugin only supports Apache Hive 1.2 or vendor specific variants of the
@@ -299,7 +300,6 @@
         </executions>
       </plugin>
 
-
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-resources-plugin</artifactId>
@@ -460,6 +460,16 @@
             <arguments>-Papache-release ${arguments}</arguments>
           </configuration>
         </plugin>
+        <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>findbugs-maven-plugin</artifactId>
+          <version>${findbugs.version}</version>
+        </plugin>
+        <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>xml-maven-plugin</artifactId>
+          <version>1.0</version>
+        </plugin>
 
         <!--This plugin's configuration is used to store Eclipse m2e settings
           only. It has no influence on the Maven build itself. -->
@@ -2219,6 +2229,88 @@
         <module>contrib</module>
       </modules>
     </profile>
+    <profile>
+      <id>findbugs</id>
+      <activation>
+        <activeByDefault>false</activeByDefault>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>findbugs-maven-plugin</artifactId>
+            <version>3.0.0</version>
+            <configuration>
+              <!--
+               Enables analysis which takes more memory but finds more bugs.
+               If you run out of memory, changes the value of the effort element
+               to 'Low'.
+               -->
+              <effort>Normal</effort>
+              <!-- Reports all bugs (other values are medium and max) -->
+              <threshold>Low</threshold>
+              <!-- Build doesn't fail if problems are found -->
+              <failOnError>false</failOnError>
+              <!-- Produces XML report -->
+              <xmlOutput>true</xmlOutput>
+              <!-- Configures the directory in which the XML report is created -->
+              <findbugsXmlOutputDirectory>${project.build.directory}/findbugs
+              </findbugsXmlOutputDirectory>
+            </configuration>
+            <executions>
+              <!--
+                Ensures that FindBugs inspects source code when project is compiled.
+              -->
+              <execution>
+                <phase>verify</phase>
+                <goals>
+                  <goal>check</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>xml-maven-plugin</artifactId>
+            <version>1.0</version>
+            <executions>
+              <execution>
+                <phase>verify</phase>
+                <goals>
+                  <goal>transform</goal>
+                </goals>
+              </execution>
+            </executions>
+            <configuration>
+              <transformationSets>
+                <transformationSet>
+                  <dir>${project.build.directory}/findbugs</dir>
+                  <outputDir>${project.build.directory}/findbugs</outputDir>
+                  <stylesheet>fancy-hist.xsl</stylesheet>
+                  <!--<stylesheet>default.xsl</stylesheet>-->
+                  <!--<stylesheet>plain.xsl</stylesheet>-->
+                  <!--<stylesheet>fancy.xsl</stylesheet>-->
+                  <!--<stylesheet>summary.xsl</stylesheet>-->
+                  <fileMappers>
+                    <fileMapper
+                            implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
+                      <targetExtension>.html</targetExtension>
+                    </fileMapper>
+                  </fileMappers>
+                </transformationSet>
+              </transformationSets>
+            </configuration>
+            <dependencies>
+              <dependency>
+                <groupId>com.google.code.findbugs</groupId>
+                <artifactId>findbugs</artifactId>
+                <version>2.0.0</version>
+              </dependency>
+            </dependencies>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
   </profiles>
   <modules>
     <module>tools</module>