def get_metastore_client(self):
import hmsclient<EOL>from thrift.transport import TSocket, TTransport<EOL>from thrift.protocol import TBinaryProtocol<EOL>ms = self.metastore_conn<EOL>auth_mechanism = ms.extra_dejson.get('<STR_LIT>', '<STR_LIT>')<EOL>if configuration.conf.get('<STR_LIT>', '<STR_LIT>') == '<STR_LIT>':<EOL><INDENT>auth_mechanism = ms.extra_dejson.get('<STR_LIT>', '<STR_LIT>')<EOL>kerberos_service_name = ms.extra_dejson.get('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>socket = TSocket.TSocket(ms.host, ms.port)<EOL>if configuration.conf.get('<STR_LIT>', '<STR_LIT>') == '<STR_LIT>'and auth_mechanism == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>import saslwrapper as sasl<EOL><DEDENT>except ImportError:<EOL><INDENT>import sasl<EOL><DEDENT>def sasl_factory():<EOL><INDENT>sasl_client = sasl.Client()<EOL>sasl_client.setAttr("<STR_LIT:host>", ms.host)<EOL>sasl_client.setAttr("<STR_LIT>", kerberos_service_name)<EOL>sasl_client.init()<EOL>return sasl_client<EOL><DEDENT>from thrift_sasl import TSaslClientTransport<EOL>transport = TSaslClientTransport(sasl_factory, "<STR_LIT>", socket)<EOL><DEDENT>else:<EOL><INDENT>transport = TTransport.TBufferedTransport(socket)<EOL><DEDENT>protocol = TBinaryProtocol.TBinaryProtocol(transport)<EOL>return hmsclient.HMSClient(iprot=protocol)<EOL>
Returns a Hive thrift client.