Skip to content

Commit

Permalink
[Java] add ClusterTool options to get/increase catalog size
Browse files Browse the repository at this point in the history
  • Loading branch information
JPWatson committed Jun 12, 2018
1 parent 49a3241 commit 3281802
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
5 changes: 5 additions & 0 deletions aeron-archive/src/main/java/io/aeron/archive/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ public int maxEntries()
return maxRecordingId + 1;
}

public long entries()
{
return nextRecordingId;
}

long addNewRecording(
final long startPosition,
final long startTimestamp,
Expand Down
37 changes: 31 additions & 6 deletions aeron-archive/src/main/java/io/aeron/archive/CatalogTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,30 @@ else if (args.length == 3 && args[1].equals("verify"))
catalog.forEntry(CatalogTool::verify, Long.valueOf(args[2]));
}
}
else if (args.length == 2 && args[1].equals("entries"))
{
try (Catalog catalog = openCatalog())
{
System.out.println(catalog.entries());
}
}
else if (args.length == 2 && args[1].equals("max-entries"))
{
try (Catalog catalog = openCatalog())
{
System.out.println(catalog.maxEntries());
}
}
else if (args.length == 3 && args[1].equals("max-entries"))
{
final long newMaxEntries = Long.parseLong(args[2]);

try (Catalog catalog = new Catalog(archiveDir, null, 0, newMaxEntries, System::currentTimeMillis))
{
System.out.println(catalog.maxEntries());
}
}

// TODO: add a manual override tool to force mark entries as unusable
}

Expand Down Expand Up @@ -329,12 +353,13 @@ private static boolean verifyFirstFile(

private static void printHelp()
{
System.out.println("Usage: <archive-dir> <command> <optional recordingId>");
System.out.println(" describe: prints out all descriptors in the file. Optionally specify a recording id" +
" to describe a single recording.");
System.out.println("Usage: <archive-dir> <command>");
System.out.println(" describe <optional recordingId>: prints out descriptor(s) in the catalog.");
System.out.println(" pid: prints just PID of archive.");
System.out.println(" verify: verifies all descriptors in the file, checking recording files availability %n" +
"and contents. Faulty entries are marked as unusable. Optionally specify a recording id%n" +
"to verify a single recording.");
System.out.println(" verify <optional recordingId>: verifies descriptor(s) in the catalog, checking");
System.out.println(" recording files availability and contents. Faulty entries are marked as unusable.");
System.out.println(" entries: gets the number of recording entries in the catalog.");
System.out.println(" max-entries <optional number of entries>: gets or increases the maximum number of");
System.out.println(" recording entries the catalog can store.");
}
}

0 comments on commit 3281802

Please sign in to comment.