Permalink
Browse files

Merge branch 'master' of github.com:nimbusproject/nimbus

  • Loading branch information...
2 parents 7dd9ee9 + e732ad4 commit fb4fc6a531d43838e7e8a24238ae6d0bb335fd03 @buzztroll buzztroll committed Jun 22, 2011
@@ -344,3 +344,21 @@ destpath VARCHAR(512),
on_image SMALLINT NOT NULL
);
+CREATE TABLE async_requests_allocated_vms
+(
+id VARCHAR(512) NOT NULL,
+vmid INT NOT NULL
+);
+
+CREATE TABLE async_requests_finished_vms
+(
+id VARCHAR(512) NOT NULL,
+vmid INT NOT NULL
+);
+
+CREATE TABLE async_requests_to_be_preempted
+(
+id VARCHAR(512) NOT NULL,
+vmid INT NOT NULL
+);
+
@@ -1,6 +1,8 @@
package org.globus.workspace.async;
+import java.io.InterruptedIOException;
import java.io.Serializable;
+import java.lang.reflect.Array;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
@@ -11,6 +13,7 @@
import org.nimbustools.api.repr.Caller;
import org.nimbustools.api.repr.ctx.Context;
import org.nimbustools.api.repr.vm.NIC;
+import sun.text.normalizer.IntTrie;
public class AsyncRequest implements Comparable<AsyncRequest>, Serializable {
@@ -119,7 +122,15 @@ public Integer getAllocatedInstances() {
public void addAllocatedVM(int createdId) {
this.allocatedVMs.add(createdId);
}
-
+
+ public void addFinishedVM(int createdId) {
+ this.finishedVMs.add(createdId);
+ }
+
+ public void addToBePreempted(int createdId) {
+ this.toBePreempted.add(createdId);
+ }
+
public Integer getUnallocatedInstances(){
return this.getNeededInstances() - getAllocatedInstances();
}
@@ -278,6 +289,36 @@ public boolean finishVM(int vmid) {
return result;
}
+ public int[] getAllocatedVMs() {
+ int[] allocated = new int[this.allocatedVMs.size()];
+ int i=0;
+ for (int vm : this.allocatedVMs) {
+ allocated[i] = vm;
+ i++;
+ }
+ return allocated;
+ }
+
+ public int[] getFinishedVMs() {
+ int[] finished = new int[this.finishedVMs.size()];
+ int i=0;
+ for (int vm : this.finishedVMs) {
+ finished[i] = vm;
+ i++;
+ }
+ return finished;
+ }
+
+ public int[] getToBePreempted() {
+ int[] preempted = new int[this.toBePreempted.size()];
+ int i=0;
+ for (int vm : this.toBePreempted) {
+ preempted[i] = vm;
+ i++;
+ }
+ return preempted;
+ }
+
public Calendar getCreationTime() {
return this.creationTime;
}
@@ -262,8 +262,59 @@
"(async_id, binding_index, id, name, node, prop_required, unprop_required, network, kernel_parameters, vmm, vmm_version, assocs_needed, md_user_data, preemptable, credential_name) " +
" VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ public static final String SQL_INSERT_ASYNC_REQUESTS_VM_DEPLOYMENT =
+ "INSERT INTO async_requests_vm_deployment " +
+ "(async_id, binding_index, vmid, requested_state, requested_shutdown, min_duration, ind_physmem, ind_physcpu) " +
+ " VALUES (?,?,?,?,?,?,?,?)";
+
+ public static final String SQL_INSERT_ASYNC_REQUESTS_VM_PARTITIONS =
+ "INSERT INTO async_requests_vm_partitions " +
+ "(async_id, binding_index, vmid, image, imagemount, readwrite, rootdisk, blankspace, prop_required, unprop_required, alternate_unprop) " +
+ " VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+
+ public static final String SQL_INSERT_ASYNC_REQUESTS_VM_FILE_COPY =
+ "INSERT INTO async_requests_vm_file_copy " +
+ "(async_id, binding_index, vmid, sourcepath, destpath, on_image) " +
+ " VALUES (?,?,?,?,?,?)";
+
+ public static final String SQL_INSERT_ASYNC_REQUESTS_ALLOCATED_VMS =
+ "INSERT INTO async_requests_allocated_vms " +
+ "(id, vmid) VALUES (?,?)";
+
+ public static final String SQL_INSERT_ASYNC_REQUESTS_FINISHED_VMS =
+ "INSERT INTO async_requests_finished_vms " +
+ "(id, vmid) VALUES (?,?)";
+
+ public static final String SQL_INSERT_ASYNC_REQUESTS_TO_BE_PREEMPTED =
+ "INSERT INTO async_requests_to_be_preempted " +
+ "(id, vmid) VALUES (?,?)";
+
+ public static final String SQL_DELETE_ASYNC_REQUESTS_ALLOCATED_VMS =
+ "DELETE FROM async_requests_allocated_vms " +
+ "WHERE id=?";
+
+ public static final String SQL_DELETE_ASYNC_REQUESTS_FINISHED_VMS =
+ "DELETE FROM async_requests_finished_vms " +
+ "WHERE id=?";
+
+ public static final String SQL_DELETE_ASYNC_REQUESTS_TO_BE_PREEMPTED =
+ "DELETE FROM async_requests_to_be_preempted " +
+ "WHERE id=?";
+
+ public static final String SQL_LOAD_ASYNC_REQUESTS_ALLOCATED_VMS =
+ "SELECT vmid FROM async_requests_allocated_vms " +
+ "WHERE id=?";
+
+ public static final String SQL_LOAD_ASYNC_REQUESTS_FINISHED_VMS =
+ "SELECT vmid FROM async_requests_finished_vms " +
+ "WHERE id=?";
+
+ public static final String SQL_LOAD_ASYNC_REQUESTS_TO_BE_PREEMPTED =
+ "SELECT vmid FROM async_requests_to_be_preempted " +
+ "WHERE id=?";
+
public static final String SQL_UPDATE_ASYNC_REQUEST =
- "UPDATE async_requests SET id=?, max_bid=?, spot=?, group_id=?, persistent=?, creator_dn=?, creator_is_superuser=?, ssh_key_name=?, creation_time=?, nics=?, status=?";
+ "UPDATE async_requests SET id=?, max_bid=?, spot=?, group_id=?, persistent=?, creator_dn=?, creator_is_superuser=?, ssh_key_name=?, creation_time=?, nics=?, status=? WHERE id=?";
public static final String SQL_LOAD_ASYNC_REQUESTS_VM_DEPLOYMENT =
"SELECT requested_state, requested_shutdown, min_duration, " +
@@ -60,6 +60,7 @@
import org.nimbustools.api.repr.vm.NIC;
import org.nimbustools.api.services.rm.DoesNotExistException;
import org.nimbustools.api.services.rm.ManageException;
+import org.springframework.scheduling.annotation.Async;
public class PersistenceAdapterImpl implements WorkspaceConstants,
PersistenceAdapterConstants,
@@ -3254,11 +3255,20 @@ public void addAsyncRequest(AsyncRequest asyncRequest)
pstmt = AsyncRequestMapPersistenceUtil.getDeleteAsyncRequestVMs(asyncRequest, c);
pstmt.executeUpdate();
+ AsyncRequestMapPersistenceUtil.removeAllocatedVMs(asyncRequest, c);
+ AsyncRequestMapPersistenceUtil.removeFinishedVMs(asyncRequest, c);
+ AsyncRequestMapPersistenceUtil.removeToBePreempted(asyncRequest, c);
+ AsyncRequestMapPersistenceUtil.putAllocatedVMs(asyncRequest, c);
+ AsyncRequestMapPersistenceUtil.putFinishedVMs(asyncRequest, c);
+ AsyncRequestMapPersistenceUtil.putToBePreempted(asyncRequest, c);
}
else {
logger.debug("Persisting request: " + asyncRequest.getId());
pstmt = AsyncRequestMapPersistenceUtil.getInsertAsyncRequest(asyncRequest, this.repr, c);
pstmt.executeUpdate();
+ AsyncRequestMapPersistenceUtil.putAllocatedVMs(asyncRequest, c);
+ AsyncRequestMapPersistenceUtil.putFinishedVMs(asyncRequest, c);
+ AsyncRequestMapPersistenceUtil.putToBePreempted(asyncRequest, c);
}
AsyncRequestMapPersistenceUtil.putAsyncRequestBindings(asyncRequest, c);
@@ -3314,6 +3324,9 @@ public AsyncRequest getAsyncRequest(String id)
asyncRequest = AsyncRequestMapPersistenceUtil.rsToAsyncRequest(rs, this.repr, c);
VirtualMachine[] bindings = AsyncRequestMapPersistenceUtil.getAsyncVMs(asyncRequest.getId(), c);
asyncRequest.setBindings(bindings);
+ AsyncRequestMapPersistenceUtil.addAllocatedVMs(asyncRequest, c);
+ AsyncRequestMapPersistenceUtil.addFinishedVMs(asyncRequest, c);
+ AsyncRequestMapPersistenceUtil.addToBePreempted(asyncRequest, c);
} catch (SQLException e) {
logger.error("",e);
Oops, something went wrong.

0 comments on commit fb4fc6a

Please sign in to comment.