Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

redirector work

ommit message for your changes. Lines starting
  • Loading branch information...
commit caa801bd2aec012a39179b26e25353a8bdd758eb 1 parent d75a89c
John Bresnahan authored BuzzTroll committed
View
11 cumulus/cb/pycb/cbRedirector.py
@@ -1,5 +1,6 @@
import os
import sys
+import random
from pycb.cbException import cbException
import pycb
import stat
@@ -35,7 +36,7 @@ def __init__(self, parser):
def new_connection(self, request):
h = None
self.connection_count = self.connection_count + 1
- if self.connection_count >= self.max:
+ if self.connection_count > self.max:
h = self.get_next_host()
return h
@@ -51,14 +52,14 @@ def get_next_host(self):
f.close()
my_host = "%s:%d" % (pycb.config.hostname, pycb.config.port)
-
- for i in range(0, 10):
+ for i in range(0, 5):
ndx = random.randint(0, len(hosts)-1)
h = hosts[ndx]
+ pycb.log(logging.INFO, "redirector found %s, my host %s" % (h, my_host))
if h != my_host:
return h
- return h
+ return None
except Exception, ex:
- log(logging.ERROR, "get next host error %s" % (str(ex)))
+ pycb.log(logging.ERROR, "get next host error %s" % (str(ex)))
return None
View
6 cumulus/cb/pycb/cumulus.py
@@ -38,11 +38,11 @@ def init_redirector(req, bucketName, objectName):
req.notifyFinish().addBoth(end_redirector, req)
if redir_host:
- pycb.log(logging.INFO, "REDIRECT %s" % (next_host))
+ pycb.log(logging.INFO, "REDIRECT %s" % (redir_host))
ex = cbException('TemporaryRedirect')
- req.setHeader('location', "http://%s%s" % (next_host, req.uri))
+ req.setHeader('location', "http://%s%s" % (redir_host, req.uri))
ex.add_custom_xml("Bucket", bucketName)
- ex.add_custom_xml("Endpoint", next_host)
+ ex.add_custom_xml("Endpoint", redir_host)
raise ex
def path_to_bucket_object(path):
View
18 cumulus/perf/scale1.py
@@ -29,7 +29,7 @@
def cb_get_conn(hostname, port):
cf = OrdinaryCallingFormat()
- conn = S3Connection(g_id, g_pw, host=hostname, port=port, is_secure=False, calling_format=cf)
+ conn = S3Connection(g_id, g_pw, host=hostname, port=port, is_secure=False, calling_format=cf, debug=15)
return conn
@@ -41,7 +41,6 @@ def upload_file(filename):
bucket = conn.get_bucket(g_bucket)
except Exception, ex:
bucket = conn.create_bucket(g_bucket)
- print bucket
k = boto.s3.key.Key(bucket)
k.key = g_key_name
@@ -56,7 +55,8 @@ def time_upload(file):
try:
my_char = threading.current_thread().getName()
start_tm = datetime.now()
- key = upload_file(file+"."+my_char)
+ #key = upload_file(file+"."+my_char)
+ key = upload_file(file)
end_tm = datetime.now()
delt = end_tm - start_tm
@@ -90,7 +90,6 @@ def main():
t.start()
for i in range(0, its):
- print "joining %s" % (t_a[i].getName())
t_a[i].join()
end_tm = datetime.now()
@@ -99,10 +98,9 @@ def main():
us = float(delt.microseconds) / 1000000.0
tm = float(delt.seconds) + us
- print "cleaning up the keys"
- conn = cb_get_conn(g_hostname, g_port)
- bucket = conn.get_bucket(g_bucket)
- rs = bucket.list()
+# conn = cb_get_conn(g_hostname, g_port)
+# bucket = conn.get_bucket(g_bucket)
+# rs = bucket.list()
# for k in rs:
# try:
# k.delete()
@@ -117,8 +115,8 @@ def main():
if tm < min:
min = tm
- size = os.path.getsize(file)
- print "file %s of %d bytes" % (file, size)
+ #size = os.path.getsize(file)
+ size = 0
sizeMB = size * 1024*1024
total_bytes = size * its
total_bw = float(total_bytes) / float(tm)
Please sign in to comment.
Something went wrong with that request. Please try again.