示例#1
0
    def _set_global_timer(self):
        """Set global timer for the request at the head of the
        global_seq_queue.
        """
        if self.global_req_timer is not None:
            self.global_req_timer.cancel()
        if not self.global_req_queue.empty():
            timestamp = self.global_req_queue.head.data.request_timestamp
            interval = self.config.REQUEST_TIMEOUT - (
                time.time() - utils.nanos_to_sec(timestamp))

            self.global_req_timer = threading.Timer(interval,
                                                    self.remove_request)
            self.global_req_timer.start()
示例#2
0
    def _set_global_timer(self):
        """Set global timer for the request at the head of the
        global_seq_queue.
        """
        if self.global_req_timer is not None:
            self.global_req_timer.cancel()
        if not self.global_req_queue.empty():
            timestamp = self.global_req_queue.head.data.request_timestamp
            interval = self.config.REQUEST_TIMEOUT - (time.time() -
                    utils.nanos_to_sec(timestamp))

            self.global_req_timer = threading.Timer(
                interval, self.remove_request)
            self.global_req_timer.start()
示例#3
0
    def guess_server(self):
        ''' None -> int

            Guess the next server that should be written to.

        '''
        if self.last_state == INITIAL:
            return random.randint(0, self.config.FLASH_PER_GROUP - 1)
        elif self.last_state == FULL:
            return self.last_server + 1
        else:
            # SUCCESS or FAIL here
            guess_inc = (utils.nanos_to_sec(self.delay + utils.nanotime() -
                self.largest_timestamp) * self.latest_ips + 1 +
                self.config.CLIENT_GUESS_OVERESTIMATION)
            guess_token = int(math.ceil(self.largest_token + guess_inc))
            guess_token += random.randint(1, 2)
            (guess_server, _, _, _) = self.projection.translate(guess_token)
            return guess_server
示例#4
0
    def guess_server(self):
        ''' None -> int

            Guess the next server that should be written to.

        '''
        if self.last_state == INITIAL:
            return random.randint(0, self.config.FLASH_PER_GROUP - 1)
        elif self.last_state == FULL:
            return self.last_server + 1
        else:
            # SUCCESS or FAIL here
            guess_inc = (
                utils.nanos_to_sec(self.delay + utils.nanotime() -
                                   self.largest_timestamp) * self.latest_ips +
                1 + self.config.CLIENT_GUESS_OVERESTIMATION)
            guess_token = int(math.ceil(self.largest_token + guess_inc))
            guess_token += random.randint(1, 2)
            (guess_server, _, _, _) = self.projection.translate(guess_token)
            return guess_server