Upgrade Procedure

  1. Write the XML sequence descriptor
  2. Update MostRecentVersions.txt
  3. Create new data element classes
  4. Update data holder class
  5. Update the fields in the reader to reflect the changes in the data holder class
  6. Update and re-compile the XML schema describing the data holder class

XML Sequence Descriptor

This file should have the same root name as the other descriptors for the same data type, but the version tags should be properly incremented. If this represents a new version of the data format, then the release number should be set to zero. Otherwise, the release number should be incremented one value and the version number should stay the same. Finally, the current data sequence descriptors are located in domtest/resources/jar/ where they can be viewed and used as templates for new data sequence descriptors, which should go in the same folder.

The XML sequence descriptor should be an XML file consisting only of DataElement tags enclosing fully-qualified class names. An example of a fully-qualified class name is "icecube.testdaq.testdaqio.VersionSystem.FlashData". The version reader system will read the data elements in the exact order and with the exact names that they are listed in the sequence description, so be extremely careful about the order and names of the data elements.

If there is a change to the structure of an existing data element, such as a definition of the spare byte in the Event Information wrapper of a DOM Engineering Record, the data element must be given an entirely new name.

NOTE: The version reader system assumes that a record produced by the Data Collector and the record that is wrapped within it have the same version number. This means that a format change in either will require that the most recent XML sequence descriptor for the other be reproduced with a different vesion tag, matching the new version tag for the altered data format.

NOTE: The Hardware State Event and Configuration Events that are contained in the MonitorRecord have different format tags than the other data sequences. These tags are a single digit without the V and R modifiers. This is a result of the format of the MonitorRecord defined by LBNL, in which the MonitorRecord contains a single identifier for its wrapped event. A new version of these event types will therefore accept a single integer in the XML Sequence rather than the full version identifier used with other formats.


Update MostRecentVersions.txt

This text file is found in domtest/resources/jar/ and allows some readers to read data without needing to be given the version and release of the data a priori. In the case that a reader for data produced by the DOM Hub does not receive a version number, it assumes that the data is of the most recent version, and it looks up the most recent version tag for the appropriate data type in MostRecentVersions.txt.

Changing the version tag on the appropriate line of the file (each line is labelled by a data type name) causes the readers to read the listed version as the default.


Create New Data Element Classes

Note that the title of this section is "Create New Data Element Classes." Nowhere does it say that old classes may be modified, and for good reason. The structure of the version reader system is predicated on the assumption that data elements will remain in existence, unaltered, for the lifetime of the IceCube project. Altering an existing data element, although it may seem appropriate, will prevent the system from correctly reading older data formats that depend on the data element that was altered. Changing a data element therefore invalidates all data produced up to the point of the version upgrade, and it may never be read again. This is obviously a situation to be avoided.


The constructor for every data element has the same method signature. This is because the constructors must be called from a generic context within the reader in order to function properly. As a result, the constructor signature is defined to be quite simple. It accepts only a single argument, the parent reader that will call it. As a result of this, even data elements which are duplicated across several structures, such as the wrapper bytes in Data Collector files, must be reproduced with different names for each of the readers that will call it.

Failing to conform to the signature described above will cause the version reader system to pass exceptions all the way up to the application that called testdaqio, where these exceptions must be handled. If this occurs, it will cause great annoyance to the person using the software, and will mean that data of the format you have encoded can never be read.

All new data elements should contain code to read their data from the ByteBuffer, called dataHolder, in the parent reader. All new data elements should also return their data to the parent reader, if it is relevant. For example, the event length byte is not returned to the parent reader because it is not necessary for the parent reader to have that information to read the rest of its data or to return its data holder object. This is, however, the exception rather than the rule. Any data element that features bit-encoding must also contain code, probably in a private read() method, to decode the information encoded into its byte(s) and report that data to the parent reader.

Once a new data element has been created, it must be placed in the VersionReader sub-package of testdaqio. Though not strictly necessary for the function of the readers, this convention is designed to keep all data elements in the same location, so that they may be easily found and to help reduce the chance of naming conflicts in the system.


Update Data Holder Class

Data holder classes, such as DomHitRecord, are returned to implementing software that performs operations on the holder objects to extract and use the data they contain. When a new field is added to a data stream, it may become necessary to add an identical field and the related methods to the associated data holder class. Doing so guarantees that the implementing software has access to the new information.

However, if you feel that the new information is strictly related to the contents of the data stream itself, such as a new format byte, then it may not be necessary to add this information to the data holder class. This decision is left to the discretion of the upgrading programmer. However, should you deem a change to be necessary in the data holder class, you are asked to make the change yourself and then to submit the changes to the Penn State group for encorporation into the next software release.

Finally, if the procedure described herein is necessary, please do not begin to produce data in the new format until the next release of the reader software becomes available. Otherwise, people using the software will experience bugs in their data-reading routines that they will be unable to trace, and the Penn State group will receive a large number of telephone calls from very annoyed software developers.


Update the Fields in the Reader to Reflect the Changes in the Data Holder Class

If new fields are introduced in the data holder class, changes will inevitably be necessary in the reader that produces that class as well. Any new field in the data holder should be reflected by a new field in the reader class as well, and the code in the reader class that produces the data holder object will need to be modified as well.

However, as older data will not contain these fields, and they will therefore not be set during read-time, you must hard-code a default value for these new fields into the reader. If this is impossible or will serve no useful purpose, please consider very carefully whether the addition of your new is data field into the data holder class is really necessary. If you believe that it is, but there is no reasonable default value, please contact the Penn State group, who will discuss options with you and attempt to find a solution.

As above, if these sort of changes are necessary, please complete them and then submit them to the Penn State group for encorporation into the next software release.


Update and re-compile the XML schema describing the data holder class

The data held in each data holder class might potentially be exported to XML format and stored on disk on some user's machine. In anticipation of this need, testdaqio will contain writers for producing this XML data. These classes will be public and accessible directly by implementing software. They will also rely on JAXB to produce valid XML that conforms to a schema that describes the data it should contain.

In order to maintain version consistency, a new XML schema must be produced to describe the new elements in the data holder class. The writer must also be altered to correctly extract the new fields from the data holder class and place their values into the Java content tree that will be exported to XML.


Note from the Developers

We at Penn State realize that the task of upgrading to a new format version may seem unnecessarily long and complex, and in some cases it may indeed require quite a bit of effort. However, we hope that in most cases the first three steps will be sufficient and that in some cases only the first two may be necessary. We do not believe that a complete upgrade of all of the software in the system will be necessary for most new versions.

However, even if this proves incorrect, it is important to remember that the alternative also requires a great deal of energy. To find the correct version of a data structure dynamically is not an easy task, and producing a new reader class for every new data release is even more difficult. We believe that the structure that we have put into place will require the least amount of energy in the long run, and will make reading data subtantially easier over the lifetime of the project.