diff --git a/cave/com.raytheon.uf.viz.archive.feature/feature.xml b/cave/com.raytheon.uf.viz.archive.feature/feature.xml
index 37b1cd68f2..6b25bdef69 100644
--- a/cave/com.raytheon.uf.viz.archive.feature/feature.xml
+++ b/cave/com.raytheon.uf.viz.archive.feature/feature.xml
@@ -36,12 +36,6 @@
version="0.0.0"
unpack="false"/>
-
-
*
@@ -113,6 +115,9 @@ public class DatabaseArchiver implements IPluginArchiver {
/** Mapping for plug-in formatters. */
private final Map pluginArchiveFormatters;
+ /** When true dump the pdos. */
+ private final boolean debugArchiver;
+
/**
* The constructor.
*/
@@ -120,6 +125,7 @@ public class DatabaseArchiver implements IPluginArchiver {
pluginArchiveFormatters = new HashMap();
pluginArchiveFormatters.put("default",
new DefaultPluginArchiveFileNameFormatter());
+ debugArchiver = Boolean.parseBoolean(System.getenv("DEBUG_ARCHIVER"));
}
@Override
@@ -306,19 +312,20 @@ public class DatabaseArchiver implements IPluginArchiver {
throws SerializationException, IOException {
int recordsSaved = 0;
+ StringBuilder path = new StringBuilder();
for (Map.Entry> entry : pdoMap
.entrySet()) {
- String path = archivePath + File.separator + pluginName
- + File.separator + entry.getKey();
-
+ path.setLength(0);
+ path.append(archivePath).append(File.separator).append(pluginName)
+ .append(File.separator).append(entry.getKey());
// remove .h5
- if (path.endsWith(".h5")) {
- path = path.substring(0, path.length() - 3);
+ if (path.lastIndexOf(".h5") == (path.length() - 3)) {
+ path.setLength(path.length() - 3);
}
+ int pathDebugLength = path.length();
+ path.append(".bin.gz");
- path += ".bin.gz";
-
- File file = new File(path);
+ File file = new File(path.toString());
List pdosToSerialize = entry.getValue();
recordsSaved += pdosToSerialize.size();
@@ -385,6 +392,11 @@ public class DatabaseArchiver implements IPluginArchiver {
file.getParentFile().mkdirs();
}
+ if (debugArchiver) {
+ String debugRootName = path.substring(0, pathDebugLength);
+ dumpPdos(pluginName, pdosToSerialize, debugRootName);
+ }
+
// created gzip'd stream
os = new GZIPOutputStream(new FileOutputStream(file), 8192);
@@ -406,6 +418,48 @@ public class DatabaseArchiver implements IPluginArchiver {
return recordsSaved;
}
+ /**
+ * Dump the record information being archived to a file.
+ */
+ @SuppressWarnings("rawtypes")
+ private void dumpPdos(String pluginName,
+ List pdosToSerialize, String debugRootName) {
+ StringBuilder sb = new StringBuilder(debugRootName);
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
+ sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
+ sb.append("_").append(sdf.format(Calendar.getInstance().getTime()))
+ .append(".txt");
+ File file = new File(sb.toString());
+ FileWriter writer = null;
+ try {
+ PersistableDataObject>[] pdoArray = pdosToSerialize
+ .toArray(new PersistableDataObject>[0]);
+ writer = new FileWriter(file);
+ statusHandler.info(String.format("Dumping %s records to: %s",
+ pdoArray.length, file.getAbsolutePath()));
+ for (int i = 0; i < pdosToSerialize.size(); ++i) {
+ if (pdoArray[i] instanceof PluginDataObject) {
+ PluginDataObject pdo = (PluginDataObject) pdoArray[i];
+ writer.write(pdo.getDataURI());
+ } else {
+ writer.write(pdoArray[i].toString());
+ }
+ writer.write("\n");
+ }
+ } catch (Exception e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ } finally {
+ if (writer != null) {
+ try {
+ writer.close();
+ } catch (Exception e) {
+ // Ignore
+ }
+ writer = null;
+ }
+ }
+ }
+
/**
* Get the plug-in's start time for a query.
*