retval.user = work.user;
retval.tablesThatMustBeEmpty = new String[0]; // ensure non-null
try {
// catalog change specific boiler plate
CatalogContext context = VoltDB.instance().getCatalogContext();
// Start by assuming we're doing an @UpdateApplicationCatalog. If-ladder below
// will complete with newCatalogBytes actually containing the bytes of the
// catalog to be applied, and deploymentString will contain an actual deployment string,
// or null if it still needs to be filled in.
byte[] newCatalogBytes = work.operationBytes;
String deploymentString = work.operationString;
if (work.invocationName.equals("@UpdateApplicationCatalog")) {
// Do the straight-forward thing with the args, filling in nulls as appropriate
// Grab the current catalog bytes if @UAC had a null catalog
// (deployment-only update)
if (newCatalogBytes == null) {
try {
newCatalogBytes = context.getCatalogJarBytes();
}
catch (IOException ioe) {
retval.errorMsg = "Unexpected exception retrieving internal catalog bytes: " +
ioe.getMessage();
return retval;
}
}
// If the deploymentString is null, we'll fill it in with current deployment later
// Otherwise, deploymentString has the right contents, don't need to touch it
}
else if (work.invocationName.equals("@UpdateClasses")) {
// Need the original catalog bytes, then delete classes, then add
try {
newCatalogBytes = context.getCatalogJarBytes();
}
catch (IOException ioe) {
retval.errorMsg = "Unexpected exception retrieving internal catalog bytes: " +
ioe.getMessage();
return retval;
}
// provided operationString is really a String with class patterns to delete,
// provided operationBytes is the jarfile with the upsertable classes
try {
newCatalogBytes = modifyCatalogClasses(newCatalogBytes, work.operationString,
work.operationBytes);
}
catch (IOException e) {
retval.errorMsg = "Unexpected exception @UpdateClasses modifying classes " +
"from catalog: " + e.getMessage();
return retval;
}
// Real deploymentString should be the current deployment, just set it to null
// here and let it get filled in correctly later.
deploymentString = null;
}
else if (work.invocationName.startsWith("@AdHoc")) {
// newCatalogBytes and deploymentString should be null.
// work.adhocDDLStmts should be applied to the current catalog
try {
newCatalogBytes = addDDLToCatalog(context.getCatalogJarBytes(),
work.adhocDDLStmts);
}
catch (IOException ioe) {
retval.errorMsg = "Unexpected exception applying DDL statements to " +
" original catalog: " + ioe.getMessage();