Esempio n. 1
0
class Hammer(threading.Thread):
    def __init__(self, hostname, op, num, threadNum):
        threading.Thread.__init__(self)
        self.conn = CachedHTTPConnection(hostname)
        self.op = op
        self.num = num
        self.threadNum = threadNum

    def run(self):
        if self.op == "insertDirect":
            sitename = "test"
            rrs = rapidrecsite.RapidRecSite(sitename)

        for j in range(self.num):
            if self.op == "insert":
                self.conn.post("/users/%s/items/%s/rating" % (randUsername(), randItemname()), randRating())
            else:
                rrs.insert_relation(
                    src_group="user",
                    src_name=randUsername(),
                    tgt_group="item",
                    tgt_name=randItemname(),
                    field="rating",
                    value=randRating(),
                )
Esempio n. 2
0
 def __init__(self, hostname, op, num, threadNum):
     threading.Thread.__init__(self)
     self.conn = CachedHTTPConnection(hostname)
     self.op = op
     self.num = num
     self.threadNum = threadNum