Browse files

redirector abstraction passes tests

  • Loading branch information...
1 parent e730abc commit 116a3d8bba8e96231308c72881d47dfa975a6596 BuzzTroll committed Oct 11, 2010
Showing with 16 additions and 13 deletions.
  1. +2 −0 cumulus/cb/pycb/__init__.py
  2. +10 −10 cumulus/cb/pycb/cbRedirector.py
  3. +4 −3 cumulus/cb/pycb/cumulus.py
View
2 cumulus/cb/pycb/__init__.py
@@ -12,6 +12,8 @@
import random
from optparse import OptionParser
import hmac
+from pycb.cbRedirector import *
+
try:
from hashlib import sha1 as sha
from hashlib import sha256 as sha256
View
20 cumulus/cb/pycb/cbRedirector.py
@@ -51,15 +51,15 @@ def get_next_host():
hosts.append(l.strip())
f.close()
- my_host = "%s:%d" % (pycb.config.hostname, pycb.config.port)
+ my_host = "%s:%d" % (pycb.config.hostname, pycb.config.port)
- for i in range(0, 10):
- ndx = random.randint(0, len(hosts)-1)
- h = hosts[ndx]
- if h != my_host:
- return h
- return h
- except Exception, ex:
- log(logging.ERROR, "get next host error %s" % (str(ex)))
- return None
+ for i in range(0, 10):
+ ndx = random.randint(0, len(hosts)-1)
+ h = hosts[ndx]
+ if h != my_host:
+ return h
+ return h
+ except Exception, ex:
+ log(logging.ERROR, "get next host error %s" % (str(ex)))
+ return None
View
7 cumulus/cb/pycb/cumulus.py
@@ -15,6 +15,7 @@
from pycb.cbRequest import cbPutObject
from pycb.cbRequest import cbHeadObject
from pycb.cbRequest import cbCopyObject
+from pycb.cbRedirector import *
from datetime import date, datetime
from xml.dom.minidom import Document
import uuid
@@ -29,11 +30,11 @@
import tempfile
import threading
-def end_redirector(request):
- self.redirector.end_connection()
+def end_redirector(result, request):
+ pycb.config.redirector.end_connection(request)
def init_redirector(req, bucketName, objectName):
- redir_host = self.redirector.new_connection(request)
+ redir_host = pycb.config.redirector.new_connection(req)
req.notifyFinish().addBoth(end_redirector, req)
if redir_host:

0 comments on commit 116a3d8

Please sign in to comment.