Merge lp:~gholt/swift/walt into lp:~david-goetz/swift/walt

Proposed by gholt
Status: Merged
Approved by: David Goetz
Approved revision: 207
Merged at revision: 207
Proposed branch: lp:~gholt/swift/walt
Merge into: lp:~david-goetz/swift/walt
Diff against target: 132 lines (+68/-14)
3 files modified
bin/walt (+66/-12)
setup.py (+1/-1)
swift/common/direct_client.py (+1/-1)
To merge this branch: bzr merge lp:~gholt/swift/walt
Reviewer Review Type Date Requested Status
David Goetz Pending
Review via email: mp+48398@code.launchpad.net

Description of the change

walt: Renaming swift-walt to just walt. Update to support direct objects deletes to a container server.

To post a comment you must log in.
lp:~gholt/swift/walt updated
208. By gholt

Fixed setup.py, self help

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'bin/swift-walt' => 'bin/walt'
2--- bin/swift-walt 2011-02-01 19:54:23 +0000
3+++ bin/walt 2011-02-02 23:32:11 +0000
4@@ -60,6 +60,27 @@
5 return resp.status
6
7
8+def direct_delete_object_c(node, part, account, container, obj, conn_timeout=5,
9+ response_timeout=15):
10+ path = '/%s/%s/%s' % (account, container, obj)
11+ with Timeout(conn_timeout):
12+ conn = http_connect(node['ip'], node['port'], node['device'], part,
13+ 'DELETE', path,
14+ headers={'x-timestamp': normalize_timestamp(time())})
15+ with Timeout(response_timeout):
16+ resp = conn.getresponse()
17+ resp.read()
18+ if resp.status < 200 or resp.status >= 300:
19+ raise ClientException(
20+ 'Container server %s:%s direct object DELETE %s gave status %s' %
21+ (node['ip'], node['port'],
22+ repr('/%s/%s%s' % (node['device'], part, path)), resp.status),
23+ http_host=node['ip'], http_port=node['port'],
24+ http_device=node['device'], http_status=resp.status,
25+ http_reason=resp.reason)
26+ return resp.status
27+
28+
29 def do_listings(left, sleep_amount, options, extra, extra2):
30 if options.direct:
31 while left[0] > 0:
32@@ -78,21 +99,54 @@
33
34
35 def fill_queue_from_listings(options, queue):
36- conn = Connection(options.auth, options.user, options.key,
37- preauthurl=options.preauthurl,
38- preauthtoken=options.preauthtoken, snet=options.snet)
39- for cont_name in container_names(options.num_containers):
40- cont_list = conn.get_container(cont_name)
41- if cont_list and cont_list[1]:
42- for obj_dict in cont_list[1]:
43- if (cont_name, obj_dict['name']) not in queue['used']:
44- queue['ok'].add((cont_name, obj_dict['name']))
45- break
46+ if options.direct:
47+ for cont_name in container_names(options.num_containers):
48+ _junk, cont_list = retry(direct_get_container, options.node,
49+ options.part, options.account, options.container)
50+ if cont_list and cont_list[1]:
51+ for obj_dict in cont_list[1]:
52+ if (cont_name, obj_dict['name']) not in queue['used']:
53+ queue['ok'].add((cont_name, obj_dict['name']))
54+ break
55+ else:
56+ conn = Connection(options.auth, options.user, options.key,
57+ preauthurl=options.preauthurl,
58+ preauthtoken=options.preauthtoken, snet=options.snet)
59+ for cont_name in container_names(options.num_containers):
60+ cont_list = conn.get_container(cont_name)
61+ if cont_list and cont_list[1]:
62+ for obj_dict in cont_list[1]:
63+ if (cont_name, obj_dict['name']) not in queue['used']:
64+ queue['ok'].add((cont_name, obj_dict['name']))
65+ break
66
67
68 def do_object_deletes(left, sleep_amount, options, queue, sema):
69 if options.direct:
70- raise Exception("Not Implemented")
71+ num_sleeps = 0
72+ tried_listing = False
73+ while left[0] > 0:
74+ try:
75+ with sema:
76+ cont_name, obj_name = queue['ok'].pop()
77+ queue['used'].add((cont_name, obj_name))
78+ except KeyError:
79+ if num_sleeps > 1:
80+ if not tried_listing:
81+ with sema:
82+ fill_queue_from_listings(options, queue)
83+ tried_listing = True
84+ continue
85+ left[0] = 0
86+ print "Nothing more to delete!!"
87+ break
88+ num_sleeps += 1
89+ sleep(1)
90+ continue
91+ retry(direct_delete_object_c, options.node, options.part,
92+ options.account, cont_name, obj_name)
93+ left[0] -= 1
94+ sleep(sleep_amount)
95 else:
96 conn = Connection(options.auth, options.user, options.key,
97 preauthurl=options.preauthurl,
98@@ -245,7 +299,7 @@
99 1 Does listing requests on the container named walt
100 2 Does zero byte object puts into the container named walt
101 3 Does head requests on the container named walt
102- 4 Does object deletes (only for non direct server tests
103+ 4 Does object deletes
104
105 If -C (multiple containers) is set then instead of hitting walt it will use a
106 randomly chosen container
107
108=== modified file 'setup.py'
109--- setup.py 2011-02-01 19:54:23 +0000
110+++ setup.py 2011-02-02 23:32:11 +0000
111@@ -101,7 +101,7 @@
112 'bin/swauth-cleanup-tokens', 'bin/swauth-delete-account',
113 'bin/swauth-delete-user', 'bin/swauth-list', 'bin/swauth-prep',
114 'bin/swauth-set-account-service', 'bin/swift-auth-to-swauth',
115- 'bin/swift-walt',
116+ 'bin/walt',
117 ],
118 entry_points={
119 'paste.app_factory': [
120
121=== modified file 'swift/common/direct_client.py'
122--- swift/common/direct_client.py 2011-01-04 23:34:43 +0000
123+++ swift/common/direct_client.py 2011-02-02 23:32:11 +0000
124@@ -330,7 +330,7 @@
125 :param kwargs: keyward arguments to send to func (if retries or
126 error_log are sent, they will be deleted from kwargs
127 before sending on to func)
128- :returns: restult of func
129+ :returns: A tuple of (attempts, result of func)
130 """
131 retries = 5
132 if 'retries' in kwargs:

Subscribers

People subscribed via source and target branches

to all changes: