• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python TTransport.TBufferedTransport类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中thrift.transport.TTransport.TBufferedTransport的典型用法代码示例。如果您正苦于以下问题:Python TBufferedTransport类的具体用法?Python TBufferedTransport怎么用?Python TBufferedTransport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TBufferedTransport类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, host=DEFAULT_HOST, port=DEFAULT_PORT, autoconnect=True,
                 compat='0.92', table_prefix=None, table_prefix_separator='_'):

        # Allow host and port to be None, which may be easier for
        # applications wrapping a Connection instance.
        self.host = host or DEFAULT_HOST
        self.port = port or DEFAULT_PORT

        if compat not in COMPAT_MODES:
            raise ValueError("'compat' must be one of %s"
                             % ", ".join(COMPAT_MODES))

        if table_prefix is not None and not isinstance(table_prefix, basestring):
            raise TypeError("'table_prefix' must be a string")

        if not isinstance(table_prefix_separator, basestring):
            raise TypeError("'table_prefix_separator' must be a string")

        self.compat = compat
        self.table_prefix = table_prefix
        self.table_prefix_separator = table_prefix_separator

        socket = TSocket(self.host, self.port)
        framed_transport = False  # TODO: make parameter, add docs
        if framed_transport:
            self.transport = TFramedTransport(socket)
        else:
            self.transport = TBufferedTransport(socket)
        protocol = TBinaryProtocol.TBinaryProtocolAccelerated(self.transport)
        self.client = Hbase.Client(protocol)
        if autoconnect:
            self.open()

        self._initialized = True
开发者ID:ebottabi,项目名称:happybase,代码行数:34,代码来源:api.py


示例2: __init__

 def __init__(self, host=None, port=10000, authMechanism=None, user=None, password=None, database=None, cursorclass = Cursor):
     authMechanisms = set(['NOSASL', 'PLAIN', 'KERBEROS', 'LDAP'])
     if authMechanism not in authMechanisms or authMechanism == 'KERBEROS':
         raise NotImplementedError('authMechanism is either not supported or not implemented')
     #Must set a password for thrift, even if it doesn't need one
     #Open issue with python-sasl
     if authMechanism == 'PLAIN' and (password is None or len(password) == 0):
         password = 'password'
     socket = TSocket(host, port)
     self.cursorclass = cursorclass
     if authMechanism == 'NOSASL':
         transport = TBufferedTransport(socket)
     else:
         saslc = sasl.Client()
         saslc.setAttr("username", user)
         saslc.setAttr("password", password)
         saslc.init()
         transport = TSaslClientTransport(saslc, "PLAIN", socket)
     self.client = TCLIService.Client(TBinaryProtocol(transport))
     transport.open()
     res = self.client.OpenSession(TOpenSessionReq())
     self.session = res.sessionHandle
     if database is not None:
         with self.cursor() as cur:
             query = "USE {0}".format(database)
             cur.execute(query) 
开发者ID:gene-peters,项目名称:kix-redshift_etl,代码行数:26,代码来源:connections.py


示例3: main

def main(args):

#    getColumnInfo(table_name)            

    if(len(args)<2):
        print "TableScan.py tableName No[10]"
        sys.exit(1)

    table_name=args[1]
    NO=10;
    if(len(args)<3):
        NO=10; 
    else:
        NO=int(args[2]);

    getConfiguration('host.properties')

    transport = TBufferedTransport(TSocket(hbaseHost, 9090))
    transport.open()
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    global client
    client = Hbase.Client(protocol)

    ret=getRowsLimit(table_name,NO)
    printRowsResult(ret)
开发者ID:blueskywalker,项目名称:lyris-mystuff,代码行数:25,代码来源:TableScan.py


示例4: main

def main(args):
    if(len(args) < 4):
        print "%s tablename column pattern output[option]"%(args[0])
        sys.exit(1)

    tablename=args[1]
    column = args[2]
    pattern = args[3]

    outputfile = ""
    if(len(args)>4):
        outputfile=args[4]
    
    getConfiguration('host.properties')
    
    transport = TBufferedTransport(TSocket(hbaseHost, 9090))
    transport.open()
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    
    global client
    client = Hbase.Client(protocol)

#    tablename = "%s_%s_master_%s"%(orgId,subOrgId,orgId)

    rowlist = columnGrep(tablename,column,pattern)
    
    print len(rowlist)
    printStdout(rowlist,outputfile)
开发者ID:blueskywalker,项目名称:lyris-mystuff,代码行数:28,代码来源:HbaseColumnGrep.py


示例5: __init__

    def __init__(self, host=None, port=10000, authMechanism=None, user=None, password=None, database=None, configuration=None, timeout=None):
        authMechanisms = set(['NOSASL', 'PLAIN', 'KERBEROS', 'LDAP'])
        if authMechanism not in authMechanisms:
            raise NotImplementedError('authMechanism is either not supported or not implemented')
        #Must set a password for thrift, even if it doesn't need one
        #Open issue with python-sasl
        if authMechanism == 'PLAIN' and (password is None or len(password) == 0):
            password = 'password'
        socket = TSocket(host, port)
        socket.setTimeout(timeout)
        if authMechanism == 'NOSASL':
            transport = TBufferedTransport(socket)
        else:
            sasl_mech = 'PLAIN'
            saslc = sasl.Client()
            saslc.setAttr("username", user)
            saslc.setAttr("password", password)
            if authMechanism == 'KERBEROS':
                krb_host,krb_service = self._get_krb_settings(host, configuration)
                sasl_mech = 'GSSAPI'
                saslc.setAttr("host", krb_host)
                saslc.setAttr("service", krb_service)

            saslc.init()
            transport = TSaslClientTransport(saslc, sasl_mech, socket)

        self.client = TCLIService.Client(TBinaryProtocol(transport))
        transport.open()
        res = self.client.OpenSession(TOpenSessionReq(username=user, password=password, configuration=configuration))
        self.session = res.sessionHandle
        if database is not None:
            with self.cursor() as cur:
                query = "USE {0}".format(database)
                cur.execute(query) 
开发者ID:Aireed,项目名称:pyhs2,代码行数:34,代码来源:connections.py


示例6: __init__

    def __init__( self, host, port ):
        transport = TBufferedTransport(TSocket(host, port))
        transport.open()
        protocol = TBinaryProtocol.TBinaryProtocol(transport)

        self.client = HBaseThrift.Client(protocol)
        self.client
开发者ID:PerilousApricot,项目名称:HBaseR,代码行数:7,代码来源:HBase.py


示例7: __init__

    def __init__(self,context):
        self.context=context
        self.table = self.context.config.HBASE_STORAGE_TABLE
        self.data_fam = self.context.config.HBASE_STORAGE_FAMILY
        transport = TBufferedTransport(TSocket(host=self.context.config.HBASE_STORAGE_SERVER_HOST, port=self.context.config.HBASE_STORAGE_SERVER_PORT))
        transport.open()
        protocol = TBinaryProtocol.TBinaryProtocol(transport)

        self.storage = Hbase.Client(protocol)
开发者ID:nhuray,项目名称:thumbor_hbase,代码行数:9,代码来源:storage.py


示例8: connect

def connect(server='localhost', port=9090, timeout=None):
    socket = TSocket(server, int(port))
    if timeout is not None:
        socket.setTimeout(timeout)
    transport = TBufferedTransport(socket)
    transport.open()
    protocol = TBinaryProtocol.TBinaryProtocolAccelerated(transport)
    client = Hbase.Client(protocol)
    return client
开发者ID:bwhite,项目名称:hadoopy_hbase,代码行数:9,代码来源:__init__.py


示例9: HS2TestSuite

class HS2TestSuite(ImpalaTestSuite):
  def setup(self):
    host, port = IMPALAD_HS2_HOST_PORT.split(":")
    self.socket = TSocket(host, port)
    self.transport = TBufferedTransport(self.socket)
    self.transport.open()
    self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport)
    self.hs2_client = TCLIService.Client(self.protocol)

  def teardown(self):
    if self.socket:
      self.socket.close()

  @staticmethod
  def check_response(response,
                       expected_status_code = TCLIService.TStatusCode.SUCCESS_STATUS,
                       expected_error_prefix = None):
    assert response.status.statusCode == expected_status_code
    if expected_status_code != TCLIService.TStatusCode.SUCCESS_STATUS\
       and expected_error_prefix is not None:
      assert response.status.errorMessage.startswith(expected_error_prefix)

  def close(self, op_handle):
    close_op_req = TCLIService.TCloseOperationReq()
    close_op_req.operationHandle = op_handle
    close_op_resp = self.hs2_client.CloseOperation(close_op_req)
    assert close_op_resp.status.statusCode == TCLIService.TStatusCode.SUCCESS_STATUS

  def fetch(self, handle, orientation, size, expected_num_rows = None):
    """Fetches at most size number of rows from the query identified by the given
    operation handle. Uses the given fetch orientation. Asserts that the fetch returns
    a success status, and that the number of rows returned is equal to size, or
    equal to the given expected_num_rows (it one was given)."""
    fetch_results_req = TCLIService.TFetchResultsReq()
    fetch_results_req.operationHandle = handle
    fetch_results_req.orientation = orientation
    fetch_results_req.maxRows = size
    fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req)
    HS2TestSuite.check_response(fetch_results_resp)
    num_rows = size
    if expected_num_rows is not None:
      num_rows = expected_num_rows
    assert len(fetch_results_resp.results.rows) == num_rows
    return fetch_results_resp

  def fetch_fail(self, handle, orientation, expected_error_prefix):
    """Attempts to fetch rows from the query identified by the given operation handle.
    Asserts that the fetch returns an error with an error message matching the given
    expected_error_prefix."""
    fetch_results_req = TCLIService.TFetchResultsReq()
    fetch_results_req.operationHandle = handle
    fetch_results_req.orientation = orientation
    fetch_results_req.maxRows = 100
    fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req)
    HS2TestSuite.check_response(fetch_results_resp, TCLIService.TStatusCode.ERROR_STATUS,
                                expected_error_prefix)
    return fetch_results_resp
开发者ID:AhmedKammorah,项目名称:Impala,代码行数:57,代码来源:hs2_test_suite.py


示例10: run

    def run(self):
        global work_mutex
        global work_numbers
                
        err_local = 0
        try:
    	    socket = TSocket(self.server_ip, int(self.server_port))
            transport = TFramedTransport(socket)
            transport.open()
            protocol = TBinaryProtocol.TBinaryProtocol(transport)
            client = ThriftNeloEventServer.Client(protocol)   


            stop_flag = True
            while stop_flag:
    	        #read thrift from file
                f = file(file_name, 'r')
                fd_transport = TFileObjectTransport(f)
                buffered_transport = TBufferedTransport(fd_transport)
                binary_protocol = TBinaryProtocol.TBinaryProtocol(buffered_transport)
                fd_transport.open()
                stop_flag = False
                try:
                    evt = ThriftNeloEvent()
                    while True:
                        evt.read(binary_protocol)
				        #send the log to each project name
                        for prjName, logCnt in prj_dict.items():
                            try:
                                if logCnt_dict.has_key(prjName):
                                    if int(logCnt_dict[prjName]) < int(logCnt):
                                        evt.projectName = prjName
                                        evt.sendTime = int(time.time() * 1000)
                                        err = client.ackedAppend(evt)
                                        tps_remember(err)
                                        err_local += err
                                        logCnt_dict[prjName] = logCnt_dict[prjName] + 1
                                        stop_flag = True
                                else:
                                    evt.projectName = prjName
                                    err = client.ackedAppend(evt)
                                    tps_remember(err)
                                    err_local += err
                                    logCnt_dict[prjName] = 1
                                    stop_flag = True
                            except TException, msg:
                                print msg, prjName
                except EOFError,msg:
                    buffered_transport.close() #close the transport
                    stop_flag = True

            work_mutex.acquire()
            work_numbers -= 1
            work_mutex.release()
 
            socket.close()
开发者ID:russ168,项目名称:scripts,代码行数:56,代码来源:pushTestData.py


示例11: getMasterTables

def getMasterTables(hbaseHost):
    transport = TBufferedTransport(TSocket(hbaseHost, 9090))
    transport.open()
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    client = Hbase.Client(protocol)

    for table in client.getTableNames():
        if 'master' in table:
            print table

    transport.close()
开发者ID:blueskywalker,项目名称:lyris-mystuff,代码行数:11,代码来源:getMasterTable.py


示例12: main

def main(args):

    getConfiguration('host.properties')

    transport = TBufferedTransport(TSocket(hbaseHost, 9090))
    transport.open()
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    global client
    client = Hbase.Client(protocol)

    getTableNames()
开发者ID:blueskywalker,项目名称:lyris-mystuff,代码行数:11,代码来源:TableNames.py


示例13: hs2_port_is_open

 def hs2_port_is_open(self):
   """Test if the HS2 port is open. Does not need to authenticate."""
   # Impyla will try to authenticate as part of connecting, so preserve previous logic
   # that uses the HS2 thrift code directly.
   try:
     socket = TSocket(self.hostname, self.hs2_port)
     transport = TBufferedTransport(socket)
     transport.open()
     transport.close()
     return True
   except Exception, e:
     LOG.info(e)
     return False
开发者ID:timarmstrong,项目名称:incubator-impala,代码行数:13,代码来源:impala_service.py


示例14: start

def start():

    logger = logging.getLogger('ted')
    logger.addHandler(logging.StreamHandler())

    transport = TBufferedTransport(TSocket('localhost', 9030))
    transport.open()

    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    global client
    client = ted.TedService.Client(protocol)

    shell = code.InteractiveConsole(globals())
    shell.interact("Run client.<command> where command is a Ted command (eg: getWatching())\nSee dir(Iface) for commands")
开发者ID:florinspatar,项目名称:ted,代码行数:14,代码来源:ted-ui.py


示例15: __init__

    def __init__(self, host, sampling_port, reporting_port, ioloop=None):
        # ioloop
        if ioloop is None:
            self.create_new_threadloop()
        else:
            self.io_loop = ioloop

        # http sampling
        self.local_agent_http = LocalAgentHTTP(host, sampling_port)

        # udp reporting - this will only get written to after our flush() call.
        # We are buffering things up because we are a TBufferedTransport.
        udp = TUDPTransport(host, reporting_port)
        TBufferedTransport.__init__(self, udp)
开发者ID:thepaulm,项目名称:jaeger-client-python,代码行数:14,代码来源:local_agent_net.py


示例16: setup

 def setup(self):
   host, port = IMPALAD_HS2_HOST_PORT.split(":")
   self.socket = TSocket(host, port)
   self.transport = TBufferedTransport(self.socket)
   self.transport.open()
   self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport)
   self.hs2_client = TCLIService.Client(self.protocol)
开发者ID:AhmedKammorah,项目名称:Impala,代码行数:7,代码来源:hs2_test_suite.py


示例17: connect

	def connect (self, host, port, username, password):
		'''
		Connect to the specified backend
		'''
		self.__connected = False
		
		self.host = host
		self.port = port
		self.username = username
		self.password = password
		
		self.socket = TSocket (host, port)
		self.transport = TBufferedTransport (self.socket)
		self.protocol = TBinaryProtocol (self.transport)
		self.client = Pyload.Client (self.protocol)
		
		try:
			self.transport.open()
			self.__connected = True
			logging.info ("Connected to {0}:{1}".format(host, port))
		
		except:
			logging.warn ("Failed to connect to {0}:{1}".format(host, port))
			raise ConnectionFailed
		
		if self.client.login (username, password):
			logging.info ("Server version: {0}".format(self.version))
			self.on_connected()
			return True
		
		return False
开发者ID:gsterjov,项目名称:pyLoader,代码行数:31,代码来源:client.py


示例18: ThriftClient

class ThriftClient(object):
    def __init__(self, port=6458, host="127.0.0.1"):
        self.host = host
        self.port = port
        self.client = None
        self.transport = None

    def connect(self):
        self.transport = TSocket(self.host, self.port)
        self.transport = TBufferedTransport(self.transport)
        protocol = TBinaryProtocol(self.transport)
        self.client = Client(protocol)
        self.transport.open()

    def execute(self, name, *args, **kwargs):
        if self.client is None:
            self.connect()
        result = getattr(self.client, name)(*args, **kwargs)
        return result

    def create(self, key, second, minute = -1, hour = -1, day = -1, month = -1, week = -1, action="shell", params={}):
        return self.execute("create", key, second, minute, hour, day, month, week, action, params)

    def create_timeout(self, key, second, minute = -1, hour = -1, day = -1, month = -1, week = -1, count=1, action="shell", params={}):
        return self.execute("createTimeout", key, second, minute, hour, day, month, week, count, action, params)

    def remove(self, key):
        return self.execute("remove", key)

    def get(self, key):
        return self.execute("get", key)

    def get_current(self):
        return self.execute("getCurrent")

    def get_time(self, timestamp):
        return self.execute("getTime", timestamp)

    def get_keys(self, prefix=''):
        return self.execute("getKeys", prefix)

    def __del__(self):
        if self.client:
            self.transport.close()
            self.transport = None
            self.client = None
开发者ID:soszrg,项目名称:forsun,代码行数:46,代码来源:__init__.py


示例19: setup

 def setup(self):
   self.cleanup_db(self.TEST_DB)
   host, port = IMPALAD_HS2_HOST_PORT.split(":")
   self.socket = TSocket(host, port)
   self.transport = TBufferedTransport(self.socket)
   self.transport.open()
   self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport)
   self.hs2_client = ImpalaHiveServer2Service.Client(self.protocol)
开发者ID:dayutianfei,项目名称:impala-Q,代码行数:8,代码来源:hs2_test_suite.py


示例20: __init__

 def __init__(self, host=None, port=10000, authMechanism=None, user=None, password=None, database=None):
     authMechanisms = {'NOSASL', 'PLAIN', 'KERBEROS', 'LDAP'}
     if authMechanism not in authMechanisms or authMechanism == 'KERBEROS':
         raise NotImplementedError('authMechanism is either not supported or not implemented')
     socket = TSocket(host, port)
     if authMechanism == 'NOSASL':
         transport = TBufferedTransport(socket)
     else:
         saslc = sasl.Client()
         saslc.setAttr("username", user)
         saslc.setAttr("password", password)
         saslc.init()
         transport = TSaslClientTransport(saslc, "PLAIN", socket)
     self.client = TCLIService.Client(TBinaryProtocol(transport))
     transport.open()
     res = self.client.OpenSession(TOpenSessionReq())
     self.session = res.sessionHandle
开发者ID:andrewmains12,项目名称:pyhs2,代码行数:17,代码来源:connections.py



注:本文中的thrift.transport.TTransport.TBufferedTransport类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python TTransport.TMemoryBuffer类代码示例发布时间:2022-05-27
下一篇:
Python TSocket.TSocket类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap