Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a separate condition that checks for a completely infeasible memo…

…ry request. This greatly reduces the number of corner cases related to GH-26
  • Loading branch information...
commit 5da43c11434df6f8e39ad4a46c10a07d949600b3 1 parent 3511c12
@timf timf authored
View
20 service-api/java/source/src/org/nimbustools/api/services/rm/ImpossibleAmountOfMemoryException.java
@@ -0,0 +1,20 @@
+package org.nimbustools.api.services.rm;
+
+public class ImpossibleAmountOfMemoryException extends ResourceRequestDeniedException {
+
+ public ImpossibleAmountOfMemoryException() {
+ super();
+ }
+
+ public ImpossibleAmountOfMemoryException(String message) {
+ super(message);
+ }
+
+ public ImpossibleAmountOfMemoryException(String message, Throwable e) {
+ super(message, e);
+ }
+
+ public ImpossibleAmountOfMemoryException(Exception e) {
+ super(e);
+ }
+}
View
3  service/service/java/source/src/org/globus/workspace/persistence/PersistenceAdapter.java
@@ -202,6 +202,9 @@ public void updateCursorPosition(long currentPosition)
public List<ResourcepoolEntry> getAvailableEntriesSortedByFreeMemoryPercentage(int requestedMem)
throws WorkspaceDatabaseException;
+
+ // returns true if memory request is bigger than any VMM could ever handle
+ public boolean isInfeasibleRequest(int requestedMem) throws WorkspaceDatabaseException;
//Spot Instances
View
5 service/service/java/source/src/org/globus/workspace/persistence/PersistenceAdapterConstants.java
@@ -207,6 +207,10 @@
"SELECT * FROM resourcepool_entries WHERE active = 1 AND " +
"available_memory >= ? " +
"ORDER BY (available_memory/maximum_memory) ASC";
+
+ public static final String SQL_SELECT_INFEASIBLE_MEMORY =
+ "SELECT COUNT(DISTINCT hostname) FROM resourcepool_entries WHERE active = 1 AND " +
+ "? <= maximum_memory";
public static final String SQL_INSERT_SPOT_PRICE =
"INSERT INTO spot_prices VALUES(?,?)";
@@ -290,6 +294,7 @@
SQL_SELECT_TOTAL_AVAILABLE_MEMORY,
SQL_SELECT_TOTAL_MAX_MEMORY,
SQL_SELECT_TOTAL_PREEMPTABLE_MEMORY,
+ SQL_SELECT_INFEASIBLE_MEMORY,
SQL_SELECT_USED_NON_PREEMPTABLE_MEMORY,
SQL_INSERT_SPOT_PRICE,
SQL_SELECT_LAST_SPOT_PRICE,
View
44 service/service/java/source/src/org/globus/workspace/persistence/PersistenceAdapterImpl.java
@@ -2419,6 +2419,50 @@ private int readCounter(int n, String prepd)
}
}
}
+
+ public boolean isInfeasibleRequest(int requestedMem)
+ throws WorkspaceDatabaseException{
+
+ Connection c = null;
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+
+ try {
+ c = getConnection();
+ pstmt = c.prepareStatement(SQL_SELECT_INFEASIBLE_MEMORY);
+ pstmt.setInt(1, requestedMem);
+ rs = pstmt.executeQuery();
+
+ if (rs == null || !rs.next()) {
+ throw new WorkspaceDatabaseException("Should always have a result");
+ } else {
+ int numPossibleVmms = rs.getInt(1);
+ if (numPossibleVmms > 0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ } catch(SQLException e) {
+ logger.error("",e);
+ throw new WorkspaceDatabaseException(e);
+ } finally {
+ try {
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ if (rs != null) {
+ rs.close();
+ }
+ if (c != null) {
+ returnConnection(c);
+ }
+ } catch (SQLException sql) {
+ logger.error("SQLException in finally cleanup", sql);
+ }
+ }
+ }
public List<ResourcepoolEntry> getAvailableEntriesSortedByFreeMemoryPercentage(int requestedMem)
throws WorkspaceDatabaseException{
View
8 service/service/java/source/src/org/globus/workspace/scheduler/defaults/DefaultSlotManagement.java
@@ -39,6 +39,7 @@
import org.globus.workspace.service.binding.vm.VirtualMachine;
import org.globus.workspace.service.binding.vm.VirtualMachineDeployment;
import org.nimbustools.api.services.rm.DoesNotExistException;
+import org.nimbustools.api.services.rm.ImpossibleAmountOfMemoryException;
import org.nimbustools.api.services.rm.ManageException;
import org.nimbustools.api.services.rm.NotEnoughMemoryException;
import org.nimbustools.api.services.rm.ResourceRequestDeniedException;
@@ -424,6 +425,8 @@ private Reservation _reserveCoscheduledSpace(NodeRequest[] requests,
throw new ProgrammingError(
"returned node should not be null");
}
+ } catch (ImpossibleAmountOfMemoryException e) {
+ throw e;
} catch (NotEnoughMemoryException e) {
if(!preemptable){
try {
@@ -441,6 +444,11 @@ private Reservation _reserveCoscheduledSpace(NodeRequest[] requests,
Integer neededMem = (vmids.length-i)*memory;
+ if (usedPreemptable == 0) {
+ // impossible to fulfill the request
+ throw e;
+ }
+
if(realAvailable >= neededMem){
//There will be sufficient space to
//fulfill this reservation
View
8 service/service/java/source/src/org/globus/workspace/scheduler/defaults/ResourcepoolUtil.java
@@ -21,6 +21,7 @@
import org.globus.workspace.Lager;
import org.globus.workspace.persistence.PersistenceAdapter;
import org.globus.workspace.persistence.WorkspaceDatabaseException;
+import org.nimbustools.api.services.rm.ImpossibleAmountOfMemoryException;
import org.nimbustools.api.services.rm.NotEnoughMemoryException;
import org.nimbustools.api.services.rm.ResourceRequestDeniedException;
import org.nimbustools.api.services.rm.ManageException;
@@ -218,7 +219,12 @@ static String getResourcePoolEntry(int mem,
if (trace) {
traceLookingForResource(mem, neededAssociations, greedy);
- }
+ }
+
+ if (db.isInfeasibleRequest(mem)) {
+ throw new ImpossibleAmountOfMemoryException(mem + "MB memory request is too " +
+ "large to ever be fulfilled");
+ }
//availableEntries is never empty
final List<ResourcepoolEntry> availableEntries =
View
9 .../java/tests/suites/spotinstances/src/org/globus/workspace/testing/suites/spotinstances/Issue26Suite.java
@@ -26,6 +26,7 @@
import org.nimbustools.api.repr.CreateRequest;
import org.nimbustools.api.repr.CreateResult;
import org.nimbustools.api.services.admin.RemoteNodeManagement;
+import org.nimbustools.api.services.rm.ImpossibleAmountOfMemoryException;
import org.nimbustools.api.services.rm.Manager;
import org.nimbustools.api.services.rm.NotEnoughMemoryException;
import org.springframework.test.annotation.DirtiesContext;
@@ -96,12 +97,12 @@ public void tooMuchMemory() throws Exception {
final Caller caller = this.populator().getCaller();
final CreateRequest request =
this.populator().getCreateRequest("suite:issue26:tooMuchMemory", 240, 3584, 1);
- boolean notEnoughMemory = false;
+ boolean impossibleMemory = false;
try {
final CreateResult result = rm.create(request, caller);
- } catch (NotEnoughMemoryException e) {
- notEnoughMemory = true;
+ } catch (ImpossibleAmountOfMemoryException e) {
+ impossibleMemory = true;
}
- assertTrue(notEnoughMemory);
+ assertTrue(impossibleMemory);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.