Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Introducing a parameter validation for the local snapshot config parameters #1175

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions src/main/java/com/iota/iri/conf/BaseIotaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ public boolean getLocalSnapshotsPruningEnabled() {
}

@JsonProperty
@Parameter(names = {"--local-snapshots-pruning-enabled"}, description = SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_PRUNING_ENABLED)
@Parameter(names = {"--local-snapshots-pruning-enabled"}, description =
SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_PRUNING_ENABLED)
protected void setLocalSnapshotsPruningEnabled(boolean localSnapshotsPruningEnabled) {
this.localSnapshotsPruningEnabled = localSnapshotsPruningEnabled;
}
Expand All @@ -480,8 +481,14 @@ public int getLocalSnapshotsPruningDelay() {
}

@JsonProperty
@Parameter(names = {"--local-snapshots-pruning-delay"}, description = SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_PRUNING_DELAY)
@Parameter(names = {"--local-snapshots-pruning-delay"}, description =
SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_PRUNING_DELAY)
protected void setLocalSnapshotsPruningDelay(int localSnapshotsPruningDelay) {
if (localSnapshotsPruningDelay < 0) {
throw new ParameterException("LOCAL_SNAPSHOTS_PRUNING_DELAY should be positive (found " +
localSnapshotsPruningDelay +")");
}

this.localSnapshotsPruningDelay = localSnapshotsPruningDelay;
}

Expand All @@ -491,8 +498,14 @@ public int getLocalSnapshotsIntervalSynced() {
}

@JsonProperty
@Parameter(names = {"--local-snapshots-interval-synced"}, description = SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_INTERVAL_SYNCED)
@Parameter(names = {"--local-snapshots-interval-synced"}, description =
SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_INTERVAL_SYNCED)
protected void setLocalSnapshotsIntervalSynced(int localSnapshotsIntervalSynced) {
if (localSnapshotsIntervalSynced < 1) {
throw new ParameterException("LOCAL_SNAPSHOTS_INTERVAL_SYNCED should be at least 1 (found " +
localSnapshotsIntervalSynced +")");
}

this.localSnapshotsIntervalSynced = localSnapshotsIntervalSynced;
}

Expand All @@ -502,8 +515,14 @@ public int getLocalSnapshotsIntervalUnsynced() {
}

@JsonProperty
@Parameter(names = {"--local-snapshots-interval-unsynced"}, description = SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_INTERVAL_UNSYNCED)
@Parameter(names = {"--local-snapshots-interval-unsynced"}, description =
SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_INTERVAL_UNSYNCED)
protected void setLocalSnapshotsIntervalUnsynced(int localSnapshotsIntervalUnsynced) {
if (localSnapshotsIntervalUnsynced < 1) {
throw new ParameterException("LOCAL_SNAPSHOTS_INTERVAL_UNSYNCED should be at least 1 (found " +
localSnapshotsIntervalUnsynced +")");
}

this.localSnapshotsIntervalUnsynced = localSnapshotsIntervalUnsynced;
}

Expand All @@ -515,6 +534,11 @@ public int getLocalSnapshotsDepth() {
@JsonProperty
@Parameter(names = {"--local-snapshots-depth"}, description = SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_DEPTH)
protected void setLocalSnapshotsDepth(int localSnapshotsDepth) {
if (localSnapshotsDepth < 50) {
throw new ParameterException("LOCAL_SNAPSHOTS_DEPTH should be at least 50 (found " +
localSnapshotsDepth +")");
}

this.localSnapshotsDepth = localSnapshotsDepth;
}

Expand All @@ -524,7 +548,8 @@ public String getLocalSnapshotsBasePath() {
}

@JsonProperty
@Parameter(names = {"--local-snapshots-base-path"}, description = SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_BASE_PATH)
@Parameter(names = {"--local-snapshots-base-path"}, description =
SnapshotConfig.Descriptions.LOCAL_SNAPSHOTS_BASE_PATH)
protected void setLocalSnapshotsBasePath(String localSnapshotsBasePath) {
this.localSnapshotsBasePath = localSnapshotsBasePath;
}
Expand Down