Browse files

Fix writing async vm partion, deployment and file copy tables

One more test passes!
  • Loading branch information...
1 parent 59a3688 commit b6a77a71c43ada6c7a7d297c509884be2c0241ab @oldpatricka oldpatricka committed Jun 22, 2011
View
17 ...service/java/source/src/org/globus/workspace/persistence/PersistenceAdapterConstants.java
@@ -262,8 +262,23 @@
"(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_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, " +
View
102 ...ava/source/src/org/globus/workspace/persistence/impls/AsyncRequestMapPersistenceUtil.java
@@ -124,6 +124,8 @@ public static PreparedStatement getUpdateAsyncRequest(AsyncRequest asyncRequest,
String nics = dataConvert.nicsAsString(asyncRequest.getRequestedNics());
pstmt.setString(10, nics);
pstmt.setString(11, asyncRequest.getStatus().toString());
+
+ pstmt.setString(12, asyncRequest.getId());
return pstmt;
}
@@ -264,7 +266,7 @@ public static void addPartitions(VirtualMachine vm, String asyncID, int binding_
return;
}
- final ArrayList partitions = new ArrayList(8);
+ final ArrayList<VirtualMachinePartition> partitions = new ArrayList<VirtualMachinePartition>(8);
do {
final VirtualMachinePartition partition =
@@ -281,7 +283,7 @@ public static void addPartitions(VirtualMachine vm, String asyncID, int binding_
partitions.add(partition);
} while (rs.next());
- VirtualMachinePartition[] final_partitions = new VirtualMachinePartition[partitions.size()];
+ VirtualMachinePartition[] final_partitions = partitions.toArray(new VirtualMachinePartition[partitions.size()]);
vm.setPartitions(final_partitions);
}
@@ -352,6 +354,102 @@ public static void putAsyncRequestBindings(AsyncRequest asyncRequest, Connection
pstmt.setString(15, binding.getCredentialName());
pstmt.executeUpdate();
pstmt.close();
+
+ putAsyncRequestVMDeployment(asyncRequest, i, c);
+ putAsyncRequestVMPartitions(asyncRequest, i, c);
+ putAsyncRequestVMFileCopies(asyncRequest, i, c);
+ }
+ }
+
+ public static void putAsyncRequestVMDeployment(AsyncRequest asyncRequest, int binding_index, Connection c) throws SQLException {
+
+ VirtualMachine binding = asyncRequest.getBindings()[binding_index];
+ VirtualMachineDeployment dep = binding.getDeployment();
+ PreparedStatement pstmt = c.prepareStatement(SQL_INSERT_ASYNC_REQUESTS_VM_DEPLOYMENT);
+
+ pstmt.setString(1, asyncRequest.getId());
+ pstmt.setInt(2, binding_index);
+ pstmt.setInt(3, binding.getID());
+ pstmt.setInt(4, dep.getRequestedState());
+ pstmt.setInt(5, dep.getRequestedShutdown());
+ pstmt.setInt(6, dep.getMinDuration());
+ pstmt.setInt(7, dep.getIndividualPhysicalMemory());
+ pstmt.setInt(8, dep.getIndividualCPUCount());
+ pstmt.executeUpdate();
+ pstmt.close();
+ }
+
+ public static void putAsyncRequestVMPartitions(AsyncRequest asyncRequest, int binding_index, Connection c) throws SQLException {
+
+ VirtualMachine binding = asyncRequest.getBindings()[binding_index];
+
+ for (VirtualMachinePartition partition : binding.getPartitions()) {
+
+ PreparedStatement pstmt = c.prepareStatement(SQL_INSERT_ASYNC_REQUESTS_VM_PARTITIONS);
+ pstmt.setString(1, asyncRequest.getId());
+ pstmt.setInt(2, binding_index);
+ pstmt.setInt(3, binding.getID());
+ pstmt.setString(4, partition.getImage());
+ pstmt.setString(5, partition.getImagemount());
+ boolean isReadWrite = partition.isReadwrite();
+ if (isReadWrite) {
+ pstmt.setInt(6, 1);
+ }
+ else {
+ pstmt.setInt(6, 0);
+ }
+ boolean isRootDisk = partition.isRootdisk();
+ if (isRootDisk) {
+ pstmt.setInt(7, 1);
+ }
+ else {
+ pstmt.setInt(7, 0);
+ }
+ pstmt.setInt(8, partition.getBlankspace());
+ boolean isPropRequired = partition.isPropRequired();
+ if (isPropRequired) {
+ pstmt.setInt(9, 1);
+ }
+ else {
+ pstmt.setInt(9, 0);
+ }
+ boolean isUnPropRequired = partition.isUnPropRequired();
+ if (isUnPropRequired) {
+ pstmt.setInt(10, 1);
+ }
+ else {
+ pstmt.setInt(10, 0);
+ }
+ pstmt.setString(11, partition.getAlternateUnpropTarget());
+
+ pstmt.executeUpdate();
+ pstmt.close();
+ }
+ }
+
+ public static void putAsyncRequestVMFileCopies(AsyncRequest asyncRequest, int binding_index, Connection c) throws SQLException {
+
+ VirtualMachine binding = asyncRequest.getBindings()[binding_index];
+
+ for (FileCopyNeed copy : binding.getFileCopyNeeds()) {
+
+ PreparedStatement pstmt = c.prepareStatement(SQL_INSERT_ASYNC_REQUESTS_VM_FILE_COPY);
+
+ pstmt.setString(1, asyncRequest.getId());
+ pstmt.setInt(2, binding_index);
+ pstmt.setInt(3, binding.getID());
+ pstmt.setString(4, copy.sourcePath);
+ pstmt.setString(5, copy.destPath);
+ boolean onImage = copy.onImage();
+ if (onImage) {
+ pstmt.setInt(6, 1);
+ }
+ else {
+ pstmt.setInt(6, 0);
+ }
+
+ pstmt.executeUpdate();
+ pstmt.close();
}
}

0 comments on commit b6a77a7

Please sign in to comment.