diff --git a/service-rpc/if/TCLIService.thrift b/service-rpc/if/TCLIService.thrift index d17930a..ce70b2d 100644 --- a/service-rpc/if/TCLIService.thrift +++ b/service-rpc/if/TCLIService.thrift @@ -587,7 +587,6 @@ struct TOpenSessionResp { 4: optional map configuration } - // CloseSession() // // Closes the specified session and frees any resources @@ -1202,10 +1201,32 @@ struct TRenewDelegationTokenResp { 1: required TStatus status } +// BindSession() +// +// Bind a session (connection) on the server against +// which operations may be executed. +struct TBindSessionReq { + // The version of the HiveServer2 protocol that the client is using. + 1: required TProtocolVersion client_protocol = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8 + + // Session Handle + 2: required TSessionHandle sessionHandle +} + +struct TBindSessionResp { + 1: required TStatus status + + // The protocol version that the server is using. + 2: required TProtocolVersion serverProtocolVersion = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8 +} + + service TCLIService { TOpenSessionResp OpenSession(1:TOpenSessionReq req); + TBindSessionResp BindSession(1:TBindSessionReq req); + TCloseSessionResp CloseSession(1:TCloseSessionReq req); TGetInfoResp GetInfo(1:TGetInfoReq req); diff --git a/service-rpc/src/gen/thrift/gen-cpp/TCLIService.cpp b/service-rpc/src/gen/thrift/gen-cpp/TCLIService.cpp index 3597d44..6a9ac8b 100644 --- a/service-rpc/src/gen/thrift/gen-cpp/TCLIService.cpp +++ b/service-rpc/src/gen/thrift/gen-cpp/TCLIService.cpp @@ -196,6 +196,193 @@ uint32_t TCLIService_OpenSession_presult::read(::apache::thrift::protocol::TProt } +TCLIService_BindSession_args::~TCLIService_BindSession_args() throw() { +} + + +uint32_t TCLIService_BindSession_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_BindSession_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("TCLIService_BindSession_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_BindSession_pargs::~TCLIService_BindSession_pargs() throw() { +} + + +uint32_t TCLIService_BindSession_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("TCLIService_BindSession_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_BindSession_result::~TCLIService_BindSession_result() throw() { +} + + +uint32_t TCLIService_BindSession_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_BindSession_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("TCLIService_BindSession_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_BindSession_presult::~TCLIService_BindSession_presult() throw() { +} + + +uint32_t TCLIService_BindSession_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; +} + + TCLIService_CloseSession_args::~TCLIService_CloseSession_args() throw() { } @@ -3993,6 +4180,64 @@ void TCLIServiceClient::recv_OpenSession(TOpenSessionResp& _return) throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "OpenSession failed: unknown result"); } +void TCLIServiceClient::BindSession(TBindSessionResp& _return, const TBindSessionReq& req) +{ + send_BindSession(req); + recv_BindSession(_return); +} + +void TCLIServiceClient::send_BindSession(const TBindSessionReq& req) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("BindSession", ::apache::thrift::protocol::T_CALL, cseqid); + + TCLIService_BindSession_pargs args; + args.req = &req; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void TCLIServiceClient::recv_BindSession(TBindSessionResp& _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("BindSession") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + TCLIService_BindSession_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, "BindSession failed: unknown result"); +} + void TCLIServiceClient::CloseSession(TCloseSessionResp& _return, const TCloseSessionReq& req) { send_CloseSession(req); @@ -5226,6 +5471,60 @@ void TCLIServiceProcessor::process_OpenSession(int32_t seqid, ::apache::thrift:: } } +void TCLIServiceProcessor::process_BindSession(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.BindSession", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "TCLIService.BindSession"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "TCLIService.BindSession"); + } + + TCLIService_BindSession_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "TCLIService.BindSession", bytes); + } + + TCLIService_BindSession_result result; + try { + iface_->BindSession(result.success, args.req); + result.__isset.success = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "TCLIService.BindSession"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("BindSession", ::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.BindSession"); + } + + oprot->writeMessageBegin("BindSession", ::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.BindSession", bytes); + } +} + void TCLIServiceProcessor::process_CloseSession(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) { void* ctx = NULL; @@ -6397,6 +6696,90 @@ void TCLIServiceConcurrentClient::recv_OpenSession(TOpenSessionResp& _return, co } // end while(true) } +void TCLIServiceConcurrentClient::BindSession(TBindSessionResp& _return, const TBindSessionReq& req) +{ + int32_t seqid = send_BindSession(req); + recv_BindSession(_return, seqid); +} + +int32_t TCLIServiceConcurrentClient::send_BindSession(const TBindSessionReq& req) +{ + int32_t cseqid = this->sync_.generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + oprot_->writeMessageBegin("BindSession", ::apache::thrift::protocol::T_CALL, cseqid); + + TCLIService_BindSession_pargs args; + args.req = &req; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +void TCLIServiceConcurrentClient::recv_BindSession(TBindSessionResp& _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("BindSession") != 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_BindSession_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, "BindSession 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) +} + void TCLIServiceConcurrentClient::CloseSession(TCloseSessionResp& _return, const TCloseSessionReq& req) { int32_t seqid = send_CloseSession(req); diff --git a/service-rpc/src/gen/thrift/gen-cpp/TCLIService.h b/service-rpc/src/gen/thrift/gen-cpp/TCLIService.h index 5fd423d..e7380bc 100644 --- a/service-rpc/src/gen/thrift/gen-cpp/TCLIService.h +++ b/service-rpc/src/gen/thrift/gen-cpp/TCLIService.h @@ -22,6 +22,7 @@ class TCLIServiceIf { public: virtual ~TCLIServiceIf() {} virtual void OpenSession(TOpenSessionResp& _return, const TOpenSessionReq& req) = 0; + virtual void BindSession(TBindSessionResp& _return, const TBindSessionReq& req) = 0; virtual void CloseSession(TCloseSessionResp& _return, const TCloseSessionReq& req) = 0; virtual void GetInfo(TGetInfoResp& _return, const TGetInfoReq& req) = 0; virtual void ExecuteStatement(TExecuteStatementResp& _return, const TExecuteStatementReq& req) = 0; @@ -74,6 +75,9 @@ class TCLIServiceNull : virtual public TCLIServiceIf { void OpenSession(TOpenSessionResp& /* _return */, const TOpenSessionReq& /* req */) { return; } + void BindSession(TBindSessionResp& /* _return */, const TBindSessionReq& /* req */) { + return; + } void CloseSession(TCloseSessionResp& /* _return */, const TCloseSessionReq& /* req */) { return; } @@ -240,6 +244,110 @@ class TCLIService_OpenSession_presult { }; +typedef struct _TCLIService_BindSession_args__isset { + _TCLIService_BindSession_args__isset() : req(false) {} + bool req :1; +} _TCLIService_BindSession_args__isset; + +class TCLIService_BindSession_args { + public: + + TCLIService_BindSession_args(const TCLIService_BindSession_args&); + TCLIService_BindSession_args& operator=(const TCLIService_BindSession_args&); + TCLIService_BindSession_args() { + } + + virtual ~TCLIService_BindSession_args() throw(); + TBindSessionReq req; + + _TCLIService_BindSession_args__isset __isset; + + void __set_req(const TBindSessionReq& val); + + bool operator == (const TCLIService_BindSession_args & rhs) const + { + if (!(req == rhs.req)) + return false; + return true; + } + bool operator != (const TCLIService_BindSession_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const TCLIService_BindSession_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class TCLIService_BindSession_pargs { + public: + + + virtual ~TCLIService_BindSession_pargs() throw(); + const TBindSessionReq* req; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _TCLIService_BindSession_result__isset { + _TCLIService_BindSession_result__isset() : success(false) {} + bool success :1; +} _TCLIService_BindSession_result__isset; + +class TCLIService_BindSession_result { + public: + + TCLIService_BindSession_result(const TCLIService_BindSession_result&); + TCLIService_BindSession_result& operator=(const TCLIService_BindSession_result&); + TCLIService_BindSession_result() { + } + + virtual ~TCLIService_BindSession_result() throw(); + TBindSessionResp success; + + _TCLIService_BindSession_result__isset __isset; + + void __set_success(const TBindSessionResp& val); + + bool operator == (const TCLIService_BindSession_result & rhs) const + { + if (!(success == rhs.success)) + return false; + return true; + } + bool operator != (const TCLIService_BindSession_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const TCLIService_BindSession_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _TCLIService_BindSession_presult__isset { + _TCLIService_BindSession_presult__isset() : success(false) {} + bool success :1; +} _TCLIService_BindSession_presult__isset; + +class TCLIService_BindSession_presult { + public: + + + virtual ~TCLIService_BindSession_presult() throw(); + TBindSessionResp* success; + + _TCLIService_BindSession_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + typedef struct _TCLIService_CloseSession_args__isset { _TCLIService_CloseSession_args__isset() : req(false) {} bool req :1; @@ -2348,6 +2456,9 @@ class TCLIServiceClient : virtual public TCLIServiceIf { void OpenSession(TOpenSessionResp& _return, const TOpenSessionReq& req); void send_OpenSession(const TOpenSessionReq& req); void recv_OpenSession(TOpenSessionResp& _return); + void BindSession(TBindSessionResp& _return, const TBindSessionReq& req); + void send_BindSession(const TBindSessionReq& req); + void recv_BindSession(TBindSessionResp& _return); void CloseSession(TCloseSessionResp& _return, const TCloseSessionReq& req); void send_CloseSession(const TCloseSessionReq& req); void recv_CloseSession(TCloseSessionResp& _return); @@ -2424,6 +2535,7 @@ class TCLIServiceProcessor : public ::apache::thrift::TDispatchProcessor { typedef std::map ProcessMap; ProcessMap processMap_; void process_OpenSession(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_BindSession(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_CloseSession(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_GetInfo(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_ExecuteStatement(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); @@ -2448,6 +2560,7 @@ class TCLIServiceProcessor : public ::apache::thrift::TDispatchProcessor { TCLIServiceProcessor(boost::shared_ptr iface) : iface_(iface) { processMap_["OpenSession"] = &TCLIServiceProcessor::process_OpenSession; + processMap_["BindSession"] = &TCLIServiceProcessor::process_BindSession; processMap_["CloseSession"] = &TCLIServiceProcessor::process_CloseSession; processMap_["GetInfo"] = &TCLIServiceProcessor::process_GetInfo; processMap_["ExecuteStatement"] = &TCLIServiceProcessor::process_ExecuteStatement; @@ -2506,6 +2619,16 @@ class TCLIServiceMultiface : virtual public TCLIServiceIf { return; } + void BindSession(TBindSessionResp& _return, const TBindSessionReq& req) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->BindSession(_return, req); + } + ifaces_[i]->BindSession(_return, req); + return; + } + void CloseSession(TCloseSessionResp& _return, const TCloseSessionReq& req) { size_t sz = ifaces_.size(); size_t i = 0; @@ -2739,6 +2862,9 @@ class TCLIServiceConcurrentClient : virtual public TCLIServiceIf { void OpenSession(TOpenSessionResp& _return, const TOpenSessionReq& req); int32_t send_OpenSession(const TOpenSessionReq& req); void recv_OpenSession(TOpenSessionResp& _return, const int32_t seqid); + void BindSession(TBindSessionResp& _return, const TBindSessionReq& req); + int32_t send_BindSession(const TBindSessionReq& req); + void recv_BindSession(TBindSessionResp& _return, const int32_t seqid); void CloseSession(TCloseSessionResp& _return, const TCloseSessionReq& req); int32_t send_CloseSession(const TCloseSessionReq& req); void recv_CloseSession(TCloseSessionResp& _return, const int32_t seqid); 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 5d7caf9..b72d02c 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 @@ -27,6 +27,11 @@ class TCLIServiceHandler : virtual public TCLIServiceIf { printf("OpenSession\n"); } + void BindSession(TBindSessionResp& _return, const TBindSessionReq& req) { + // Your implementation goes here + printf("BindSession\n"); + } + void CloseSession(TCloseSessionResp& _return, const TCloseSessionReq& req) { // Your implementation goes here printf("CloseSession\n"); diff --git a/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.cpp b/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.cpp index 2f460e8..a49fa13 100644 --- a/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.cpp +++ b/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.cpp @@ -9984,4 +9984,226 @@ void TRenewDelegationTokenResp::printTo(std::ostream& out) const { out << ")"; } + +TBindSessionReq::~TBindSessionReq() throw() { +} + + +void TBindSessionReq::__set_client_protocol(const TProtocolVersion::type val) { + this->client_protocol = val; +} + +void TBindSessionReq::__set_sessionHandle(const TSessionHandle& val) { + this->sessionHandle = val; +} + +uint32_t TBindSessionReq::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; + + bool isset_client_protocol = false; + bool isset_sessionHandle = false; + + 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_I32) { + int32_t ecast302; + xfer += iprot->readI32(ecast302); + this->client_protocol = (TProtocolVersion::type)ecast302; + isset_client_protocol = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->sessionHandle.read(iprot); + isset_sessionHandle = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_client_protocol) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_sessionHandle) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t TBindSessionReq::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("TBindSessionReq"); + + xfer += oprot->writeFieldBegin("client_protocol", ::apache::thrift::protocol::T_I32, 1); + xfer += oprot->writeI32((int32_t)this->client_protocol); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("sessionHandle", ::apache::thrift::protocol::T_STRUCT, 2); + xfer += this->sessionHandle.write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(TBindSessionReq &a, TBindSessionReq &b) { + using ::std::swap; + swap(a.client_protocol, b.client_protocol); + swap(a.sessionHandle, b.sessionHandle); +} + +TBindSessionReq::TBindSessionReq(const TBindSessionReq& other303) { + client_protocol = other303.client_protocol; + sessionHandle = other303.sessionHandle; +} +TBindSessionReq& TBindSessionReq::operator=(const TBindSessionReq& other304) { + client_protocol = other304.client_protocol; + sessionHandle = other304.sessionHandle; + return *this; +} +void TBindSessionReq::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "TBindSessionReq("; + out << "client_protocol=" << to_string(client_protocol); + out << ", " << "sessionHandle=" << to_string(sessionHandle); + out << ")"; +} + + +TBindSessionResp::~TBindSessionResp() throw() { +} + + +void TBindSessionResp::__set_status(const TStatus& val) { + this->status = val; +} + +void TBindSessionResp::__set_serverProtocolVersion(const TProtocolVersion::type val) { + this->serverProtocolVersion = val; +} + +uint32_t TBindSessionResp::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; + + bool isset_status = false; + bool isset_serverProtocolVersion = false; + + 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->status.read(iprot); + isset_status = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_I32) { + int32_t ecast305; + xfer += iprot->readI32(ecast305); + this->serverProtocolVersion = (TProtocolVersion::type)ecast305; + isset_serverProtocolVersion = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_status) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_serverProtocolVersion) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t TBindSessionResp::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("TBindSessionResp"); + + xfer += oprot->writeFieldBegin("status", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->status.write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("serverProtocolVersion", ::apache::thrift::protocol::T_I32, 2); + xfer += oprot->writeI32((int32_t)this->serverProtocolVersion); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(TBindSessionResp &a, TBindSessionResp &b) { + using ::std::swap; + swap(a.status, b.status); + swap(a.serverProtocolVersion, b.serverProtocolVersion); +} + +TBindSessionResp::TBindSessionResp(const TBindSessionResp& other306) { + status = other306.status; + serverProtocolVersion = other306.serverProtocolVersion; +} +TBindSessionResp& TBindSessionResp::operator=(const TBindSessionResp& other307) { + status = other307.status; + serverProtocolVersion = other307.serverProtocolVersion; + return *this; +} +void TBindSessionResp::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "TBindSessionResp("; + out << "status=" << to_string(status); + out << ", " << "serverProtocolVersion=" << to_string(serverProtocolVersion); + out << ")"; +} + }}}}} // namespace diff --git a/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.h b/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.h index fa02090..ac48889 100644 --- a/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.h +++ b/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.h @@ -339,6 +339,10 @@ class TRenewDelegationTokenReq; class TRenewDelegationTokenResp; +class TBindSessionReq; + +class TBindSessionResp; + typedef struct _TTypeQualifierValue__isset { _TTypeQualifierValue__isset() : i32Value(false), stringValue(false) {} bool i32Value :1; @@ -4470,6 +4474,100 @@ inline std::ostream& operator<<(std::ostream& out, const TRenewDelegationTokenRe return out; } + +class TBindSessionReq { + public: + + TBindSessionReq(const TBindSessionReq&); + TBindSessionReq& operator=(const TBindSessionReq&); + TBindSessionReq() : client_protocol((TProtocolVersion::type)7) { + client_protocol = (TProtocolVersion::type)7; + + } + + virtual ~TBindSessionReq() throw(); + TProtocolVersion::type client_protocol; + TSessionHandle sessionHandle; + + void __set_client_protocol(const TProtocolVersion::type val); + + void __set_sessionHandle(const TSessionHandle& val); + + bool operator == (const TBindSessionReq & rhs) const + { + if (!(client_protocol == rhs.client_protocol)) + return false; + if (!(sessionHandle == rhs.sessionHandle)) + return false; + return true; + } + bool operator != (const TBindSessionReq &rhs) const { + return !(*this == rhs); + } + + bool operator < (const TBindSessionReq & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(TBindSessionReq &a, TBindSessionReq &b); + +inline std::ostream& operator<<(std::ostream& out, const TBindSessionReq& obj) +{ + obj.printTo(out); + return out; +} + + +class TBindSessionResp { + public: + + TBindSessionResp(const TBindSessionResp&); + TBindSessionResp& operator=(const TBindSessionResp&); + TBindSessionResp() : serverProtocolVersion((TProtocolVersion::type)7) { + serverProtocolVersion = (TProtocolVersion::type)7; + + } + + virtual ~TBindSessionResp() throw(); + TStatus status; + TProtocolVersion::type serverProtocolVersion; + + void __set_status(const TStatus& val); + + void __set_serverProtocolVersion(const TProtocolVersion::type val); + + bool operator == (const TBindSessionResp & rhs) const + { + if (!(status == rhs.status)) + return false; + if (!(serverProtocolVersion == rhs.serverProtocolVersion)) + return false; + return true; + } + bool operator != (const TBindSessionResp &rhs) const { + return !(*this == rhs); + } + + bool operator < (const TBindSessionResp & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(TBindSessionResp &a, TBindSessionResp &b); + +inline std::ostream& operator<<(std::ostream& out, const TBindSessionResp& obj) +{ + obj.printTo(out); + return out; +} + }}}}} // namespace #endif diff --git a/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TBindSessionReq.java b/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TBindSessionReq.java new file mode 100644 index 0000000..bc77d6e --- /dev/null +++ b/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TBindSessionReq.java @@ -0,0 +1,510 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.hive.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") +public class TBindSessionReq implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TBindSessionReq"); + + private static final org.apache.thrift.protocol.TField CLIENT_PROTOCOL_FIELD_DESC = new org.apache.thrift.protocol.TField("client_protocol", org.apache.thrift.protocol.TType.I32, (short)1); + private static final org.apache.thrift.protocol.TField SESSION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionHandle", org.apache.thrift.protocol.TType.STRUCT, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TBindSessionReqStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TBindSessionReqTupleSchemeFactory()); + } + + private TProtocolVersion client_protocol; // required + private TSessionHandle sessionHandle; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + /** + * + * @see TProtocolVersion + */ + CLIENT_PROTOCOL((short)1, "client_protocol"), + SESSION_HANDLE((short)2, "sessionHandle"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CLIENT_PROTOCOL + return CLIENT_PROTOCOL; + case 2: // SESSION_HANDLE + return SESSION_HANDLE; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CLIENT_PROTOCOL, new org.apache.thrift.meta_data.FieldMetaData("client_protocol", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TProtocolVersion.class))); + tmpMap.put(_Fields.SESSION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("sessionHandle", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSessionHandle.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TBindSessionReq.class, metaDataMap); + } + + public TBindSessionReq() { + this.client_protocol = org.apache.hive.service.rpc.thrift.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8; + + } + + public TBindSessionReq( + TProtocolVersion client_protocol, + TSessionHandle sessionHandle) + { + this(); + this.client_protocol = client_protocol; + this.sessionHandle = sessionHandle; + } + + /** + * Performs a deep copy on other. + */ + public TBindSessionReq(TBindSessionReq other) { + if (other.isSetClient_protocol()) { + this.client_protocol = other.client_protocol; + } + if (other.isSetSessionHandle()) { + this.sessionHandle = new TSessionHandle(other.sessionHandle); + } + } + + public TBindSessionReq deepCopy() { + return new TBindSessionReq(this); + } + + @Override + public void clear() { + this.client_protocol = org.apache.hive.service.rpc.thrift.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8; + + this.sessionHandle = null; + } + + /** + * + * @see TProtocolVersion + */ + public TProtocolVersion getClient_protocol() { + return this.client_protocol; + } + + /** + * + * @see TProtocolVersion + */ + public void setClient_protocol(TProtocolVersion client_protocol) { + this.client_protocol = client_protocol; + } + + public void unsetClient_protocol() { + this.client_protocol = null; + } + + /** Returns true if field client_protocol is set (has been assigned a value) and false otherwise */ + public boolean isSetClient_protocol() { + return this.client_protocol != null; + } + + public void setClient_protocolIsSet(boolean value) { + if (!value) { + this.client_protocol = null; + } + } + + public TSessionHandle getSessionHandle() { + return this.sessionHandle; + } + + public void setSessionHandle(TSessionHandle sessionHandle) { + this.sessionHandle = sessionHandle; + } + + public void unsetSessionHandle() { + this.sessionHandle = null; + } + + /** Returns true if field sessionHandle is set (has been assigned a value) and false otherwise */ + public boolean isSetSessionHandle() { + return this.sessionHandle != null; + } + + public void setSessionHandleIsSet(boolean value) { + if (!value) { + this.sessionHandle = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CLIENT_PROTOCOL: + if (value == null) { + unsetClient_protocol(); + } else { + setClient_protocol((TProtocolVersion)value); + } + break; + + case SESSION_HANDLE: + if (value == null) { + unsetSessionHandle(); + } else { + setSessionHandle((TSessionHandle)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CLIENT_PROTOCOL: + return getClient_protocol(); + + case SESSION_HANDLE: + return getSessionHandle(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CLIENT_PROTOCOL: + return isSetClient_protocol(); + case SESSION_HANDLE: + return isSetSessionHandle(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TBindSessionReq) + return this.equals((TBindSessionReq)that); + return false; + } + + public boolean equals(TBindSessionReq that) { + if (that == null) + return false; + + boolean this_present_client_protocol = true && this.isSetClient_protocol(); + boolean that_present_client_protocol = true && that.isSetClient_protocol(); + if (this_present_client_protocol || that_present_client_protocol) { + if (!(this_present_client_protocol && that_present_client_protocol)) + return false; + if (!this.client_protocol.equals(that.client_protocol)) + return false; + } + + boolean this_present_sessionHandle = true && this.isSetSessionHandle(); + boolean that_present_sessionHandle = true && that.isSetSessionHandle(); + if (this_present_sessionHandle || that_present_sessionHandle) { + if (!(this_present_sessionHandle && that_present_sessionHandle)) + return false; + if (!this.sessionHandle.equals(that.sessionHandle)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_client_protocol = true && (isSetClient_protocol()); + list.add(present_client_protocol); + if (present_client_protocol) + list.add(client_protocol.getValue()); + + boolean present_sessionHandle = true && (isSetSessionHandle()); + list.add(present_sessionHandle); + if (present_sessionHandle) + list.add(sessionHandle); + + return list.hashCode(); + } + + @Override + public int compareTo(TBindSessionReq other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetClient_protocol()).compareTo(other.isSetClient_protocol()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetClient_protocol()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.client_protocol, other.client_protocol); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSessionHandle()).compareTo(other.isSetSessionHandle()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSessionHandle()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sessionHandle, other.sessionHandle); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TBindSessionReq("); + boolean first = true; + + sb.append("client_protocol:"); + if (this.client_protocol == null) { + sb.append("null"); + } else { + sb.append(this.client_protocol); + } + first = false; + if (!first) sb.append(", "); + sb.append("sessionHandle:"); + if (this.sessionHandle == null) { + sb.append("null"); + } else { + sb.append(this.sessionHandle); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (!isSetClient_protocol()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'client_protocol' is unset! Struct:" + toString()); + } + + if (!isSetSessionHandle()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'sessionHandle' is unset! Struct:" + toString()); + } + + // check for sub-struct validity + if (sessionHandle != null) { + sessionHandle.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TBindSessionReqStandardSchemeFactory implements SchemeFactory { + public TBindSessionReqStandardScheme getScheme() { + return new TBindSessionReqStandardScheme(); + } + } + + private static class TBindSessionReqStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TBindSessionReq struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CLIENT_PROTOCOL + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.client_protocol = org.apache.hive.service.rpc.thrift.TProtocolVersion.findByValue(iprot.readI32()); + struct.setClient_protocolIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // SESSION_HANDLE + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.sessionHandle = new TSessionHandle(); + struct.sessionHandle.read(iprot); + struct.setSessionHandleIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TBindSessionReq struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.client_protocol != null) { + oprot.writeFieldBegin(CLIENT_PROTOCOL_FIELD_DESC); + oprot.writeI32(struct.client_protocol.getValue()); + oprot.writeFieldEnd(); + } + if (struct.sessionHandle != null) { + oprot.writeFieldBegin(SESSION_HANDLE_FIELD_DESC); + struct.sessionHandle.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TBindSessionReqTupleSchemeFactory implements SchemeFactory { + public TBindSessionReqTupleScheme getScheme() { + return new TBindSessionReqTupleScheme(); + } + } + + private static class TBindSessionReqTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TBindSessionReq struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeI32(struct.client_protocol.getValue()); + struct.sessionHandle.write(oprot); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TBindSessionReq struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.client_protocol = org.apache.hive.service.rpc.thrift.TProtocolVersion.findByValue(iprot.readI32()); + struct.setClient_protocolIsSet(true); + struct.sessionHandle = new TSessionHandle(); + struct.sessionHandle.read(iprot); + struct.setSessionHandleIsSet(true); + } + } + +} + diff --git a/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TBindSessionResp.java b/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TBindSessionResp.java new file mode 100644 index 0000000..1e40a14 --- /dev/null +++ b/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TBindSessionResp.java @@ -0,0 +1,510 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.hive.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") +public class TBindSessionResp implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TBindSessionResp"); + + private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField SERVER_PROTOCOL_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("serverProtocolVersion", org.apache.thrift.protocol.TType.I32, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TBindSessionRespStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TBindSessionRespTupleSchemeFactory()); + } + + private TStatus status; // required + private TProtocolVersion serverProtocolVersion; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STATUS((short)1, "status"), + /** + * + * @see TProtocolVersion + */ + SERVER_PROTOCOL_VERSION((short)2, "serverProtocolVersion"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATUS + return STATUS; + case 2: // SERVER_PROTOCOL_VERSION + return SERVER_PROTOCOL_VERSION; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TStatus.class))); + tmpMap.put(_Fields.SERVER_PROTOCOL_VERSION, new org.apache.thrift.meta_data.FieldMetaData("serverProtocolVersion", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TProtocolVersion.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TBindSessionResp.class, metaDataMap); + } + + public TBindSessionResp() { + this.serverProtocolVersion = org.apache.hive.service.rpc.thrift.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8; + + } + + public TBindSessionResp( + TStatus status, + TProtocolVersion serverProtocolVersion) + { + this(); + this.status = status; + this.serverProtocolVersion = serverProtocolVersion; + } + + /** + * Performs a deep copy on other. + */ + public TBindSessionResp(TBindSessionResp other) { + if (other.isSetStatus()) { + this.status = new TStatus(other.status); + } + if (other.isSetServerProtocolVersion()) { + this.serverProtocolVersion = other.serverProtocolVersion; + } + } + + public TBindSessionResp deepCopy() { + return new TBindSessionResp(this); + } + + @Override + public void clear() { + this.status = null; + this.serverProtocolVersion = org.apache.hive.service.rpc.thrift.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8; + + } + + public TStatus getStatus() { + return this.status; + } + + public void setStatus(TStatus status) { + this.status = status; + } + + public void unsetStatus() { + this.status = null; + } + + /** Returns true if field status is set (has been assigned a value) and false otherwise */ + public boolean isSetStatus() { + return this.status != null; + } + + public void setStatusIsSet(boolean value) { + if (!value) { + this.status = null; + } + } + + /** + * + * @see TProtocolVersion + */ + public TProtocolVersion getServerProtocolVersion() { + return this.serverProtocolVersion; + } + + /** + * + * @see TProtocolVersion + */ + public void setServerProtocolVersion(TProtocolVersion serverProtocolVersion) { + this.serverProtocolVersion = serverProtocolVersion; + } + + public void unsetServerProtocolVersion() { + this.serverProtocolVersion = null; + } + + /** Returns true if field serverProtocolVersion is set (has been assigned a value) and false otherwise */ + public boolean isSetServerProtocolVersion() { + return this.serverProtocolVersion != null; + } + + public void setServerProtocolVersionIsSet(boolean value) { + if (!value) { + this.serverProtocolVersion = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATUS: + if (value == null) { + unsetStatus(); + } else { + setStatus((TStatus)value); + } + break; + + case SERVER_PROTOCOL_VERSION: + if (value == null) { + unsetServerProtocolVersion(); + } else { + setServerProtocolVersion((TProtocolVersion)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATUS: + return getStatus(); + + case SERVER_PROTOCOL_VERSION: + return getServerProtocolVersion(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case STATUS: + return isSetStatus(); + case SERVER_PROTOCOL_VERSION: + return isSetServerProtocolVersion(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TBindSessionResp) + return this.equals((TBindSessionResp)that); + return false; + } + + public boolean equals(TBindSessionResp that) { + if (that == null) + return false; + + boolean this_present_status = true && this.isSetStatus(); + boolean that_present_status = true && that.isSetStatus(); + if (this_present_status || that_present_status) { + if (!(this_present_status && that_present_status)) + return false; + if (!this.status.equals(that.status)) + return false; + } + + boolean this_present_serverProtocolVersion = true && this.isSetServerProtocolVersion(); + boolean that_present_serverProtocolVersion = true && that.isSetServerProtocolVersion(); + if (this_present_serverProtocolVersion || that_present_serverProtocolVersion) { + if (!(this_present_serverProtocolVersion && that_present_serverProtocolVersion)) + return false; + if (!this.serverProtocolVersion.equals(that.serverProtocolVersion)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_status = true && (isSetStatus()); + list.add(present_status); + if (present_status) + list.add(status); + + boolean present_serverProtocolVersion = true && (isSetServerProtocolVersion()); + list.add(present_serverProtocolVersion); + if (present_serverProtocolVersion) + list.add(serverProtocolVersion.getValue()); + + return list.hashCode(); + } + + @Override + public int compareTo(TBindSessionResp other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatus()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetServerProtocolVersion()).compareTo(other.isSetServerProtocolVersion()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetServerProtocolVersion()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serverProtocolVersion, other.serverProtocolVersion); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TBindSessionResp("); + boolean first = true; + + sb.append("status:"); + if (this.status == null) { + sb.append("null"); + } else { + sb.append(this.status); + } + first = false; + if (!first) sb.append(", "); + sb.append("serverProtocolVersion:"); + if (this.serverProtocolVersion == null) { + sb.append("null"); + } else { + sb.append(this.serverProtocolVersion); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (!isSetStatus()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' is unset! Struct:" + toString()); + } + + if (!isSetServerProtocolVersion()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'serverProtocolVersion' is unset! Struct:" + toString()); + } + + // check for sub-struct validity + if (status != null) { + status.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TBindSessionRespStandardSchemeFactory implements SchemeFactory { + public TBindSessionRespStandardScheme getScheme() { + return new TBindSessionRespStandardScheme(); + } + } + + private static class TBindSessionRespStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TBindSessionResp struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATUS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.status = new TStatus(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // SERVER_PROTOCOL_VERSION + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.serverProtocolVersion = org.apache.hive.service.rpc.thrift.TProtocolVersion.findByValue(iprot.readI32()); + struct.setServerProtocolVersionIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TBindSessionResp struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.status != null) { + oprot.writeFieldBegin(STATUS_FIELD_DESC); + struct.status.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.serverProtocolVersion != null) { + oprot.writeFieldBegin(SERVER_PROTOCOL_VERSION_FIELD_DESC); + oprot.writeI32(struct.serverProtocolVersion.getValue()); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TBindSessionRespTupleSchemeFactory implements SchemeFactory { + public TBindSessionRespTupleScheme getScheme() { + return new TBindSessionRespTupleScheme(); + } + } + + private static class TBindSessionRespTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TBindSessionResp struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.status.write(oprot); + oprot.writeI32(struct.serverProtocolVersion.getValue()); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TBindSessionResp struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.status = new TStatus(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + struct.serverProtocolVersion = org.apache.hive.service.rpc.thrift.TProtocolVersion.findByValue(iprot.readI32()); + struct.setServerProtocolVersionIsSet(true); + } + } + +} + diff --git a/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TCLIService.java b/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TCLIService.java index 6dba051..ea6ff40 100644 --- a/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TCLIService.java +++ b/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TCLIService.java @@ -41,6 +41,8 @@ public TOpenSessionResp OpenSession(TOpenSessionReq req) throws org.apache.thrift.TException; + public TBindSessionResp BindSession(TBindSessionReq req) throws org.apache.thrift.TException; + public TCloseSessionResp CloseSession(TCloseSessionReq req) throws org.apache.thrift.TException; public TGetInfoResp GetInfo(TGetInfoReq req) throws org.apache.thrift.TException; @@ -87,6 +89,8 @@ public void OpenSession(TOpenSessionReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void BindSession(TBindSessionReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void CloseSession(TCloseSessionReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void GetInfo(TGetInfoReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; @@ -172,6 +176,29 @@ public TOpenSessionResp recv_OpenSession() throws org.apache.thrift.TException throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "OpenSession failed: unknown result"); } + public TBindSessionResp BindSession(TBindSessionReq req) throws org.apache.thrift.TException + { + send_BindSession(req); + return recv_BindSession(); + } + + public void send_BindSession(TBindSessionReq req) throws org.apache.thrift.TException + { + BindSession_args args = new BindSession_args(); + args.setReq(req); + sendBase("BindSession", args); + } + + public TBindSessionResp recv_BindSession() throws org.apache.thrift.TException + { + BindSession_result result = new BindSession_result(); + receiveBase(result, "BindSession"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "BindSession failed: unknown result"); + } + public TCloseSessionResp CloseSession(TCloseSessionReq req) throws org.apache.thrift.TException { send_CloseSession(req); @@ -682,6 +709,38 @@ public TOpenSessionResp getResult() throws org.apache.thrift.TException { } } + public void BindSession(TBindSessionReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + BindSession_call method_call = new BindSession_call(req, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class BindSession_call extends org.apache.thrift.async.TAsyncMethodCall { + private TBindSessionReq req; + public BindSession_call(TBindSessionReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.req = req; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("BindSession", org.apache.thrift.protocol.TMessageType.CALL, 0)); + BindSession_args args = new BindSession_args(); + args.setReq(req); + args.write(prot); + prot.writeMessageEnd(); + } + + public TBindSessionResp getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_BindSession(); + } + } + public void CloseSession(TCloseSessionReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); CloseSession_call method_call = new CloseSession_call(req, resultHandler, this, ___protocolFactory, ___transport); @@ -1336,6 +1395,7 @@ protected Processor(I iface, Map Map> getProcessMap(Map> processMap) { processMap.put("OpenSession", new OpenSession()); + processMap.put("BindSession", new BindSession()); processMap.put("CloseSession", new CloseSession()); processMap.put("GetInfo", new GetInfo()); processMap.put("ExecuteStatement", new ExecuteStatement()); @@ -1379,6 +1439,26 @@ public OpenSession_result getResult(I iface, OpenSession_args args) throws org.a } } + public static class BindSession extends org.apache.thrift.ProcessFunction { + public BindSession() { + super("BindSession"); + } + + public BindSession_args getEmptyArgsInstance() { + return new BindSession_args(); + } + + protected boolean isOneway() { + return false; + } + + public BindSession_result getResult(I iface, BindSession_args args) throws org.apache.thrift.TException { + BindSession_result result = new BindSession_result(); + result.success = iface.BindSession(args.req); + return result; + } + } + public static class CloseSession extends org.apache.thrift.ProcessFunction { public CloseSession() { super("CloseSession"); @@ -1793,6 +1873,7 @@ protected AsyncProcessor(I iface, Map Map> getProcessMap(Map> processMap) { processMap.put("OpenSession", new OpenSession()); + processMap.put("BindSession", new BindSession()); processMap.put("CloseSession", new CloseSession()); processMap.put("GetInfo", new GetInfo()); processMap.put("ExecuteStatement", new ExecuteStatement()); @@ -1867,6 +1948,57 @@ public void start(I iface, OpenSession_args args, org.apache.thrift.async.AsyncM } } + public static class BindSession extends org.apache.thrift.AsyncProcessFunction { + public BindSession() { + super("BindSession"); + } + + public BindSession_args getEmptyArgsInstance() { + return new BindSession_args(); + } + + public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback() { + public void onComplete(TBindSessionResp o) { + BindSession_result result = new BindSession_result(); + result.success = o; + try { + fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + return; + } catch (Exception e) { + LOGGER.error("Exception writing to internal frame buffer", e); + } + fb.close(); + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TBase msg; + BindSession_result result = new BindSession_result(); + { + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + return; + } catch (Exception ex) { + LOGGER.error("Exception writing to internal frame buffer", ex); + } + fb.close(); + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, BindSession_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { + iface.BindSession(args.req,resultHandler); + } + } + public static class CloseSession extends org.apache.thrift.AsyncProcessFunction { public CloseSession() { super("CloseSession"); @@ -3615,6 +3747,732 @@ public void read(org.apache.thrift.protocol.TProtocol prot, OpenSession_result s } + public static class BindSession_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("BindSession_args"); + + private static final org.apache.thrift.protocol.TField REQ_FIELD_DESC = new org.apache.thrift.protocol.TField("req", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new BindSession_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new BindSession_argsTupleSchemeFactory()); + } + + private TBindSessionReq req; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + REQ((short)1, "req"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // REQ + return REQ; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.REQ, new org.apache.thrift.meta_data.FieldMetaData("req", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TBindSessionReq.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(BindSession_args.class, metaDataMap); + } + + public BindSession_args() { + } + + public BindSession_args( + TBindSessionReq req) + { + this(); + this.req = req; + } + + /** + * Performs a deep copy on other. + */ + public BindSession_args(BindSession_args other) { + if (other.isSetReq()) { + this.req = new TBindSessionReq(other.req); + } + } + + public BindSession_args deepCopy() { + return new BindSession_args(this); + } + + @Override + public void clear() { + this.req = null; + } + + public TBindSessionReq getReq() { + return this.req; + } + + public void setReq(TBindSessionReq req) { + this.req = req; + } + + public void unsetReq() { + this.req = null; + } + + /** Returns true if field req is set (has been assigned a value) and false otherwise */ + public boolean isSetReq() { + return this.req != null; + } + + public void setReqIsSet(boolean value) { + if (!value) { + this.req = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case REQ: + if (value == null) { + unsetReq(); + } else { + setReq((TBindSessionReq)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case REQ: + return getReq(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case REQ: + return isSetReq(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof BindSession_args) + return this.equals((BindSession_args)that); + return false; + } + + public boolean equals(BindSession_args that) { + if (that == null) + return false; + + boolean this_present_req = true && this.isSetReq(); + boolean that_present_req = true && that.isSetReq(); + if (this_present_req || that_present_req) { + if (!(this_present_req && that_present_req)) + return false; + if (!this.req.equals(that.req)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_req = true && (isSetReq()); + list.add(present_req); + if (present_req) + list.add(req); + + return list.hashCode(); + } + + @Override + public int compareTo(BindSession_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetReq()).compareTo(other.isSetReq()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetReq()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.req, other.req); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("BindSession_args("); + boolean first = true; + + sb.append("req:"); + if (this.req == null) { + sb.append("null"); + } else { + sb.append(this.req); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (req != null) { + req.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class BindSession_argsStandardSchemeFactory implements SchemeFactory { + public BindSession_argsStandardScheme getScheme() { + return new BindSession_argsStandardScheme(); + } + } + + private static class BindSession_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, BindSession_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // REQ + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.req = new TBindSessionReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, BindSession_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.req != null) { + oprot.writeFieldBegin(REQ_FIELD_DESC); + struct.req.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class BindSession_argsTupleSchemeFactory implements SchemeFactory { + public BindSession_argsTupleScheme getScheme() { + return new BindSession_argsTupleScheme(); + } + } + + private static class BindSession_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, BindSession_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetReq()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetReq()) { + struct.req.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, BindSession_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.req = new TBindSessionReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } + } + } + + } + + public static class BindSession_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("BindSession_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new BindSession_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new BindSession_resultTupleSchemeFactory()); + } + + private TBindSessionResp success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TBindSessionResp.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(BindSession_result.class, metaDataMap); + } + + public BindSession_result() { + } + + public BindSession_result( + TBindSessionResp success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public BindSession_result(BindSession_result other) { + if (other.isSetSuccess()) { + this.success = new TBindSessionResp(other.success); + } + } + + public BindSession_result deepCopy() { + return new BindSession_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public TBindSessionResp getSuccess() { + return this.success; + } + + public void setSuccess(TBindSessionResp success) { + this.success = success; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TBindSessionResp)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof BindSession_result) + return this.equals((BindSession_result)that); + return false; + } + + public boolean equals(BindSession_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_success = true && (isSetSuccess()); + list.add(present_success); + if (present_success) + list.add(success); + + return list.hashCode(); + } + + @Override + public int compareTo(BindSession_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("BindSession_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (success != null) { + success.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class BindSession_resultStandardSchemeFactory implements SchemeFactory { + public BindSession_resultStandardScheme getScheme() { + return new BindSession_resultStandardScheme(); + } + } + + private static class BindSession_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, BindSession_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new TBindSessionResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, BindSession_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class BindSession_resultTupleSchemeFactory implements SchemeFactory { + public BindSession_resultTupleScheme getScheme() { + return new BindSession_resultTupleScheme(); + } + } + + private static class BindSession_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, BindSession_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, BindSession_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new TBindSessionResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + public static class CloseSession_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CloseSession_args"); diff --git a/service-rpc/src/gen/thrift/gen-php/TCLIService.php b/service-rpc/src/gen/thrift/gen-php/TCLIService.php index d283145..96c584b 100644 --- a/service-rpc/src/gen/thrift/gen-php/TCLIService.php +++ b/service-rpc/src/gen/thrift/gen-php/TCLIService.php @@ -22,6 +22,11 @@ interface TCLIServiceIf { */ public function OpenSession(\TOpenSessionReq $req); /** + * @param \TBindSessionReq $req + * @return \TBindSessionResp + */ + public function BindSession(\TBindSessionReq $req); + /** * @param \TCloseSessionReq $req * @return \TCloseSessionResp */ @@ -185,6 +190,57 @@ class TCLIServiceClient implements \TCLIServiceIf { throw new \Exception("OpenSession failed: unknown result"); } + public function BindSession(\TBindSessionReq $req) + { + $this->send_BindSession($req); + return $this->recv_BindSession(); + } + + public function send_BindSession(\TBindSessionReq $req) + { + $args = new \TCLIService_BindSession_args(); + $args->req = $req; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'BindSession', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('BindSession', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_BindSession() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\TCLIService_BindSession_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \TCLIService_BindSession_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + throw new \Exception("BindSession failed: unknown result"); + } + public function CloseSession(\TCloseSessionReq $req) { $this->send_CloseSession($req); @@ -1369,6 +1425,166 @@ class TCLIService_OpenSession_result { } +class TCLIService_BindSession_args { + static $_TSPEC; + + /** + * @var \TBindSessionReq + */ + public $req = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'req', + 'type' => TType::STRUCT, + 'class' => '\TBindSessionReq', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['req'])) { + $this->req = $vals['req']; + } + } + } + + public function getName() { + return 'TCLIService_BindSession_args'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRUCT) { + $this->req = new \TBindSessionReq(); + $xfer += $this->req->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('TCLIService_BindSession_args'); + if ($this->req !== null) { + if (!is_object($this->req)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('req', TType::STRUCT, 1); + $xfer += $this->req->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class TCLIService_BindSession_result { + static $_TSPEC; + + /** + * @var \TBindSessionResp + */ + public $success = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 0 => array( + 'var' => 'success', + 'type' => TType::STRUCT, + 'class' => '\TBindSessionResp', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['success'])) { + $this->success = $vals['success']; + } + } + } + + public function getName() { + return 'TCLIService_BindSession_result'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 0: + if ($ftype == TType::STRUCT) { + $this->success = new \TBindSessionResp(); + $xfer += $this->success->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('TCLIService_BindSession_result'); + if ($this->success !== null) { + if (!is_object($this->success)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('success', TType::STRUCT, 0); + $xfer += $this->success->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + class TCLIService_CloseSession_args { static $_TSPEC; diff --git a/service-rpc/src/gen/thrift/gen-php/Types.php b/service-rpc/src/gen/thrift/gen-php/Types.php index 9dcfd67..af78b8f 100644 --- a/service-rpc/src/gen/thrift/gen-php/Types.php +++ b/service-rpc/src/gen/thrift/gen-php/Types.php @@ -9696,6 +9696,212 @@ class TRenewDelegationTokenResp { } +class TBindSessionReq { + static $_TSPEC; + + /** + * @var int + */ + public $client_protocol = 7; + /** + * @var \TSessionHandle + */ + public $sessionHandle = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'client_protocol', + 'type' => TType::I32, + ), + 2 => array( + 'var' => 'sessionHandle', + 'type' => TType::STRUCT, + 'class' => '\TSessionHandle', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['client_protocol'])) { + $this->client_protocol = $vals['client_protocol']; + } + if (isset($vals['sessionHandle'])) { + $this->sessionHandle = $vals['sessionHandle']; + } + } + } + + public function getName() { + return 'TBindSessionReq'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->client_protocol); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRUCT) { + $this->sessionHandle = new \TSessionHandle(); + $xfer += $this->sessionHandle->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('TBindSessionReq'); + if ($this->client_protocol !== null) { + $xfer += $output->writeFieldBegin('client_protocol', TType::I32, 1); + $xfer += $output->writeI32($this->client_protocol); + $xfer += $output->writeFieldEnd(); + } + if ($this->sessionHandle !== null) { + if (!is_object($this->sessionHandle)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('sessionHandle', TType::STRUCT, 2); + $xfer += $this->sessionHandle->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class TBindSessionResp { + static $_TSPEC; + + /** + * @var \TStatus + */ + public $status = null; + /** + * @var int + */ + public $serverProtocolVersion = 7; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'status', + 'type' => TType::STRUCT, + 'class' => '\TStatus', + ), + 2 => array( + 'var' => 'serverProtocolVersion', + 'type' => TType::I32, + ), + ); + } + if (is_array($vals)) { + if (isset($vals['status'])) { + $this->status = $vals['status']; + } + if (isset($vals['serverProtocolVersion'])) { + $this->serverProtocolVersion = $vals['serverProtocolVersion']; + } + } + } + + public function getName() { + return 'TBindSessionResp'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRUCT) { + $this->status = new \TStatus(); + $xfer += $this->status->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->serverProtocolVersion); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('TBindSessionResp'); + if ($this->status !== null) { + if (!is_object($this->status)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('status', TType::STRUCT, 1); + $xfer += $this->status->write($output); + $xfer += $output->writeFieldEnd(); + } + if ($this->serverProtocolVersion !== null) { + $xfer += $output->writeFieldBegin('serverProtocolVersion', TType::I32, 2); + $xfer += $output->writeI32($this->serverProtocolVersion); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + final class Constant extends \Thrift\Type\TConstant { static protected $PRIMITIVE_TYPES; static protected $COMPLEX_TYPES; diff --git a/service-rpc/src/gen/thrift/gen-py/TCLIService/TCLIService-remote b/service-rpc/src/gen/thrift/gen-py/TCLIService/TCLIService-remote index 62b87a3..7bd8884 100755 --- a/service-rpc/src/gen/thrift/gen-py/TCLIService/TCLIService-remote +++ b/service-rpc/src/gen/thrift/gen-py/TCLIService/TCLIService-remote @@ -25,6 +25,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help': print('') print('Functions:') print(' TOpenSessionResp OpenSession(TOpenSessionReq req)') + print(' TBindSessionResp BindSession(TBindSessionReq req)') print(' TCloseSessionResp CloseSession(TCloseSessionReq req)') print(' TGetInfoResp GetInfo(TGetInfoReq req)') print(' TExecuteStatementResp ExecuteStatement(TExecuteStatementReq req)') @@ -107,6 +108,12 @@ if cmd == 'OpenSession': sys.exit(1) pp.pprint(client.OpenSession(eval(args[0]),)) +elif cmd == 'BindSession': + if len(args) != 1: + print('BindSession requires 1 args') + sys.exit(1) + pp.pprint(client.BindSession(eval(args[0]),)) + elif cmd == 'CloseSession': if len(args) != 1: print('CloseSession requires 1 args') diff --git a/service-rpc/src/gen/thrift/gen-py/TCLIService/TCLIService.py b/service-rpc/src/gen/thrift/gen-py/TCLIService/TCLIService.py index 35f2ae4..a1e08dd 100644 --- a/service-rpc/src/gen/thrift/gen-py/TCLIService/TCLIService.py +++ b/service-rpc/src/gen/thrift/gen-py/TCLIService/TCLIService.py @@ -26,6 +26,13 @@ def OpenSession(self, req): """ pass + def BindSession(self, req): + """ + Parameters: + - req + """ + pass + def CloseSession(self, req): """ Parameters: @@ -205,6 +212,37 @@ def recv_OpenSession(self): return result.success raise TApplicationException(TApplicationException.MISSING_RESULT, "OpenSession failed: unknown result") + def BindSession(self, req): + """ + Parameters: + - req + """ + self.send_BindSession(req) + return self.recv_BindSession() + + def send_BindSession(self, req): + self._oprot.writeMessageBegin('BindSession', TMessageType.CALL, self._seqid) + args = BindSession_args() + args.req = req + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_BindSession(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = BindSession_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "BindSession failed: unknown result") + def CloseSession(self, req): """ Parameters: @@ -831,6 +869,7 @@ def __init__(self, handler): self._handler = handler self._processMap = {} self._processMap["OpenSession"] = Processor.process_OpenSession + self._processMap["BindSession"] = Processor.process_BindSession self._processMap["CloseSession"] = Processor.process_CloseSession self._processMap["GetInfo"] = Processor.process_GetInfo self._processMap["ExecuteStatement"] = Processor.process_ExecuteStatement @@ -886,6 +925,25 @@ def process_OpenSession(self, seqid, iprot, oprot): oprot.writeMessageEnd() oprot.trans.flush() + def process_BindSession(self, seqid, iprot, oprot): + args = BindSession_args() + args.read(iprot) + iprot.readMessageEnd() + result = BindSession_result() + try: + result.success = self._handler.BindSession(args.req) + msg_type = TMessageType.REPLY + except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): + raise + except Exception as ex: + msg_type = TMessageType.EXCEPTION + logging.exception(ex) + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("BindSession", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + def process_CloseSession(self, seqid, iprot, oprot): args = CloseSession_args() args.read(iprot) @@ -1400,6 +1458,137 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +class BindSession_args: + """ + Attributes: + - req + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'req', (TBindSessionReq, TBindSessionReq.thrift_spec), None, ), # 1 + ) + + def __init__(self, req=None,): + self.req = req + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.req = TBindSessionReq() + self.req.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('BindSession_args') + if self.req is not None: + oprot.writeFieldBegin('req', TType.STRUCT, 1) + self.req.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __hash__(self): + value = 17 + value = (value * 31) ^ hash(self.req) + return value + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class BindSession_result: + """ + Attributes: + - success + """ + + thrift_spec = ( + (0, TType.STRUCT, 'success', (TBindSessionResp, TBindSessionResp.thrift_spec), None, ), # 0 + ) + + def __init__(self, success=None,): + self.success = success + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRUCT: + self.success = TBindSessionResp() + self.success.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('BindSession_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __hash__(self): + value = 17 + value = (value * 31) ^ hash(self.success) + return value + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class CloseSession_args: """ Attributes: diff --git a/service-rpc/src/gen/thrift/gen-py/TCLIService/ttypes.py b/service-rpc/src/gen/thrift/gen-py/TCLIService/ttypes.py index ebb7e5f..dab4a3b 100644 --- a/service-rpc/src/gen/thrift/gen-py/TCLIService/ttypes.py +++ b/service-rpc/src/gen/thrift/gen-py/TCLIService/ttypes.py @@ -7369,3 +7369,169 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) + +class TBindSessionReq: + """ + Attributes: + - client_protocol + - sessionHandle + """ + + thrift_spec = ( + None, # 0 + (1, TType.I32, 'client_protocol', None, 7, ), # 1 + (2, TType.STRUCT, 'sessionHandle', (TSessionHandle, TSessionHandle.thrift_spec), None, ), # 2 + ) + + def __init__(self, client_protocol=thrift_spec[1][4], sessionHandle=None,): + self.client_protocol = client_protocol + self.sessionHandle = sessionHandle + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.client_protocol = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.sessionHandle = TSessionHandle() + self.sessionHandle.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('TBindSessionReq') + if self.client_protocol is not None: + oprot.writeFieldBegin('client_protocol', TType.I32, 1) + oprot.writeI32(self.client_protocol) + oprot.writeFieldEnd() + if self.sessionHandle is not None: + oprot.writeFieldBegin('sessionHandle', TType.STRUCT, 2) + self.sessionHandle.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.client_protocol is None: + raise TProtocol.TProtocolException(message='Required field client_protocol is unset!') + if self.sessionHandle is None: + raise TProtocol.TProtocolException(message='Required field sessionHandle is unset!') + return + + + def __hash__(self): + value = 17 + value = (value * 31) ^ hash(self.client_protocol) + value = (value * 31) ^ hash(self.sessionHandle) + return value + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class TBindSessionResp: + """ + Attributes: + - status + - serverProtocolVersion + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'status', (TStatus, TStatus.thrift_spec), None, ), # 1 + (2, TType.I32, 'serverProtocolVersion', None, 7, ), # 2 + ) + + def __init__(self, status=None, serverProtocolVersion=thrift_spec[2][4],): + self.status = status + self.serverProtocolVersion = serverProtocolVersion + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.status = TStatus() + self.status.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.I32: + self.serverProtocolVersion = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('TBindSessionResp') + if self.status is not None: + oprot.writeFieldBegin('status', TType.STRUCT, 1) + self.status.write(oprot) + oprot.writeFieldEnd() + if self.serverProtocolVersion is not None: + oprot.writeFieldBegin('serverProtocolVersion', TType.I32, 2) + oprot.writeI32(self.serverProtocolVersion) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.status is None: + raise TProtocol.TProtocolException(message='Required field status is unset!') + if self.serverProtocolVersion is None: + raise TProtocol.TProtocolException(message='Required field serverProtocolVersion is unset!') + return + + + def __hash__(self): + value = 17 + value = (value * 31) ^ hash(self.status) + value = (value * 31) ^ hash(self.serverProtocolVersion) + return value + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) diff --git a/service-rpc/src/gen/thrift/gen-rb/t_c_l_i_service.rb b/service-rpc/src/gen/thrift/gen-rb/t_c_l_i_service.rb index a50fe25..fb4d7af 100644 --- a/service-rpc/src/gen/thrift/gen-rb/t_c_l_i_service.rb +++ b/service-rpc/src/gen/thrift/gen-rb/t_c_l_i_service.rb @@ -26,6 +26,21 @@ module TCLIService raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'OpenSession failed: unknown result') end + def BindSession(req) + send_BindSession(req) + return recv_BindSession() + end + + def send_BindSession(req) + send_message('BindSession', BindSession_args, :req => req) + end + + def recv_BindSession() + result = receive_message(BindSession_result) + return result.success unless result.success.nil? + raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'BindSession failed: unknown result') + end + def CloseSession(req) send_CloseSession(req) return recv_CloseSession() @@ -338,6 +353,13 @@ module TCLIService write_result(result, oprot, 'OpenSession', seqid) end + def process_BindSession(seqid, iprot, oprot) + args = read_args(iprot, BindSession_args) + result = BindSession_result.new() + result.success = @handler.BindSession(args.req) + write_result(result, oprot, 'BindSession', seqid) + end + def process_CloseSession(seqid, iprot, oprot) args = read_args(iprot, CloseSession_args) result = CloseSession_result.new() @@ -514,6 +536,38 @@ module TCLIService ::Thrift::Struct.generate_accessors self end + class BindSession_args + include ::Thrift::Struct, ::Thrift::Struct_Union + REQ = 1 + + FIELDS = { + REQ => {:type => ::Thrift::Types::STRUCT, :name => 'req', :class => ::TBindSessionReq} + } + + def struct_fields; FIELDS; end + + def validate + end + + ::Thrift::Struct.generate_accessors self + end + + class BindSession_result + include ::Thrift::Struct, ::Thrift::Struct_Union + SUCCESS = 0 + + FIELDS = { + SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::TBindSessionResp} + } + + def struct_fields; FIELDS; end + + def validate + end + + ::Thrift::Struct.generate_accessors self + end + class CloseSession_args include ::Thrift::Struct, ::Thrift::Struct_Union REQ = 1 diff --git a/service-rpc/src/gen/thrift/gen-rb/t_c_l_i_service_types.rb b/service-rpc/src/gen/thrift/gen-rb/t_c_l_i_service_types.rb index 6269a2d..42f29d1 100644 --- a/service-rpc/src/gen/thrift/gen-rb/t_c_l_i_service_types.rb +++ b/service-rpc/src/gen/thrift/gen-rb/t_c_l_i_service_types.rb @@ -1867,3 +1867,49 @@ class TRenewDelegationTokenResp ::Thrift::Struct.generate_accessors self end +class TBindSessionReq + include ::Thrift::Struct, ::Thrift::Struct_Union + CLIENT_PROTOCOL = 1 + SESSIONHANDLE = 2 + + FIELDS = { + CLIENT_PROTOCOL => {:type => ::Thrift::Types::I32, :name => 'client_protocol', :default => 7, :enum_class => ::TProtocolVersion}, + SESSIONHANDLE => {:type => ::Thrift::Types::STRUCT, :name => 'sessionHandle', :class => ::TSessionHandle} + } + + def struct_fields; FIELDS; end + + def validate + raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field client_protocol is unset!') unless @client_protocol + raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field sessionHandle is unset!') unless @sessionHandle + unless @client_protocol.nil? || ::TProtocolVersion::VALID_VALUES.include?(@client_protocol) + raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field client_protocol!') + end + end + + ::Thrift::Struct.generate_accessors self +end + +class TBindSessionResp + include ::Thrift::Struct, ::Thrift::Struct_Union + STATUS = 1 + SERVERPROTOCOLVERSION = 2 + + FIELDS = { + STATUS => {:type => ::Thrift::Types::STRUCT, :name => 'status', :class => ::TStatus}, + SERVERPROTOCOLVERSION => {:type => ::Thrift::Types::I32, :name => 'serverProtocolVersion', :default => 7, :enum_class => ::TProtocolVersion} + } + + def struct_fields; FIELDS; end + + def validate + raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field status is unset!') unless @status + raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field serverProtocolVersion is unset!') unless @serverProtocolVersion + unless @serverProtocolVersion.nil? || ::TProtocolVersion::VALID_VALUES.include?(@serverProtocolVersion) + raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field serverProtocolVersion!') + end + end + + ::Thrift::Struct.generate_accessors self +end + diff --git a/service/src/java/org/apache/hive/service/cli/CLIService.java b/service/src/java/org/apache/hive/service/cli/CLIService.java index ed52b4a..cb2abfa 100644 --- a/service/src/java/org/apache/hive/service/cli/CLIService.java +++ b/service/src/java/org/apache/hive/service/cli/CLIService.java @@ -226,13 +226,20 @@ public SessionHandle openSessionWithImpersonation(String username, String passwo return sessionHandle; } + @Override + public void bindSession(SessionHandle sessionHandle) + throws HiveSQLException { + sessionManager.bindSession(sessionHandle); + LOG.debug(sessionHandle + ": bindSession()"); + } + /* (non-Javadoc) * @see org.apache.hive.service.cli.ICLIService#closeSession(org.apache.hive.service.cli.SessionHandle) */ @Override public void closeSession(SessionHandle sessionHandle) throws HiveSQLException { - sessionManager.closeSession(sessionHandle); + sessionManager.unbindSession(sessionHandle); LOG.debug(sessionHandle + ": closeSession()"); } diff --git a/service/src/java/org/apache/hive/service/cli/EmbeddedCLIServiceClient.java b/service/src/java/org/apache/hive/service/cli/EmbeddedCLIServiceClient.java index 86e9bb1..031dfd5 100644 --- a/service/src/java/org/apache/hive/service/cli/EmbeddedCLIServiceClient.java +++ b/service/src/java/org/apache/hive/service/cli/EmbeddedCLIServiceClient.java @@ -223,4 +223,9 @@ public OperationHandle getCrossReference(SessionHandle sessionHandle, return cliService.getCrossReference(sessionHandle, primaryCatalog, primarySchema, primaryTable, foreignCatalog, foreignSchema, foreignTable); } + + @Override + public void bindSession(SessionHandle sessionHandle) throws HiveSQLException { + cliService.bindSession(sessionHandle); + } } diff --git a/service/src/java/org/apache/hive/service/cli/ICLIService.java b/service/src/java/org/apache/hive/service/cli/ICLIService.java index fef772d..dbb070b 100644 --- a/service/src/java/org/apache/hive/service/cli/ICLIService.java +++ b/service/src/java/org/apache/hive/service/cli/ICLIService.java @@ -28,6 +28,9 @@ SessionHandle openSession(String username, String password, Map configuration) throws HiveSQLException; + void bindSession(SessionHandle sessionHandle) + throws HiveSQLException; + SessionHandle openSessionWithImpersonation(String username, String password, Map configuration, String delegationToken) throws HiveSQLException; diff --git a/service/src/java/org/apache/hive/service/cli/session/HiveSession.java b/service/src/java/org/apache/hive/service/cli/session/HiveSession.java index e5d865b..e6eb2ed 100644 --- a/service/src/java/org/apache/hive/service/cli/session/HiveSession.java +++ b/service/src/java/org/apache/hive/service/cli/session/HiveSession.java @@ -32,6 +32,7 @@ import org.apache.hive.service.cli.HiveSQLException; import org.apache.hive.service.cli.OperationHandle; import org.apache.hive.service.cli.RowSet; +import org.apache.hive.service.cli.SessionHandle; import org.apache.hive.service.cli.TableSchema; public interface HiveSession extends HiveSessionBase { @@ -190,6 +191,19 @@ OperationHandle getCrossReference(String primaryCatalog, */ void close() throws HiveSQLException; + /** + * Bind the session + */ + void bind(); + + /** + * To unbind the session. handleToSession needs to remove the entry if the session + * should be closed. + * @param handleToSession the mapping from sessionHandle to sessions. + * @throws HiveSQLException + */ + void unbind(Map handleToSession) throws HiveSQLException; + void cancelOperation(OperationHandle opHandle) throws HiveSQLException; void closeOperation(OperationHandle opHandle) throws HiveSQLException; diff --git a/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java b/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java index ef37ff5..fc0d506 100644 --- a/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java +++ b/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java @@ -31,6 +31,7 @@ import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import java.util.concurrent.Semaphore; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; @@ -116,6 +117,7 @@ private volatile int activeCalls = 0; private final Semaphore operationLock; + private AtomicInteger activeConnections = new AtomicInteger(); public HiveSessionImpl(SessionHandle sessionHandle, TProtocolVersion protocol, String username, String password, HiveConf serverConf, String ipAddress) { @@ -187,6 +189,7 @@ public void open(Map sessionConfMap) throws HiveSQLException { } lastAccessTime = System.currentTimeMillis(); lastIdleTime = lastAccessTime; + activeConnections.set(1); } /** @@ -727,6 +730,22 @@ public void close() throws HiveSQLException { } } + + @Override + public void bind() { + activeConnections.incrementAndGet(); + } + + @Override + public void unbind(Map handleToSession) throws HiveSQLException { + synchronized(activeConnections) { + if (activeConnections.decrementAndGet() == 0) { + handleToSession.remove(sessionHandle); + close(); + } + } + } + private void cleanupSessionLogDir() { if (isOperationLogEnabled) { try { diff --git a/service/src/java/org/apache/hive/service/cli/session/SessionManager.java b/service/src/java/org/apache/hive/service/cli/session/SessionManager.java index 4f5a852..0d962f4 100644 --- a/service/src/java/org/apache/hive/service/cli/session/SessionManager.java +++ b/service/src/java/org/apache/hive/service/cli/session/SessionManager.java @@ -383,6 +383,23 @@ public void run() { } } + public void bindSession(SessionHandle sessionHandle) throws HiveSQLException { + HiveSession session = handleToSession.get(sessionHandle); + if (session == null) { + throw new HiveSQLException("Session does not exist: " + sessionHandle); + } + session.bind(); + } + + public void unbindSession(SessionHandle sessionHandle) throws HiveSQLException { + HiveSession session = handleToSession.get(sessionHandle); + if (session == null) { + throw new HiveSQLException("Session does not exist: " + sessionHandle); + } + + session.unbind(handleToSession); + } + public HiveSession getSession(SessionHandle sessionHandle) throws HiveSQLException { HiveSession session = handleToSession.get(sessionHandle); if (session == null) { diff --git a/service/src/java/org/apache/hive/service/cli/thrift/RetryingThriftCLIServiceClient.java b/service/src/java/org/apache/hive/service/cli/thrift/RetryingThriftCLIServiceClient.java index 933750b..f271519 100644 --- a/service/src/java/org/apache/hive/service/cli/thrift/RetryingThriftCLIServiceClient.java +++ b/service/src/java/org/apache/hive/service/cli/thrift/RetryingThriftCLIServiceClient.java @@ -233,6 +233,12 @@ public OperationHandle getCrossReference(SessionHandle sessionHandle, return cliService.getCrossReference(sessionHandle, primaryCatalog, primarySchema, primaryTable, foreignCatalog, foreignSchema, foreignTable); } + + @Override + public void bindSession(SessionHandle sessionHandle) + throws HiveSQLException { + cliService.bindSession(sessionHandle); + } } protected RetryingThriftCLIServiceClient(HiveConf conf) { diff --git a/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java b/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java index 0dd56cb..77a1fb8 100644 --- a/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java +++ b/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java @@ -52,6 +52,8 @@ import org.apache.hive.service.cli.SessionHandle; import org.apache.hive.service.cli.TableSchema; import org.apache.hive.service.cli.session.SessionManager; +import org.apache.hive.service.rpc.thrift.TBindSessionReq; +import org.apache.hive.service.rpc.thrift.TBindSessionResp; import org.apache.hive.service.rpc.thrift.TCLIService; import org.apache.hive.service.rpc.thrift.TCancelDelegationTokenReq; import org.apache.hive.service.rpc.thrift.TCancelDelegationTokenResp; @@ -328,6 +330,34 @@ public TOpenSessionResp OpenSession(TOpenSessionReq req) throws TException { return resp; } + @Override + public TBindSessionResp BindSession(TBindSessionReq req) throws TException { + LOG.info("Client protocol version: " + req.getClient_protocol()); + TBindSessionResp resp = new TBindSessionResp(); + try { + SessionHandle sessionHandle = new SessionHandle(req.getSessionHandle()); + ThriftCLIServerContext context = + (ThriftCLIServerContext)currentServerContext.get(); + if (context != null) { + if (context.getSessionHandle() != null) { + resp.setStatus(HiveSQLException.toTStatus( + new HiveSQLException("Error binding session " + sessionHandle + + ". Session is opened or bound on the current connection:" + context.getSessionHandle()))); + } else { + context.setSessionHandle(sessionHandle); + cliService.bindSession(sessionHandle); + resp.setStatus(OK_STATUS); + } + } + + LOG.info("Bound a session " + sessionHandle); + } catch (Exception e) { + LOG.warn("Error binding session: ", e); + resp.setStatus(HiveSQLException.toTStatus(e)); + } + return resp; + } + private String getIpAddress() { String clientIpAddress; // Http transport mode. @@ -460,11 +490,22 @@ private TProtocolVersion getMinVersion(TProtocolVersion... versions) { throw new IllegalArgumentException("never"); } + private SessionHandle checkAndGetSessionHandle() throws HiveSQLException { + ThriftCLIServerContext context = + (ThriftCLIServerContext)currentServerContext.get(); + if (context == null || context.getSessionHandle() == null) { + throw new HiveSQLException("No opened/bound session on current connection. Call bindSession or openSession first."); + } + + return context.getSessionHandle(); + } + @Override public TCloseSessionResp CloseSession(TCloseSessionReq req) throws TException { TCloseSessionResp resp = new TCloseSessionResp(); try { - SessionHandle sessionHandle = new SessionHandle(req.getSessionHandle()); + SessionHandle sessionHandle = checkAndGetSessionHandle(); + cliService.closeSession(sessionHandle); LOG.info("Closed a session " + sessionHandle + ", current sessions: " + sessionCount.decrementAndGet()); resp.setStatus(OK_STATUS); @@ -485,7 +526,7 @@ public TGetInfoResp GetInfo(TGetInfoReq req) throws TException { TGetInfoResp resp = new TGetInfoResp(); try { GetInfoValue getInfoValue = - cliService.getInfo(new SessionHandle(req.getSessionHandle()), + cliService.getInfo(checkAndGetSessionHandle(), GetInfoType.getGetInfoType(req.getInfoType())); resp.setInfoValue(getInfoValue.toTGetInfoValue()); resp.setStatus(OK_STATUS); @@ -500,7 +541,7 @@ public TGetInfoResp GetInfo(TGetInfoReq req) throws TException { public TExecuteStatementResp ExecuteStatement(TExecuteStatementReq req) throws TException { TExecuteStatementResp resp = new TExecuteStatementResp(); try { - SessionHandle sessionHandle = new SessionHandle(req.getSessionHandle()); + SessionHandle sessionHandle = checkAndGetSessionHandle(); String statement = req.getStatement(); Map confOverlay = req.getConfOverlay(); Boolean runAsync = req.isRunAsync(); @@ -525,7 +566,7 @@ public TExecuteStatementResp ExecuteStatement(TExecuteStatementReq req) throws T public TGetTypeInfoResp GetTypeInfo(TGetTypeInfoReq req) throws TException { TGetTypeInfoResp resp = new TGetTypeInfoResp(); try { - OperationHandle operationHandle = cliService.getTypeInfo(new SessionHandle(req.getSessionHandle())); + OperationHandle operationHandle = cliService.getTypeInfo(checkAndGetSessionHandle()); resp.setOperationHandle(operationHandle.toTOperationHandle()); resp.setStatus(OK_STATUS); } catch (Exception e) { @@ -539,7 +580,7 @@ public TGetTypeInfoResp GetTypeInfo(TGetTypeInfoReq req) throws TException { public TGetCatalogsResp GetCatalogs(TGetCatalogsReq req) throws TException { TGetCatalogsResp resp = new TGetCatalogsResp(); try { - OperationHandle opHandle = cliService.getCatalogs(new SessionHandle(req.getSessionHandle())); + OperationHandle opHandle = cliService.getCatalogs(checkAndGetSessionHandle()); resp.setOperationHandle(opHandle.toTOperationHandle()); resp.setStatus(OK_STATUS); } catch (Exception e) { @@ -554,7 +595,7 @@ public TGetSchemasResp GetSchemas(TGetSchemasReq req) throws TException { TGetSchemasResp resp = new TGetSchemasResp(); try { OperationHandle opHandle = cliService.getSchemas( - new SessionHandle(req.getSessionHandle()), req.getCatalogName(), req.getSchemaName()); + checkAndGetSessionHandle(), req.getCatalogName(), req.getSchemaName()); resp.setOperationHandle(opHandle.toTOperationHandle()); resp.setStatus(OK_STATUS); } catch (Exception e) { @@ -569,7 +610,7 @@ public TGetTablesResp GetTables(TGetTablesReq req) throws TException { TGetTablesResp resp = new TGetTablesResp(); try { OperationHandle opHandle = cliService - .getTables(new SessionHandle(req.getSessionHandle()), req.getCatalogName(), + .getTables(checkAndGetSessionHandle(), req.getCatalogName(), req.getSchemaName(), req.getTableName(), req.getTableTypes()); resp.setOperationHandle(opHandle.toTOperationHandle()); resp.setStatus(OK_STATUS); @@ -584,7 +625,7 @@ public TGetTablesResp GetTables(TGetTablesReq req) throws TException { public TGetTableTypesResp GetTableTypes(TGetTableTypesReq req) throws TException { TGetTableTypesResp resp = new TGetTableTypesResp(); try { - OperationHandle opHandle = cliService.getTableTypes(new SessionHandle(req.getSessionHandle())); + OperationHandle opHandle = cliService.getTableTypes(checkAndGetSessionHandle()); resp.setOperationHandle(opHandle.toTOperationHandle()); resp.setStatus(OK_STATUS); } catch (Exception e) { @@ -599,7 +640,7 @@ public TGetColumnsResp GetColumns(TGetColumnsReq req) throws TException { TGetColumnsResp resp = new TGetColumnsResp(); try { OperationHandle opHandle = cliService.getColumns( - new SessionHandle(req.getSessionHandle()), + checkAndGetSessionHandle(), req.getCatalogName(), req.getSchemaName(), req.getTableName(), @@ -618,7 +659,7 @@ public TGetFunctionsResp GetFunctions(TGetFunctionsReq req) throws TException { TGetFunctionsResp resp = new TGetFunctionsResp(); try { OperationHandle opHandle = cliService.getFunctions( - new SessionHandle(req.getSessionHandle()), req.getCatalogName(), + checkAndGetSessionHandle(), req.getCatalogName(), req.getSchemaName(), req.getFunctionName()); resp.setOperationHandle(opHandle.toTOperationHandle()); resp.setStatus(OK_STATUS); @@ -720,7 +761,7 @@ public TGetPrimaryKeysResp GetPrimaryKeys(TGetPrimaryKeysReq req) TGetPrimaryKeysResp resp = new TGetPrimaryKeysResp(); try { OperationHandle opHandle = cliService.getPrimaryKeys( - new SessionHandle(req.getSessionHandle()), req.getCatalogName(), + checkAndGetSessionHandle(), req.getCatalogName(), req.getSchemaName(), req.getTableName()); resp.setOperationHandle(opHandle.toTOperationHandle()); resp.setStatus(OK_STATUS); @@ -737,7 +778,7 @@ public TGetCrossReferenceResp GetCrossReference(TGetCrossReferenceReq req) TGetCrossReferenceResp resp = new TGetCrossReferenceResp(); try { OperationHandle opHandle = cliService.getCrossReference( - new SessionHandle(req.getSessionHandle()), req.getParentCatalogName(), + checkAndGetSessionHandle(), req.getParentCatalogName(), req.getParentSchemaName(), req.getParentTableName(), req.getForeignCatalogName(), req.getForeignSchemaName(), req.getForeignTableName()); resp.setOperationHandle(opHandle.toTOperationHandle()); diff --git a/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIServiceClient.java b/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIServiceClient.java index 3c48dbb..85ead7b 100644 --- a/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIServiceClient.java +++ b/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIServiceClient.java @@ -35,6 +35,8 @@ import org.apache.hive.service.cli.RowSetFactory; import org.apache.hive.service.cli.SessionHandle; import org.apache.hive.service.cli.TableSchema; +import org.apache.hive.service.rpc.thrift.TBindSessionReq; +import org.apache.hive.service.rpc.thrift.TBindSessionResp; import org.apache.hive.service.rpc.thrift.TCLIService; import org.apache.hive.service.rpc.thrift.TCancelDelegationTokenReq; import org.apache.hive.service.rpc.thrift.TCancelDelegationTokenResp; @@ -543,4 +545,18 @@ public OperationHandle getCrossReference(SessionHandle sessionHandle, throw new HiveSQLException(e); } } + + @Override + public void bindSession(SessionHandle sessionHandle) throws HiveSQLException { + try { + TBindSessionReq req = new TBindSessionReq(sessionHandle.getProtocolVersion(), sessionHandle.toTSessionHandle()); + TBindSessionResp resp = cliService.BindSession(req); + checkStatus(resp.getStatus()); + } catch (HiveSQLException e) { + throw e; + } catch (Exception e) { + throw new HiveSQLException(e); + } + + } }