Skip to content

Commit

Permalink
A couple more changes per PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Helma <chelma+github@amazon.com>
  • Loading branch information
chelma committed May 27, 2024
1 parent fe266eb commit 5105030
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
18 changes: 18 additions & 0 deletions RFS/src/main/java/com/rfs/cms/CmsEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public class CmsEntry {
public abstract static class Base {
protected Base() {}
public abstract String toString();
}

public static enum SnapshotStatus {
Expand All @@ -23,6 +24,14 @@ public Snapshot(String name, SnapshotStatus status) {
this.name = name;
this.status = status;
}

@Override
public String toString() {
return "Snapshot("
+ "name='" + name + ","
+ "status=" + status +
")";
}
}

public static enum MetadataStatus {
Expand Down Expand Up @@ -60,6 +69,15 @@ public Metadata(MetadataStatus status, String leaseExpiry, int numAttempts) {
this.leaseExpiry = leaseExpiry;
this.numAttempts = numAttempts;
}

@Override
public String toString() {
return "Metadata("
+ "status=" + status.toString() + ","
+ "leaseExpiry=" + leaseExpiry + ","
+ "numAttempts=" + numAttempts.toString() +
")";
}
}

public static class CouldNotFindNextLeaseDuration extends RfsException {
Expand Down
7 changes: 3 additions & 4 deletions RFS/src/main/java/com/rfs/worker/MetadataStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ public SharedMembers(GlobalState globalState, CmsClient cmsClient, String snapsh
// A convient way to check if the CMS entry is present before retrieving it. In some places, it's fine/expected
// for the CMS entry to be missing, but in others, it's a problem.
public CmsEntry.Metadata getCmsEntryNotMissing() {
if (cmsEntry.isEmpty()) {
throw new MissingMigrationEntry("The Metadata Migration CMS entry we expected to be stored in local memory was null");
}
return cmsEntry.get();
return cmsEntry.orElseThrow(
() -> new MissingMigrationEntry("The Metadata Migration CMS entry we expected to be stored in local memory was empty")
);
}
}

Expand Down

0 comments on commit 5105030

Please sign in to comment.