diff --git common/src/java/org/apache/hadoop/hive/conf/HiveConf.java common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index 8490558..e716d09 100644 --- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -68,6 +68,7 @@ private static final Map vars = new HashMap(); + private static final Map metaConfs = new HashMap(); private final List restrictList = new ArrayList(); private boolean isWhiteListRestrictionEnabled = false; @@ -153,6 +154,19 @@ HiveConf.ConfVars.HIVE_TXN_MAX_OPEN_BATCH, }; + /** + * User configurable Metastore vars + */ + public static final HiveConf.ConfVars[] metaConfVars = { + HiveConf.ConfVars.METASTORE_TRY_DIRECT_SQL, + HiveConf.ConfVars.METASTORE_TRY_DIRECT_SQL_DDL + }; + + static { + for (ConfVars confVar : metaConfVars) { + metaConfs.put(confVar.varname, confVar); + } + } /** * dbVars are the parameters can be set per database. If these @@ -2027,6 +2041,10 @@ public static ConfVars getConfVars(String name) { return vars.get(name); } + public static ConfVars getMetaConf(String name) { + return metaConfs.get(name); + } + public String getVar(ConfVars var) { return getVar(this, var); } diff --git common/src/java/org/apache/hadoop/hive/conf/SystemVariables.java common/src/java/org/apache/hadoop/hive/conf/SystemVariables.java index ee98d17..0bbed90 100644 --- common/src/java/org/apache/hadoop/hive/conf/SystemVariables.java +++ common/src/java/org/apache/hadoop/hive/conf/SystemVariables.java @@ -33,6 +33,7 @@ public static final String SYSTEM_PREFIX = "system:"; public static final String HIVECONF_PREFIX = "hiveconf:"; public static final String HIVEVAR_PREFIX = "hivevar:"; + public static final String METACONF_PREFIX = "metaconf:"; public static final String SET_COLUMN_NAME = "set"; protected String getSubstitute(Configuration conf, String var) { diff --git itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java index 9e416b5..1f6748b 100644 --- itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java +++ itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java @@ -35,6 +35,7 @@ import org.apache.hadoop.hive.metastore.events.AddPartitionEvent; import org.apache.hadoop.hive.metastore.events.AlterPartitionEvent; import org.apache.hadoop.hive.metastore.events.AlterTableEvent; +import org.apache.hadoop.hive.metastore.events.ConfigChangeEvent; import org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent; import org.apache.hadoop.hive.metastore.events.CreateTableEvent; import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent; @@ -53,6 +54,7 @@ import org.apache.hadoop.hive.metastore.events.PreEventContext; import org.apache.hadoop.hive.metastore.events.PreLoadPartitionDoneEvent; import org.apache.hadoop.hive.ql.Driver; +import org.apache.hadoop.hive.ql.processors.SetProcessor; import org.apache.hadoop.hive.ql.session.SessionState; import org.apache.hadoop.hive.shims.ShimLoader; @@ -377,6 +379,12 @@ public void testListener() throws Exception { PreDropDatabaseEvent preDropDB = (PreDropDatabaseEvent)preNotifyList.get(listSize-1); assert dropDB.getStatus(); validateDropDb(db, preDropDB.getDatabase()); + + SetProcessor.setVariable("metaconf:hive.metastore.try.direct.sql", "false"); + ConfigChangeEvent event = (ConfigChangeEvent) notifyList.get(notifyList.size() - 1); + assertEquals("hive.metastore.try.direct.sql", event.getKey()); + assertEquals("true", event.getOldValue()); + assertEquals("false", event.getNewValue()); } } diff --git metastore/if/hive_metastore.thrift metastore/if/hive_metastore.thrift index 9e93b95..d88f0da 100755 --- metastore/if/hive_metastore.thrift +++ metastore/if/hive_metastore.thrift @@ -682,6 +682,7 @@ exception NoSuchLockException { */ service ThriftHiveMetastore extends fb303.FacebookService { + void configure(1:string key, 2:string value) throws(1:MetaException o1) void create_database(1:Database database) throws(1:AlreadyExistsException o1, 2:InvalidObjectException o2, 3:MetaException o3) Database get_database(1:string name) throws(1:NoSuchObjectException o1, 2:MetaException o2) void drop_database(1:string name, 2:bool deleteData, 3:bool cascade) throws(1:NoSuchObjectException o1, 2:InvalidOperationException o2, 3:MetaException o3) diff --git metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp index 5fbd1de..bf3bffa 100644 --- metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp +++ metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp @@ -8,6 +8,184 @@ namespace Apache { namespace Hadoop { namespace Hive { +uint32_t ThriftHiveMetastore_configure_args::read(::apache::thrift::protocol::TProtocol* 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_STRING) { + xfer += iprot->readString(this->key); + this->__isset.key = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->value); + this->__isset.value = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t ThriftHiveMetastore_configure_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + xfer += oprot->writeStructBegin("ThriftHiveMetastore_configure_args"); + + xfer += oprot->writeFieldBegin("key", ::apache::thrift::protocol::T_STRING, 1); + xfer += oprot->writeString(this->key); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("value", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString(this->value); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +uint32_t ThriftHiveMetastore_configure_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + xfer += oprot->writeStructBegin("ThriftHiveMetastore_configure_pargs"); + + xfer += oprot->writeFieldBegin("key", ::apache::thrift::protocol::T_STRING, 1); + xfer += oprot->writeString((*(this->key))); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("value", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString((*(this->value))); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +uint32_t ThriftHiveMetastore_configure_result::read(::apache::thrift::protocol::TProtocol* 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->o1.read(iprot); + this->__isset.o1 = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t ThriftHiveMetastore_configure_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("ThriftHiveMetastore_configure_result"); + + if (this->__isset.o1) { + xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->o1.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +uint32_t ThriftHiveMetastore_configure_presult::read(::apache::thrift::protocol::TProtocol* 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->o1.read(iprot); + this->__isset.o1 = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + uint32_t ThriftHiveMetastore_create_database_args::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; @@ -25464,6 +25642,63 @@ uint32_t ThriftHiveMetastore_show_compact_presult::read(::apache::thrift::protoc return xfer; } +void ThriftHiveMetastoreClient::configure(const std::string& key, const std::string& value) +{ + send_configure(key, value); + recv_configure(); +} + +void ThriftHiveMetastoreClient::send_configure(const std::string& key, const std::string& value) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("configure", ::apache::thrift::protocol::T_CALL, cseqid); + + ThriftHiveMetastore_configure_pargs args; + args.key = &key; + args.value = &value; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void ThriftHiveMetastoreClient::recv_configure() +{ + + 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("configure") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + ThriftHiveMetastore_configure_presult result; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.o1) { + throw result.o1; + } + return; +} + void ThriftHiveMetastoreClient::create_database(const Database& database) { send_create_database(database); @@ -32535,6 +32770,62 @@ bool ThriftHiveMetastoreProcessor::dispatchCall(::apache::thrift::protocol::TPro return true; } +void ThriftHiveMetastoreProcessor::process_configure(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("ThriftHiveMetastore.configure", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ThriftHiveMetastore.configure"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "ThriftHiveMetastore.configure"); + } + + ThriftHiveMetastore_configure_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "ThriftHiveMetastore.configure", bytes); + } + + ThriftHiveMetastore_configure_result result; + try { + iface_->configure(args.key, args.value); + } catch (MetaException &o1) { + result.o1 = o1; + result.__isset.o1 = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "ThriftHiveMetastore.configure"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("configure", ::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, "ThriftHiveMetastore.configure"); + } + + oprot->writeMessageBegin("configure", ::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, "ThriftHiveMetastore.configure", bytes); + } +} + void ThriftHiveMetastoreProcessor::process_create_database(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) { void* ctx = NULL; diff --git metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h index 35894a2..0259498 100644 --- metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h +++ metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h @@ -16,6 +16,7 @@ namespace Apache { namespace Hadoop { namespace Hive { class ThriftHiveMetastoreIf : virtual public ::facebook::fb303::FacebookServiceIf { public: virtual ~ThriftHiveMetastoreIf() {} + virtual void configure(const std::string& key, const std::string& value) = 0; virtual void create_database(const Database& database) = 0; virtual void get_database(Database& _return, const std::string& name) = 0; virtual void drop_database(const std::string& name, const bool deleteData, const bool cascade) = 0; @@ -155,6 +156,9 @@ class ThriftHiveMetastoreIfSingletonFactory : virtual public ThriftHiveMetastore class ThriftHiveMetastoreNull : virtual public ThriftHiveMetastoreIf , virtual public ::facebook::fb303::FacebookServiceNull { public: virtual ~ThriftHiveMetastoreNull() {} + void configure(const std::string& /* key */, const std::string& /* value */) { + return; + } void create_database(const Database& /* database */) { return; } @@ -508,6 +512,123 @@ class ThriftHiveMetastoreNull : virtual public ThriftHiveMetastoreIf , virtual p } }; +typedef struct _ThriftHiveMetastore_configure_args__isset { + _ThriftHiveMetastore_configure_args__isset() : key(false), value(false) {} + bool key; + bool value; +} _ThriftHiveMetastore_configure_args__isset; + +class ThriftHiveMetastore_configure_args { + public: + + ThriftHiveMetastore_configure_args() : key(), value() { + } + + virtual ~ThriftHiveMetastore_configure_args() throw() {} + + std::string key; + std::string value; + + _ThriftHiveMetastore_configure_args__isset __isset; + + void __set_key(const std::string& val) { + key = val; + } + + void __set_value(const std::string& val) { + value = val; + } + + bool operator == (const ThriftHiveMetastore_configure_args & rhs) const + { + if (!(key == rhs.key)) + return false; + if (!(value == rhs.value)) + return false; + return true; + } + bool operator != (const ThriftHiveMetastore_configure_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const ThriftHiveMetastore_configure_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class ThriftHiveMetastore_configure_pargs { + public: + + + virtual ~ThriftHiveMetastore_configure_pargs() throw() {} + + const std::string* key; + const std::string* value; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _ThriftHiveMetastore_configure_result__isset { + _ThriftHiveMetastore_configure_result__isset() : o1(false) {} + bool o1; +} _ThriftHiveMetastore_configure_result__isset; + +class ThriftHiveMetastore_configure_result { + public: + + ThriftHiveMetastore_configure_result() { + } + + virtual ~ThriftHiveMetastore_configure_result() throw() {} + + MetaException o1; + + _ThriftHiveMetastore_configure_result__isset __isset; + + void __set_o1(const MetaException& val) { + o1 = val; + } + + bool operator == (const ThriftHiveMetastore_configure_result & rhs) const + { + if (!(o1 == rhs.o1)) + return false; + return true; + } + bool operator != (const ThriftHiveMetastore_configure_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const ThriftHiveMetastore_configure_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _ThriftHiveMetastore_configure_presult__isset { + _ThriftHiveMetastore_configure_presult__isset() : o1(false) {} + bool o1; +} _ThriftHiveMetastore_configure_presult__isset; + +class ThriftHiveMetastore_configure_presult { + public: + + + virtual ~ThriftHiveMetastore_configure_presult() throw() {} + + MetaException o1; + + _ThriftHiveMetastore_configure_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + typedef struct _ThriftHiveMetastore_create_database_args__isset { _ThriftHiveMetastore_create_database_args__isset() : database(false) {} bool database; @@ -15582,6 +15703,9 @@ class ThriftHiveMetastoreClient : virtual public ThriftHiveMetastoreIf, public boost::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { return poprot_; } + void configure(const std::string& key, const std::string& value); + void send_configure(const std::string& key, const std::string& value); + void recv_configure(); void create_database(const Database& database); void send_create_database(const Database& database); void recv_create_database(); @@ -15922,6 +16046,7 @@ class ThriftHiveMetastoreProcessor : public ::facebook::fb303::FacebookServiceP typedef void (ThriftHiveMetastoreProcessor::*ProcessFunction)(int32_t, ::apache::thrift::protocol::TProtocol*, ::apache::thrift::protocol::TProtocol*, void*); typedef std::map ProcessMap; ProcessMap processMap_; + void process_configure(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_create_database(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_get_database(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_drop_database(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); @@ -16036,6 +16161,7 @@ class ThriftHiveMetastoreProcessor : public ::facebook::fb303::FacebookServiceP ThriftHiveMetastoreProcessor(boost::shared_ptr iface) : ::facebook::fb303::FacebookServiceProcessor(iface), iface_(iface) { + processMap_["configure"] = &ThriftHiveMetastoreProcessor::process_configure; processMap_["create_database"] = &ThriftHiveMetastoreProcessor::process_create_database; processMap_["get_database"] = &ThriftHiveMetastoreProcessor::process_get_database; processMap_["drop_database"] = &ThriftHiveMetastoreProcessor::process_drop_database; @@ -16179,6 +16305,15 @@ class ThriftHiveMetastoreMultiface : virtual public ThriftHiveMetastoreIf, publi ifaces_.push_back(iface); } public: + void configure(const std::string& key, const std::string& value) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->configure(key, value); + } + ifaces_[i]->configure(key, value); + } + void create_database(const Database& database) { size_t sz = ifaces_.size(); size_t i = 0; diff --git metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp index 822e8d7..2604755 100644 --- metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp +++ metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp @@ -22,6 +22,11 @@ class ThriftHiveMetastoreHandler : virtual public ThriftHiveMetastoreIf { // Your initialization goes here } + void configure(const std::string& key, const std::string& value) { + // Your implementation goes here + printf("configure\n"); + } + void create_database(const Database& database) { // Your implementation goes here printf("create_database\n"); diff --git metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java index e2bc91f..8b71f3d 100644 --- metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java +++ metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java @@ -38,6 +38,8 @@ */ public interface Iface extends com.facebook.fb303.FacebookService.Iface { + public void configure(String key, String value) throws MetaException, org.apache.thrift.TException; + public void create_database(Database database) throws AlreadyExistsException, InvalidObjectException, MetaException, org.apache.thrift.TException; public Database get_database(String name) throws NoSuchObjectException, MetaException, org.apache.thrift.TException; @@ -262,6 +264,8 @@ public interface AsyncIface extends com.facebook.fb303.FacebookService .AsyncIface { + public void configure(String key, String value, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void create_database(Database database, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void get_database(String name, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; @@ -504,6 +508,30 @@ public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.prot super(iprot, oprot); } + public void configure(String key, String value) throws MetaException, org.apache.thrift.TException + { + send_configure(key, value); + recv_configure(); + } + + public void send_configure(String key, String value) throws org.apache.thrift.TException + { + configure_args args = new configure_args(); + args.setKey(key); + args.setValue(value); + sendBase("configure", args); + } + + public void recv_configure() throws MetaException, org.apache.thrift.TException + { + configure_result result = new configure_result(); + receiveBase(result, "configure"); + if (result.o1 != null) { + throw result.o1; + } + return; + } + public void create_database(Database database) throws AlreadyExistsException, InvalidObjectException, MetaException, org.apache.thrift.TException { send_create_database(database); @@ -3781,6 +3809,41 @@ public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, super(protocolFactory, clientManager, transport); } + public void configure(String key, String value, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + configure_call method_call = new configure_call(key, value, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class configure_call extends org.apache.thrift.async.TAsyncMethodCall { + private String key; + private String value; + public configure_call(String key, String value, 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.key = key; + this.value = value; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("configure", org.apache.thrift.protocol.TMessageType.CALL, 0)); + configure_args args = new configure_args(); + args.setKey(key); + args.setValue(value); + args.write(prot); + prot.writeMessageEnd(); + } + + public void getResult() throws MetaException, 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); + (new Client(prot)).recv_configure(); + } + } + public void create_database(Database database, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); create_database_call method_call = new create_database_call(database, resultHandler, this, ___protocolFactory, ___transport); @@ -7728,6 +7791,7 @@ protected Processor(I iface, Map Map> getProcessMap(Map> processMap) { + processMap.put("configure", new configure()); processMap.put("create_database", new create_database()); processMap.put("get_database", new get_database()); processMap.put("drop_database", new drop_database()); @@ -7841,6 +7905,30 @@ protected Processor(I iface, Map extends org.apache.thrift.ProcessFunction { + public configure() { + super("configure"); + } + + public configure_args getEmptyArgsInstance() { + return new configure_args(); + } + + protected boolean isOneway() { + return false; + } + + public configure_result getResult(I iface, configure_args args) throws org.apache.thrift.TException { + configure_result result = new configure_result(); + try { + iface.configure(args.key, args.value); + } catch (MetaException o1) { + result.o1 = o1; + } + return result; + } + } + public static class create_database extends org.apache.thrift.ProcessFunction { public create_database() { super("create_database"); @@ -10712,6 +10800,828 @@ public show_compact_result getResult(I iface, show_compact_args args) throws org } + public static class configure_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("configure_args"); + + private static final org.apache.thrift.protocol.TField KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("key", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField VALUE_FIELD_DESC = new org.apache.thrift.protocol.TField("value", org.apache.thrift.protocol.TType.STRING, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new configure_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new configure_argsTupleSchemeFactory()); + } + + private String key; // required + private String value; // 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 { + KEY((short)1, "key"), + VALUE((short)2, "value"); + + 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: // KEY + return KEY; + case 2: // VALUE + return VALUE; + 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.KEY, new org.apache.thrift.meta_data.FieldMetaData("key", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.VALUE, new org.apache.thrift.meta_data.FieldMetaData("value", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(configure_args.class, metaDataMap); + } + + public configure_args() { + } + + public configure_args( + String key, + String value) + { + this(); + this.key = key; + this.value = value; + } + + /** + * Performs a deep copy on other. + */ + public configure_args(configure_args other) { + if (other.isSetKey()) { + this.key = other.key; + } + if (other.isSetValue()) { + this.value = other.value; + } + } + + public configure_args deepCopy() { + return new configure_args(this); + } + + @Override + public void clear() { + this.key = null; + this.value = null; + } + + public String getKey() { + return this.key; + } + + public void setKey(String key) { + this.key = key; + } + + public void unsetKey() { + this.key = null; + } + + /** Returns true if field key is set (has been assigned a value) and false otherwise */ + public boolean isSetKey() { + return this.key != null; + } + + public void setKeyIsSet(boolean value) { + if (!value) { + this.key = null; + } + } + + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public void unsetValue() { + this.value = null; + } + + /** Returns true if field value is set (has been assigned a value) and false otherwise */ + public boolean isSetValue() { + return this.value != null; + } + + public void setValueIsSet(boolean value) { + if (!value) { + this.value = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case KEY: + if (value == null) { + unsetKey(); + } else { + setKey((String)value); + } + break; + + case VALUE: + if (value == null) { + unsetValue(); + } else { + setValue((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case KEY: + return getKey(); + + case VALUE: + return getValue(); + + } + 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 KEY: + return isSetKey(); + case VALUE: + return isSetValue(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof configure_args) + return this.equals((configure_args)that); + return false; + } + + public boolean equals(configure_args that) { + if (that == null) + return false; + + boolean this_present_key = true && this.isSetKey(); + boolean that_present_key = true && that.isSetKey(); + if (this_present_key || that_present_key) { + if (!(this_present_key && that_present_key)) + return false; + if (!this.key.equals(that.key)) + return false; + } + + boolean this_present_value = true && this.isSetValue(); + boolean that_present_value = true && that.isSetValue(); + if (this_present_value || that_present_value) { + if (!(this_present_value && that_present_value)) + return false; + if (!this.value.equals(that.value)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_key = true && (isSetKey()); + builder.append(present_key); + if (present_key) + builder.append(key); + + boolean present_value = true && (isSetValue()); + builder.append(present_value); + if (present_value) + builder.append(value); + + return builder.toHashCode(); + } + + public int compareTo(configure_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + configure_args typedOther = (configure_args)other; + + lastComparison = Boolean.valueOf(isSetKey()).compareTo(typedOther.isSetKey()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetKey()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.key, typedOther.key); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetValue()).compareTo(typedOther.isSetValue()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetValue()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.value, typedOther.value); + 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("configure_args("); + boolean first = true; + + sb.append("key:"); + if (this.key == null) { + sb.append("null"); + } else { + sb.append(this.key); + } + first = false; + if (!first) sb.append(", "); + sb.append("value:"); + if (this.value == null) { + sb.append("null"); + } else { + sb.append(this.value); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + 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 configure_argsStandardSchemeFactory implements SchemeFactory { + public configure_argsStandardScheme getScheme() { + return new configure_argsStandardScheme(); + } + } + + private static class configure_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, configure_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: // KEY + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.key = iprot.readString(); + struct.setKeyIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // VALUE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.value = iprot.readString(); + struct.setValueIsSet(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, configure_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.key != null) { + oprot.writeFieldBegin(KEY_FIELD_DESC); + oprot.writeString(struct.key); + oprot.writeFieldEnd(); + } + if (struct.value != null) { + oprot.writeFieldBegin(VALUE_FIELD_DESC); + oprot.writeString(struct.value); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class configure_argsTupleSchemeFactory implements SchemeFactory { + public configure_argsTupleScheme getScheme() { + return new configure_argsTupleScheme(); + } + } + + private static class configure_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, configure_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetKey()) { + optionals.set(0); + } + if (struct.isSetValue()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetKey()) { + oprot.writeString(struct.key); + } + if (struct.isSetValue()) { + oprot.writeString(struct.value); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, configure_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.key = iprot.readString(); + struct.setKeyIsSet(true); + } + if (incoming.get(1)) { + struct.value = iprot.readString(); + struct.setValueIsSet(true); + } + } + } + + } + + public static class configure_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("configure_result"); + + private static final org.apache.thrift.protocol.TField O1_FIELD_DESC = new org.apache.thrift.protocol.TField("o1", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new configure_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new configure_resultTupleSchemeFactory()); + } + + private MetaException o1; // 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 { + O1((short)1, "o1"); + + 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: // O1 + return O1; + 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.O1, new org.apache.thrift.meta_data.FieldMetaData("o1", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(configure_result.class, metaDataMap); + } + + public configure_result() { + } + + public configure_result( + MetaException o1) + { + this(); + this.o1 = o1; + } + + /** + * Performs a deep copy on other. + */ + public configure_result(configure_result other) { + if (other.isSetO1()) { + this.o1 = new MetaException(other.o1); + } + } + + public configure_result deepCopy() { + return new configure_result(this); + } + + @Override + public void clear() { + this.o1 = null; + } + + public MetaException getO1() { + return this.o1; + } + + public void setO1(MetaException o1) { + this.o1 = o1; + } + + public void unsetO1() { + this.o1 = null; + } + + /** Returns true if field o1 is set (has been assigned a value) and false otherwise */ + public boolean isSetO1() { + return this.o1 != null; + } + + public void setO1IsSet(boolean value) { + if (!value) { + this.o1 = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case O1: + if (value == null) { + unsetO1(); + } else { + setO1((MetaException)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case O1: + return getO1(); + + } + 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 O1: + return isSetO1(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof configure_result) + return this.equals((configure_result)that); + return false; + } + + public boolean equals(configure_result that) { + if (that == null) + return false; + + boolean this_present_o1 = true && this.isSetO1(); + boolean that_present_o1 = true && that.isSetO1(); + if (this_present_o1 || that_present_o1) { + if (!(this_present_o1 && that_present_o1)) + return false; + if (!this.o1.equals(that.o1)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_o1 = true && (isSetO1()); + builder.append(present_o1); + if (present_o1) + builder.append(o1); + + return builder.toHashCode(); + } + + public int compareTo(configure_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + configure_result typedOther = (configure_result)other; + + lastComparison = Boolean.valueOf(isSetO1()).compareTo(typedOther.isSetO1()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetO1()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.o1, typedOther.o1); + 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("configure_result("); + boolean first = true; + + sb.append("o1:"); + if (this.o1 == null) { + sb.append("null"); + } else { + sb.append(this.o1); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + 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 configure_resultStandardSchemeFactory implements SchemeFactory { + public configure_resultStandardScheme getScheme() { + return new configure_resultStandardScheme(); + } + } + + private static class configure_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, configure_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 1: // O1 + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.o1 = new MetaException(); + struct.o1.read(iprot); + struct.setO1IsSet(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, configure_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.o1 != null) { + oprot.writeFieldBegin(O1_FIELD_DESC); + struct.o1.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class configure_resultTupleSchemeFactory implements SchemeFactory { + public configure_resultTupleScheme getScheme() { + return new configure_resultTupleScheme(); + } + } + + private static class configure_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, configure_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetO1()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetO1()) { + struct.o1.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, configure_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.o1 = new MetaException(); + struct.o1.read(iprot); + struct.setO1IsSet(true); + } + } + } + + } + public static class create_database_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("create_database_args"); diff --git metastore/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore.php metastore/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore.php index 3f5c737..f32706b 100644 --- metastore/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore.php +++ metastore/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore.php @@ -16,6 +16,7 @@ use Thrift\Exception\TApplicationException; interface ThriftHiveMetastoreIf extends \FacebookServiceIf { + public function configure($key, $value); public function create_database(\metastore\Database $database); public function get_database($name); public function drop_database($name, $deleteData, $cascade); @@ -133,6 +134,58 @@ class ThriftHiveMetastoreClient extends \FacebookServiceClient implements \metas parent::__construct($input, $output); } + public function configure($key, $value) + { + $this->send_configure($key, $value); + $this->recv_configure(); + } + + public function send_configure($key, $value) + { + $args = new \metastore\ThriftHiveMetastore_configure_args(); + $args->key = $key; + $args->value = $value; + $bin_accel = ($this->output_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'configure', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('configure', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_configure() + { + $bin_accel = ($this->input_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\metastore\ThriftHiveMetastore_configure_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 \metastore\ThriftHiveMetastore_configure_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->o1 !== null) { + throw $result->o1; + } + return; + } + public function create_database(\metastore\Database $database) { $this->send_create_database($database); @@ -6476,6 +6529,172 @@ class ThriftHiveMetastoreClient extends \FacebookServiceClient implements \metas // HELPER FUNCTIONS AND STRUCTURES +class ThriftHiveMetastore_configure_args { + static $_TSPEC; + + public $key = null; + public $value = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'key', + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'value', + 'type' => TType::STRING, + ), + ); + } + if (is_array($vals)) { + if (isset($vals['key'])) { + $this->key = $vals['key']; + } + if (isset($vals['value'])) { + $this->value = $vals['value']; + } + } + } + + public function getName() { + return 'ThriftHiveMetastore_configure_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::STRING) { + $xfer += $input->readString($this->key); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->value); + } 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('ThriftHiveMetastore_configure_args'); + if ($this->key !== null) { + $xfer += $output->writeFieldBegin('key', TType::STRING, 1); + $xfer += $output->writeString($this->key); + $xfer += $output->writeFieldEnd(); + } + if ($this->value !== null) { + $xfer += $output->writeFieldBegin('value', TType::STRING, 2); + $xfer += $output->writeString($this->value); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ThriftHiveMetastore_configure_result { + static $_TSPEC; + + public $o1 = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'o1', + 'type' => TType::STRUCT, + 'class' => '\metastore\MetaException', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['o1'])) { + $this->o1 = $vals['o1']; + } + } + } + + public function getName() { + return 'ThriftHiveMetastore_configure_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 1: + if ($ftype == TType::STRUCT) { + $this->o1 = new \metastore\MetaException(); + $xfer += $this->o1->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('ThriftHiveMetastore_configure_result'); + if ($this->o1 !== null) { + $xfer += $output->writeFieldBegin('o1', TType::STRUCT, 1); + $xfer += $this->o1->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + class ThriftHiveMetastore_create_database_args { static $_TSPEC; diff --git metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote old mode 100644 new mode 100755 index 2874737..498c22d --- metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote +++ metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote @@ -23,6 +23,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help': print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]' print '' print 'Functions:' + print ' void configure(string key, string value)' print ' void create_database(Database database)' print ' Database get_database(string name)' print ' void drop_database(string name, bool deleteData, bool cascade)' @@ -184,7 +185,13 @@ protocol = TBinaryProtocol.TBinaryProtocol(transport) client = ThriftHiveMetastore.Client(protocol) transport.open() -if cmd == 'create_database': +if cmd == 'configure': + if len(args) != 2: + print 'configure requires 2 args' + sys.exit(1) + pp.pprint(client.configure(args[0],args[1],)) + +elif cmd == 'create_database': if len(args) != 1: print 'create_database requires 1 args' sys.exit(1) diff --git metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py index 2f2c34c..57b3dcf 100644 --- metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py +++ metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py @@ -22,6 +22,14 @@ class Iface(fb303.FacebookService.Iface): """ This interface is live. """ + def configure(self, key, value): + """ + Parameters: + - key + - value + """ + pass + def create_database(self, database): """ Parameters: @@ -926,6 +934,38 @@ class Client(fb303.FacebookService.Client, Iface): def __init__(self, iprot, oprot=None): fb303.FacebookService.Client.__init__(self, iprot, oprot) + def configure(self, key, value): + """ + Parameters: + - key + - value + """ + self.send_configure(key, value) + self.recv_configure() + + def send_configure(self, key, value): + self._oprot.writeMessageBegin('configure', TMessageType.CALL, self._seqid) + args = configure_args() + args.key = key + args.value = value + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_configure(self, ): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = configure_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.o1 is not None: + raise result.o1 + return + def create_database(self, database): """ Parameters: @@ -4888,6 +4928,7 @@ def recv_show_compact(self, ): class Processor(fb303.FacebookService.Processor, Iface, TProcessor): def __init__(self, handler): fb303.FacebookService.Processor.__init__(self, handler) + self._processMap["configure"] = Processor.process_configure self._processMap["create_database"] = Processor.process_create_database self._processMap["get_database"] = Processor.process_get_database self._processMap["drop_database"] = Processor.process_drop_database @@ -5014,6 +5055,20 @@ def process(self, iprot, oprot): self._processMap[name](self, seqid, iprot, oprot) return True + def process_configure(self, seqid, iprot, oprot): + args = configure_args() + args.read(iprot) + iprot.readMessageEnd() + result = configure_result() + try: + self._handler.configure(args.key, args.value) + except MetaException as o1: + result.o1 = o1 + oprot.writeMessageBegin("configure", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + def process_create_database(self, seqid, iprot, oprot): args = create_database_args() args.read(iprot) @@ -6772,6 +6827,139 @@ def process_show_compact(self, seqid, iprot, oprot): # HELPER FUNCTIONS AND STRUCTURES +class configure_args: + """ + Attributes: + - key + - value + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'key', None, None, ), # 1 + (2, TType.STRING, 'value', None, None, ), # 2 + ) + + def __init__(self, key=None, value=None,): + self.key = key + self.value = value + + 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.STRING: + self.key = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.value = iprot.readString(); + 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('configure_args') + if self.key is not None: + oprot.writeFieldBegin('key', TType.STRING, 1) + oprot.writeString(self.key) + oprot.writeFieldEnd() + if self.value is not None: + oprot.writeFieldBegin('value', TType.STRING, 2) + oprot.writeString(self.value) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + 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 configure_result: + """ + Attributes: + - o1 + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'o1', (MetaException, MetaException.thrift_spec), None, ), # 1 + ) + + def __init__(self, o1=None,): + self.o1 = o1 + + 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.o1 = MetaException() + self.o1.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('configure_result') + if self.o1 is not None: + oprot.writeFieldBegin('o1', TType.STRUCT, 1) + self.o1.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + 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 create_database_args: """ Attributes: diff --git metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb index 70b1418..4ff79f6 100644 --- metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb +++ metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb @@ -12,6 +12,21 @@ module ThriftHiveMetastore class Client < ::FacebookService::Client include ::Thrift::Client + def configure(key, value) + send_configure(key, value) + recv_configure() + end + + def send_configure(key, value) + send_message('configure', Configure_args, :key => key, :value => value) + end + + def recv_configure() + result = receive_message(Configure_result) + raise result.o1 unless result.o1.nil? + return + end + def create_database(database) send_create_database(database) recv_create_database() @@ -1864,6 +1879,17 @@ module ThriftHiveMetastore class Processor < ::FacebookService::Processor include ::Thrift::Processor + def process_configure(seqid, iprot, oprot) + args = read_args(iprot, Configure_args) + result = Configure_result.new() + begin + @handler.configure(args.key, args.value) + rescue ::MetaException => o1 + result.o1 = o1 + end + write_result(result, oprot, 'configure', seqid) + end + def process_create_database(seqid, iprot, oprot) args = read_args(iprot, Create_database_args) result = Create_database_result.new() @@ -3286,6 +3312,40 @@ module ThriftHiveMetastore # HELPER FUNCTIONS AND STRUCTURES + class Configure_args + include ::Thrift::Struct, ::Thrift::Struct_Union + KEY = 1 + VALUE = 2 + + FIELDS = { + KEY => {:type => ::Thrift::Types::STRING, :name => 'key'}, + VALUE => {:type => ::Thrift::Types::STRING, :name => 'value'} + } + + def struct_fields; FIELDS; end + + def validate + end + + ::Thrift::Struct.generate_accessors self + end + + class Configure_result + include ::Thrift::Struct, ::Thrift::Struct_Union + O1 = 1 + + FIELDS = { + O1 => {:type => ::Thrift::Types::STRUCT, :name => 'o1', :class => ::MetaException} + } + + def struct_fields; FIELDS; end + + def validate + end + + ::Thrift::Struct.generate_accessors self + end + class Create_database_args include ::Thrift::Struct, ::Thrift::Struct_Union DATABASE = 1 diff --git metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index ff282c5..6212004 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -142,6 +142,7 @@ import org.apache.hadoop.hive.metastore.events.AddPartitionEvent; import org.apache.hadoop.hive.metastore.events.AlterPartitionEvent; import org.apache.hadoop.hive.metastore.events.AlterTableEvent; +import org.apache.hadoop.hive.metastore.events.ConfigChangeEvent; import org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent; import org.apache.hadoop.hive.metastore.events.CreateTableEvent; import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent; @@ -348,15 +349,19 @@ public static Integer get() { } public HMSHandler(String name) throws MetaException { - super(name); - hiveConf = new HiveConf(this.getClass()); - init(); + this(name, new HiveConf(HMSHandler.class), true); } public HMSHandler(String name, HiveConf conf) throws MetaException { + this(name, conf, true); + } + + public HMSHandler(String name, HiveConf conf, boolean init) throws MetaException { super(name); hiveConf = conf; - init(); + if (init) { + init(); + } } public HiveConf getHiveConf() { @@ -378,7 +383,7 @@ public HiveConf getHiveConf() { } } - private boolean init() throws MetaException { + public void init() throws MetaException { rawStoreClassName = hiveConf.getVar(HiveConf.ConfVars.METASTORE_RAW_STORE_IMPL); initListeners = MetaStoreUtils.getMetaStoreListeners( MetaStoreInitListener.class, hiveConf, @@ -436,7 +441,6 @@ private boolean init() throws MetaException { Timer cleaner = new Timer("Metastore Events Cleaner Thread", true); cleaner.schedule(new EventCleanerTask(this), cleanFreq, cleanFreq); } - return true; } private String addPrefix(String s) { @@ -448,10 +452,11 @@ public void setConf(Configuration conf) { threadLocalConf.set(conf); RawStore ms = threadLocalMS.get(); if (ms != null) { - ms.setConf(conf); + ms.setConf(conf); // reload if DS related configuration is changed } } + @Override public Configuration getConf() { Configuration conf = threadLocalConf.get(); if (conf == null) { @@ -465,6 +470,25 @@ public Warehouse getWh() { return wh; } + public void configure(String key, String value) throws MetaException { + ConfVars confVar = HiveConf.getMetaConf(key); + if (confVar == null) { + throw new MetaException("Invalid configuration key " + key); + } + String validate = confVar.validate(value); + if (validate != null) { + throw new MetaException("Invalid configuration value " + value + " for key " + key + + " by " + validate); + } + Configuration configuration = getConf(); + String oldValue = configuration.get(key); + configuration.set(key, value); + + for (MetaStoreEventListener listener : listeners) { + listener.onConfigChange(new ConfigChangeEvent(this, key, oldValue, value)); + } + } + /** * Get a cached RawStore. * @@ -676,8 +700,11 @@ public void shutdown() { logInfo("Shutting down the object store..."); RawStore ms = threadLocalMS.get(); if (ms != null) { - ms.shutdown(); - threadLocalMS.remove(); + try { + ms.shutdown(); + } finally { + threadLocalMS.remove(); + } } logInfo("Metastore shutdown complete."); } @@ -4999,9 +5026,13 @@ public AggrStats get_aggr_stats_for(PartitionsStatsRequest request) } public static IHMSHandler newHMSHandler(String name, HiveConf hiveConf) throws MetaException { - return RetryingHMSHandler.getProxy(hiveConf, name); + return newHMSHandler(name, hiveConf, false); } + public static IHMSHandler newHMSHandler(String name, HiveConf hiveConf, boolean local) + throws MetaException { + return RetryingHMSHandler.getProxy(hiveConf, name, local); + } /** * Discard a current delegation token. diff --git metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index 85a77d9..0575ff4 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -173,7 +173,7 @@ public HiveMetaStoreClient(HiveConf conf, HiveMetaHookLoader hookLoader) if (localMetaStore) { // instantiate the metastore server handler directly instead of connecting // through the network - client = HiveMetaStore.newHMSHandler("hive client", conf); + client = HiveMetaStore.newHMSHandler("hive client", conf, true); isConnected = true; snapshotActiveConf(); return; @@ -443,6 +443,11 @@ public void close() { } } + @Override + public void configure(String key, String value) throws TException { + client.configure(key, value); + } + /** * @param new_part * @return the added partition diff --git metastore/src/java/org/apache/hadoop/hive/metastore/IHMSHandler.java metastore/src/java/org/apache/hadoop/hive/metastore/IHMSHandler.java index 1675751..cc7ae1d 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/IHMSHandler.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/IHMSHandler.java @@ -18,10 +18,11 @@ package org.apache.hadoop.hive.metastore; -import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.conf.Configurable; +import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore; -public interface IHMSHandler extends ThriftHiveMetastore.Iface { +public interface IHMSHandler extends ThriftHiveMetastore.Iface, Configurable { - public abstract void setConf(Configuration conf); + void init() throws MetaException; } diff --git metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java index 8746c37..7566f1b 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java @@ -80,14 +80,16 @@ * Returns whether current client is convertible with conf or not * @return */ - public boolean isCompatibleWith(HiveConf conf); + boolean isCompatibleWith(HiveConf conf); /** * Tries to reconnect this MetaStoreClient to the MetaStore. */ - public void reconnect() throws MetaException; + void reconnect() throws MetaException; - public void close(); + void close(); + + void configure(String key, String value) throws MetaException, TException; /** * Get the names of all databases in the MetaStore that match the given pattern. @@ -96,8 +98,7 @@ * @throws MetaException * @throws TException */ - public List getDatabases(String databasePattern) - throws MetaException, TException; + List getDatabases(String databasePattern) throws MetaException, TException; /** * Get the names of all databases in the MetaStore. @@ -105,8 +106,7 @@ * @throws MetaException * @throws TException */ - public List getAllDatabases() - throws MetaException, TException; + List getAllDatabases() throws MetaException, TException; /** * Get the names of all tables in the specified database that satisfy the supplied @@ -118,7 +118,7 @@ * @throws TException * @throws UnknownDBException */ - public List getTables(String dbName, String tablePattern) + List getTables(String dbName, String tablePattern) throws MetaException, TException, UnknownDBException; /** @@ -129,8 +129,7 @@ * @throws TException * @throws UnknownDBException */ - public List getAllTables(String dbName) - throws MetaException, TException, UnknownDBException; + List getAllTables(String dbName) throws MetaException, TException, UnknownDBException; /** * Get a list of table names that match a filter. @@ -168,7 +167,7 @@ * The maximum number of tables returned * @return A list of table names that match the desired filter */ - public List listTableNamesByFilter(String dbName, String filter, short maxTables) + List listTableNamesByFilter(String dbName, String filter, short maxTables) throws MetaException, TException, InvalidOperationException, UnknownDBException; @@ -186,7 +185,7 @@ * @throws TException * A thrift communication error occurred */ - public void dropTable(String dbname, String tableName, boolean deleteData, + void dropTable(String dbname, String tableName, boolean deleteData, boolean ignoreUknownTab) throws MetaException, TException, NoSuchObjectException; @@ -210,14 +209,13 @@ public void dropTable(String dbname, String tableName, boolean deleteData, * This method will be removed in release 0.7.0. */ @Deprecated - public void dropTable(String tableName, boolean deleteData) - throws MetaException, UnknownTableException, TException, - NoSuchObjectException; + void dropTable(String tableName, boolean deleteData) + throws MetaException, UnknownTableException, TException, NoSuchObjectException; - public void dropTable(String dbname, String tableName) + void dropTable(String dbname, String tableName) throws MetaException, TException, NoSuchObjectException; - public boolean tableExists(String databaseName, String tableName) throws MetaException, + boolean tableExists(String databaseName, String tableName) throws MetaException, TException, UnknownDBException; /** @@ -231,7 +229,7 @@ public boolean tableExists(String databaseName, String tableName) throws MetaExc * This method will be removed in release 0.7.0. */ @Deprecated - public boolean tableExists(String tableName) throws MetaException, + boolean tableExists(String tableName) throws MetaException, TException, UnknownDBException; /** @@ -250,8 +248,7 @@ public boolean tableExists(String tableName) throws MetaException, * This method will be removed in release 0.7.0. */ @Deprecated - public Table getTable(String tableName) throws MetaException, TException, - NoSuchObjectException; + Table getTable(String tableName) throws MetaException, TException, NoSuchObjectException; /** * Get a Database Object @@ -261,8 +258,8 @@ public Table getTable(String tableName) throws MetaException, TException, * @throws MetaException Could not fetch the database * @throws TException A thrift communication error occurred */ - public Database getDatabase(String databaseName) - throws NoSuchObjectException, MetaException, TException; + Database getDatabase(String databaseName) + throws NoSuchObjectException, MetaException, TException; /** @@ -280,7 +277,7 @@ public Database getDatabase(String databaseName) * @throws NoSuchObjectException * In case the table wasn't found. */ - public Table getTable(String dbName, String tableName) throws MetaException, + Table getTable(String dbName, String tableName) throws MetaException, TException, NoSuchObjectException; /** @@ -302,7 +299,7 @@ public Table getTable(String dbName, String tableName) throws MetaException, * @throws MetaException * Any other errors */ - public List getTableObjectsByName(String dbName, List tableNames) + List
getTableObjectsByName(String dbName, List tableNames) throws MetaException, InvalidOperationException, UnknownDBException, TException; /** @@ -317,11 +314,11 @@ public Table getTable(String dbName, String tableName) throws MetaException, * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#append_partition(java.lang.String, * java.lang.String, java.util.List) */ - public Partition appendPartition(String tableName, String dbName, + Partition appendPartition(String tableName, String dbName, List partVals) throws InvalidObjectException, AlreadyExistsException, MetaException, TException; - public Partition appendPartition(String tableName, String dbName, String name) + Partition appendPartition(String tableName, String dbName, String name) throws InvalidObjectException, AlreadyExistsException, MetaException, TException; /** @@ -339,9 +336,8 @@ public Partition appendPartition(String tableName, String dbName, String name) * @throws TException * Thrift exception */ - public Partition add_partition(Partition partition) - throws InvalidObjectException, AlreadyExistsException, MetaException, - TException; + Partition add_partition(Partition partition) + throws InvalidObjectException, AlreadyExistsException, MetaException, TException; /** * Add partitions to the table. @@ -357,7 +353,7 @@ public Partition add_partition(Partition partition) * @throws TException * Thrift exception */ - public int add_partitions(List partitions) + int add_partitions(List partitions) throws InvalidObjectException, AlreadyExistsException, MetaException, TException; /** @@ -368,7 +364,7 @@ public int add_partitions(List partitions) * @param needResults Whether the results are needed * @return the partitions that were added, or null if !needResults */ - public List add_partitions( + List add_partitions( List partitions, boolean ifNotExists, boolean needResults) throws InvalidObjectException, AlreadyExistsException, MetaException, TException; @@ -382,7 +378,7 @@ public int add_partitions(List partitions) * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#get_partition(java.lang.String, * java.lang.String, java.util.List) */ - public Partition getPartition(String tblName, String dbName, + Partition getPartition(String tblName, String dbName, List partVals) throws NoSuchObjectException, MetaException, TException; /** @@ -393,7 +389,7 @@ public Partition getPartition(String tblName, String dbName, * @param destTableName * @return partition object */ - public Partition exchange_partition(Map partitionSpecs, + Partition exchange_partition(Map partitionSpecs, String sourceDb, String sourceTable, String destdb, String destTableName) throws MetaException, NoSuchObjectException, InvalidObjectException, TException; @@ -408,7 +404,7 @@ public Partition exchange_partition(Map partitionSpecs, * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#get_partition(java.lang.String, * java.lang.String, java.util.List) */ - public Partition getPartition(String dbName, String tblName, + Partition getPartition(String dbName, String tblName, String name) throws MetaException, UnknownTableException, NoSuchObjectException, TException; @@ -424,7 +420,7 @@ public Partition getPartition(String dbName, String tblName, * @throws NoSuchObjectException * @throws TException */ - public Partition getPartitionWithAuthInfo(String dbName, String tableName, + Partition getPartitionWithAuthInfo(String dbName, String tableName, List pvals, String userName, List groupNames) throws MetaException, UnknownTableException, NoSuchObjectException, TException; @@ -437,16 +433,16 @@ public Partition getPartitionWithAuthInfo(String dbName, String tableName, * @throws MetaException * @throws TException */ - public List listPartitions(String db_name, String tbl_name, + List listPartitions(String db_name, String tbl_name, short max_parts) throws NoSuchObjectException, MetaException, TException; - public List listPartitions(String db_name, String tbl_name, + List listPartitions(String db_name, String tbl_name, List part_vals, short max_parts) throws NoSuchObjectException, MetaException, TException; - public List listPartitionNames(String db_name, String tbl_name, + List listPartitionNames(String db_name, String tbl_name, short max_parts) throws MetaException, TException; - public List listPartitionNames(String db_name, String tbl_name, + List listPartitionNames(String db_name, String tbl_name, List part_vals, short max_parts) throws MetaException, TException, NoSuchObjectException; @@ -464,7 +460,7 @@ public Partition getPartitionWithAuthInfo(String dbName, String tableName, * @throws NoSuchObjectException * @throws TException */ - public List listPartitionsByFilter(String db_name, String tbl_name, + List listPartitionsByFilter(String db_name, String tbl_name, String filter, short max_parts) throws MetaException, NoSuchObjectException, TException; @@ -481,7 +477,7 @@ public Partition getPartitionWithAuthInfo(String dbName, String tableName, * @param result the resulting list of partitions * @return whether the resulting list contains partitions which may or may not match the expr */ - public boolean listPartitionsByExpr(String db_name, String tbl_name, + boolean listPartitionsByExpr(String db_name, String tbl_name, byte[] expr, String default_partition_name, short max_parts, List result) throws TException; @@ -494,7 +490,7 @@ public boolean listPartitionsByExpr(String db_name, String tbl_name, * @return the list of partitions * @throws NoSuchObjectException */ - public List listPartitionsWithAuthInfo(String dbName, + List listPartitionsWithAuthInfo(String dbName, String tableName, short s, String userName, List groupNames) throws MetaException, TException, NoSuchObjectException; @@ -508,7 +504,7 @@ public boolean listPartitionsByExpr(String db_name, String tbl_name, * @throws MetaException * @throws TException */ - public List getPartitionsByNames(String db_name, String tbl_name, + List getPartitionsByNames(String db_name, String tbl_name, List part_names) throws NoSuchObjectException, MetaException, TException; /** @@ -521,7 +517,7 @@ public boolean listPartitionsByExpr(String db_name, String tbl_name, * @return the list of paritions * @throws NoSuchObjectException */ - public List listPartitionsWithAuthInfo(String dbName, + List listPartitionsWithAuthInfo(String dbName, String tableName, List partialPvals, short s, String userName, List groupNames) throws MetaException, TException, NoSuchObjectException; @@ -538,7 +534,7 @@ public boolean listPartitionsByExpr(String db_name, String tbl_name, * @throws UnknownPartitionException * @throws InvalidPartitionException */ - public void markPartitionForEvent(String db_name, String tbl_name, Map partKVs, + void markPartitionForEvent(String db_name, String tbl_name, Map partKVs, PartitionEventType eventType) throws MetaException, NoSuchObjectException, TException, UnknownTableException, UnknownDBException, UnknownPartitionException, InvalidPartitionException; @@ -555,7 +551,7 @@ public void markPartitionForEvent(String db_name, String tbl_name, Map partKVs, + boolean isPartitionMarkedForEvent(String db_name, String tbl_name, Map partKVs, PartitionEventType eventType) throws MetaException, NoSuchObjectException, TException, UnknownTableException, UnknownDBException, UnknownPartitionException, InvalidPartitionException; @@ -564,9 +560,7 @@ public boolean isPartitionMarkedForEvent(String db_name, String tbl_name, Map partVals) - throws TException, MetaException; - + void validatePartitionNameCharacters(List partVals) throws TException, MetaException; /** * @param tbl @@ -578,25 +572,25 @@ public void validatePartitionNameCharacters(List partVals) * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#create_table(org.apache.hadoop.hive.metastore.api.Table) */ - public void createTable(Table tbl) throws AlreadyExistsException, + void createTable(Table tbl) throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException, TException; - public void alter_table(String defaultDatabaseName, String tblName, + void alter_table(String defaultDatabaseName, String tblName, Table table) throws InvalidOperationException, MetaException, TException; - public void createDatabase(Database db) + void createDatabase(Database db) throws InvalidObjectException, AlreadyExistsException, MetaException, TException; - public void dropDatabase(String name) + void dropDatabase(String name) throws NoSuchObjectException, InvalidOperationException, MetaException, TException; - public void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb) + void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb) throws NoSuchObjectException, InvalidOperationException, MetaException, TException; - public void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb, boolean cascade) + void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb, boolean cascade) throws NoSuchObjectException, InvalidOperationException, MetaException, TException; - public void alterDatabase(String name, Database db) + void alterDatabase(String name, Database db) throws NoSuchObjectException, MetaException, TException; /** @@ -612,7 +606,7 @@ public void alterDatabase(String name, Database db) * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#drop_partition(java.lang.String, * java.lang.String, java.util.List, boolean) */ - public boolean dropPartition(String db_name, String tbl_name, + boolean dropPartition(String db_name, String tbl_name, List part_vals, boolean deleteData) throws NoSuchObjectException, MetaException, TException; @@ -620,7 +614,7 @@ public boolean dropPartition(String db_name, String tbl_name, List> partExprs, boolean deleteData, boolean ignoreProtection, boolean ifExists) throws NoSuchObjectException, MetaException, TException; - public boolean dropPartition(String db_name, String tbl_name, + boolean dropPartition(String db_name, String tbl_name, String name, boolean deleteData) throws NoSuchObjectException, MetaException, TException; /** @@ -639,7 +633,7 @@ public boolean dropPartition(String db_name, String tbl_name, * @throws TException * if error in communicating with metastore server */ - public void alter_partition(String dbName, String tblName, Partition newPart) + void alter_partition(String dbName, String tblName, Partition newPart) throws InvalidOperationException, MetaException, TException; /** @@ -658,7 +652,7 @@ public void alter_partition(String dbName, String tblName, Partition newPart) * @throws TException * if error in communicating with metastore server */ - public void alter_partitions(String dbName, String tblName, List newParts) + void alter_partitions(String dbName, String tblName, List newParts) throws InvalidOperationException, MetaException, TException; /** @@ -679,7 +673,7 @@ public void alter_partitions(String dbName, String tblName, List newP * @throws TException * if error in communicating with metastore server */ - public void renamePartition(final String dbname, final String name, final List part_vals, final Partition newPart) + void renamePartition(final String dbname, final String name, final List part_vals, final Partition newPart) throws InvalidOperationException, MetaException, TException; /** @@ -692,7 +686,7 @@ public void renamePartition(final String dbname, final String name, final List getFields(String db, String tableName) + List getFields(String db, String tableName) throws MetaException, TException, UnknownTableException, UnknownDBException; @@ -706,7 +700,7 @@ public void renamePartition(final String dbname, final String name, final List getSchema(String db, String tableName) + List getSchema(String db, String tableName) throws MetaException, TException, UnknownTableException, UnknownDBException; @@ -719,7 +713,7 @@ public void renamePartition(final String dbname, final String name, final List partitionNameToVals(String name) + List partitionNameToVals(String name) throws MetaException, TException; /** * @@ -740,7 +734,7 @@ public String getConfigValue(String name, String defaultValue) * @throws MetaException * @throws TException */ - public Map partitionNameToSpec(String name) + Map partitionNameToSpec(String name) throws MetaException, TException; /** @@ -752,10 +746,10 @@ public String getConfigValue(String name, String defaultValue) * @throws TException * @throws AlreadyExistsException */ - public void createIndex(Index index, Table indexTable) throws InvalidObjectException, + void createIndex(Index index, Table indexTable) throws InvalidObjectException, MetaException, NoSuchObjectException, TException, AlreadyExistsException; - public void alter_index(String dbName, String tblName, String indexName, + void alter_index(String dbName, String tblName, String indexName, Index index) throws InvalidOperationException, MetaException, TException; /** @@ -769,7 +763,7 @@ public void alter_index(String dbName, String tblName, String indexName, * @throws NoSuchObjectException * @throws TException */ - public Index getIndex(String dbName, String tblName, String indexName) + Index getIndex(String dbName, String tblName, String indexName) throws MetaException, UnknownTableException, NoSuchObjectException, TException; @@ -784,7 +778,7 @@ public Index getIndex(String dbName, String tblName, String indexName) * @throws MetaException * @throws TException */ - public List listIndexes(String db_name, String tbl_name, + List listIndexes(String db_name, String tbl_name, short max) throws NoSuchObjectException, MetaException, TException; /** @@ -797,7 +791,7 @@ public Index getIndex(String dbName, String tblName, String indexName) * @throws MetaException * @throws TException */ - public List listIndexNames(String db_name, String tbl_name, + List listIndexNames(String db_name, String tbl_name, short max) throws MetaException, TException; /** @@ -810,7 +804,7 @@ public Index getIndex(String dbName, String tblName, String indexName) * @throws MetaException * @throws TException */ - public boolean dropIndex(String db_name, String tbl_name, + boolean dropIndex(String db_name, String tbl_name, String name, boolean deleteData) throws NoSuchObjectException, MetaException, TException; @@ -825,7 +819,7 @@ public boolean dropIndex(String db_name, String tbl_name, * @throws InvalidInputException */ - public boolean updateTableColumnStatistics(ColumnStatistics statsObj) + boolean updateTableColumnStatistics(ColumnStatistics statsObj) throws NoSuchObjectException, InvalidObjectException, MetaException, TException, InvalidInputException; @@ -840,7 +834,7 @@ public boolean updateTableColumnStatistics(ColumnStatistics statsObj) * @throws InvalidInputException */ - public boolean updatePartitionColumnStatistics(ColumnStatistics statsObj) + boolean updatePartitionColumnStatistics(ColumnStatistics statsObj) throws NoSuchObjectException, InvalidObjectException, MetaException, TException, InvalidInputException; @@ -848,14 +842,14 @@ public boolean updatePartitionColumnStatistics(ColumnStatistics statsObj) * Get table column statistics given dbName, tableName and multiple colName-s * @return ColumnStatistics struct for a given db, table and columns */ - public List getTableColumnStatistics(String dbName, String tableName, + List getTableColumnStatistics(String dbName, String tableName, List colNames) throws NoSuchObjectException, MetaException, TException; /** * Get partitions column statistics given dbName, tableName, multiple partitions and colName-s * @return ColumnStatistics struct for a given db, table and columns */ - public Map> getPartitionColumnStatistics(String dbName, + Map> getPartitionColumnStatistics(String dbName, String tableName, List partNames, List colNames) throws NoSuchObjectException, MetaException, TException; @@ -873,24 +867,23 @@ public boolean updatePartitionColumnStatistics(ColumnStatistics statsObj) * @throws InvalidInputException */ - public boolean deletePartitionColumnStatistics(String dbName, String tableName, + boolean deletePartitionColumnStatistics(String dbName, String tableName, String partName, String colName) throws NoSuchObjectException, MetaException, InvalidObjectException, TException, InvalidInputException; - /** - * Delete table level column statistics given dbName, tableName and colName - * @param dbName - * @param tableName - * @param colName - * @return boolean indicating the outcome of the operation - * @throws NoSuchObjectException - * @throws MetaException - * @throws InvalidObjectException - * @throws TException - * @throws InvalidInputException - */ - - public boolean deleteTableColumnStatistics(String dbName, String tableName, String colName) throws + /** + * Delete table level column statistics given dbName, tableName and colName + * @param dbName + * @param tableName + * @param colName + * @return boolean indicating the outcome of the operation + * @throws NoSuchObjectException + * @throws MetaException + * @throws InvalidObjectException + * @throws TException + * @throws InvalidInputException + */ + boolean deleteTableColumnStatistics(String dbName, String tableName, String colName) throws NoSuchObjectException, MetaException, InvalidObjectException, TException, InvalidInputException; /** @@ -900,7 +893,7 @@ public boolean deleteTableColumnStatistics(String dbName, String tableName, Stri * @throws MetaException * @throws TException */ - public boolean create_role(Role role) + boolean create_role(Role role) throws MetaException, TException; /** @@ -911,7 +904,7 @@ public boolean create_role(Role role) * @throws MetaException * @throws TException */ - public boolean drop_role(String role_name) throws MetaException, TException; + boolean drop_role(String role_name) throws MetaException, TException; /** * list all role names @@ -919,7 +912,7 @@ public boolean create_role(Role role) * @throws TException * @throws MetaException */ - public List listRoleNames() throws MetaException, TException; + List listRoleNames() throws MetaException, TException; /** * @@ -933,7 +926,7 @@ public boolean create_role(Role role) * @throws MetaException * @throws TException */ - public boolean grant_role(String role_name, String user_name, + boolean grant_role(String role_name, String user_name, PrincipalType principalType, String grantor, PrincipalType grantorType, boolean grantOption) throws MetaException, TException; @@ -948,7 +941,7 @@ public boolean grant_role(String role_name, String user_name, * @throws MetaException * @throws TException */ - public boolean revoke_role(String role_name, String user_name, + boolean revoke_role(String role_name, String user_name, PrincipalType principalType, boolean grantOption) throws MetaException, TException; /** @@ -959,7 +952,7 @@ public boolean revoke_role(String role_name, String user_name, * @throws MetaException * @throws TException */ - public List list_roles(String principalName, PrincipalType principalType) + List list_roles(String principalName, PrincipalType principalType) throws MetaException, TException; /** @@ -972,7 +965,7 @@ public boolean revoke_role(String role_name, String user_name, * @throws MetaException * @throws TException */ - public PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, + PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, String user_name, List group_names) throws MetaException, TException; @@ -985,7 +978,7 @@ public PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, * @throws MetaException * @throws TException */ - public List list_privileges(String principal_name, + List list_privileges(String principal_name, PrincipalType principal_type, HiveObjectRef hiveObject) throws MetaException, TException; @@ -995,7 +988,7 @@ public PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, * @throws MetaException * @throws TException */ - public boolean grant_privileges(PrivilegeBag privileges) + boolean grant_privileges(PrivilegeBag privileges) throws MetaException, TException; /** @@ -1004,7 +997,7 @@ public boolean grant_privileges(PrivilegeBag privileges) * @throws MetaException * @throws TException */ - public boolean revoke_privileges(PrivilegeBag privileges, boolean grantOption) + boolean revoke_privileges(PrivilegeBag privileges, boolean grantOption) throws MetaException, TException; /** @@ -1014,7 +1007,7 @@ public boolean revoke_privileges(PrivilegeBag privileges, boolean grantOption) * @throws MetaException * @throws TException */ - public String getDelegationToken(String owner, String renewerKerberosPrincipalName) + String getDelegationToken(String owner, String renewerKerberosPrincipalName) throws MetaException, TException; /** @@ -1023,28 +1016,28 @@ public String getDelegationToken(String owner, String renewerKerberosPrincipalNa * @throws MetaException * @throws TException */ - public long renewDelegationToken(String tokenStrForm) throws MetaException, TException; + long renewDelegationToken(String tokenStrForm) throws MetaException, TException; /** * @param tokenStrForm * @throws MetaException * @throws TException */ - public void cancelDelegationToken(String tokenStrForm) throws MetaException, TException; + void cancelDelegationToken(String tokenStrForm) throws MetaException, TException; - public void createFunction(Function func) + void createFunction(Function func) throws InvalidObjectException, MetaException, TException; - public void alterFunction(String dbName, String funcName, Function newFunction) + void alterFunction(String dbName, String funcName, Function newFunction) throws InvalidObjectException, MetaException, TException; - public void dropFunction(String dbName, String funcName) throws MetaException, + void dropFunction(String dbName, String funcName) throws MetaException, NoSuchObjectException, InvalidObjectException, InvalidInputException, TException; - public Function getFunction(String dbName, String funcName) + Function getFunction(String dbName, String funcName) throws MetaException, TException; - public List getFunctions(String dbName, String pattern) + List getFunctions(String dbName, String pattern) throws MetaException, TException; /** @@ -1052,7 +1045,7 @@ public Function getFunction(String dbName, String funcName) * @return list of valid transactions * @throws TException */ - public ValidTxnList getValidTxns() throws TException; + ValidTxnList getValidTxns() throws TException; /** * Initiate a transaction. @@ -1062,7 +1055,7 @@ public Function getFunction(String dbName, String funcName) * @return transaction identifier * @throws TException */ - public long openTxn(String user) throws TException; + long openTxn(String user) throws TException; /** * Initiate a batch of transactions. It is not guaranteed that the @@ -1089,7 +1082,7 @@ public Function getFunction(String dbName, String funcName) * optimistically assuming that the result matches the request. * @throws TException */ - public OpenTxnsResponse openTxns(String user, int numTxns) throws TException; + OpenTxnsResponse openTxns(String user, int numTxns) throws TException; /** * Rollback a transaction. This will also unlock any locks associated with @@ -1100,7 +1093,7 @@ public Function getFunction(String dbName, String funcName) * deleted. * @throws TException */ - public void rollbackTxn(long txnid) throws NoSuchTxnException, TException; + void rollbackTxn(long txnid) throws NoSuchTxnException, TException; /** * Commit a transaction. This will also unlock any locks associated with @@ -1113,7 +1106,7 @@ public Function getFunction(String dbName, String funcName) * aborted. This can result from the transaction timing out. * @throws TException */ - public void commitTxn(long txnid) + void commitTxn(long txnid) throws NoSuchTxnException, TxnAbortedException, TException; /** @@ -1123,7 +1116,7 @@ public void commitTxn(long txnid) * @return List of currently opened transactions, included aborted ones. * @throws TException */ - public GetOpenTxnsInfoResponse showTxns() throws TException; + GetOpenTxnsInfoResponse showTxns() throws TException; /** * Request a set of locks. All locks needed for a particular query, DML, @@ -1153,7 +1146,7 @@ public void commitTxn(long txnid) * aborted. This can result from the transaction timing out. * @throws TException */ - public LockResponse lock(LockRequest request) + LockResponse lock(LockRequest request) throws NoSuchTxnException, TxnAbortedException, TException; /** @@ -1177,7 +1170,7 @@ public LockResponse lock(LockRequest request) * This can result from the lock timing out and being unlocked by the system. * @throws TException */ - public LockResponse checkLock(long lockid) + LockResponse checkLock(long lockid) throws NoSuchTxnException, TxnAbortedException, NoSuchLockException, TException; @@ -1192,7 +1185,7 @@ public LockResponse checkLock(long lockid) * transaction. * @throws TException */ - public void unlock(long lockid) + void unlock(long lockid) throws NoSuchLockException, TxnOpenException, TException; /** @@ -1200,7 +1193,7 @@ public void unlock(long lockid) * @return List of currently held and waiting locks. * @throws TException */ - public ShowLocksResponse showLocks() throws TException; + ShowLocksResponse showLocks() throws TException; /** * Send a heartbeat to indicate that the client holding these locks (if @@ -1222,7 +1215,7 @@ public void unlock(long lockid) * This can result from the lock timing out and being unlocked by the system. * @throws TException */ - public void heartbeat(long txnid, long lockid) + void heartbeat(long txnid, long lockid) throws NoSuchLockException, NoSuchTxnException, TxnAbortedException, TException; @@ -1236,7 +1229,7 @@ public void heartbeat(long txnid, long lockid) * have already been closed) and which were aborted. * @throws TException */ - public HeartbeatTxnRangeResponse heartbeatTxnRange(long min, long max) throws TException; + HeartbeatTxnRangeResponse heartbeatTxnRange(long min, long max) throws TException; /** * Send a request to compact a table or partition. This will not block until the compaction is @@ -1251,7 +1244,7 @@ public void heartbeat(long txnid, long lockid) * @param type Whether this is a major or minor compaction. * @throws TException */ - public void compact(String dbname, String tableName, String partitionName, CompactionType type) + void compact(String dbname, String tableName, String partitionName, CompactionType type) throws TException; /** @@ -1260,10 +1253,10 @@ public void compact(String dbname, String tableName, String partitionName, Comp * in progress, and finished but waiting to clean the existing files. * @throws TException */ - public ShowCompactResponse showCompactions() throws TException; + ShowCompactResponse showCompactions() throws TException; - public class IncompatibleMetastoreException extends MetaException { - public IncompatibleMetastoreException(String message) { + class IncompatibleMetastoreException extends MetaException { + IncompatibleMetastoreException(String message) { super(message); } } diff --git metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java index c28c46a..ec1dca2 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java @@ -24,6 +24,7 @@ import org.apache.hadoop.hive.metastore.events.AddPartitionEvent; import org.apache.hadoop.hive.metastore.events.AlterPartitionEvent; import org.apache.hadoop.hive.metastore.events.AlterTableEvent; +import org.apache.hadoop.hive.metastore.events.ConfigChangeEvent; import org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent; import org.apache.hadoop.hive.metastore.events.CreateTableEvent; import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent; @@ -50,6 +51,13 @@ public MetaStoreEventListener(Configuration config){ * @param tableEvent table event. * @throws MetaException */ + public void onConfigChange(ConfigChangeEvent tableEvent) throws MetaException { + } + + /** + * @param tableEvent table event. + * @throws MetaException + */ public void onCreateTable (CreateTableEvent tableEvent) throws MetaException { } diff --git metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java index 86172b9..84e6dcd 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java @@ -43,44 +43,40 @@ private final IHMSHandler base; private final MetaStoreInit.MetaStoreInitData metaStoreInitData = new MetaStoreInit.MetaStoreInitData(); - private final HiveConf hiveConf; - protected RetryingHMSHandler(final HiveConf hiveConf, final String name) throws MetaException { + private final HiveConf hiveConf; // base configuration + private final Configuration configuration; // active configuration + + private RetryingHMSHandler(HiveConf hiveConf, String name, boolean local) throws MetaException { this.hiveConf = hiveConf; + this.base = new HiveMetaStore.HMSHandler(name, hiveConf, false); + if (local) { + base.setConf(hiveConf); // tests expect configuration changes applied directly to metastore + } + configuration = base.getConf(); // This has to be called before initializing the instance of HMSHandler - init(); + // Using the hook on startup ensures that the hook always has priority + // over settings in *.xml. The thread local conf needs to be used because at this point + // it has already been initialized using hiveConf. + MetaStoreInit.updateConnectionURL(hiveConf, getConf(), null, metaStoreInitData); - this.base = new HiveMetaStore.HMSHandler(name, hiveConf); + base.init(); } - public static IHMSHandler getProxy(HiveConf hiveConf, String name) throws MetaException { + public static IHMSHandler getProxy(HiveConf hiveConf, String name, boolean local) + throws MetaException { - RetryingHMSHandler handler = new RetryingHMSHandler(hiveConf, name); + RetryingHMSHandler handler = new RetryingHMSHandler(hiveConf, name, local); return (IHMSHandler) Proxy.newProxyInstance( RetryingHMSHandler.class.getClassLoader(), new Class[] { IHMSHandler.class }, handler); } - private void init() throws MetaException { - // Using the hook on startup ensures that the hook always has priority - // over settings in *.xml. The thread local conf needs to be used because at this point - // it has already been initialized using hiveConf. - MetaStoreInit.updateConnectionURL(hiveConf, getConf(), null, metaStoreInitData); - - } - - private void initMS() { - base.setConf(getConf()); - } - - @Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { - Object ret = null; - boolean gotNewConnectUrl = false; boolean reloadConf = HiveConf.getBoolVar(hiveConf, HiveConf.ConfVars.HMSHANDLERFORCERELOADCONF); @@ -95,15 +91,14 @@ public Object invoke(final Object proxy, final Method method, final Object[] arg } int retryCount = 0; - // Exception caughtException = null; Throwable caughtException = null; while (true) { try { if (reloadConf || gotNewConnectUrl) { - initMS(); + base.setConf(getConf()); } - ret = method.invoke(base, args); - break; + return method.invoke(base, args); + } catch (javax.jdo.JDOException e) { caughtException = e; } catch (UndeclaredThrowableException e) { @@ -166,10 +161,9 @@ public Object invoke(final Object proxy, final Method method, final Object[] arg gotNewConnectUrl = MetaStoreInit.updateConnectionURL(hiveConf, getConf(), lastUrl, metaStoreInitData); } - return ret; } public Configuration getConf() { - return hiveConf; + return configuration; } } diff --git metastore/src/java/org/apache/hadoop/hive/metastore/events/ConfigChangeEvent.java metastore/src/java/org/apache/hadoop/hive/metastore/events/ConfigChangeEvent.java new file mode 100644 index 0000000..e06b960 --- /dev/null +++ metastore/src/java/org/apache/hadoop/hive/metastore/events/ConfigChangeEvent.java @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.hive.metastore.events; + +import org.apache.hadoop.hive.metastore.HiveMetaStore; + +public class ConfigChangeEvent extends ListenerEvent { + + private final String key; + private final String oldValue; + private final String newValue; + + public ConfigChangeEvent(HiveMetaStore.HMSHandler handler, String key, + String oldValue, String newValue) { + super(true, handler); + this.key = key; + this.oldValue = oldValue; + this.newValue = newValue; + } + + public String getKey() { + return key; + } + + public String getOldValue() { + return oldValue; + } + + public String getNewValue() { + return newValue; + } +} diff --git metastore/src/test/org/apache/hadoop/hive/metastore/DummyListener.java metastore/src/test/org/apache/hadoop/hive/metastore/DummyListener.java index 92f2388..37daf52 100644 --- metastore/src/test/org/apache/hadoop/hive/metastore/DummyListener.java +++ metastore/src/test/org/apache/hadoop/hive/metastore/DummyListener.java @@ -26,6 +26,7 @@ import org.apache.hadoop.hive.metastore.events.AddPartitionEvent; import org.apache.hadoop.hive.metastore.events.AlterPartitionEvent; import org.apache.hadoop.hive.metastore.events.AlterTableEvent; +import org.apache.hadoop.hive.metastore.events.ConfigChangeEvent; import org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent; import org.apache.hadoop.hive.metastore.events.CreateTableEvent; import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent; @@ -58,6 +59,11 @@ public DummyListener(Configuration config) { } @Override + public void onConfigChange(ConfigChangeEvent configChange) { + notifyList.add(configChange); + } + + @Override public void onAddPartition(AddPartitionEvent partition) throws MetaException { notifyList.add(partition); } diff --git ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java index ebf2443..451850d 100644 --- ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java +++ ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java @@ -2719,4 +2719,11 @@ public Function getFunction(String dbName, String funcName) throws HiveException } } + public void configure(String propName, String propValue) throws HiveException { + try { + getMSC().configure(propName, propValue); + } catch (TException te) { + throw new HiveException(te); + } + } }; diff --git ql/src/java/org/apache/hadoop/hive/ql/processors/SetProcessor.java ql/src/java/org/apache/hadoop/hive/ql/processors/SetProcessor.java index 2baa24a..2a455f0 100644 --- ql/src/java/org/apache/hadoop/hive/ql/processors/SetProcessor.java +++ ql/src/java/org/apache/hadoop/hive/ql/processors/SetProcessor.java @@ -32,6 +32,7 @@ import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.metastore.api.FieldSchema; import org.apache.hadoop.hive.metastore.api.Schema; +import org.apache.hadoop.hive.ql.metadata.Hive; import org.apache.hadoop.hive.ql.parse.VariableSubstitution; import org.apache.hadoop.hive.ql.session.SessionState; @@ -104,11 +105,12 @@ public CommandProcessorResponse executeSetVariable(String varname, String varval try { return new CommandProcessorResponse(setVariable(varname, varvalue)); } catch (Exception e) { - return new CommandProcessorResponse(1, e.getMessage(), "42000"); + return new CommandProcessorResponse(1, e.getMessage(), "42000", + e instanceof IllegalArgumentException ? null : e); } } - public static int setVariable(String varname, String varvalue) throws IllegalArgumentException { + public static int setVariable(String varname, String varvalue) throws Exception { SessionState ss = SessionState.get(); if (varvalue.contains("\n")){ ss.err.println("Warning: Value had a \\n character in it."); @@ -126,6 +128,10 @@ public static int setVariable(String varname, String varvalue) throws IllegalArg } else if (varname.startsWith(HIVEVAR_PREFIX)) { String propName = varname.substring(HIVEVAR_PREFIX.length()); ss.getHiveVariables().put(propName, new VariableSubstitution().substitute(ss.getConf(),varvalue)); + } else if (varname.startsWith(METACONF_PREFIX)) { + String propName = varname.substring(METACONF_PREFIX.length()); + Hive hive = Hive.get(ss.getConf()); + hive.configure(propName, new VariableSubstitution().substitute(ss.getConf(), varvalue)); } else { setConf(varname, varname, varvalue, true); } diff --git ql/src/test/queries/clientpositive/set_metaconf.q ql/src/test/queries/clientpositive/set_metaconf.q new file mode 100644 index 0000000..e69de29 diff --git service/src/java/org/apache/hive/service/cli/session/HiveSessionBase.java service/src/java/org/apache/hive/service/cli/session/HiveSessionBase.java index 4c3164e..eee1cc6 100644 --- service/src/java/org/apache/hive/service/cli/session/HiveSessionBase.java +++ service/src/java/org/apache/hive/service/cli/session/HiveSessionBase.java @@ -55,7 +55,7 @@ * Initialize the session * @param sessionConfMap */ - public void initialize(Map sessionConfMap); + public void initialize(Map sessionConfMap) throws Exception; public SessionHandle getSessionHandle(); diff --git service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java index b39d64d..bc0a02c 100644 --- service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java +++ service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java @@ -110,7 +110,7 @@ public HiveSessionImpl(TProtocolVersion protocol, String username, String passwo } @Override - public void initialize(Map sessionConfMap) { + public void initialize(Map sessionConfMap) throws Exception { //process global init file: .hiverc processGlobalInitFile(); SessionState.setCurrentSessionState(sessionState); @@ -168,7 +168,7 @@ private void processGlobalInitFile() { } } - private void configureSession(Map sessionConfMap) { + private void configureSession(Map sessionConfMap) throws Exception { for (Map.Entry entry : sessionConfMap.entrySet()) { String key = entry.getKey(); if (key.startsWith("set:")) { diff --git service/src/java/org/apache/hive/service/cli/session/SessionManager.java service/src/java/org/apache/hive/service/cli/session/SessionManager.java index c2f0495..cfad9b9 100644 --- service/src/java/org/apache/hive/service/cli/session/SessionManager.java +++ service/src/java/org/apache/hive/service/cli/session/SessionManager.java @@ -131,8 +131,12 @@ public SessionHandle openSession(TProtocolVersion protocol, String username, Str } session.setSessionManager(this); session.setOperationManager(operationManager); - session.initialize(sessionConf); - session.open(); + try { + session.initialize(sessionConf); + session.open(); + } catch (Exception e) { + throw new HiveSQLException("Failed to execute session hooks", e); + } handleToSession.put(session.getSessionHandle(), session); try {