Permalink
Browse files

-Renamed Spot Instances references (SIRequest, SIManager, etc) to Asy…

…nchronous Requests in order to acomodate backfill requests

-Added support to backfill requests
-Fixed tests
  • Loading branch information...
1 parent 145a404 commit 3048a2cc2a572d4e390190546d200a9274a938db @pauloricardomg pauloricardomg committed Aug 2, 2010
Showing with 458 additions and 328 deletions.
  1. +5 −5 service/service/java/source/etc/workspace-service/other/main.xml
  2. +5 −6 service/service/java/source/src/org/globus/workspace/spotinstances/AbstractPricingModel.java
  3. +57 −26 ...e/service/java/source/src/org/globus/workspace/spotinstances/{SIRequest.java → AsyncRequest.java}
  4. +4 −4 ...va/source/src/org/globus/workspace/spotinstances/{SpotInstancesHome.java → AsyncRequestHome.java}
  5. +2 −2 ...rce/src/org/globus/workspace/spotinstances/{SpotInstancesManager.java → AsyncRequestManager.java}
  6. +224 −145 ...org/globus/workspace/spotinstances/{SpotInstancesManagerImpl.java → AsyncRequestManagerImpl.java}
  7. +1 −1 ...va/source/src/org/globus/workspace/spotinstances/{SIRequestStatus.java → AsyncRequestStatus.java}
  8. +13 −13 service/service/java/source/src/org/globus/workspace/spotinstances/MaximizeProfitPricingModel.java
  9. +4 −6 ...e/service/java/source/src/org/globus/workspace/spotinstances/MaximizeUtilizationPricingModel.java
  10. +1 −1 service/service/java/source/src/org/globus/workspace/spotinstances/PricingModel.java
  11. +47 −36 service/service/java/source/src/org/globus/workspace/spotinstances/SIRequestUtils.java
  12. +34 −28 ...ce/service/java/tests/unit/org/globus/workspace/spotinstances/MaximizeProfitPricingModelTest.java
  13. +56 −49 ...rvice/java/tests/unit/org/globus/workspace/spotinstances/MaximizeUtilizationPricingModelTest.java
  14. +5 −6 service/service/java/tests/unit/org/globus/workspace/spotinstances/PricingModelTestUtils.java
@@ -19,7 +19,7 @@
<constructor-arg ref="nimbus-repr.ReprFactory"/>
<constructor-arg ref="nimbus-rm.persistence.DataConvert"/>
<constructor-arg ref="nimbus-rm.loglevels" />
- <constructor-arg ref="nimbus-rm.spotinstances.manager" />
+ <constructor-arg ref="nimbus-rm.async.manager" />
<property name="accounting"
ref="nimbus-rm.accounting" />
@@ -102,7 +102,7 @@
<!-- set after object creation time to avoid circular dep -->
<property name="siManager"
- ref="nimbus-rm.spotinstances.manager" />
+ ref="nimbus-rm.async.manager" />
</bean>
@@ -538,7 +538,7 @@
<!-- set after object creation time to avoid circular dep with home -->
<property name="home" ref="nimbus-rm.home.instance" />
<property name="siManager"
- ref="nimbus-rm.spotinstances.manager" />
+ ref="nimbus-rm.async.manager" />
<!-- definition of this bean is in "resource-locator-ACTIVE.xml" -->
<property name="slotManager"
ref="nimbus-rm.scheduler.SlotManagement" />
@@ -551,8 +551,8 @@
<bean id="nimbus-rm.spotinstances.pricingmodel"
class="$SI{si.pricingmodel}" />
- <bean id="nimbus-rm.spotinstances.manager"
- class="org.globus.workspace.spotinstances.SpotInstancesManagerImpl">
+ <bean id="nimbus-rm.async.manager"
+ class="org.globus.workspace.spotinstances.AsyncRequestManagerImpl">
<constructor-arg ref="nimbus-rm.persistence.PersistenceAdapter" />
<constructor-arg ref="nimbus-rm.loglevels" />
@@ -1,10 +1,9 @@
package org.globus.workspace.spotinstances;
import java.util.Collection;
+import java.util.Collections;
import java.util.LinkedList;
-import edu.emory.mathcs.backport.java.util.Collections;
-
public abstract class AbstractPricingModel implements PricingModel{
public static final Double DEFAULT_MIN_PRICE = 0.1;
@@ -22,7 +21,7 @@ public Double getMinPrice(){
return this.minPrice;
}
- public Double getNextPrice(Integer totalReservedResources, Collection<SIRequest> requests, Double currentPrice) {
+ public Double getNextPrice(Integer totalReservedResources, Collection<AsyncRequest> requests, Double currentPrice) {
if(requests.isEmpty()){
return minPrice;
@@ -40,14 +39,14 @@ public Double getNextPrice(Integer totalReservedResources, Collection<SIRequest>
protected abstract Double getNextPriceImpl(Integer totalReservedResources,
- Collection<SIRequest> requests, Double currentPrice);
+ Collection<AsyncRequest> requests, Double currentPrice);
- protected LinkedList<Double> getOrderedPriceCandidates(Collection<SIRequest> requests) {
+ protected LinkedList<Double> getOrderedPriceCandidates(Collection<AsyncRequest> requests) {
LinkedList<Double> priceCandidates = new LinkedList<Double>();
- for (SIRequest siRequest : requests) {
+ for (AsyncRequest siRequest : requests) {
Double requestBid = siRequest.getMaxBid();
if(requestBid >= minPrice){
priceCandidates.add(requestBid);
@@ -11,15 +11,14 @@
import org.nimbustools.api.repr.ctx.Context;
import org.nimbustools.api.repr.vm.NIC;
-
-
-public class SIRequest implements Comparable<SIRequest>{
+public class AsyncRequest implements Comparable<AsyncRequest>{
private String id;
+ private boolean spot;
+
private Double maxBid;
- private Integer requestedInstances;
private boolean persistent;
- private SIRequestStatus status;
+ private AsyncRequestStatus status;
private Caller caller;
private VirtualMachine[] bindings;
@@ -34,24 +33,52 @@
private LinkedHashSet<Integer> toBePreempted = new LinkedHashSet<Integer>();
private Calendar creationTime;
- public SIRequest(String id, Double highestPrice, Integer requestedInstances) {
- this(id, highestPrice, requestedInstances, false);
+ //Test-only
+ public AsyncRequest(String id, Double highestPrice, VirtualMachine[] bindings) {
+ this(id, highestPrice, false, null, null, bindings, null, null, null);
}
+
+ /**
+ * Constructor for Spot Instance requests
+ * @param id
+ * @param spotPrice
+ * @param persistent
+ * @param caller
+ * @param groupID
+ * @param bindings
+ * @param context
+ * @param requestedNics
+ * @param creationTime
+ */
+ public AsyncRequest(String id, Double spotPrice, boolean persistent,
+ Caller caller, String groupID, VirtualMachine[] bindings, Context context,
+ NIC[] requestedNics, Calendar creationTime) {
+ this(id, true, spotPrice, persistent, caller, groupID, bindings, context, requestedNics, creationTime);
+ }
- public SIRequest(String id, Double highestPrice, Integer requestedInstances, boolean persistent) {
- this.id = id;
- this.maxBid = highestPrice;
- this.requestedInstances = requestedInstances;
- this.persistent = persistent;
- this.status = SIRequestStatus.OPEN;
- }
+ /**
+ * Constructor for backfill requests
+ * @param id
+ * @param spotPrice
+ * @param persistent
+ * @param caller
+ * @param groupID
+ * @param bindings
+ * @param context
+ * @param requestedNics
+ * @param creationTime
+ */
+ public AsyncRequest(String id, Caller caller, String groupID, VirtualMachine[] bindings, Context context,
+ NIC[] requestedNics, Calendar creationTime) {
+ this(id, false, -1.0, true, caller, groupID, bindings, context, requestedNics, creationTime);
+ }
- public SIRequest(String id, Double spotPrice, boolean persistent,
+ public AsyncRequest(String id, boolean spotinstances, Double spotPrice, boolean persistent,
Caller caller, String groupID, VirtualMachine[] bindings, Context context,
NIC[] requestedNics, Calendar creationTime) {
- this.requestedInstances = bindings.length;
- this.status = SIRequestStatus.OPEN;
+ this.status = AsyncRequestStatus.OPEN;
this.id = id;
+ this.spot = spotinstances;
this.maxBid = spotPrice;
this.persistent = persistent;
this.bindings = bindings;
@@ -60,8 +87,8 @@ public SIRequest(String id, Double spotPrice, boolean persistent,
this.groupID = groupID;
this.caller = caller;
this.creationTime = creationTime;
- }
-
+ }
+
public Double getMaxBid() {
return maxBid;
}
@@ -72,9 +99,9 @@ public void setMaxBid(Double maxBid) {
public Integer getNeededInstances(){
if(this.persistent){
- return this.requestedInstances;
+ return this.getRequestedInstances();
} else {
- return this.requestedInstances-this.finishedVMs.size();
+ return this.getRequestedInstances()-this.finishedVMs.size();
}
}
@@ -110,19 +137,19 @@ public void setPersistent(boolean persistent) {
this.persistent = persistent;
}
- public SIRequestStatus getStatus() {
+ public AsyncRequestStatus getStatus() {
return status;
}
- public boolean setStatus(SIRequestStatus status) {
+ public boolean setStatus(AsyncRequestStatus status) {
if(this.status.isAlive()){
this.status = status;
return true;
}
return false;
}
- public int compareTo(SIRequest o) {
+ public int compareTo(AsyncRequest o) {
int compareBid = getMaxBid().compareTo(o.getMaxBid());
if(compareBid == 0){
@@ -168,7 +195,7 @@ public void setProblem(Throwable problem) {
@Override
public String toString() {
return "SIRequest [id " + id + ", status= " + status + ", requestedInstances="
- + requestedInstances + ", allocatedInstances=" + getAllocatedInstances()
+ + getRequestedInstances() + ", allocatedInstances=" + getAllocatedInstances()
+ ", maxBid=" + maxBid + ", persistent=" + persistent
+ ", caller=" + caller + "]";
}
@@ -241,7 +268,7 @@ public Calendar getCreationTime() {
}
public Integer getRequestedInstances() {
- return this.requestedInstances;
+ return bindings.length;
}
public void preemptAll() {
@@ -255,4 +282,8 @@ public void preempt(int[] preemptionList) {
toBePreempted.add(i);
}
}
+
+ public boolean isSpotRequest() {
+ return spot;
+ }
}
@@ -29,7 +29,7 @@
* RETRIEVE and CANCEL operations to
* Spot Instance Requests
*/
-public interface SpotInstancesHome {
+public interface AsyncRequestHome {
/**
* Cancels a Spot Instance request
@@ -38,7 +38,7 @@
* @throws DoesNotExistException in case the id argument does not map
* to any spot instance request
*/
- public SIRequest cancelRequest(String reqID) throws DoesNotExistException;
+ public AsyncRequest cancelRequest(String reqID) throws DoesNotExistException;
/**
* Retrieves a Spot Instance request and its related information
@@ -47,14 +47,14 @@
* @throws DoesNotExistException in case the id argument does not map
* to any spot instance request
*/
- public SIRequest getRequest(String id) throws DoesNotExistException;
+ public AsyncRequest getRequest(String id) throws DoesNotExistException;
/**
* Retrieves all Spot Instance requests from a caller
* @param caller the owner of the Spot Instances' requests
* @return an array of spot instance requests from this caller
*/
- public SIRequest[] getRequests(Caller caller);
+ public AsyncRequest[] getRequests(Caller caller, boolean spot);
/**
* Retrieves current spot price
@@ -22,13 +22,13 @@
* Interface that represents
* a Spot Instances module
*/
-public interface SpotInstancesManager extends SpotInstancesHome, PreemptableSpaceManager, StateChangeInterested {
+public interface AsyncRequestManager extends AsyncRequestHome, PreemptableSpaceManager, StateChangeInterested {
/**
* Adds a Spot Instances request
* to this module
* @param request the request to be added
*/
- public void addRequest(SIRequest request);
+ public void addRequest(AsyncRequest request);
}
Oops, something went wrong.

0 comments on commit 3048a2c

Please sign in to comment.