forked from couchbaselabs/pydcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.py
66 lines (54 loc) · 1.73 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import pprint
import time
from uprclient import UprClient
from mcdclient import McdClient
from constants import *
def simple_handshake_demo():
upr_client = UprClient('127.0.0.1', 12000)
mcd_client = McdClient('127.0.0.1', 12000)
op = upr_client.open_producer("mystream")
print 'Sending open connection (producer)'
print op
response = op.next_response()
print 'Response: %s\n' % response
assert response['status'] == SUCCESS
op = upr_client.stream_req(0, 0, 0, 0, 0, 0)
print 'Sending Stream Request'
print op
while op.has_response():
response = op.next_response()
print 'Response: %s' % response
assert response['status'] == SUCCESS
print '\nGet Tap Stats\n'
op = mcd_client.stats('tap')
response = op.next_response()
pprint.pprint(response['value'])
upr_client.shutdown()
print '\n'
print 'Closed Upr Connection'
print '\nGet Tap Stats\n'
op = mcd_client.stats('tap')
response = op.next_response()
pprint.pprint(response['value'])
mcd_client.shutdown()
def add_stream_demo():
upr_client = UprClient('127.0.0.1', 12000)
mcd_client = McdClient('127.0.0.1', 12000)
op = upr_client.open_consumer("mystream")
print 'Sending open connection (consumer)'
print op
response = op.next_response()
print 'Response: %s\n' % response
assert response['status'] == SUCCESS
op = upr_client.add_stream(0, 0)
print 'Sending add stream request'
print op
response = op.next_response()
assert response['status'] == SUCCESS
print 'Got add stream response'
print response
upr_client.shutdown()
mcd_client.shutdown()
if __name__ == "__main__":
#simple_handshake_demo()
add_stream_demo()