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
=== renamed file 'bin/swift-walt' => 'bin/walt'
--- bin/swift-walt 2011-02-01 19:54:23 +0000
+++ bin/walt 2011-02-02 23:32:11 +0000
@@ -60,6 +60,27 @@
60 return resp.status60 return resp.status
6161
6262
63def direct_delete_object_c(node, part, account, container, obj, conn_timeout=5,
64 response_timeout=15):
65 path = '/%s/%s/%s' % (account, container, obj)
66 with Timeout(conn_timeout):
67 conn = http_connect(node['ip'], node['port'], node['device'], part,
68 'DELETE', path,
69 headers={'x-timestamp': normalize_timestamp(time())})
70 with Timeout(response_timeout):
71 resp = conn.getresponse()
72 resp.read()
73 if resp.status < 200 or resp.status >= 300:
74 raise ClientException(
75 'Container server %s:%s direct object DELETE %s gave status %s' %
76 (node['ip'], node['port'],
77 repr('/%s/%s%s' % (node['device'], part, path)), resp.status),
78 http_host=node['ip'], http_port=node['port'],
79 http_device=node['device'], http_status=resp.status,
80 http_reason=resp.reason)
81 return resp.status
82
83
63def do_listings(left, sleep_amount, options, extra, extra2):84def do_listings(left, sleep_amount, options, extra, extra2):
64 if options.direct:85 if options.direct:
65 while left[0] > 0:86 while left[0] > 0:
@@ -78,21 +99,54 @@
7899
79100
80def fill_queue_from_listings(options, queue):101def fill_queue_from_listings(options, queue):
81 conn = Connection(options.auth, options.user, options.key,102 if options.direct:
82 preauthurl=options.preauthurl,103 for cont_name in container_names(options.num_containers):
83 preauthtoken=options.preauthtoken, snet=options.snet)104 _junk, cont_list = retry(direct_get_container, options.node,
84 for cont_name in container_names(options.num_containers):105 options.part, options.account, options.container)
85 cont_list = conn.get_container(cont_name)106 if cont_list and cont_list[1]:
86 if cont_list and cont_list[1]:107 for obj_dict in cont_list[1]:
87 for obj_dict in cont_list[1]:108 if (cont_name, obj_dict['name']) not in queue['used']:
88 if (cont_name, obj_dict['name']) not in queue['used']:109 queue['ok'].add((cont_name, obj_dict['name']))
89 queue['ok'].add((cont_name, obj_dict['name']))110 break
90 break111 else:
112 conn = Connection(options.auth, options.user, options.key,
113 preauthurl=options.preauthurl,
114 preauthtoken=options.preauthtoken, snet=options.snet)
115 for cont_name in container_names(options.num_containers):
116 cont_list = conn.get_container(cont_name)
117 if cont_list and cont_list[1]:
118 for obj_dict in cont_list[1]:
119 if (cont_name, obj_dict['name']) not in queue['used']:
120 queue['ok'].add((cont_name, obj_dict['name']))
121 break
91122
92123
93def do_object_deletes(left, sleep_amount, options, queue, sema):124def do_object_deletes(left, sleep_amount, options, queue, sema):
94 if options.direct:125 if options.direct:
95 raise Exception("Not Implemented")126 num_sleeps = 0
127 tried_listing = False
128 while left[0] > 0:
129 try:
130 with sema:
131 cont_name, obj_name = queue['ok'].pop()
132 queue['used'].add((cont_name, obj_name))
133 except KeyError:
134 if num_sleeps > 1:
135 if not tried_listing:
136 with sema:
137 fill_queue_from_listings(options, queue)
138 tried_listing = True
139 continue
140 left[0] = 0
141 print "Nothing more to delete!!"
142 break
143 num_sleeps += 1
144 sleep(1)
145 continue
146 retry(direct_delete_object_c, options.node, options.part,
147 options.account, cont_name, obj_name)
148 left[0] -= 1
149 sleep(sleep_amount)
96 else:150 else:
97 conn = Connection(options.auth, options.user, options.key,151 conn = Connection(options.auth, options.user, options.key,
98 preauthurl=options.preauthurl,152 preauthurl=options.preauthurl,
@@ -245,7 +299,7 @@
245 1 Does listing requests on the container named walt299 1 Does listing requests on the container named walt
246 2 Does zero byte object puts into the container named walt300 2 Does zero byte object puts into the container named walt
247 3 Does head requests on the container named walt301 3 Does head requests on the container named walt
248 4 Does object deletes (only for non direct server tests302 4 Does object deletes
249303
250If -C (multiple containers) is set then instead of hitting walt it will use a304If -C (multiple containers) is set then instead of hitting walt it will use a
251randomly chosen container305randomly chosen container
252306
=== modified file 'setup.py'
--- setup.py 2011-02-01 19:54:23 +0000
+++ setup.py 2011-02-02 23:32:11 +0000
@@ -101,7 +101,7 @@
101 'bin/swauth-cleanup-tokens', 'bin/swauth-delete-account',101 'bin/swauth-cleanup-tokens', 'bin/swauth-delete-account',
102 'bin/swauth-delete-user', 'bin/swauth-list', 'bin/swauth-prep',102 'bin/swauth-delete-user', 'bin/swauth-list', 'bin/swauth-prep',
103 'bin/swauth-set-account-service', 'bin/swift-auth-to-swauth',103 'bin/swauth-set-account-service', 'bin/swift-auth-to-swauth',
104 'bin/swift-walt',104 'bin/walt',
105 ],105 ],
106 entry_points={106 entry_points={
107 'paste.app_factory': [107 'paste.app_factory': [
108108
=== modified file 'swift/common/direct_client.py'
--- swift/common/direct_client.py 2011-01-04 23:34:43 +0000
+++ swift/common/direct_client.py 2011-02-02 23:32:11 +0000
@@ -330,7 +330,7 @@
330 :param kwargs: keyward arguments to send to func (if retries or330 :param kwargs: keyward arguments to send to func (if retries or
331 error_log are sent, they will be deleted from kwargs331 error_log are sent, they will be deleted from kwargs
332 before sending on to func)332 before sending on to func)
333 :returns: restult of func333 :returns: A tuple of (attempts, result of func)
334 """334 """
335 retries = 5335 retries = 5
336 if 'retries' in kwargs:336 if 'retries' in kwargs:

Subscribers

People subscribed via source and target branches

to all changes: