/** * This method is invoked when a round finishes * * @see gridsim.auction.OneSidedAuction#onClose(int) */ public void onClose(int round) { // our implementation of the first price sealed auction has // a single round. So, since we are using a reverse auction, the // lowest bid is the best one MessageBid best = getFirstBid(-1); if (best != null) { double price = best.getPrice(); // if the price of the bid is below the reserve price, it means // that the broker will accept the offer and will send the job // to be executed by the resource provider if (price <= super.getReservePrice()) { super.setFinalPrice(price); super.setWinner(best.getBidder()); } else { super.setFinalPrice(super.getCurrentPrice()); } } else { // there is no best bid, what means that no resource provider // has bidden to execute the job super.setFinalPrice(super.getCurrentPrice()); } }
/* * @param round * @param excBidder the bids done by excBidder will be excluded from the response * @return */ private synchronized LinkedList getBids(int round, int excBidder) { LinkedList aux = new LinkedList(); synchronized (this) { Iterator iter = bids.iterator(); while (iter.hasNext()) { MessageBid bid = (MessageBid) iter.next(); if (bid.getRound() == round && bid.getBidder() != excBidder) { aux.add(bid); } } } return aux; }