コード例 #1
0
ファイル: dptest.py プロジェクト: ichengzi/sperm
def queryColumnFamily():
    print '----------queryColumnFamily----------'
    request = message_pb2.ReadRequest()

    request.table_name = 'appbenchmark'
    request.row_key = '2012-04-08_YULE'
    request.column_family = 'stat'

    data = request.SerializeToString()
    data2 = raiseHTTPRequest('http://dp0:12345/read', data, timeout=20)

    response = message_pb2.ReadResponse()
    response.ParseFromString(data2)
コード例 #2
0
ファイル: benchmark.py プロジェクト: ichengzi/sperm
def queryColumn(times=100):
    print '----------queryColumn----------'
    request = message_pb2.ReadRequest()

    request.table_name = 'appuserstat'
    request.row_key = '2012-12-19_4c14d4471d41c86c6400072b'
    request.column_family = 'stat'
    request.qualifiers.append('duTime_d_1_3')
    request.qualifiers.append('duTime_d_4_10')
    request.qualifiers.append('duTime_d_11_30')
    request.qualifiers.append('duTime_d_31_60')
    request.qualifiers.append('duTime_d_61_180')
    request.qualifiers.append('duTime_d_181_600')
    request.qualifiers.append('duTime_d_601_1800')
    request.qualifiers.append('duTime_d_1801_')

    data = request.SerializeToString()
    # long-lived connection.
    conn = httplib.HTTPConnection('dp0', 12345, timeout=20)
    conn.connect()
    conn.sock.settimeout(20)  # 20 seconds.
    s = time.time()
    for i in xrange(0, times):
        conn.request('GET', '/read', data)
        try:
            data2 = conn.getresponse().read()
        except:
            print 'fast timeout'
    e = time.time()
    print 'fast time spent %lf / %d, avg %.4lf' % ((e - s), times,
                                                   (e - s) / times)

    response = message_pb2.ReadResponse()
    response.ParseFromString(data2)
    #print response

    s = time.time()
    conn = httplib.HTTPConnection('dp30', 8080, timeout=20)
    for i in xrange(0, times):
        conn.request(
            'GET',
            '/appuserstat/2012-12-19_4c14d4471d41c86c6400072b/stat:duTime_d_1_3,stat:duTime_d_4_10,stat:duTime_d_11_30,stat:duTime_d_31_60,stat:duTime_d_61_180,stat:duTime_d_181_600,stat:duTime_d_601_1800,stat:duTime_d_1801_?v=1',
            headers={'Keep-Alive': 'timeout=10'})
        try:
            data2 = conn.getresponse().read()
        except:
            print 'rest timeout'

    e = time.time()
    print 'rest time spent %lf / %d, avg %.4lf' % ((e - s), times,
                                                   (e - s) / times)
コード例 #3
0
ファイル: test.py プロジェクト: ichengzi/sperm
def queryColumnFamily():
    print '----------queryColumnFamily----------'
    request = message_pb2.ReadRequest()

    request.table_name = 't1'
    request.row_key = 'r1'
    request.column_family = 'cf'

    data = request.SerializeToString()
    data2 = raiseHTTPRequest('http://localhost:8000/read', data, timeout=20)

    response = message_pb2.ReadResponse()
    response.ParseFromString(data2)
    print response
コード例 #4
0
ファイル: dptest.py プロジェクト: ichengzi/sperm
def queryColumn():
    print '----------queryColumn----------'
    request = message_pb2.ReadRequest()

    request.table_name = 'appbenchmark'
    request.row_key = '2012-04-08_YULE'
    request.column_family = 'stat'
    request.qualifiers.append('14_day_active_count_avg')

    data = request.SerializeToString()
    data2 = raiseHTTPRequest('http://dp0:12345/read', data, timeout=20)

    response = message_pb2.ReadResponse()
    response.ParseFromString(data2)
コード例 #5
0
ファイル: dptest.py プロジェクト: ichengzi/sperm
def queryColumn2():
    print '----------queryColumn2----------'
    request = message_pb2.ReadRequest()

    request.table_name = 'appuserstat'
    request.row_key = '2013-03-08_4db949a2112cf75caa00002a'
    request.column_family = 'stat'
    request.qualifiers.append('provinces_7_lanCnt')

    data = request.SerializeToString()
    data2 = raiseHTTPRequest('http://dp0:12345/read', data, timeout=20)

    response = message_pb2.ReadResponse()
    response.ParseFromString(data2)
    print response
コード例 #6
0
ファイル: test.py プロジェクト: ichengzi/sperm
def queryColumnSameConnection():
    print '----------queryColumn----------'
    request = message_pb2.ReadRequest()

    request.table_name = 't1'
    request.row_key = 'r1'
    request.column_family = 'cf'
    request.qualifiers.append('c2')
    request.qualifiers.append('c1')

    data = request.SerializeToString()

    conn = httplib.HTTPConnection('localhost', 8000, timeout=20)
    for i in range(0, 3):
        conn.request('GET', '/read', data)
        data2 = conn.getresponse().read()
        response = message_pb2.ReadResponse()
        response.ParseFromString(data2)
        print response
コード例 #7
0
ファイル: dptest.py プロジェクト: ichengzi/sperm
def queryModels():
    print '----------Models----------'
    request = message_pb2.ReadRequest()

    request.table_name = 'appuserstat'
    request.row_key = '2013-03-21_4d707f5e112cf75410007470'
    request.column_family = 'stat'
    request.qualifiers.append('models_1_day_installCnt_values')

    data = request.SerializeToString()
    data2 = raiseHTTPRequest('http://dp0:12345/read', data, timeout=20)

    response = message_pb2.ReadResponse()
    response.ParseFromString(data2)

    xs = response.kvs[0].content.split("\0")
    for x in xs[:100]:
        ss = x.split("\f")
        print ss
コード例 #8
0
ファイル: dptest.py プロジェクト: ichengzi/sperm
def queryColumnLarge():
    print '----------queryColumnLarge----------'
    request = message_pb2.ReadRequest()

    request.table_name = 'appuserstat'
    request.row_key = '2013-03-08_4d707f5e112cf75410007470'
    request.column_family = 'stat'
    request.qualifiers.append('models_1_lanCnt')

    data = request.SerializeToString()
    s = time.time()
    data2 = raiseHTTPRequest('http://dp0:12345/read', data, timeout=20)
    print "data size = %d bytes" % (len(data2))
    e = time.time()
    print 'time spent %.2lfs' % ((e - s))

    response = message_pb2.ReadResponse()
    response.ParseFromString(data2)

    x = response.kvs[0].content
    xs = x.split("\f")
    print "models size = %d" % (len(xs))