Svc::DpCatalog Component
1 Introduction
DpCatalog is an active F´ component that manages the downlink of generate data products. The data products were previously generated by components into a project-specific set of directories. Upon command, DpCatalog will build a catalog of existing data products and start downloading them. They are downloaded in order of priority, then generation time. The priority is the one stored in the file unless it was changed with SET_DP_PRIORITY, which reprioritizes a single product and, if a state file is configured, records the new priority in it so that the change is kept across catalog rebuilds and restarts.
NOTE: This release has an early prototype that will do the following:
- Reads the data product files from the specified directory.
- Puts them in priority sorted list.
- Sends requests to
Svc/FileDownlinkto downlink each file in the list. - Stop transmissions in progress
- Allow insertion of new products after the catalog is built
- Clear the catalog via command
- Restrict a transmission to an inclusive priority range (
START_XMIT_CATALOG_WITH_PRIORITY) - Change the transmit priority of one product by command (
SET_DP_PRIORITY); the change is kept in the state file, if one is configured - Delete one product by command (
DELETE_DP): its file, its catalog entry and its state file record - Reschedule one transmitted product for downlink by command (
RETRANSMIT_DP), for a product corrupted in transit or lost on the ground
It does not:
- Send data product files in pieces. It only sends whole files, so if the downlink is interrupted, the whole file will have to be retransmitted.
Features and more extended unit testing will be added over time. Use at your own risk!
2 Requirements
| Requirement | Description | Rationale | Verification Method |
|---|---|---|---|
| SVC-DPCAT-001 | DpCatalog shall read a set of directories and build a catalog of data products. |
DpCatalog needs to know at least one directory where data products reside |
Test |
| SVC-DPCAT-002 | DpCatalog shall sort data products first based on the internally recorded priority where the highest priority is represented by the lowest number. |
DpCatalog needs to downlink highest priority items first |
Test |
| SVC-DPCAT-003 | DpCatalog shall sort data products second based on the internally recorded time with oldest products as higher priority. |
DpCatalog needs to downlink oldest items first |
Test |
| SVC-DPCAT-004 | DpCatalog shall sort data products third based on the internally recorded product ID with the lowest as higher priority. |
DpCatalog needs to resolve case where priority and time match |
Test |
| SVC-DPCAT-005 | DpCatalog shall update the data product metadata once download is complete |
DpCatalog needs to track completion status to avoid duplicate downloads |
Test |
| SVC-DPCAT-006 | DpCatalog shall implement a command and port to build the catalog. |
DpCatalog should consume the resources to build the catalog only when needed |
Test |
| SVC-DPCAT-007 | DpCatalog shall implement a command and port to start downloading the catalog. |
DpCatalog downloads should be timed for when communications are ready, and not consume comm window time building |
Test |
| SVC-DPCAT-008 | DpCatalog shall have filters for the download based on container ID, priority, and data size limit. |
DpCatalog downloads should be tunable for available bandwidth and container metadata |
Test |
| SVC-DPCAT-009 | DpCatalog shall implement a way to insert newly-generated data products into the catalog after the catalog is built |
DpCatalog should notice new products and not require a rebuild of the catalog |
Test |
| SVC-DPCAT-010 | DpCatalog shall implement commands to modify the priority of existing data products |
Operators made change the priority to lower or raise priorities due to troubleshooting, etc | Test |
| SVC-DPCAT-011 | DpCatalog shall implement commands to delete data products |
Ground tools can use DpManager commands to automatically delete DPs | Test |
| SVC-DPCAT-012 | DpCatalog shall implement a catalog data product that is a listing of existing data products and their metadata |
Allow operators to know what products exist | Test |
| SVC-DPCAT-013 | DpCatalog shall have filters for the catalog data product for priority, container ID, and time range |
Allow operators to know what products exist | Test |
| SVC-DPCAT-014 | DpCatalog shall implement a START_XMIT_CATALOG_WITH_PRIORITY command that accepts an inclusive start and end priority and transmits only the pending data products whose priority is within that range, in priority order; START_XMIT_CATALOG shall transmit the whole catalog with an unchanged argument list |
Operations tune which priority levels are downlinked during a pass without breaking existing sequences | Unit Test, Integration Test |
| SVC-DPCAT-015 | START_XMIT_CATALOG_WITH_PRIORITY shall reject a range whose start priority exceeds its end priority with a VALIDATION_ERROR command response and a warning event, leaving the catalog and transmit state unchanged |
Invalid ground input must fail visibly and safely | Unit Test, Integration Test |
| SVC-DPCAT-016 | Data products outside the requested priority range shall remain pending in the catalog, available to a later transmit command, without any change to the catalog data structures or the state file format | The range is a transmit filter, not a deletion; existing state files stay compatible | Unit Test |
| SVC-DPCAT-017 | DpCatalog shall implement a command that sets the transmit priority of one data product, identified by container ID and time tag, so that it is transmitted in the order given by the new priority |
Operators may raise or lower the priority of a product to debug an issue or prioritize data (#5860); implements SVC-DPCAT-010 | Test |
| SVC-DPCAT-018 | DpCatalog shall reject a priority change for a data product that is not in the catalog with an event and a failed command response |
Operators need to know the product was not affected | Test |
| SVC-DPCAT-019 | DpCatalog shall apply a priority change made during catalog transmission to the transmit order of the products not yet sent without disturbing the send in flight |
Operators change priorities during a pass; the transmit must not be corrupted | Test |
| SVC-DPCAT-020 | DpCatalog shall treat a priority change to the current priority as a no-op that reports the unchanged priority and succeeds |
Idempotent command for sequences | Test |
| SVC-DPCAT-021 | DpCatalog shall record a priority change in the state file, when one is configured, so that it is kept across catalog rebuilds and restarts, without modifying the data product file or the state file format |
The change outlives a restart before the pass (#5860); the file is mission data and existing state files stay readable | Test |
| SVC-DPCAT-022 | DpCatalog shall report with an event, and fail the command, a priority change that cannot be recorded in the configured state file |
Operators know when the change will not survive a restart | Test |
| SVC-DPCAT-023 | DpCatalog shall implement a command that deletes one data product, identified by container ID and time tag, removing its file, its catalog entry and its record in the state file, when one is configured |
Operators and ground tools reclaim storage from products that are transmitted or no longer wanted (SVC-DPCAT-011) | Test |
| SVC-DPCAT-024 | DpCatalog shall refuse to delete the data product being transmitted, and shall reject with an event and a failed command response a product that it does not know |
The send in flight is never preempted; operators need to know when nothing was deleted | Test |
| SVC-DPCAT-025 | DpCatalog shall implement a command that reschedules one transmitted data product, identified by container ID and time tag, for downlink at its header priority, resetting its transmitted state in memory and in the state file, when one is configured |
Data products may be corrupted in transit or lost on the ground and must be downlinked again (#6284) | Test |
| SVC-DPCAT-026 | DpCatalog shall reject a retransmit request with an event naming the reason and a failed command response when the catalog is not built, the product is being transmitted or is pending, no file of the product exists in a managed directory, or the file cannot be cataloged |
The operator must learn why nothing was rescheduled; a pending or in-flight product is sent anyway | Test |
| SVC-DPCAT-027 | A product rescheduled for retransmission shall be downlinked as a product inserted at runtime is: by the transmission in progress, by resuming a finished or stopped transmission under remainActive, or by the next transmit command |
Retransmission reuses the existing downlink scheduling rather than adding a second path | Test |
| SVC-DPCAT-028 | DpCatalog shall skip, with an event, a state file record whose directory index is not in the configured directory list |
The directory list can change across a restart, and a corrupt record must not index past the directory list | Test |
3 Design
3.1 Assumptions
The design of DpCatalog assumes the following:
- A file system exists to store the data product files.
- The contents of the data product files match the data product specification.
- The file downlink will acknowledge completion of each file
3.2 Ports
3.2.1 Role Ports
These ports will be automatically connected in the topology to F Prime services.
| Name | Role |
|---|---|
| cmdDisp | Receives commands |
| CmdReg | Registers commands |
| CmdStatus | Returns command status |
| Log | Outputs events for ground |
| LogText | Outputs events for console |
| Time | Gets time for time tags |
| Tlm | Outputs telemetry |
3.2.2 Component-Specific Ports
| Name | Type | Kind | Purpose |
|---|---|---|---|
| pingIn | Svc.Ping | async input | Ping from Health |
| pingOut | Svc.Ping | output | Ping response to Health |
| fileOut | Svc.SendFileRequest | output | Send next file to downlink |
| fileDone | Svc.SendFileComplete | async input | Last requested file is complete |
| addToCat | Svc.DpWritten | async input | Insert a newly written data product into the catalog |
3.3 Constants
DpCatalog can be statically configured with the following constants:
| Constant | Purpose |
|---|---|
| DP_MAX_DIRECTORIES | Maximum directories that can be provided for DPs |
| DP_MAX_FILES | Maximum number of files that can be tracked across directories |
These constants are located in DpCatalogCfg.hpp in the config directory.
3.4 Configuration
During initialization, the configuration function takes a set of parameters:
void configure(
const Fw::ExternalArray<Fw::FileNameString>& directories,
Fw::FileNameString& stateFile,
FwEnumStoreType memId,
Fw::MemAllocator& allocator
);
| Parameter | Purpose |
|---|---|
directories |
An array of strings up to DP_MAX_DIRECTORIES that are directory names where DPs are written |
stateFile |
The location of the file tracking product downlink state |
memId |
The id of the RAM memory segment used to store catalog state. Not needed for heap allocation. |
allocator |
Memory allocator for RAM memory storage |
3.5 Commands
| Command | Arguments | Description |
|---|---|---|
BUILD_CATALOG |
none | Builds the in-RAM catalog by scanning the directories provided during initialization. Downlink state file will be read in to set downlink state for products |
START_XMIT_CATALOG |
Start transmitting the catalog to the ground in priority order | |
| wait | Wait for the transmission to complete before sending command completion status. Used when a sequence wishes to wait for completion before issuing subsequent commands. | |
remainActive |
When true, a data product added at runtime through addToCat (3.6.7) after transmission has finished (or been stopped) resumes transmission. When false, runtime additions wait for the next transmit command. START_XMIT_CATALOG transmits the full priority range (0 through the maximum FwDpPriorityType value) and resets any range set by an earlier START_XMIT_CATALOG_WITH_PRIORITY. |
|
START_XMIT_CATALOG_WITH_PRIORITY |
Start transmitting, in priority order, only the pending products inside an inclusive priority range. Behaves as START_XMIT_CATALOG otherwise |
|
wait |
As for START_XMIT_CATALOG: the command completes when the in-range products have been transmitted. |
|
remainActive |
When true, a data product added at runtime through addToCat after transmission has finished (or been stopped) resumes transmission if any pending product in the catalog, the new one or one left behind, is inside the active range; the in-range products are then sent in priority order. If none is in range nothing is started and the product stays pending for a later transmit command. The range also bounds urgent products: a runtime product whose priority is below startPriority (more urgent than the range) is not sent either and is announced only by DpFileAdded; use startPriority = 0 when urgent products must always go out. When false, runtime additions wait for the next transmit command. |
|
startPriority, endPriority |
Inclusive priority range (FwDpPriorityType) to transmit; lower values are more urgent and are sent first. Only pending products with startPriority <= priority <= endPriority are sent; the others stay pending for a later command. 0 through the maximum FwDpPriorityType value (4294967295 for the default U32) is equivalent to START_XMIT_CATALOG. startPriority > endPriority is rejected with VALIDATION_ERROR and XmitPriorityRangeInvalid (WARNING_LO, id 51) before any state changes. Each accepted transmit command (either form) reports its range with CatalogXmitRangeStarted (ACTIVITY_HI, id 52). The range stays in effect for runtime additions sent under remainActive until the next transmit command. A transmit command that resumes a send left in flight by STOP_XMIT_CATALOG applies its range only from the next file: the file in flight completes whatever its priority, and its bytes are included in that command's CatalogXmitCompleted tally. |
|
STOP_XMIT_CATALOG |
none | Stop existing catalog transmission. The command completes immediately and no further files are started; the file in flight completes normally and is recorded. Its bytes are counted in neither CatalogXmitStopped (emitted before that completion) nor a later CatalogXmitCompleted (a START_XMIT_CATALOG issued after the completion starts a fresh tally); reconstruct them from ProductComplete. A START_XMIT_CATALOG (or a runtime addToCat with remainActive while a pending product is inside the active range) issued before that completion resumes the transmission without re-sending the file: no new send is started until its completion arrives, which then continues the catalog walk, and the session's byte tally reported by CatalogXmitCompleted is kept. As with any send, the resumed transmission stays in progress until FileDownlink delivers that completion; if it never arrives, STOP_XMIT_CATALOG (then BUILD_CATALOG) or CLEAR_CATALOG is the recovery, as for a stalled send started normally. A BUILD_CATALOG or CLEAR_CATALOG issued before that completion abandons the file: its late completion is reported as StaleFileDone and it is re-sent on the next START_XMIT_CATALOG. |
CLEAR_CATALOG |
none | Clears existing RAM catalog and resets downlink state, reporting the pending products and bytes dropped with CatalogCleared. A transmission in progress is aborted (a waited START_XMIT_CATALOG is answered with EXECUTION_ERROR). Should be followed by BUILD_CATALOG. Used for recovery if state file gets corrupted or out of sync with file system contents. |
SET_DP_PRIORITY |
Set the transmit priority of one data product. The product is identified the way the catalog identifies it: container id and time tag (tSec, tSub), which are the fields of its file name. The entry is re-linked into the catalog at the position given by the new priority (lower is higher priority; ties are broken by time, id, and directory as for any entry) and DpPrioritySet reports the old and new priority. A product that is not in the catalog (including before BUILD_CATALOG, or after it was transmitted and removed) is reported with DpNotFound and the command fails with EXECUTION_ERROR. Setting the current priority is a no-op: DpPriorityUnchanged reports it and the command succeeds. During a transmission the new order takes effect from the next send; the send in flight is not restarted or abandoned, and its own entry may be reprioritized (the new priority only matters if the send fails and the entry stays in the catalog). If a state file is configured, a changed priority is recorded in it, so it is kept across BUILD_CATALOG, CLEAR_CATALOG, and restart; the data product file is not modified. If it cannot be recorded (state file data full, reported with StateFileFull (id 55), or a state file write error) the new order still applies until the next rebuild and the command fails with EXECUTION_ERROR (see 3.6.8). |
|
| id | Container ID of the data product | |
| tSec | Seconds of the data product time tag | |
| tSub | Microseconds of the data product time tag | |
| priority | New transmit priority | |
DELETE_DP |
Delete one data product, identified as for SET_DP_PRIORITY by container id and time tag (tSec, tSub). The product's file is removed, its catalog entry (if pending) is dropped with the pending counters, and its state file record (if transmitted, or if the record exists) is dropped and the state file rewritten when one is configured. DpDeleted reports the file and the transmit state the product had. The behavior is detailed in 3.6.9. |
|
| id | Container ID of the data product | |
| tSec | Seconds of the data product time tag | |
| tSub | Microseconds of the data product time tag | |
RETRANSMIT_DP |
Reschedule one transmitted data product for downlink, identified as for SET_DP_PRIORITY by container id and time tag (tSec, tSub). The product is cataloged again from its file at its header priority (a priority set by SET_DP_PRIORITY before its downlink does not carry over), its state file record is replaced by an UNTRANSMITTED one, and it is downlinked as a product inserted at runtime is (3.6.7). Refused while the product is pending or being transmitted (3.6.10) |
|
| id | Container ID of the data product | |
| tSec | Seconds of the data product time tag | |
| tSub | Microseconds of the data product time tag |
Sequence of Commands
When the software is first started, the catalog data structure is empty. The catalog must be built before starting downlink. The BUILD_CATALOG command was implemented separately from the START_XMIT_CATALOG command to start downlinking so the software could build the catalog prior to a communication session and execute the downlink during communication. Downlink can be halted by issuing the STOP_XMIT_COMMAND in the middle of the downlink. If for some reason the state in the state file, the contents of the tree and the data products get out of sync, a CLEAR_CATALOG command can be issued. Then the BUILD_CATALOG command can be invoked to rebuild the state based on the existing set of data product files only. This will caused downlinked state to be lost, so data products not deleted after downlink would be readded to the pending list of downlinks. DELETE_DP likewise needs a built catalog (or the state file data loaded by the last build); a transmitted product deleted with it is not readded by a later CLEAR_CATALOG/BUILD_CATALOG (3.6.9). SET_DP_PRIORITY can be issued once the catalog is built, before or during a START_XMIT_CATALOG, to change the order of products not yet sent; if a state file is configured the change is recorded in it and kept across BUILD_CATALOG, CLEAR_CATALOG, and restart (3.6.8). RETRANSMIT_DP also needs a built catalog (it is rejected NOT_BUILT before BUILD_CATALOG and after CLEAR_CATALOG) and, like SET_DP_PRIORITY, is accepted during a transmission (3.6.10).
3.6 Algorithms
3.6.1 Data Product Sorting
Overall priority is determined by comparing two entries' priority, timestamp, id, and directory index in that order with lower numerical values holding higher priority (see DpCatalog::DpStateEntry::compareEntries). The following logic is implemented:
- Data Product Priority - Data products are generated with a priority, where the lower the number the higher the priority.
- Data Product Generation Time - If priorities are the same, the older data is prioritized over the newer.
- Data Product ID - If priorities and time are the same (highly unlikely), then lower IDs are prioritized first.
- Directory Index - If a file of the same name (same priority, time, and id) is held in two configured directories, the lower index in the configured directory list is prioritized first. The directory is part of the key so that two distinct files never share a catalog entry, whatever priorities they hold or are set to (3.6.8).
3.6.2 Reading Files
The configure() function is provided an array of directories where data product files are generated by Svc/DpWriter. When the BUILD_CATALOG command is executed, the headers of the data product files are read and the metadata in their headers is processed and stored as a data structure for sorting. The file name is not stored to conserve memory.
3.6.3 Sorting Algorithm
The data products are sorted using a Fw::RedBlackTreeSet (a self-balancing binary search tree). Entries are ordered by the priority comparison described above, so the highest priority entry is always first in the set.
3.6.4 Tree Traversal for Downlink
When data products are downlinked, entries are retrieved in priority order by iterating the set from begin(), which always yields the highest priority (lowest value) entry. The walk skips, without removing, entries whose priority value is below the startPriority of the active transmit command and stops at the first entry above its endPriority, since nothing after it can be in range; the first entry inside the range is the next file to send. As each file completes downlink, its entry is removed from the set, so the next walk again starts at begin(). Entries inserted while a downlink is in progress (e.g. via addToCat) are placed in priority order and picked up by subsequent walks if they fall inside the range. The walk is bounded by the catalog size (DP_MAX_FILES); skipped out-of-range entries are revisited on every sendNextEntry, which is acceptable at that bound. Entries left outside the range remain pending (and counted in m_pendingFiles) for a later transmit command with a range that covers them. Consequently CatalogXmitCompleted means that the requested range is exhausted, not that the catalog is empty: products outside the range may still be pending. A range that matches no pending product is accepted and reports CatalogXmitRangeStarted immediately followed by CatalogXmitCompleted with 0 bytes, exactly as an empty catalog does, unless a send left in flight by STOP_XMIT_CATALOG is pending: CatalogXmitCompleted then follows that file's completion and reports its bytes. The file in flight is never preempted: when its fileDone arrives the next send is the highest priority in-range entry remaining in the set, whether it was there at BUILD_CATALOG or was inserted since.
3.6.5 State File
When a data product is downlinked, it is marked in the node as completed, but the state is also written to a file so that downlinked state is preserved across restarts of the software. When the catalog is built, the state file is first read into a data structure in memory. A record whose directory index is not in the configured directory list (the list changed across a restart, or the file is corrupt) names a file this configuration cannot locate: it is skipped with StateFileDirectoryInvalid (WARNING_HI, id 63, throttled per load) and not loaded (SVC-DPCAT-028), so every record in the state file data has a valid directory index. The next state file rewrite leaves the skipped record out.
Entries whose state-file record is TRANSMITTED are skipped during catalog build, emit a DpFileSkipped event, and are not counted as pending.
3.6.6 FileDone Handling
Every sendFile call returns a SendFileResponse whose context FileDownlink assigns to that send and echoes back in fileDone. DpCatalog keeps the context of the send in flight and applies a fileDone only while a send is in flight and the context matches. Anything else is a late callback from a send abandoned by BUILD_CATALOG or CLEAR_CATALOG (STOP_XMIT_CATALOG alone keeps the send in flight, so its completion is still recorded, and a START_XMIT_CATALOG issued before it arrives starts no new send until then, so the file is not sent twice): it is reported with StaleFileDone (WARNING_LO, id 50, an expected consequence of an operator command rather than a fault) and the transmit in flight, if any, is left untouched. CLEAR_CATALOG issued mid-transmit closes the transmit session itself, as STOP_XMIT_CATALOG does: a waited START_XMIT_CATALOG is answered with EXECUTION_ERROR at that point, so a later BUILD_CATALOG or START_XMIT_CATALOG is not refused as in progress and the late callback is only reported. This replaces the FW_ASSERT that made a late fileDone FATAL (#5777). The discrimination requires the provider to assign a distinct context to every send, as Svc/FileDownlink does; a provider that echoes a constant context (for example Svc/Ccsds/CfdpManager, which returns the port number) cannot distinguish a late callback from the current send and is not supported on this port. Note: FileComplete must not be shared with other SendFile clients on the same FileDownlink; foreign completions would be reported as StaleFileDone.
3.6.7 Runtime Insertion (addToCat)
Svc/DpWriter reports every data product file it writes on its dpWrittenOut port (file name, priority, size); the DataProducts subtopology connects it to addToCat. The handler reads the header of the named file and inserts an entry exactly as BUILD_CATALOG does (processFile), so a product added at runtime sorts identically to one found by a build. The priority and size carried by the port are not used: the header is the authoritative source and is read anyway for the id and time tag, which the port does not carry. The cases are handled as follows:
| Condition | Behavior |
|---|---|
Component not configured (ComponentNotInitialized) or configured with no slots (ComponentNoMemory) |
The file is not recorded; the corresponding warning is emitted, as for the commands. |
Catalog not built (no BUILD_CATALOG yet, or CLEAR_CATALOG since the last build) |
The file is not recorded; NotLoaded is emitted. The file is on disk in a managed directory and is found by the next BUILD_CATALOG. |
| File is not under a configured directory | DirectoryNotManaged; the file is ignored. |
| File cannot be read or has a bad size, header, CRC, or name | The same FileSizeError/FileOpenError/FileReadError/FileHdrError/FileHdrDesError/FileNameFormatError/InvalidFileName events as at build time; nothing is inserted. |
| Tree insert fails although a slot is free (not expected) | DpInsertError; nothing is inserted. |
Product already in the catalog (same directory, id, tSec, tSub; the priority is not compared, since SET_DP_PRIORITY may have changed it) |
DpDuplicate; pending counters are unchanged. DpDuplicate is DIAGNOSTIC, which Svc/EventManager filters out by default (FILTER_DIAGNOSTIC_DEFAULT), so it is not downlinked unless that filter is enabled. |
Product recorded as TRANSMITTED in the state file data (loaded by the last BUILD_CATALOG and updated by each completion since, 3.6.8) |
The file is not recorded; DpFileSkipped is emitted, as at build time. Records appended since that build (3.6.6) are applied at the next BUILD_CATALOG as long as the product has, or can get, a slot in the state file data: the file may hold several records for one product (3.6.8) and loadStateFile reads them all, but a record for a product beyond the configured number of distinct products (at most DP_MAX_FILES) is skipped without an event, so such a transmitted product is re-added and re-sent by the rebuild. Delete downlinked products with DELETE_DP (3.6.9), which drops the state file record and frees the slot, so the number of distinct products in the state file stays within the slot budget; a file removed outside the component keeps its record until the next BUILD_CATALOG prunes it. RETRANSMIT_DP (3.6.10) resets such a record so that the product is sent again. DpWriter reports each file once, so the runtime skip only arises if an identical product is rewritten. |
Catalog has no free slot (DP_MAX_FILES/configured slots in use) |
DpCatalogFull; nothing is inserted. The product is not inserted when a slot later frees: the entry being downlinked holds its slot until its fileDone, so at most slots − 1 products can be inserted during a transmission. The file remains on disk and is found by the next BUILD_CATALOG, which a transmission in progress refuses. DpCatalogFull is throttled after 10 occurrences, after which refused products are not reported. |
| Otherwise | The entry is inserted in priority order, DpFileAdded is emitted, and the pending file/byte counts are updated. |
After a successful insert: if a transmission is in progress, the entry is picked up as described in 3.6.4. Otherwise, if the most recent transmit command (START_XMIT_CATALOG or START_XMIT_CATALOG_WITH_PRIORITY) had remainActive set and a pending entry lies inside its priority range, the transmission is (re)started immediately and the highest priority in-range entry is sent; this holds whether that transmission completed or was halted by STOP_XMIT_CATALOG, because remainActive and the range are replaced only by the next transmit command, so a runtime insert resumes a stopped transmission. A transmission restarted this way keeps the byte tally of the session it continues: the tally is zeroed only by a transmit command, so the CatalogXmitCompleted emitted when the restarted transmission drains reports the bytes of the previous session plus the newly inserted product(s). Otherwise the entry waits for the next transmit command. The state file is not rewritten on insert: a newly written product has no transmit state to record, and its TRANSMITTED record is appended when its downlink completes, as for any other entry.
3.6.8 Reprioritization
SET_DP_PRIORITY changes the transmit priority of one catalog entry (SVC-DPCAT-017). The priority is the first field of the sort key (3.6.1), so the entry cannot be modified in place: the handler looks the entry up by its identity fields (id, tSec, tSub) with a linear walk of the set (findProductEntry, bounded by DP_MAX_FILES), removes it, sets the new priority, and re-inserts it. Only that entry moves and the set is only touched from the component's own thread, so a transmission in progress is not corrupted: each send restarts the walk at begin() (3.6.4), so the next send honors the new order. If the reprioritized entry is the one in flight, the send itself is unaffected: fileDone locates the entry to remove by identity, not by the sort key of the copy it keeps (m_currentXmitEntry, which is updated too so that the record written on completion carries the current priority).
A START_XMIT_CATALOG_WITH_PRIORITY range is checked against the priority each entry has when it is reached, so a product moved into or out of the active range by SET_DP_PRIORITY is sent, or left pending, accordingly.
The change is made by setDpPriority, which a future port could call as the command handler does. It updates the product's record in the state file data (updateStateFileData), which holds one DpRecord per product, or adds one with the product's current state. If a state file is configured, the new priority is then recorded in it (SVC-DPCAT-021) by rewriting the file from the state file data; DpRecord already carries a priority field, so the file format is unchanged. Unlike the data in memory, the file on disk may hold more than one record for a product: the rewrite after a priority change, then the record appended on completion (3.6.6); the last one read wins. On the next BUILD_CATALOG, records are matched to files by directory and identity (id, tSec, tSub) rather than by the full record, and a matched record supplies the priority as well as the transmit state, so the product keeps its new priority, and once sent is skipped as transmitted. Completion also updates the state file data, so a later rewrite (another priority change or the next BUILD_CATALOG) keeps it. The data product file header is not rewritten. A runtime addToCat of a file already in the catalog is recognized as a duplicate after a priority change, with or without a state file and whether or not the change could be recorded, because the duplicate check compares the product identity (directory, id, tSec, tSub) rather than the sort key (3.6.7). A slot of the state file data is consumed by each product loaded from the state file at build, and by each product first recorded by a completion or a priority change since; a slot not visited by the last build belongs to a file that is gone and is reused. If no slot is free, StateFileFull (WARNING_HI, id 55) is reported when a state file is configured: on SET_DP_PRIORITY the new order still applies until the next rebuild and the command fails; on completion the product is still appended to the state file. A rewrite that fails part-way leaves the records written before the failure in the file; the next successful rewrite replaces them. Without a state file the change applies to the catalog in memory only and the command succeeds. To return to the file priority, set it again. The lookup is by identity without the directory, so if two configured directories hold a file of the same name (same id, tSec, tSub), the command moves the first entry found in sort order. The directory index is the last field of the sort key (3.6.1), so the two entries never share a key: moving one onto the other's priority keeps both in the catalog, both are transmitted (lower directory index first), and the pending counters stay exact (DpWriter writes each product once, to one directory, so the case does not occur with the standard producer).
3.6.9 Deleting a Data Product
DELETE_DP deletes one data product (SVC-DPCAT-023), named by id, tSec and tSub as SET_DP_PRIORITY names it. A pending product is found in the catalog (findProductEntry); a transmitted product has no catalog entry and is found by its record in the state file data (findStateFileSlotByIdentity), which BUILD_CATALOG loads from the state file and every completion or priority change keeps current (3.6.8). Both lookups are linear walks bounded by DP_MAX_FILES. The cases are handled as follows:
| Condition | Behavior |
|---|---|
Component not configured (ComponentNotInitialized) or configured with no slots (ComponentNoMemory) |
Nothing is deleted; the corresponding warning is emitted, as for the other commands. |
Product is the one being transmitted (m_currentXmitEntry), including a send left in flight by STOP_XMIT_CATALOG |
Nothing is deleted; DpInFlight (WARNING_HI, id 58) is emitted and the command fails with EXECUTION_ERROR (SVC-DPCAT-024). The product can be deleted once its fileDone arrives and its completion is recorded. |
Product is neither in the catalog nor in the state file data (including before BUILD_CATALOG, after CLEAR_CATALOG, already deleted, or a transmitted product whose completion was reported with StateFileFull, 3.6.8: rebuild the catalog, which re-adds it as pending, then delete it; or a product whose state file record was skipped at load because its directory is no longer configured, 3.6.5) |
Nothing is deleted; DpNotFound is emitted, as for SET_DP_PRIORITY, and the command fails with EXECUTION_ERROR. |
| File name cannot be formatted (not expected) | FileNameFormatError; nothing is deleted and the command fails with EXECUTION_ERROR. |
File cannot be removed (Os::FileSystem::removeFile fails other than DOESNT_EXIST) |
DpFileRemoveError (WARNING_HI, id 59) with the status; the catalog and state file are left as they were, describing what is still on disk, and the command fails with EXECUTION_ERROR. |
| Otherwise | The file is removed first (a file already gone is a stale reference and is treated as removed), then the catalog entry, with the pending file and byte counts, and the state file data slot (the last slot moves into it). DpDeleted (ACTIVITY_HI, id 57) reports the file and the transmit state the product had. If the product had a state file record and a state file is configured, the file is rewritten without it (pruneAndWriteStateFile), so that a rebuild or restart does not treat a product rewritten with the same identity as transmitted; a rewrite failure is reported by StateFileOpenError/StateFileWriteError and the command fails with EXECUTION_ERROR although the product is gone from disk and memory. |
The file is removed before the data structures are changed so that a failure leaves the catalog describing what is on disk. A delete during a transmission of another product is safe: only the component's thread touches the catalog, and each send restarts the walk at begin() (3.6.4), so a deleted pending product is simply never sent and CatalogXmitCompleted reports the bytes actually sent. The lookup is by identity without the directory, so if two configured directories hold a file of the same name the command deletes the first entry found in sort order (lowest directory index), as SET_DP_PRIORITY moves the first; a second DELETE_DP deletes the other. While one of them is being transmitted, DELETE_DP of that identity is refused with DpInFlight for both, since the in-flight check compares the identity only; delete the other after the send completes. Without a state file the delete applies to the file and the catalog in memory only. Deleting the product named by a START_XMIT_CATALOG range leaves the range unchanged. Deletes issued in bulk by a ground tool are queued on the component's command queue like any other command: issue them from a sequence, or wait for each command response, so that a burst never exceeds the configured queue depth (10 in Svc/Subtopologies/DataProducts).
3.6.10 Retransmission (RETRANSMIT_DP)
A product that has completed downlink is removed from the catalog (3.6.4) and recorded TRANSMITTED in the state file data and the state file (3.6.6), so every later BUILD_CATALOG skips it; the only way to send it again was to delete the state file on the file system and rebuild, which resends everything. RETRANSMIT_DP resends one product (SVC-DPCAT-025), named by id, tSec and tSub as SET_DP_PRIORITY and DELETE_DP name it. A transmitted product has no catalog entry, and may have no state file record either (no state file configured, or its completion reported StateFileFull, 3.6.8), so the command locates its file by the canonical name Dp_<id>_<tSec>_<tSub>.fdp under each managed directory, in configuration order, and uses the first file that exists; the other commands likewise act on the first match (3.6.9). The product is then cataloged again by processFile, exactly as BUILD_CATALOG and addToCat do. processFile applies the product's state file record (getFileState): a record reading TRANSMITTED would make it skip the file, and a recorded priority would replace the header priority. The record found for the file's directory and identity (findStateFileSlot) is therefore dropped first (the last slot moves into its place, as DELETE_DP does), so the product is cataloged from its header alone and rescheduled at the header priority: a priority set by SET_DP_PRIORITY before the first downlink does not carry over to a retransmission; the operator sets it again if wanted. The product is then recorded UNTRANSMITTED at the header priority in the state file data (updateStateFileData, as a completion records it: a product that had a record always gets one, since its slot was just freed, while a product without one may find the data full, StateFileFull, 3.6.8), and the state file is rewritten from the state file data (pruneAndWriteStateFile, as the other commands do), so that a BUILD_CATALOG after a restart catalogs the product rather than skipping it. The rewrite also drops a TRANSMITTED record that was appended without a slot (StateFileFull, 3.6.8), so that the stale state cannot return on a later build that has a free slot for it. The cases are handled as follows:
| Condition | Behavior |
|---|---|
Component not configured (ComponentNotInitialized) or configured with no slots (ComponentNoMemory) |
Nothing is rescheduled; the corresponding warning is emitted by checkInit and the command fails with EXECUTION_ERROR, without a DpRetransmitError, as for the other commands. |
Catalog not built (no BUILD_CATALOG yet, or CLEAR_CATALOG since the last build) |
DpRetransmitError (WARNING_HI, id 60) with NOT_BUILT; EXECUTION_ERROR. The state file data of the last build is needed to recognize the product's record. |
Product is the one being transmitted (m_currentXmitEntry), including a send left in flight by STOP_XMIT_CATALOG |
DpRetransmitError with IN_FLIGHT; EXECUTION_ERROR. The send in progress completes and is recorded normally; retransmit after its ProductComplete. |
Product is pending in the catalog (findProductEntry) |
DpRetransmitError with PENDING; EXECUTION_ERROR. The product has not been transmitted and will be sent by the transmission in progress or the next transmit command; nothing is changed. |
No file Dp_<id>_<tSec>_<tSub>.fdp exists in any managed directory |
DpRetransmitError with NOT_FOUND; EXECUTION_ERROR. A product deleted after downlink cannot be resent. |
| The file name cannot be formatted under a managed directory (not expected) | DpRetransmitNameError (WARNING_LO, id 62) names the directory and the format status; the directory is skipped and the search goes on with the next one, so a file in a shorter directory is still found, and the product is reported NOT_FOUND if no directory holds it. |
The file cannot be cataloged: bad size, header, CRC or name, header already TRANSMITTED, tree insert failure, or no free slot |
The same event as at build time (FileSizeError/FileOpenError/FileReadError/FileHdrError/FileHdrDesError/FileNameFormatError/InvalidFileName/DpFileSkipped/DpInsertError/DpCatalogFull) followed by DpRetransmitError with FILE_ERROR; EXECUTION_ERROR. The record is put back as it was (slot, record and visited flag), so neither the state file data nor the state file is changed. |
| Otherwise | The product is inserted in priority order with DpFileAdded, the pending counts are updated, and DpRetransmitScheduled (ACTIVITY_HI, id 61) reports the file and the priority it is sent at. The product is recorded UNTRANSMITTED in the state file data (StateFileFull if no slot is free and a state file is configured: the product is then known by its file alone until its completion, as after a completion reported StateFileFull). If a state file is configured, the file is rewritten; a rewrite failure is reported by StateFileOpenError/StateFileWriteError and the command fails with EXECUTION_ERROR although the product is rescheduled in memory, as for DELETE_DP; only a BUILD_CATALOG (which reloads the file) before its downlink completes would skip it again. Otherwise OK. |
After a successful request the product is scheduled as a runtime insert is (3.6.7, SVC-DPCAT-027): a transmission in progress picks it up in priority order after the file in flight if its priority is inside the active range (3.6.4); otherwise, if the last transmit command had remainActive set and any pending product (the rescheduled one or one left behind) is inside its priority range, that transmission resumes immediately, sends the in-range products in priority order and continues the byte tally of that session; otherwise it waits for the next transmit command, as does a rescheduled product outside the active range. When its downlink completes, its record is updated TRANSMITTED in the state file data and appended to the state file (3.6.6), so the next build skips it again; the state file data holds one record per product, so the file does not grow with the number of retransmissions beyond the appended completions, which the next rebuild prunes to one record per product. The command is accepted during a transmission, unlike BUILD_CATALOG. The lookup is by identity without the directory, so if two configured directories hold a file of the same name the command reschedules the one in the first directory, in configuration order; while either is pending or in flight the identity is reported PENDING or IN_FLIGHT, since both checks compare the identity only. Retransmits issued in bulk by a ground tool are queued on the component's command queue like any other command, and each one rewrites the whole state file when one is configured: issue them from a sequence, or wait for each command response, so that a burst never exceeds the configured queue depth (10 in Svc/Subtopologies/DataProducts), which is shared with fileDone and addToCat. Note that while the last transmit command had remainActive set, a successful RETRANSMIT_DP starts the downlink at once and the resumed transmission sends every pending product in range, not only the rescheduled one; between passes this records them TRANSMITTED without a receiver. To stage retransmits for a later pass, make sure the last transmit command had remainActive false (STOP_XMIT_CATALOG does not clear it), or issue the retransmits once the pass is open.
4 Unit Testing
Unit tests are located in Svc/DpCatalog/test/ut.