Ejemplo n.º 1
0
 def client(self, cname):
     peer = None
     for p in broadcaster.peerlist.values():
         if p.cname == cname:
             peer = p
             break
     if peer is None:
         raise xmlrpc.Fault(1, 'No peer with cname = %s' % cname)
     return storageclient.connect(peer.endpoint())        
Ejemplo n.º 2
0
 def xmlrpc_pull(self, hexHash):
     binaryHash = HexBytes(binascii.unhexlify(hexHash))
     candidates = netdb.db.locateHash(binaryHash)
     _log.info("Candidates for %s: %s", hexHash, candidates)
     if not candidates:
         raise xmlrpc.Fault(0, 'No such content found')
     peer = broadcaster.peerlist[candidates[0]]
     client = yield storageclient.connect(peer.endpoint())
     try:
         content = yield client.get(binaryHash)
     except RequestFailed:
         raise xmlrpc.Fault(1, 'Cannot get content')
     defer.returnValue(xmlrpc.Binary(content))
Ejemplo n.º 3
0
 def render_GET(self, request):
     cname = request.args['cname'][0]
     peer = None
     for p in broadcaster.peerlist.values():
         if p.cname == cname:
             peer = p
             break
     if peer is None:
         request.setResponseCode(http.BAD_REQUEST)
         return 'No peer with cname = %s' % cname
     d = storageclient.connect(peer.endpoint())
     d.addCallback(self.callback, request)
     d.addErrback(self.errback, request)
     return server.NOT_DONE_YET