Exemplo n.º 1
0
 def do_return_tuple():
     utils.changeOwner(matched, self._id, self._id, node)
     sendMessageToNode(
         node, None, multiple_in, self._id,
         (interserver_types.convertTupleForServer(
             node,
             matched), ))  # return the tuple to the server
Exemplo n.º 2
0
 def __del__(self):
     broadcast_tonodes(self.partitions, False, deleted_partition, self._id, server.node_id)
     if self.ts.count() > 0 and len(self.partitions) > 0:
         node = self.partitions[0]
         tups = list(self.ts.matchAllTuples())
         map(lambda x: utils.changeOwner(x, self._id, self._id, node), tups)
         sendMessageToNode(node, None, multiple_in, self._id, tuple(tups))
     else:
         tups = list(self.ts.matchAllTuples())
         map(lambda x: utils.delReference(x, self._id), tups)
Exemplo n.º 3
0
 def __del__(self):
     broadcast_tonodes(self.partitions, False, deleted_partition, self._id,
                       server.node_id)
     if self.ts.count() > 0 and len(self.partitions) > 0:
         node = self.partitions[0]
         tups = list(self.ts.matchAllTuples())
         map(lambda x: utils.changeOwner(x, self._id, self._id, node), tups)
         sendMessageToNode(node, None, multiple_in, self._id, tuple(tups))
     else:
         tups = list(self.ts.matchAllTuples())
         map(lambda x: utils.delReference(x, self._id), tups)
Exemplo n.º 4
0
    def my_name_is(self, req, msgid, message, data):
        # when someone connects who already has an id they need to let us know who they are...
        name = str(data[0])
        assert utils.isNodeId(name)

        req.name = str(name)
        req.send(msgid, (done, ))
        if neighbours.has_key(name):
            return
        neighbours[name] = req
        req.type = "SERVER"
        sendMessageToNode(name, None, my_name_is, node_id)

        stats.inc_stat("server_con_current")
        stats.inc_stat("server_con_total")
Exemplo n.º 5
0
    def my_name_is(self, req, msgid, message, data):
        # when someone connects who already has an id they need to let us know who they are...
        name = str(data[0])
        assert utils.isNodeId(name)

        req.name = str(name)
        req.send(msgid, (done, ))
        if neighbours.has_key(name):
            return
        neighbours[name] = req
        req.type = "SERVER"
        sendMessageToNode(name, None, my_name_is, node_id)

        stats.inc_stat("server_con_current")
        stats.inc_stat("server_con_total")
Exemplo n.º 6
0
def lookupForeignType(server, tid):
    try:
        return lookupType(tid)
    except KeyError:
        t = sendMessageToNode(server, None, "REQUEST_TYPE", tid)
        registerType(t, server)
        getTypesFromServer(server, (t, ))
        return t
Exemplo n.º 7
0
def lookupForeignType(server, tid):
    try:
        return lookupType(tid)
    except KeyError:
        t = sendMessageToNode(server, None, "REQUEST_TYPE", tid)
        registerType(t, server)
        getTypesFromServer(server, (t, ))
        return t
Exemplo n.º 8
0
 def get_connect_details(self, req, msgid, message, data):
     # try to find out how to connect to a server
     if str(data[0]) == node_id:
         # they're looking for us! Return our details
         req.send(msgid, ("RESULT_TUPLE", ((req.getsockname()[0], getOptions().port), None)))
     elif str(data[0]) in neighbours.keys():
         # they're looking for our neighbour, ask them how to connect to them
         r = sendMessageToNode(str(data[0]), None, get_connect_details, str(data[0]))
         if isinstance(neighbours[str(data[0])], str): # we don't have a direct connection
             req.send(msgid, ("RESULT_TUPLE", (r[1], neighbours[str(data[0])])))
         else: # we have a direct connection, tell people to go through us
             req.send(msgid, ("RESULT_TUPLE", (r[1], node_id)))
     else:
         # we don't know the node they're looking for
         req.send(msgid, (dont_know, ))
Exemplo n.º 9
0
 def get_connect_details(self, req, msgid, message, data):
     # try to find out how to connect to a server
     if str(data[0]) == node_id:
         # they're looking for us! Return our details
         req.send(msgid,
                  ("RESULT_TUPLE",
                   ((req.getsockname()[0], getOptions().port), None)))
     elif str(data[0]) in neighbours.keys():
         # they're looking for our neighbour, ask them how to connect to them
         r = sendMessageToNode(str(data[0]), None, get_connect_details,
                               str(data[0]))
         if isinstance(neighbours[str(data[0])],
                       str):  # we don't have a direct connection
             req.send(msgid,
                      ("RESULT_TUPLE", (r[1], neighbours[str(data[0])])))
         else:  # we have a direct connection, tell people to go through us
             req.send(msgid, ("RESULT_TUPLE", (r[1], node_id)))
     else:
         # we don't know the node they're looking for
         req.send(msgid, (dont_know, ))
Exemplo n.º 10
0
 def do_return_tuple():
     utils.changeOwner(matched, self._id, self._id, node)
     sendMessageToNode(node, None, multiple_in, self._id, (interserver_types.convertTupleForServer(node, matched), )) # return the tuple to the server