Permalink
Browse files

changed backfill termination to terminate as many backfill nodes as t…

…he rejected user request contains
  • Loading branch information...
1 parent b5b214c commit e7e3fdbbd0e266e6e7c7657a2f62b9167fff7788 @pdmars pdmars committed with labisso Jul 9, 2010
@@ -243,30 +243,37 @@ public void launchBackfillTimer() {
// Returns true if a backfill node was successfully killed.
// False, if it wasn't able to kill a backfill node.
- public boolean terminateBackfillNode() {
+ public int terminateBackfillNode(int numNodes) {
int vmid;
- if ((this.terminationPolicy.compareTo("ANY")) == 0) {
- logger.debug("Backfill is using the ANY policy");
- vmid = this.slotManager.getBackfillVMID();
- } else {
- logger.debug("Backfill is using the MOST_RECENT policy");
- vmid = this.slotManager.getMostRecentBackfillVMID();
- }
+ int count = 0;
+ int successfulTerminations = 0;
- String vmidStr = Integer.toString(vmid);
- logger.debug("Terminating backfill node with ID: " + vmidStr);
+ while (count < numNodes) {
+ if ((this.terminationPolicy.compareTo("ANY")) == 0) {
+ logger.debug("Backfill is using the ANY policy");
+ vmid = this.slotManager.getBackfillVMID();
+ } else {
+ logger.debug("Backfill is using the MOST_RECENT policy");
+ vmid = this.slotManager.getMostRecentBackfillVMID();
+ }
- Caller caller = this.getBackfillCaller();
- try {
- this.manager.trash(vmidStr, 0, caller);
- this.subCurInstances(1);
- return true;
- } catch (Exception e) {
- logger.error("Problem terminating backfill node: " +
- e.getMessage());
+ String vmidStr = Integer.toString(vmid);
+ logger.debug("Terminating backfill node with ID: " + vmidStr);
+
+ Caller caller = this.getBackfillCaller();
+ try {
+ this.manager.trash(vmidStr, 0, caller);
+ this.subCurInstances(1);
+ successfulTerminations += 1;
+ } catch (Exception e) {
+ logger.error("Problem terminating backfill node: " +
+ e.getMessage());
+ }
+ count += 1;
}
- return false;
+
+ return successfulTerminations;
}
/**
@@ -342,7 +342,8 @@ protected CreateResult create1(CreateRequest req, Caller caller)
bound = this.binding.processRequest(req);
continueTerminateBackfill = false;
} catch (ResourceRequestDeniedException rDE) {
- if (this.backfill.terminateBackfillNode() == false) {
+ int numNodes = req.getRequestedRA().getNodeNumber();
+ if (this.backfill.terminateBackfillNode(numNodes) == 0) {
throw rDE;
} else {
continueTerminateBackfill = true;
@@ -308,7 +308,8 @@ private Reservation scheduleImpl(NodeRequest req)
res = this.slotManager.reserveSpace(req);
continueTerminateBackfill = false;
} catch (ResourceRequestDeniedException rDE) {
- if (this.backfill.terminateBackfillNode() == false) {
+ int numNodes = req.getNumNodes();
+ if (this.backfill.terminateBackfillNode(numNodes) == 0) {
throw rDE;
} else {
continueTerminateBackfill = true;

0 comments on commit e7e3fdb

Please sign in to comment.