[workspace-commit] CVS update: MODIFIED: impls
Tim Freeman
commit at globus.org
Thu Apr 17 10:11:02 CDT 2008
, VirtualMachinePersistenceUtil.java
...
User: tfreeman
Date: 08/04/17 10:11:02
Modified: vm/service/service/java/source/src/org/globus/workspace/persistence/impls
VirtualMachinePersistenceUtil.java
Log:
- alternate unpropagation target URL
- bulk status query
- file customizations
- fault can accompany state in RP/notification
- misc changes for new WSDL
- backend VM name prefix moved from "workspace" to "wrksp" (extends ebtables NIC length limit)
Revision Changes Path
1.9 +78 -20 workspace/vm/service/service/java/source/src/org/globus/workspace/persistence/impls/VirtualMachinePersistenceUtil.java
http://viewcvs.globus.org/viewcvs.cgi/workspace/vm/service/service/java/source/src/org/globus/workspace/persistence/impls/VirtualMachinePersistenceUtil.java.diff?r1=1.8&r2=1.9
(In the diff below, changes in quantity of whitespace are not shown.)
Index: VirtualMachinePersistenceUtil.java
===================================================================
RCS file: /home/globdev/CVS/globus-packages/workspace/vm/service/service/java/source/src/org/globus/workspace/persistence/impls/VirtualMachinePersistenceUtil.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- VirtualMachinePersistenceUtil.java 2 Nov 2007 14:47:11 -0000 1.8
+++ VirtualMachinePersistenceUtil.java 17 Apr 2008 15:11:01 -0000 1.9
@@ -22,10 +22,12 @@
import org.globus.workspace.ProgrammingError;
import org.globus.workspace.WorkspaceException;
import org.globus.workspace.persistence.PersistenceAdapterConstants;
+import org.globus.workspace.persistence.WorkspaceDatabaseException;
import org.globus.workspace.service.WorkspaceResource;
import org.globus.workspace.service.binding.vm.VirtualMachine;
import org.globus.workspace.service.binding.vm.VirtualMachineDeployment;
import org.globus.workspace.service.binding.vm.VirtualMachinePartition;
+import org.globus.workspace.service.binding.vm.CustomizationNeed;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -56,7 +58,7 @@
throw new ProgrammingError("vm is null");
}
- PreparedStatement pstmt = c.prepareStatement(SQL_INSERT_VM);
+ final PreparedStatement pstmt = c.prepareStatement(SQL_INSERT_VM);
pstmt.setInt(1, id);
pstmt.setString(2, vm.getName());
@@ -124,27 +126,29 @@
pstmt2.setInt(5, dep.getIndividualPhysicalMemory());
}
- ArrayList inserts = new ArrayList();
+ final ArrayList inserts = new ArrayList(16);
inserts.add(pstmt);
if (pstmt2 != null) {
inserts.add(pstmt2);
}
- VirtualMachinePartition[] partitions = vm.getPartitions();
+ final VirtualMachinePartition[] partitions = vm.getPartitions();
if (partitions != null) {
for (int i = 0; i < partitions.length; i++) {
- PreparedStatement partStmt =
+ final PreparedStatement partStmt =
c.prepareStatement(SQL_INSERT_VM_PARTITION);
partStmt.setInt(1, id);
- if (partitions[i].getImage() != null) {
- partStmt.setString(2, partitions[i].getImage());
+ final String image = partitions[i].getImage();
+ if (image != null) {
+ partStmt.setString(2, image);
} else {
partStmt.setNull(2, Types.VARCHAR);
}
- if (partitions[i].getImagemount() != null) {
- partStmt.setString(3, partitions[i].getImagemount());
+ final String imageMount = partitions[i].getImagemount();
+ if (imageMount != null) {
+ partStmt.setString(3, imageMount);
} else {
partStmt.setNull(3, Types.VARCHAR);
}
@@ -175,11 +179,35 @@
partStmt.setInt(8, 0);
}
+ final String alt = partitions[i].getAlternateUnpropTarget();
+ if (alt != null) {
+ partStmt.setString(9, alt);
+ } else {
+ partStmt.setNull(9, Types.VARCHAR);
+ }
+
inserts.add(partStmt);
}
}
+ final CustomizationNeed[] needs = vm.getCustomizationNeeds();
+ if (needs != null) {
+ for (int i = 0; i < needs.length; i++) {
+ final PreparedStatement custStmt =
+ c.prepareStatement(SQL_INSERT_VM_CUSTOMIZATION);
+ custStmt.setInt(1, id);
+ custStmt.setString(2, needs[i].sourcePath);
+ custStmt.setString(3, needs[i].destPath);
+ if (needs[i].isSent()) {
+ custStmt.setInt(4, 1);
+ } else {
+ custStmt.setInt(4, 0);
+ }
+ inserts.add(custStmt);
+ }
+ }
+
return (PreparedStatement[]) inserts.toArray(
new PreparedStatement[inserts.size()]);
}
@@ -205,23 +233,29 @@
throw new IllegalArgumentException("vm is null");
}
- ArrayList deletes = new ArrayList();
+ final ArrayList deletes = new ArrayList();
- PreparedStatement pstmt = c.prepareStatement(SQL_DELETE_VM);
+ final PreparedStatement pstmt = c.prepareStatement(SQL_DELETE_VM);
pstmt.setInt(1, id);
deletes.add(pstmt);
- PreparedStatement pstmt2;
- if (vm.getDeployment() !=null) {
- pstmt2 = c.prepareStatement(SQL_DELETE_VM_DEPLOYMENT);
+ if (vm.getDeployment() != null) {
+ final PreparedStatement pstmt2 =
+ c.prepareStatement(SQL_DELETE_VM_DEPLOYMENT);
pstmt2.setInt(1, id);
deletes.add(pstmt2);
}
- PreparedStatement pstmt3 = c.prepareStatement(SQL_DELETE_VM_PARTITIONS);
+ final PreparedStatement pstmt3 =
+ c.prepareStatement(SQL_DELETE_VM_PARTITIONS);
pstmt3.setInt(1, id);
deletes.add(pstmt3);
+ final PreparedStatement pstmt4 =
+ c.prepareStatement(SQL_DELETE_VM_CUSTOMIZATION);
+ pstmt4.setInt(1, id);
+ deletes.add(pstmt4);
+
return (PreparedStatement[]) deletes.toArray(
new PreparedStatement[deletes.size()]);
}
@@ -234,19 +268,27 @@
logger.trace("getVMQuery(): " + Lager.id(id));
}
- PreparedStatement pstmt = c.prepareStatement(SQL_LOAD_VM);
+ final PreparedStatement pstmt =
+ c.prepareStatement(SQL_LOAD_VM);
pstmt.setInt(1, id);
- PreparedStatement pstmt2 = c.prepareStatement(SQL_LOAD_VM_DEPLOYMENT);
+ final PreparedStatement pstmt2 =
+ c.prepareStatement(SQL_LOAD_VM_DEPLOYMENT);
pstmt2.setInt(1, id);
- PreparedStatement pstmt3 = c.prepareStatement(SQL_LOAD_VM_PARTITIONS);
+ final PreparedStatement pstmt3 =
+ c.prepareStatement(SQL_LOAD_VM_PARTITIONS);
pstmt3.setInt(1, id);
- PreparedStatement[] selects = new PreparedStatement[3];
+ final PreparedStatement pstmt4 =
+ c.prepareStatement(SQL_LOAD_VM_CUSTOMIZATION);
+ pstmt4.setInt(1, id);
+
+ final PreparedStatement[] selects = new PreparedStatement[4];
selects[0] = pstmt;
selects[1] = pstmt2;
selects[2] = pstmt3;
+ selects[3] = pstmt4;
return selects;
}
@@ -281,7 +323,7 @@
logger.trace("addDeployment(): vm = " + vm);
}
- VirtualMachineDeployment dep = new VirtualMachineDeployment();
+ final VirtualMachineDeployment dep = new VirtualMachineDeployment();
dep.setRequestedState(rs.getInt(1));
dep.setRequestedShutdown(rs.getInt(2));
dep.setMinDuration(rs.getInt(3));
@@ -296,7 +338,9 @@
logger.trace("getPartition()");
}
- VirtualMachinePartition partition = new VirtualMachinePartition();
+ final VirtualMachinePartition partition =
+ new VirtualMachinePartition();
+
partition.setImage(rs.getString(1));
partition.setImagemount(rs.getString(2));
partition.setReadwrite(rs.getBoolean(3));
@@ -304,6 +348,20 @@
partition.setBlankspace(rs.getInt(5));
partition.setPropRequired(rs.getBoolean(6));
partition.setUnPropRequired(rs.getBoolean(7));
+ partition.setAlternateUnpropTarget(rs.getString(8));
return partition;
}
+
+ public static CustomizationNeed getNeed(ResultSet rs)
+ throws WorkspaceDatabaseException {
+
+ try {
+ final String src = rs.getString(1);
+ final String dst = rs.getString(2);
+ final boolean sent = rs.getBoolean(3);
+ return new CustomizationNeed(src, dst, sent);
+ } catch (Exception e) {
+ throw new WorkspaceDatabaseException(e.getMessage(), e);
+ }
+ }
}
More information about the workspace-commit
mailing list