Example #1
0
 def accept_timedout(self, accept):
     self.trace and self.trace(" accept timed out, sending cancel")
     cancel = Cancel(self, self.current_quote.seller, accept)
     cancel.send_msg(self.node, accept.seller.node)
     self.timedout.add(self.current_quote.id)
     record.record_failure_reason(accept.job.id, "Timedout")
     self.current_quote = None
     self.accept_process = None
     self.accept_best_quote()
Example #2
0
    def accept_received(self, quote):
        trace = self.trace.add('j%-5s' % quote.job.id)

        if quote in self.offers:
            # we know this one
            trace and trace("got accept from %s" % quote.buyer)
            
            self.cancel_quote_timeout(quote.id, trace)
            self.rationale.observe(quote, True)

            # can we still do it?
            if self.resource.can_allocate(quote.job): 
                self.confirm_and_start_job(
                        quote.job, quote.buyer, quote)
                
            else: # we cannot honour our original quote
                trace and trace("got accept, now too busy, rejecting")
                record.record_failure_reason(quote.job.id, "Too Busy Later")
                self.send_reject(quote.buyer, quote)
                self.nrejected += 1

        else: 
            trace and trace("got an accept for a job we've timed out on")
Example #3
0
    def quote_received(self, quote):
        trace = self.trace.add('j%-5s' % quote.job.id)
        trace and trace("advert from %s at %s" % (quote.buyer, quote.buyer.node))
        
        if quote not in self.offers:
            if self.resource.can_allocate(quote.job):

                # generate a quote and send it
                self.price = self.rationale.quote()
                quote = Ask(quote.buyer, self, quote.job, self.price)
                private = PrivateQuote(quote)
                private.send_msg(self.node, quote.buyer.node)
                self.set_quote_timeout(quote, trace)

                self.offers.add(quote)
                trace and trace("sending offer %s" % quote)

            else:
                # TODO: add this record to the job object
                record.record_failure_reason(quote.job.id, "Too Busy")
                trace and trace("resource has no room for job")
                self.nrejected += 1
        else:
            trace("WARNING: received advert for job already trading for")
Example #4
0
 def record_failure(self):
     if (self.nrejected + len(self.timedout) == 0 and 
             self.ninvalid_quotes > 0):
         record.record_failure_reason(self.job.id, "High Buyer Limit")
     quote = Bid(self, None, self.job, self.price)
     record.record_failure(self, quote)