コード例 #1
0
ファイル: proto.py プロジェクト: BackupTheBerlios/xenbee-svn
    def executeTask(self, jsdl, task):
        """send the request to the application.

        return a Deferred, that gets called when the task has finished.
        """
        msg = message.ExecuteTask(jsdl, task.id())
        self.task_id = task.id()
        self.sendMessage(msg.as_xml())
コード例 #2
0
ファイル: proto.py プロジェクト: BackupTheBerlios/xenbee-svn
 def deny(ticket):
     task = ticket.task
     TaskManager.getInstance().terminateTask(task, "auction-deny")
     if task.is_done():
         log.debug("removing task-entry: %s", task.id())
         TaskManager.getInstance().removeTask(task)
         TicketStore.getInstance().release(ticket)
         del ticket.task
コード例 #3
0
ファイル: proto.py プロジェクト: BackupTheBerlios/xenbee-svn
 def do_ReservationRequest(self, dom_node, *args, **kw):
     ticket = TicketStore.getInstance().new()
     if ticket is None:
         # if no ticket could be generated:
         msg = message.Error(errcode.SERVER_BUSY)
     else:
         task = TaskManager.getInstance().new(ticket.id())
         ticket.task = task
         msg = message.ReservationResponse(ticket.id(), task.id())
     return msg
コード例 #4
0
ファイル: proto.py プロジェクト: BackupTheBerlios/xenbee-svn
    def do_StatusRequest(self, elem, *args, **kw):
	"""Handle status request."""
        request = message.MessageBuilder.from_xml(elem.getroottree())
        ticket = TicketStore.getInstance().lookup(request.ticket())
        status_list = message.StatusList()
        try:
            if ticket is not None:
                task = ticket.task
                status_list.add(task.id(), task.state(), ticket.id(), task.getStatusInfo())

                # remove the task entry
                if task.is_done() and request.removeEntry():
                    log.debug("removing task-entry: %s", task.id())
                    TaskManager.getInstance().removeTask(task)
                    TicketStore.getInstance().release(ticket)
                    del ticket.task
            elif request.ticket() == "all":
                log.info("user requested the status of all tasks, remove that functionality")
                toberemoved = [] 
		for tid, ticket in TicketStore.getInstance().all().iteritems():
                    if ticket.task:
                        task = ticket.task
                        status_list.add(task.id(), task.state(), ticket.id(), task.getStatusInfo())

	                # remove the task entry
	                if task.is_done() and request.removeEntry():
                            toberemoved.append( (ticket, task) )
                for (ticket, task) in toberemoved:
                    log.debug("removing task-entry: %s", task.id())
                    TaskManager.getInstance().removeTask(task)
                    TicketStore.getInstance().release(ticket)
                    del ticket.task
            else:
                return message.Error(errcode.TICKET_INVALID, request.ticket())
            return status_list
        except Exception, e:
            log.warn("status request failed %s", e, exc_info=1)
コード例 #5
0
ファイル: proto.py プロジェクト: BackupTheBerlios/xenbee-svn
    def do_BookingRequest(self, elem, *args, **kw):
        # use nearly the same code as for do_ReservationRequest
        request = message.MessageBuilder.from_xml(elem.getroottree())
        log.debug("==== XenBEEBrokerProtocol::bookingRequest: ")

        #return message.BrokerError(request.uuid(), errcode.SERVER_BUSY)

        ticket = TicketStore.getInstance().new()
        if ticket is None:
            # if no ticket could be generated:
            msg = message.Error(request.uuid(), errcode.SERVER_BUSY)
        else:
            #xbedurl     = self.factory.daemon.broker_uri
            xbedurl     = self.factory.daemon.qname
            task        = TaskManager.getInstance().new(ticket.id())
            ticket.task = task
            #price       = 10*random.random()
            price       = self.factory.daemon.price
            msg = message.AuctionBidResponse(request.uuid(), xbedurl, ticket.id(), task.id(), price)
        return msg