hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject [4/4] hive git commit: HIVE-18240 : support getClientInfo/setClientInfo in JDBC (Sergey Shelukhin, reviewed by Vaibhav Gumashta)
Date Tue, 12 Dec 2017 01:43:11 GMT
HIVE-18240 : support getClientInfo/setClientInfo in JDBC (Sergey Shelukhin, reviewed by Vaibhav
Gumashta)


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

Branch: refs/heads/master
Commit: 96c2fa86b3ab09d611dbcf786d7abdbaeecfe14f
Parents: b38544f
Author: sergey <sershe@apache.org>
Authored: Mon Dec 11 17:14:57 2017 -0800
Committer: sergey <sershe@apache.org>
Committed: Mon Dec 11 17:14:57 2017 -0800

----------------------------------------------------------------------
 .../org/apache/hive/jdbc/TestJdbcDriver2.java   |   24 +
 .../org/apache/hive/jdbc/HiveConnection.java    |   51 +-
 .../apache/hive/jdbc/HiveDatabaseMetaData.java  |   50 +-
 service-rpc/if/TCLIService.thrift               |   11 +
 .../src/gen/thrift/gen-cpp/TCLIService.cpp      |  383 ++++++
 .../src/gen/thrift/gen-cpp/TCLIService.h        |  126 ++
 .../gen-cpp/TCLIService_server.skeleton.cpp     |    5 +
 .../gen/thrift/gen-cpp/TCLIService_types.cpp    | 1089 +++++++++++-------
 .../src/gen/thrift/gen-cpp/TCLIService_types.h  |   97 ++
 .../hive/service/rpc/thrift/TCLIService.java    |  858 ++++++++++++++
 .../rpc/thrift/TExecuteStatementReq.java        |   44 +-
 .../hive/service/rpc/thrift/TGetTablesReq.java  |   32 +-
 .../service/rpc/thrift/TProgressUpdateResp.java |   92 +-
 .../service/rpc/thrift/TSetClientInfoReq.java   |  556 +++++++++
 .../service/rpc/thrift/TSetClientInfoResp.java  |  394 +++++++
 .../src/gen/thrift/gen-php/TCLIService.php      |  216 ++++
 service-rpc/src/gen/thrift/gen-php/Types.php    |  315 ++++-
 .../gen-py/TCLIService/TCLIService-remote       |    7 +
 .../thrift/gen-py/TCLIService/TCLIService.py    |  189 +++
 .../src/gen/thrift/gen-py/TCLIService/ttypes.py |  223 +++-
 .../src/gen/thrift/gen-rb/t_c_l_i_service.rb    |   54 +
 .../gen/thrift/gen-rb/t_c_l_i_service_types.rb  |   36 +
 .../service/cli/thrift/ThriftCLIService.java    |   27 +-
 23 files changed, 4261 insertions(+), 618 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/96c2fa86/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
index 87595ee..7bbafa4 100644
--- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
+++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
@@ -1496,6 +1496,30 @@ public class TestJdbcDriver2 {
   }
 
   @Test
+  public void testClientInfo() throws SQLException {
+    DatabaseMetaData meta = con.getMetaData();
+    ResultSet res = meta.getClientInfoProperties();
+    try {
+      assertTrue(res.next());
+      assertEquals("ApplicationName", res.getString(1));
+      assertEquals(1000, res.getInt("MAX_LEN"));
+      assertFalse(res.next());
+    } catch (Exception e) {
+      String msg = "Unexpected exception: " + e;
+      LOG.info(msg, e);
+      fail(msg);
+    }
+
+    Connection conn = getConnection("");
+    try {
+      conn.setClientInfo("ApplicationName", "test");
+      assertEquals("test", conn.getClientInfo("ApplicationName"));
+    } finally {
+      conn.close();
+    }
+  }
+
+  @Test
   public void testResultSetColumnNameCaseInsensitive() throws SQLException {
     Statement stmt = con.createStatement();
     ResultSet res;

http://git-wip-us.apache.org/repos/asf/hive/blob/96c2fa86/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
----------------------------------------------------------------------
diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
index edf9385..fc937e6 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
@@ -18,6 +18,9 @@
 
 package org.apache.hive.jdbc;
 
+import org.apache.hive.service.rpc.thrift.TSetClientInfoResp;
+
+import org.apache.hive.service.rpc.thrift.TSetClientInfoReq;
 import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.hive.common.auth.HiveAuthUtils;
 import org.apache.hadoop.hive.shims.ShimLoader;
@@ -64,13 +67,11 @@ import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.TrustManagerFactory;
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslException;
-
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
@@ -137,6 +138,7 @@ public class HiveConnection implements java.sql.Connection {
   private TProtocolVersion protocol;
   private int fetchSize = HiveStatement.DEFAULT_FETCH_SIZE;
   private String initFile = null;
+  private Properties clientInfo;
 
   /**
    * Get all direct HiveServer2 URLs from a ZooKeeper based HiveServer2 URL
@@ -1029,8 +1031,7 @@ public class HiveConnection implements java.sql.Connection {
 
   @Override
   public Properties getClientInfo() throws SQLException {
-    // TODO Auto-generated method stub
-    throw new SQLFeatureNotSupportedException("Method not supported");
+    return clientInfo == null ? new Properties() : clientInfo;
   }
 
   /*
@@ -1041,8 +1042,8 @@ public class HiveConnection implements java.sql.Connection {
 
   @Override
   public String getClientInfo(String name) throws SQLException {
-    // TODO Auto-generated method stub
-    throw new SQLFeatureNotSupportedException("Method not supported");
+    if (clientInfo == null) return null;
+    return clientInfo.getProperty(name);
   }
 
   /*
@@ -1373,10 +1374,9 @@ public class HiveConnection implements java.sql.Connection {
    */
 
   @Override
-  public void setClientInfo(Properties properties)
-      throws SQLClientInfoException {
-    // TODO Auto-generated method stub
-    throw new SQLClientInfoException("Method not supported", null);
+  public void setClientInfo(Properties properties) throws SQLClientInfoException {
+    clientInfo = properties;
+    sendClientInfo();
   }
 
   /*
@@ -1386,10 +1386,32 @@ public class HiveConnection implements java.sql.Connection {
    */
 
   @Override
-  public void setClientInfo(String name, String value)
-      throws SQLClientInfoException {
-    // TODO Auto-generated method stub
-    throw new SQLClientInfoException("Method not supported", null);
+  public void setClientInfo(String name, String value) throws SQLClientInfoException {
+    if (clientInfo == null) {
+      clientInfo = new Properties();
+    }
+    clientInfo.put(name, value);
+    sendClientInfo();
+  }
+
+
+  private void sendClientInfo() throws SQLClientInfoException {
+    TSetClientInfoReq req = new TSetClientInfoReq(sessHandle);
+    Map<String, String> map = new HashMap<>();
+    if (clientInfo != null) {
+      for (Entry<Object, Object> e : clientInfo.entrySet()) {
+        if (e.getKey() == null || e.getValue() == null) continue;
+        map.put(e.getKey().toString(), e.getValue().toString());
+      }
+    }
+    req.setConfiguration(map);
+    try {
+      TSetClientInfoResp openResp = client.SetClientInfo(req);
+      Utils.verifySuccess(openResp.getStatus());
+    } catch (TException | SQLException e) {
+      LOG.error("Error sending client info", e);
+      throw new SQLClientInfoException("Error sending client info", null, e);
+    }
   }
 
   /*
@@ -1397,7 +1419,6 @@ public class HiveConnection implements java.sql.Connection {
    *
    * @see java.sql.Connection#setHoldability(int)
    */
-
   @Override
   public void setHoldability(int holdability) throws SQLException {
     // TODO Auto-generated method stub

http://git-wip-us.apache.org/repos/asf/hive/blob/96c2fa86/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
----------------------------------------------------------------------
diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java b/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
index 7f21bd3..09d5062 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
@@ -18,6 +18,11 @@
 
 package org.apache.hive.jdbc;
 
+import java.util.ArrayList;
+
+import java.util.List;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hive.service.cli.TableSchema;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.ResultSet;
@@ -27,7 +32,6 @@ import java.sql.SQLFeatureNotSupportedException;
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.jar.Attributes;
-
 import org.apache.hadoop.hive.metastore.TableType;
 import org.apache.hive.service.cli.GetInfoType;
 import org.apache.hive.service.rpc.thrift.TCLIService;
@@ -148,8 +152,50 @@ public class HiveDatabaseMetaData implements DatabaseMetaData {
     .build();
   }
 
+  private static final class ClientInfoPropertiesResultSet extends HiveMetaDataResultSet<Object>
{
+    private final static String[] COLUMNS = { "NAME", "MAX_LEN", "DEFAULT_VALUE", "DESCRIPTION"
};
+    private final static String[] COLUMN_TYPES = { "STRING", "INT", "STRING", "STRING" };
+
+    private final static Object[][] DATA = {
+      { "ApplicationName", 1000, null, null },
+      // Note: other standard ones include e.g. ClientUser and ClientHostname,
+      //       but we don't need them for now.
+    };
+    private int index = -1;
+
+    public ClientInfoPropertiesResultSet() throws SQLException {
+      super(Arrays.asList(COLUMNS), Arrays.asList(COLUMN_TYPES), null);
+      List<FieldSchema> fieldSchemas = new ArrayList<>(COLUMNS.length);
+      for (int i = 0; i < COLUMNS.length; ++i) {
+        fieldSchemas.add(new FieldSchema(COLUMNS[i], COLUMN_TYPES[i], null));
+      }
+      setSchema(new TableSchema(fieldSchemas));
+    }
+
+    @Override
+    public boolean next() throws SQLException {
+      if ((++index) >= DATA.length) return false;
+      row = Arrays.copyOf(DATA[index], DATA[index].length);
+      return true;
+    }
+
+    public <T> T getObject(String columnLabel, Class<T> type)  throws SQLException
{
+      for (int i = 0; i < COLUMNS.length; ++i) {
+        if (COLUMNS[i].equalsIgnoreCase(columnLabel)) return getObject(i, type);
+      }
+      throw new SQLException("No column " + columnLabel);
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T> T getObject(int columnIndex, Class<T> type)  throws SQLException
{
+      // TODO: perhaps this could use a better implementation... for now even the Hive query
result
+      //       set doesn't support this, so assume the user knows what he's doing when calling
us.
+      return (T) super.getObject(columnIndex);
+    }
+  }
+
   public ResultSet getClientInfoProperties() throws SQLException {
-    throw new SQLFeatureNotSupportedException("Method not supported");
+    return new ClientInfoPropertiesResultSet();
   }
 
   public ResultSet getColumnPrivileges(String catalog, String schema,

http://git-wip-us.apache.org/repos/asf/hive/blob/96c2fa86/service-rpc/if/TCLIService.thrift
----------------------------------------------------------------------
diff --git a/service-rpc/if/TCLIService.thrift b/service-rpc/if/TCLIService.thrift
index a1f293b..30f8af7 100644
--- a/service-rpc/if/TCLIService.thrift
+++ b/service-rpc/if/TCLIService.thrift
@@ -596,6 +596,15 @@ struct TOpenSessionResp {
   4: optional map<string, string> configuration
 }
 
+struct TSetClientInfoReq {
+  1: required TSessionHandle sessionHandle,
+  2: optional map<string, string> configuration
+}
+
+struct TSetClientInfoResp {
+  1: required TStatus status
+}
+
 
 // CloseSession()
 //
@@ -1284,4 +1293,6 @@ service TCLIService {
   TRenewDelegationTokenResp RenewDelegationToken(1:TRenewDelegationTokenReq req);
 
   TGetQueryIdResp GetQueryId(1:TGetQueryIdReq req);
+
+  TSetClientInfoResp SetClientInfo(1:TSetClientInfoReq req);
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/96c2fa86/service-rpc/src/gen/thrift/gen-cpp/TCLIService.cpp
----------------------------------------------------------------------
diff --git a/service-rpc/src/gen/thrift/gen-cpp/TCLIService.cpp b/service-rpc/src/gen/thrift/gen-cpp/TCLIService.cpp
index 1f0b683..501341f 100644
--- a/service-rpc/src/gen/thrift/gen-cpp/TCLIService.cpp
+++ b/service-rpc/src/gen/thrift/gen-cpp/TCLIService.cpp
@@ -4122,6 +4122,193 @@ uint32_t TCLIService_GetQueryId_presult::read(::apache::thrift::protocol::TProto
   return xfer;
 }
 
+
+TCLIService_SetClientInfo_args::~TCLIService_SetClientInfo_args() throw() {
+}
+
+
+uint32_t TCLIService_SetClientInfo_args::read(::apache::thrift::protocol::TProtocol* iprot)
{
+
+  apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->req.read(iprot);
+          this->__isset.req = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t TCLIService_SetClientInfo_args::write(::apache::thrift::protocol::TProtocol* oprot)
const {
+  uint32_t xfer = 0;
+  apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("TCLIService_SetClientInfo_args");
+
+  xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += this->req.write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+TCLIService_SetClientInfo_pargs::~TCLIService_SetClientInfo_pargs() throw() {
+}
+
+
+uint32_t TCLIService_SetClientInfo_pargs::write(::apache::thrift::protocol::TProtocol* oprot)
const {
+  uint32_t xfer = 0;
+  apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("TCLIService_SetClientInfo_pargs");
+
+  xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += (*(this->req)).write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+TCLIService_SetClientInfo_result::~TCLIService_SetClientInfo_result() throw() {
+}
+
+
+uint32_t TCLIService_SetClientInfo_result::read(::apache::thrift::protocol::TProtocol* iprot)
{
+
+  apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->success.read(iprot);
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t TCLIService_SetClientInfo_result::write(::apache::thrift::protocol::TProtocol* oprot)
const {
+
+  uint32_t xfer = 0;
+
+  xfer += oprot->writeStructBegin("TCLIService_SetClientInfo_result");
+
+  if (this->__isset.success) {
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
+    xfer += this->success.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  }
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+TCLIService_SetClientInfo_presult::~TCLIService_SetClientInfo_presult() throw() {
+}
+
+
+uint32_t TCLIService_SetClientInfo_presult::read(::apache::thrift::protocol::TProtocol* iprot)
{
+
+  apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += (*(this->success)).read(iprot);
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
 void TCLIServiceClient::OpenSession(TOpenSessionResp& _return, const TOpenSessionReq&
req)
 {
   send_OpenSession(req);
@@ -5398,6 +5585,64 @@ void TCLIServiceClient::recv_GetQueryId(TGetQueryIdResp& _return)
   throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT,
"GetQueryId failed: unknown result");
 }
 
+void TCLIServiceClient::SetClientInfo(TSetClientInfoResp& _return, const TSetClientInfoReq&
req)
+{
+  send_SetClientInfo(req);
+  recv_SetClientInfo(_return);
+}
+
+void TCLIServiceClient::send_SetClientInfo(const TSetClientInfoReq& req)
+{
+  int32_t cseqid = 0;
+  oprot_->writeMessageBegin("SetClientInfo", ::apache::thrift::protocol::T_CALL, cseqid);
+
+  TCLIService_SetClientInfo_pargs args;
+  args.req = &req;
+  args.write(oprot_);
+
+  oprot_->writeMessageEnd();
+  oprot_->getTransport()->writeEnd();
+  oprot_->getTransport()->flush();
+}
+
+void TCLIServiceClient::recv_SetClientInfo(TSetClientInfoResp& _return)
+{
+
+  int32_t rseqid = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TMessageType mtype;
+
+  iprot_->readMessageBegin(fname, mtype, rseqid);
+  if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+    ::apache::thrift::TApplicationException x;
+    x.read(iprot_);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+    throw x;
+  }
+  if (mtype != ::apache::thrift::protocol::T_REPLY) {
+    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+  }
+  if (fname.compare("SetClientInfo") != 0) {
+    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+  }
+  TCLIService_SetClientInfo_presult result;
+  result.success = &_return;
+  result.read(iprot_);
+  iprot_->readMessageEnd();
+  iprot_->getTransport()->readEnd();
+
+  if (result.__isset.success) {
+    // _return pointer has now been filled
+    return;
+  }
+  throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT,
"SetClientInfo failed: unknown result");
+}
+
 bool TCLIServiceProcessor::dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol*
oprot, const std::string& fname, int32_t seqid, void* callContext) {
   ProcessMap::iterator pfn;
   pfn = processMap_.find(fname);
@@ -6605,6 +6850,60 @@ void TCLIServiceProcessor::process_GetQueryId(int32_t seqid, ::apache::thrift::p
   }
 }
 
+void TCLIServiceProcessor::process_SetClientInfo(int32_t seqid, ::apache::thrift::protocol::TProtocol*
iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+  void* ctx = NULL;
+  if (this->eventHandler_.get() != NULL) {
+    ctx = this->eventHandler_->getContext("TCLIService.SetClientInfo", callContext);
+  }
+  ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "TCLIService.SetClientInfo");
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->preRead(ctx, "TCLIService.SetClientInfo");
+  }
+
+  TCLIService_SetClientInfo_args args;
+  args.read(iprot);
+  iprot->readMessageEnd();
+  uint32_t bytes = iprot->getTransport()->readEnd();
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->postRead(ctx, "TCLIService.SetClientInfo", bytes);
+  }
+
+  TCLIService_SetClientInfo_result result;
+  try {
+    iface_->SetClientInfo(result.success, args.req);
+    result.__isset.success = true;
+  } catch (const std::exception& e) {
+    if (this->eventHandler_.get() != NULL) {
+      this->eventHandler_->handlerError(ctx, "TCLIService.SetClientInfo");
+    }
+
+    ::apache::thrift::TApplicationException x(e.what());
+    oprot->writeMessageBegin("SetClientInfo", ::apache::thrift::protocol::T_EXCEPTION,
seqid);
+    x.write(oprot);
+    oprot->writeMessageEnd();
+    oprot->getTransport()->writeEnd();
+    oprot->getTransport()->flush();
+    return;
+  }
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->preWrite(ctx, "TCLIService.SetClientInfo");
+  }
+
+  oprot->writeMessageBegin("SetClientInfo", ::apache::thrift::protocol::T_REPLY, seqid);
+  result.write(oprot);
+  oprot->writeMessageEnd();
+  bytes = oprot->getTransport()->writeEnd();
+  oprot->getTransport()->flush();
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->postWrite(ctx, "TCLIService.SetClientInfo", bytes);
+  }
+}
+
 ::boost::shared_ptr< ::apache::thrift::TProcessor > TCLIServiceProcessorFactory::getProcessor(const
::apache::thrift::TConnectionInfo& connInfo) {
   ::apache::thrift::ReleaseHandler< TCLIServiceIfFactory > cleanup(handlerFactory_);
   ::boost::shared_ptr< TCLIServiceIf > handler(handlerFactory_->getHandler(connInfo),
cleanup);
@@ -8460,5 +8759,89 @@ void TCLIServiceConcurrentClient::recv_GetQueryId(TGetQueryIdResp&
_return, cons
   } // end while(true)
 }
 
+void TCLIServiceConcurrentClient::SetClientInfo(TSetClientInfoResp& _return, const TSetClientInfoReq&
req)
+{
+  int32_t seqid = send_SetClientInfo(req);
+  recv_SetClientInfo(_return, seqid);
+}
+
+int32_t TCLIServiceConcurrentClient::send_SetClientInfo(const TSetClientInfoReq& req)
+{
+  int32_t cseqid = this->sync_.generateSeqId();
+  ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_);
+  oprot_->writeMessageBegin("SetClientInfo", ::apache::thrift::protocol::T_CALL, cseqid);
+
+  TCLIService_SetClientInfo_pargs args;
+  args.req = &req;
+  args.write(oprot_);
+
+  oprot_->writeMessageEnd();
+  oprot_->getTransport()->writeEnd();
+  oprot_->getTransport()->flush();
+
+  sentry.commit();
+  return cseqid;
+}
+
+void TCLIServiceConcurrentClient::recv_SetClientInfo(TSetClientInfoResp& _return, const
int32_t seqid)
+{
+
+  int32_t rseqid = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TMessageType mtype;
+
+  // the read mutex gets dropped and reacquired as part of waitForWork()
+  // The destructor of this sentry wakes up other clients
+  ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid);
+
+  while(true) {
+    if(!this->sync_.getPending(fname, mtype, rseqid)) {
+      iprot_->readMessageBegin(fname, mtype, rseqid);
+    }
+    if(seqid == rseqid) {
+      if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+        ::apache::thrift::TApplicationException x;
+        x.read(iprot_);
+        iprot_->readMessageEnd();
+        iprot_->getTransport()->readEnd();
+        sentry.commit();
+        throw x;
+      }
+      if (mtype != ::apache::thrift::protocol::T_REPLY) {
+        iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+        iprot_->readMessageEnd();
+        iprot_->getTransport()->readEnd();
+      }
+      if (fname.compare("SetClientInfo") != 0) {
+        iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+        iprot_->readMessageEnd();
+        iprot_->getTransport()->readEnd();
+
+        // in a bad state, don't commit
+        using ::apache::thrift::protocol::TProtocolException;
+        throw TProtocolException(TProtocolException::INVALID_DATA);
+      }
+      TCLIService_SetClientInfo_presult result;
+      result.success = &_return;
+      result.read(iprot_);
+      iprot_->readMessageEnd();
+      iprot_->getTransport()->readEnd();
+
+      if (result.__isset.success) {
+        // _return pointer has now been filled
+        sentry.commit();
+        return;
+      }
+      // in a bad state, don't commit
+      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT,
"SetClientInfo failed: unknown result");
+    }
+    // seqid != rseqid
+    this->sync_.updatePending(fname, mtype, rseqid);
+
+    // this will temporarily unlock the readMutex, and let other clients get work done
+    this->sync_.waitForWork(seqid);
+  } // end while(true)
+}
+
 }}}}} // namespace
 

http://git-wip-us.apache.org/repos/asf/hive/blob/96c2fa86/service-rpc/src/gen/thrift/gen-cpp/TCLIService.h
----------------------------------------------------------------------
diff --git a/service-rpc/src/gen/thrift/gen-cpp/TCLIService.h b/service-rpc/src/gen/thrift/gen-cpp/TCLIService.h
index a508af7..b62234a 100644
--- a/service-rpc/src/gen/thrift/gen-cpp/TCLIService.h
+++ b/service-rpc/src/gen/thrift/gen-cpp/TCLIService.h
@@ -43,6 +43,7 @@ class TCLIServiceIf {
   virtual void CancelDelegationToken(TCancelDelegationTokenResp& _return, const TCancelDelegationTokenReq&
req) = 0;
   virtual void RenewDelegationToken(TRenewDelegationTokenResp& _return, const TRenewDelegationTokenReq&
req) = 0;
   virtual void GetQueryId(TGetQueryIdResp& _return, const TGetQueryIdReq& req) =
0;
+  virtual void SetClientInfo(TSetClientInfoResp& _return, const TSetClientInfoReq&
req) = 0;
 };
 
 class TCLIServiceIfFactory {
@@ -138,6 +139,9 @@ class TCLIServiceNull : virtual public TCLIServiceIf {
   void GetQueryId(TGetQueryIdResp& /* _return */, const TGetQueryIdReq& /* req */)
{
     return;
   }
+  void SetClientInfo(TSetClientInfoResp& /* _return */, const TSetClientInfoReq&
/* req */) {
+    return;
+  }
 };
 
 typedef struct _TCLIService_OpenSession_args__isset {
@@ -2428,6 +2432,110 @@ class TCLIService_GetQueryId_presult {
 
 };
 
+typedef struct _TCLIService_SetClientInfo_args__isset {
+  _TCLIService_SetClientInfo_args__isset() : req(false) {}
+  bool req :1;
+} _TCLIService_SetClientInfo_args__isset;
+
+class TCLIService_SetClientInfo_args {
+ public:
+
+  TCLIService_SetClientInfo_args(const TCLIService_SetClientInfo_args&);
+  TCLIService_SetClientInfo_args& operator=(const TCLIService_SetClientInfo_args&);
+  TCLIService_SetClientInfo_args() {
+  }
+
+  virtual ~TCLIService_SetClientInfo_args() throw();
+  TSetClientInfoReq req;
+
+  _TCLIService_SetClientInfo_args__isset __isset;
+
+  void __set_req(const TSetClientInfoReq& val);
+
+  bool operator == (const TCLIService_SetClientInfo_args & rhs) const
+  {
+    if (!(req == rhs.req))
+      return false;
+    return true;
+  }
+  bool operator != (const TCLIService_SetClientInfo_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const TCLIService_SetClientInfo_args & ) const;
+
+  uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+  uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+class TCLIService_SetClientInfo_pargs {
+ public:
+
+
+  virtual ~TCLIService_SetClientInfo_pargs() throw();
+  const TSetClientInfoReq* req;
+
+  uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _TCLIService_SetClientInfo_result__isset {
+  _TCLIService_SetClientInfo_result__isset() : success(false) {}
+  bool success :1;
+} _TCLIService_SetClientInfo_result__isset;
+
+class TCLIService_SetClientInfo_result {
+ public:
+
+  TCLIService_SetClientInfo_result(const TCLIService_SetClientInfo_result&);
+  TCLIService_SetClientInfo_result& operator=(const TCLIService_SetClientInfo_result&);
+  TCLIService_SetClientInfo_result() {
+  }
+
+  virtual ~TCLIService_SetClientInfo_result() throw();
+  TSetClientInfoResp success;
+
+  _TCLIService_SetClientInfo_result__isset __isset;
+
+  void __set_success(const TSetClientInfoResp& val);
+
+  bool operator == (const TCLIService_SetClientInfo_result & rhs) const
+  {
+    if (!(success == rhs.success))
+      return false;
+    return true;
+  }
+  bool operator != (const TCLIService_SetClientInfo_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const TCLIService_SetClientInfo_result & ) const;
+
+  uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+  uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _TCLIService_SetClientInfo_presult__isset {
+  _TCLIService_SetClientInfo_presult__isset() : success(false) {}
+  bool success :1;
+} _TCLIService_SetClientInfo_presult__isset;
+
+class TCLIService_SetClientInfo_presult {
+ public:
+
+
+  virtual ~TCLIService_SetClientInfo_presult() throw();
+  TSetClientInfoResp* success;
+
+  _TCLIService_SetClientInfo_presult__isset __isset;
+
+  uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+
+};
+
 class TCLIServiceClient : virtual public TCLIServiceIf {
  public:
   TCLIServiceClient(boost::shared_ptr< ::apache::thrift::protocol::TProtocol> prot)
{
@@ -2519,6 +2627,9 @@ class TCLIServiceClient : virtual public TCLIServiceIf {
   void GetQueryId(TGetQueryIdResp& _return, const TGetQueryIdReq& req);
   void send_GetQueryId(const TGetQueryIdReq& req);
   void recv_GetQueryId(TGetQueryIdResp& _return);
+  void SetClientInfo(TSetClientInfoResp& _return, const TSetClientInfoReq& req);
+  void send_SetClientInfo(const TSetClientInfoReq& req);
+  void recv_SetClientInfo(TSetClientInfoResp& _return);
  protected:
   boost::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_;
   boost::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_;
@@ -2556,6 +2667,7 @@ class TCLIServiceProcessor : public ::apache::thrift::TDispatchProcessor
{
   void process_CancelDelegationToken(int32_t seqid, ::apache::thrift::protocol::TProtocol*
iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext);
   void process_RenewDelegationToken(int32_t seqid, ::apache::thrift::protocol::TProtocol*
iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext);
   void process_GetQueryId(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol*
oprot, void* callContext);
+  void process_SetClientInfo(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot,
::apache::thrift::protocol::TProtocol* oprot, void* callContext);
  public:
   TCLIServiceProcessor(boost::shared_ptr<TCLIServiceIf> iface) :
     iface_(iface) {
@@ -2581,6 +2693,7 @@ class TCLIServiceProcessor : public ::apache::thrift::TDispatchProcessor
{
     processMap_["CancelDelegationToken"] = &TCLIServiceProcessor::process_CancelDelegationToken;
     processMap_["RenewDelegationToken"] = &TCLIServiceProcessor::process_RenewDelegationToken;
     processMap_["GetQueryId"] = &TCLIServiceProcessor::process_GetQueryId;
+    processMap_["SetClientInfo"] = &TCLIServiceProcessor::process_SetClientInfo;
   }
 
   virtual ~TCLIServiceProcessor() {}
@@ -2829,6 +2942,16 @@ class TCLIServiceMultiface : virtual public TCLIServiceIf {
     return;
   }
 
+  void SetClientInfo(TSetClientInfoResp& _return, const TSetClientInfoReq& req) {
+    size_t sz = ifaces_.size();
+    size_t i = 0;
+    for (; i < (sz - 1); ++i) {
+      ifaces_[i]->SetClientInfo(_return, req);
+    }
+    ifaces_[i]->SetClientInfo(_return, req);
+    return;
+  }
+
 };
 
 // The 'concurrent' client is a thread safe client that correctly handles
@@ -2925,6 +3048,9 @@ class TCLIServiceConcurrentClient : virtual public TCLIServiceIf {
   void GetQueryId(TGetQueryIdResp& _return, const TGetQueryIdReq& req);
   int32_t send_GetQueryId(const TGetQueryIdReq& req);
   void recv_GetQueryId(TGetQueryIdResp& _return, const int32_t seqid);
+  void SetClientInfo(TSetClientInfoResp& _return, const TSetClientInfoReq& req);
+  int32_t send_SetClientInfo(const TSetClientInfoReq& req);
+  void recv_SetClientInfo(TSetClientInfoResp& _return, const int32_t seqid);
  protected:
   boost::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_;
   boost::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_;

http://git-wip-us.apache.org/repos/asf/hive/blob/96c2fa86/service-rpc/src/gen/thrift/gen-cpp/TCLIService_server.skeleton.cpp
----------------------------------------------------------------------
diff --git a/service-rpc/src/gen/thrift/gen-cpp/TCLIService_server.skeleton.cpp b/service-rpc/src/gen/thrift/gen-cpp/TCLIService_server.skeleton.cpp
index 9c8b466..bdf8814 100644
--- a/service-rpc/src/gen/thrift/gen-cpp/TCLIService_server.skeleton.cpp
+++ b/service-rpc/src/gen/thrift/gen-cpp/TCLIService_server.skeleton.cpp
@@ -132,6 +132,11 @@ class TCLIServiceHandler : virtual public TCLIServiceIf {
     printf("GetQueryId\n");
   }
 
+  void SetClientInfo(TSetClientInfoResp& _return, const TSetClientInfoReq& req) {
+    // Your implementation goes here
+    printf("SetClientInfo\n");
+  }
+
 };
 
 int main(int argc, char **argv) {


Mime
View raw message