Return-Path: X-Original-To: apmail-hawq-commits-archive@minotaur.apache.org Delivered-To: apmail-hawq-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6ECFA19FF7 for ; Wed, 6 Apr 2016 03:42:04 +0000 (UTC) Received: (qmail 7608 invoked by uid 500); 6 Apr 2016 03:42:04 -0000 Delivered-To: apmail-hawq-commits-archive@hawq.apache.org Received: (qmail 7573 invoked by uid 500); 6 Apr 2016 03:42:04 -0000 Mailing-List: contact commits-help@hawq.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hawq.incubator.apache.org Delivered-To: mailing list commits@hawq.incubator.apache.org Received: (qmail 7562 invoked by uid 99); 6 Apr 2016 03:42:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Apr 2016 03:42:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id E5C9A18055E for ; Wed, 6 Apr 2016 03:42:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.221 X-Spam-Level: X-Spam-Status: No, score=-3.221 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 2WrwqprQ5Adr for ; Wed, 6 Apr 2016 03:42:02 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 2360B5F217 for ; Wed, 6 Apr 2016 03:42:00 +0000 (UTC) Received: (qmail 6964 invoked by uid 99); 6 Apr 2016 03:42:00 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Apr 2016 03:42:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id ED1B4DFE1B; Wed, 6 Apr 2016 03:41:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bhuvnesh2703@apache.org To: commits@hawq.incubator.apache.org Date: Wed, 06 Apr 2016 03:41:59 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [01/12] incubator-hawq git commit: HAWQ-462. Dispatch dfs_address from master to segment in secure mode Repository: incubator-hawq Updated Branches: refs/heads/HAWQ-617 c5c7d8fc0 -> 487929d54 HAWQ-462. Dispatch dfs_address from master to segment in secure mode Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/59ebfa70 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/59ebfa70 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/59ebfa70 Branch: refs/heads/HAWQ-617 Commit: 59ebfa7072621117827ae3d9464c971a61919672 Parents: e8fcfb0 Author: Shivram Mani Authored: Mon Apr 4 11:52:51 2016 -0700 Committer: Shivram Mani Committed: Mon Apr 4 11:52:51 2016 -0700 ---------------------------------------------------------------------- src/backend/cdb/cdbquerycontextdispatching.c | 63 +++++++++++++++++++++-- src/backend/storage/file/fd.c | 2 + src/bin/gpfusion/gpbridgeapi.c | 17 +++--- src/include/storage/fd.h | 2 + 4 files changed, 74 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/59ebfa70/src/backend/cdb/cdbquerycontextdispatching.c ---------------------------------------------------------------------- diff --git a/src/backend/cdb/cdbquerycontextdispatching.c b/src/backend/cdb/cdbquerycontextdispatching.c index 52f85f1..b3cf083 100644 --- a/src/backend/cdb/cdbquerycontextdispatching.c +++ b/src/backend/cdb/cdbquerycontextdispatching.c @@ -102,7 +102,7 @@ int QueryContextDispatchingSizeMemoryLimit = 100 * 1024; /* KB */ enum QueryContextDispatchingItemType { - MasterXid, TablespaceLocation, TupleType, EmptyTable, FileSystemCredential + MasterXid, TablespaceLocation, TupleType, EmptyTable, FileSystemCredential, Namespace }; typedef enum QueryContextDispatchingItemType QueryContextDispatchingItemType; @@ -183,7 +183,7 @@ static char* GetExtTableFirstLocation(Datum *array); static void -AddFileSystemCredentialForPxfTable(char *uri); +AddFileSystemCredentialForPxfTable(); /** * construct the file location for query context dispatching. @@ -770,6 +770,30 @@ RebuildTupleForRelation(QueryContextInfo *cxt) } /* + * Deserialize the Namespace data + */ +static void +RebuildNamespace(QueryContextInfo *cxt) +{ + + int len; + char buffer[4], *binary; + ReadData(cxt, buffer, sizeof(buffer), TRUE); + + len = (int) ntohl(*(uint32 *) buffer); + binary = palloc(len); + if(ReadData(cxt, binary, len, TRUE)) + { + StringInfoData buffer; + initStringInfoOfString(&buffer, binary, len); + dfs_address = strdup(buffer.data); + } else { + elog(ERROR, "Couldn't rebuild Namespace"); + } + pfree(binary); +} + +/* * rebuild execute context */ void @@ -801,6 +825,9 @@ RebuildQueryContext(QueryContextInfo *cxt, HTAB **currentFilesystemCredentials, RebuildFilesystemCredentials(cxt, currentFilesystemCredentials, currentFilesystemCredentialsMemoryContext); break; + case Namespace: + RebuildNamespace(cxt); + break; default: ereport(ERROR, (errcode(ERRCODE_GP_INTERNAL_ERROR), errmsg( "unrecognized " @@ -1746,7 +1773,8 @@ prepareDispatchedCatalogExternalTable(QueryContextInfo *cxt, if (IS_PXF_URI(location)) { Insist(array_size == 1); - AddFileSystemCredentialForPxfTable(location); + AddFileSystemCredentialForPxfTable(); + prepareDfsAddressForDispatch(cxt); } AddTupleWithToastsToContextInfo(cxt, ExtTableRelationId, "pg_exttable", tuple, @@ -2880,7 +2908,7 @@ static char* GetExtTableFirstLocation(Datum *array) * prepareDispatchedCatalogFileSystemCredential will store the token * using port == 0 in HA case (otherwise the supplied port). */ -static void AddFileSystemCredentialForPxfTable(char *uri) +static void AddFileSystemCredentialForPxfTable() { char* dfs_address = NULL; @@ -2984,3 +3012,30 @@ GetResultRelSegFileInfos(Oid relid, List *segnomaps, List *existing_seginfomaps) return existing_seginfomaps; } + +/* + * prepareDfsAddressForDispatch + * + * Given the cxt use the currently set value of cxt->sharedPath + * and add it to cxt->buffer so that it is dispatched from + * master to segment. This is only required in the case of + * a secure filesystem. + */ + +void +prepareDfsAddressForDispatch(QueryContextInfo* cxt) +{ + if (!enable_secure_filesystem) + return; + const char *namespace = cxt->sharedPath; + int size = strlen(namespace); + StringInfoData buffer; + initStringInfo(&buffer); + + pq_sendint(&buffer, (int) Namespace, sizeof(char)); + pq_sendint(&buffer, size, sizeof(int)); + + WriteData(cxt, buffer.data, buffer.len); + WriteData(cxt, namespace, size); + pfree(buffer.data); +} http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/59ebfa70/src/backend/storage/file/fd.c ---------------------------------------------------------------------- diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index e71282a..4ec458e 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -250,6 +250,8 @@ static int RecentRemoteAllocatedDesc = -1; */ static long tempFileCounter = 0; +char* dfs_address; + /*-------------------- * http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/59ebfa70/src/bin/gpfusion/gpbridgeapi.c ---------------------------------------------------------------------- diff --git a/src/bin/gpfusion/gpbridgeapi.c b/src/bin/gpfusion/gpbridgeapi.c index 6d7dfaf..63fc565 100644 --- a/src/bin/gpfusion/gpbridgeapi.c +++ b/src/bin/gpfusion/gpbridgeapi.c @@ -241,6 +241,8 @@ void gpbridge_import_start(PG_FUNCTION_ARGS) /* read some bytes to make sure the connection is established */ churl_read_check_connectivity(context->churl_handle); + + free_dfs_address(); } void gpbridge_export_start(PG_FUNCTION_ARGS) @@ -271,6 +273,7 @@ void gpbridge_export_start(PG_FUNCTION_ARGS) context->churl_handle = churl_init_upload(context->uri.data, context->churl_headers); + free_dfs_address(); } /* @@ -507,16 +510,14 @@ size_t fill_buffer(gphadoop_context* context, char* start, size_t size) void add_delegation_token(PxfInputData *inputData) { PxfHdfsTokenData *token = NULL; - char* dfs_address = NULL; if (!enable_secure_filesystem) return; - token = palloc0(sizeof(PxfHdfsTokenData)); - - get_hdfs_location_from_filespace(&dfs_address); + Assert(dfs_address); - elog(DEBUG2, "locating token for %s", dfs_address); + token = palloc0(sizeof(PxfHdfsTokenData)); + elog(DEBUG2, "locating token for %s", dfs_address); token->hdfs_token = find_filesystem_credential_with_uri(dfs_address); @@ -526,7 +527,6 @@ void add_delegation_token(PxfInputData *inputData) inputData->token = token; - pfree(dfs_address); } void free_token_resources(PxfInputData *inputData) @@ -536,3 +536,8 @@ void free_token_resources(PxfInputData *inputData) pfree(inputData->token); } + +void free_dfs_address() +{ + free(dfs_address); +} http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/59ebfa70/src/include/storage/fd.h ---------------------------------------------------------------------- diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h index 3e0782d..0c25264 100644 --- a/src/include/storage/fd.h +++ b/src/include/storage/fd.h @@ -73,6 +73,8 @@ typedef int File; extern int max_files_per_process; extern bool enable_secure_filesystem; +/* DFS address needed on segments */ +extern char* dfs_address; /* * prototypes for functions in fd.c