Exemple #1
0
    def getnextblock(self):
        #if no keys left to fetch, exit
        if (len(self.keys) == 0):
            print "done."
            self.client.close()
            return

    # setup the argument for the call to DHash
        arg = dhashgateway_prot.dhash_retrieve_arg()
        # get the next key from the array
        (id, level, off) = self.keys.pop()
        arg.blockID = id
        arg.ctype = dhash_types.DHASH_CONTENTHASH
        arg.options = 0
        arg.guess = chord_types.bigint(0)

        # we time each fetch for diagnostics: record start time
        start = time.time()
        try:
            self.outstanding += 1
            # the RPC client will call self.process when the block comes back
            res = self.client(
                dhashgateway_prot.DHASHPROC_RETRIEVE, arg,
                lambda x: self.process(start, arg, level, off, x))
            if res is not None:
                # something went badly wrong
                sys.exit(-1)

        except RPC.UnpackException, e:
            print_exc()
Exemple #2
0
    def getnextblock (self):
        #if no keys left to fetch, exit
	if (len(self.keys) == 0):
	    print "done."
	    self.client.close()
	    return

        # setup the argument for the call to DHash
        arg = dhashgateway_prot.dhash_retrieve_arg ()
        # get the next key from the array
	(id, level, off) = self.keys.pop()
        arg.blockID = id
        arg.ctype   = dhash_types.DHASH_CONTENTHASH
        arg.options = 0
        arg.guess   = chord_types.bigint(0)

        # we time each fetch for diagnostics: record start time
        start = time.time()
        try:
            self.outstanding += 1
            # the RPC client will call self.process when the block comes back
            res = self.client (dhashgateway_prot.DHASHPROC_RETRIEVE, arg,
                               lambda x: self.process(start, arg, level, off, x))
            if res is not None:
                 # something went badly wrong
                 sys.exit (-1)
                 
        except RPC.UnpackException, e:
            print_exc ()
Exemple #3
0
    def go (self):
        if self.going: return
        self.going = 1
        while (self.outstanding < self.nops and self.f.eof() == 0):
            self.inject()

        self.going = 0
        if self.outstanding == 0 and self.f.eof() == True:
            #output root key and level
	    print "file root key ", str(chord_types.bigint(self.f.root())) + ":" + str(self.f.rootlevel())
            self.client.close()
Exemple #4
0
    def go(self):
        if self.going: return
        self.going = 1
        while (self.outstanding < self.nops and self.f.eof() == 0):
            self.inject()

        self.going = 0
        if self.outstanding == 0 and self.f.eof() == True:
            #output root key and level
            print "file root key ", str(chord_types.bigint(
                self.f.root())) + ":" + str(self.f.rootlevel())
            self.client.close()
Exemple #5
0
    def inject(self):
        arg = dhashgateway_prot.dhash_insert_arg()

        # get the next block and insert it
        arg.block = self.f.next_block()
        sobj = sha.sha(arg.block)
        arg.blockID = chord_types.bigint(sobj.digest())
        print "Inserting", arg.blockID
        arg.ctype = dhash_types.DHASH_CONTENTHASH
        arg.len = len(arg.block)
        arg.options = 0
        arg.guess = chord_types.bigint(0)

        start = time.time()
        try:
            self.outstanding += 1
            res = self.client(dhashgateway_prot.DHASHPROC_INSERT, arg,
                              lambda x: self.process(start, arg, x))
            if res is not None:
                self.process(start, arg, res)
        except RPC.UnpackException, e:
            print_exc()
Exemple #6
0
    def inject (self):
        arg = dhashgateway_prot.dhash_insert_arg ()

        # get the next block and insert it
        arg.block   = self.f.next_block()
        sobj        = sha.sha(arg.block)
        arg.blockID = chord_types.bigint(sobj.digest())
        print "Inserting", arg.blockID
        arg.ctype   = dhash_types.DHASH_CONTENTHASH
        arg.len     = len(arg.block)
        arg.options = 0
        arg.guess   = chord_types.bigint(0)
        
        start = time.time()
        try:
            self.outstanding += 1
            res = self.client (dhashgateway_prot.DHASHPROC_INSERT, arg,
                               lambda x: self.process(start, arg, x))
            if res is not None:
                self.process (start, arg, res)
        except RPC.UnpackException, e:
            print_exc ()