예제 #1
0
    def out_tuple(self, req, msgid, message, data):
        # output a tuple into a tuplespace
        ts, tup = str(data[0]), data[1]

        assert utils.isTupleSpaceId(ts), "%s is not a tuplespace id" % (ts, )
        assert local_ts.has_key(ts)

        local_ts[ts]._out(tup)
        stats.inc_stat("message_out_total")

        req.send(msgid, (done, ))
예제 #2
0
    def out_tuple(self, req, msgid, message, data):
        # output a tuple into a tuplespace
        ts, tup = str(data[0]), data[1]

        assert utils.isTupleSpaceId(ts), "%s is not a tuplespace id" % (ts, )
        assert local_ts.has_key(ts)

        local_ts[ts]._out(tup)
        stats.inc_stat("message_out_total")

        req.send(msgid, (done, ))
예제 #3
0
    def register_thread(self, req, msgid, message, data):
        # When a new thread connects they need to acquire new thread id
        p_id = str(data[0])
        t_id = "%s!%i" % (p_id, pthread_count[p_id].next())
        pthreads[p_id].append(t_id)
        threads[t_id] = req
        req.type = "CLIENT"
        req.name = t_id

        req.send(msgid, ("RESULT_STRING", t_id))

        stats.inc_stat("process_con_current")
        stats.inc_stat("process_con_total")
예제 #4
0
    def register_thread(self, req, msgid, message, data):
        # When a new thread connects they need to acquire new thread id
        p_id = str(data[0])
        t_id = "%s!%i" % (p_id, pthread_count[p_id].next())
        pthreads[p_id].append(t_id)
        threads[t_id] = req
        req.type = "CLIENT"
        req.name = t_id

        req.send(msgid, ("RESULT_STRING", t_id))

        stats.inc_stat("process_con_current")
        stats.inc_stat("process_con_total")
예제 #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")
예제 #6
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")
예제 #7
0
    def in_tuple(self, req, msgid, message, data):
        ts, template, tid = str(data[0]), data[1], str(data[2])
        unblockable = message == inp_tuple

        blocked_threads[tid] = (req, ts)

        assert utils.isTupleSpaceId(ts), "%s is not a tuplespace id" % (ts, )
        assert local_ts.has_key(ts)

        r = local_ts[ts]._in(tid, template, unblockable)
        stats.inc_stat("message_in_total")

        if r is not None:
            del blocked_threads[tid]
            utils.changeOwner(r, ts, utils.getProcessIdFromThreadId(tid))
            req.send(msgid, ("RESULT_TUPLE", r))
        else:
            pass # this thread is now blocked
예제 #8
0
    def in_tuple(self, req, msgid, message, data):
        ts, template, tid = str(data[0]), data[1], str(data[2])
        unblockable = message == inp_tuple

        blocked_threads[tid] = (req, ts)

        assert utils.isTupleSpaceId(ts), "%s is not a tuplespace id" % (ts, )
        assert local_ts.has_key(ts)

        r = local_ts[ts]._in(tid, template, unblockable)
        stats.inc_stat("message_in_total")

        if r is not None:
            del blocked_threads[tid]
            utils.changeOwner(r, ts, utils.getProcessIdFromThreadId(tid))
            req.send(msgid, ("RESULT_TUPLE", r))
        else:
            pass  # this thread is now blocked
예제 #9
0
    def read_tuple(self, req, msgid, message, data):
        ts, template, tid = str(data[0]), data[1], str(data[2])
        unblockable = message == inp_tuple

        blocked_threads[tid] = (req, ts)

        assert utils.isTupleSpaceId(ts), "%s is not a tuplespace id" % (ts, )
        assert local_ts.has_key(ts)

        r = local_ts[ts]._rd(tid, template, unblockable)
        stats.inc_stat("message_rd_total")

        if r is not None:
            del blocked_threads[tid]

            # we found a tuple so update the references and return it
            utils.addReference(r, utils.getProcessIdFromThreadId(tid))

            req.send(msgid, ("RESULT_TUPLE", r))
        else:
            pass # this thread is now blocked
예제 #10
0
    def read_tuple(self, req, msgid, message, data):
        ts, template, tid = str(data[0]), data[1], str(data[2])
        unblockable = message == inp_tuple

        blocked_threads[tid] = (req, ts)

        assert utils.isTupleSpaceId(ts), "%s is not a tuplespace id" % (ts, )
        assert local_ts.has_key(ts)

        r = local_ts[ts]._rd(tid, template, unblockable)
        stats.inc_stat("message_rd_total")

        if r is not None:
            del blocked_threads[tid]

            # we found a tuple so update the references and return it
            utils.addReference(r, utils.getProcessIdFromThreadId(tid))

            req.send(msgid, ("RESULT_TUPLE", r))
        else:
            pass  # this thread is now blocked