Skip to content

Commit 3690cbc

Browse files
committed
Only archive products that have their configuration fully defined.
1 parent 9df5945 commit 3690cbc

File tree

13 files changed

+67
-30
lines changed

13 files changed

+67
-30
lines changed

mmtc-core/src/main/java/edu/jhuapl/sd/sig/mmtc/cfg/MmtcConfig.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ public void validate() throws MmtcException {
12481248
}
12491249

12501250

1251-
private static final List<String> REQD_SCLK_SCET_CONFIG_KEY_GROUP = Arrays.asList(
1251+
public static final List<String> REQD_SCLK_SCET_CONFIG_KEY_GROUP = Arrays.asList(
12521252
"product.sclkScetFile.create",
12531253
"product.sclkScetFile.dir",
12541254
"product.sclkScetFile.baseName",
@@ -1259,28 +1259,36 @@ public void validate() throws MmtcException {
12591259
"product.sclkScetFile.scetUtcPrecision"
12601260
);
12611261

1262-
private static final List<String> REQD_UPLINK_CMD_FILE_CONFIG_KEY_GROUP = Arrays.asList(
1262+
public static final List<String> REQD_UPLINK_CMD_FILE_CONFIG_KEY_GROUP = Arrays.asList(
12631263
"product.uplinkCmdFile.create",
12641264
"product.uplinkCmdFile.outputDir",
12651265
"product.uplinkCmdFile.baseName"
12661266
);
12671267

1268-
public void validateSclkScetConfiguration() throws MmtcException {
1269-
List<String> missingKeys = checkForMissingKeysInGroup(REQD_SCLK_SCET_CONFIG_KEY_GROUP);
1268+
public void ensureValidSclkScetConfiguration() throws MmtcException {
1269+
final List<String> missingKeys = getMissingSclkScetConfigurationKeys();
12701270

12711271
if (! missingKeys.isEmpty()) {
12721272
throw new MmtcException("SCLK-SCET operations require the following keys to be set: " + missingKeys.toString());
12731273
}
12741274
}
12751275

1276-
public void validateUplinkCmdFileConfiguration() throws MmtcException {
1277-
List<String> missingKeys = checkForMissingKeysInGroup(REQD_UPLINK_CMD_FILE_CONFIG_KEY_GROUP);
1276+
public List<String> getMissingSclkScetConfigurationKeys() {
1277+
return checkForMissingKeysInGroup(REQD_SCLK_SCET_CONFIG_KEY_GROUP);
1278+
}
1279+
1280+
public void ensureValidUplinkCmdFileConfiguration() throws MmtcException {
1281+
List<String> missingKeys = getMissingUplinkCmdFileConfigurationKeys();
12781282

12791283
if (! missingKeys.isEmpty()) {
12801284
throw new MmtcException("Uplink command file operations require the following keys to be set: " + missingKeys.toString());
12811285
}
12821286
}
12831287

1288+
public List<String> getMissingUplinkCmdFileConfigurationKeys() {
1289+
return checkForMissingKeysInGroup(REQD_UPLINK_CMD_FILE_CONFIG_KEY_GROUP);
1290+
}
1291+
12841292
private List<String> checkForMissingKeysInGroup(List<String> requiredKeys) {
12851293
List<String> missingKeys = new ArrayList();
12861294

mmtc-core/src/main/java/edu/jhuapl/sd/sig/mmtc/cfg/TimeCorrelationAppConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,11 @@ public void validate() throws MmtcException {
352352
super.validate();
353353

354354
if (createSclkScetFile()) {
355-
validateSclkScetConfiguration();
355+
ensureValidSclkScetConfiguration();
356356
}
357357

358358
if (isCreateUplinkCmdFile()) {
359-
validateUplinkCmdFileConfiguration();
359+
ensureValidUplinkCmdFileConfiguration();
360360
}
361361
}
362362
}

mmtc-core/src/main/java/edu/jhuapl/sd/sig/mmtc/products/definition/OutputProductDefinition.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,20 @@ public final void setIsBuiltIn(boolean newIsBuiltInStatus) {
4242
isBuiltIn.set(newIsBuiltInStatus);
4343
}
4444

45-
4645
public final boolean isBuiltIn() {
4746
return isBuiltIn.get();
4847
}
4948

49+
public abstract boolean isConfigured(MmtcConfig config);
50+
51+
/**
52+
* Where this product should be written, given the current time correlation
53+
*
54+
* @param context an object describing the time correlation inputs and results, possibly to be used in determining whether an output product should be written
55+
* @return true if the product should be written, false otherwise
56+
*/
57+
public abstract boolean shouldBeWritten(TimeCorrelationContext context);
58+
5059
/**
5160
* 'Resolve' the location of the output product file(s) on disk for this definition.
5261
*
@@ -56,13 +65,6 @@ public final boolean isBuiltIn() {
5665
*/
5766
public abstract T resolveLocation(MmtcConfig config) throws MmtcException;
5867

59-
/**
60-
* Where this product should be written, given the current time correlation
61-
*
62-
* @param context an object describing the time correlation inputs and results, possibly to be used in determining whether an output product should be written
63-
* @return true if the product should be written, false otherwise
64-
*/
65-
public abstract boolean shouldBeWritten(TimeCorrelationContext context);
6668

6769
/**
6870
* Generates a string summarizing the hypothetical changes to an output product that would have been made had this been a real

mmtc-core/src/main/java/edu/jhuapl/sd/sig/mmtc/products/definition/RawTlmTableProductDefinition.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public ResolvedProductPath resolveLocation(MmtcConfig config) {
2323
return new ResolvedProductPath(config.getRawTelemetryTablePath());
2424
}
2525

26+
@Override
27+
public boolean isConfigured(MmtcConfig config) {
28+
return true;
29+
}
30+
2631
@Override
2732
public boolean shouldBeWritten(TimeCorrelationContext context) {
2833
return true;

mmtc-core/src/main/java/edu/jhuapl/sd/sig/mmtc/products/definition/SclkKernelProductDefinition.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public ProductWriteResult writeNewProduct(TimeCorrelationContext ctx) throws Mmt
4040
return SclkKernel.writeNewProduct(ctx);
4141
}
4242

43+
@Override
44+
public boolean isConfigured(MmtcConfig config) {
45+
return true;
46+
}
47+
4348
@Override
4449
public boolean shouldBeWritten(TimeCorrelationContext context) {
4550
return true;

mmtc-core/src/main/java/edu/jhuapl/sd/sig/mmtc/products/definition/SclkScetProductDefinition.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import edu.jhuapl.sd.sig.mmtc.util.TimeConvertException;
1212

1313
import java.io.IOException;
14-
import java.util.Arrays;
1514

1615
import java.nio.file.Path;
1716
import java.util.HashMap;
@@ -20,10 +19,6 @@
2019
import java.util.stream.Collectors;
2120
import java.util.stream.IntStream;
2221

23-
import java.nio.file.Path;
24-
import java.util.HashMap;
25-
import java.util.Map;
26-
2722
/**
2823
* Describes the set of SCLK kernel output products that MMTC performs operations on.
2924
* A single SCLK kernel is modeled by {@link SclkKernel}.
@@ -34,9 +29,14 @@ public SclkScetProductDefinition() {
3429
}
3530
private final int ENTRIES_TO_PRINT = 4;
3631

32+
@Override
33+
public boolean isConfigured(MmtcConfig conf) {
34+
return conf.getMissingSclkScetConfigurationKeys().isEmpty();
35+
}
36+
3737
@Override
3838
public ResolvedProductDirPrefixSuffix resolveLocation(MmtcConfig conf) throws MmtcException {
39-
conf.validateSclkScetConfiguration();
39+
conf.ensureValidSclkScetConfiguration();
4040

4141
return new ResolvedProductDirPrefixSuffix(
4242
conf.getSclkScetOutputDir().toAbsolutePath(),

mmtc-core/src/main/java/edu/jhuapl/sd/sig/mmtc/products/definition/TimeHistoryFileProductDefinition.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public boolean shouldBeWritten(TimeCorrelationContext ctx) {
2929
return ctx.config.createTimeHistoryFile();
3030
}
3131

32+
@Override
33+
public boolean isConfigured(MmtcConfig config) {
34+
return true;
35+
}
36+
3237
@Override
3338
public String getDryRunPrintout(TimeCorrelationContext ctx) throws MmtcException {
3439
TimeHistoryFile timeHistFile = new TimeHistoryFile(ctx.config.getTimeHistoryFilePath(), ctx.config.getTimeHistoryFileExcludeColumns());

mmtc-core/src/main/java/edu/jhuapl/sd/sig/mmtc/products/definition/UplinkCommandFileProductDefinition.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public UplinkCommandFileProductDefinition() {
2424

2525
@Override
2626
public ResolvedProductDirPrefixSuffix resolveLocation(MmtcConfig conf) throws MmtcException {
27-
conf.validateUplinkCmdFileConfiguration();
27+
conf.ensureValidUplinkCmdFileConfiguration();
2828

2929
return new ResolvedProductDirPrefixSuffix(
3030
Paths.get(conf.getUplinkCmdFileDir()).toAbsolutePath(),
@@ -33,6 +33,11 @@ public ResolvedProductDirPrefixSuffix resolveLocation(MmtcConfig conf) throws Mm
3333
);
3434
}
3535

36+
@Override
37+
public boolean isConfigured(MmtcConfig config) {
38+
return config.getMissingUplinkCmdFileConfigurationKeys().isEmpty();
39+
}
40+
3641
@Override
3742
public boolean shouldBeWritten(TimeCorrelationContext context) {
3843
return context.config.isCreateUplinkCmdFile();

mmtc-core/src/main/java/edu/jhuapl/sd/sig/mmtc/products/model/SclkKernel.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ public CorrelationTriplet(double encSclk, String tdtStr, double clkChgRate) {
113113
}
114114
}
115115

116-
117116
/**
118117
* Overwrites the clock change rate field in the last time correlation record in the product with
119118
* the supplied value.

mmtc-core/src/main/java/edu/jhuapl/sd/sig/mmtc/products/util/FileZipArchiver.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
import java.io.IOException;
1414
import java.nio.file.Files;
1515
import java.nio.file.Path;
16-
import java.nio.file.Paths;
17-
import java.time.Instant;
18-
import java.time.OffsetDateTime;
1916
import java.time.ZoneOffset;
2017
import java.time.ZonedDateTime;
2118
import java.time.format.DateTimeFormatter;
@@ -24,7 +21,6 @@
2421
import java.util.zip.ZipOutputStream;
2522

2623
import static edu.jhuapl.sd.sig.mmtc.app.MmtcCli.USER_NOTICE;
27-
import static edu.jhuapl.sd.sig.mmtc.util.TimeConvert.ISO_UTC_DOY_FORMAT_NO_SUBSECONDS;
2824

2925
// Zips and stores a copy of files to a single zip on the filesystem
3026
public class FileZipArchiver {
@@ -71,7 +67,9 @@ public static void writeAllOutputProductsToArchive(MmtcConfig config, String arc
7167

7268
final Set<Path> allFilepathsToBackup = new HashSet<>();
7369
for (OutputProductDefinition<?> def : config.getAllOutputProductDefs()) {
74-
allFilepathsToBackup.addAll(def.resolveAllExistingPaths(config));
70+
if (def.isConfigured(config)) {
71+
allFilepathsToBackup.addAll(def.resolveAllExistingPaths(config));
72+
}
7573
}
7674
allFilepathsToBackup.add(config.getRunHistoryFilePath().toAbsolutePath());
7775

0 commit comments

Comments
 (0)