Last active
June 15, 2023 16:25
-
-
Save andsel/b892d9573f2c890a50baa89f518520ee to your computer and use it in GitHub Desktop.
Generates empty DLQ segments files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///usr/bin/env jbang "$0" "$@" ; exit $? | |
import java.io.FileOutputStream; | |
import java.io.File; | |
/** | |
* Accepts two arguments: | |
* - the target path where to generate the files | |
* - the max DLQ segment id to create | |
* */ | |
public class DLQSegmentCreator { | |
public static void main(String[] args) throws Exception { | |
DLQSegmentCreator creator = new DLQSegmentCreator(); | |
if (args.length != 2) { | |
System.out.println("Accepts two argument, the target path where to generate the files and the max DLQ segment id to create"); | |
System.out.println("usage: jbang DLQSegmentCreator.java /tmp 1579"); | |
System.exit(1); | |
} | |
final int maxId = Integer.parseInt(args[1]); | |
final String partialPath = args[0]; | |
for (int i = 1; i < maxId; i++){ | |
creator.createEmptyFile(partialPath + "/" + i + ".log"); | |
} | |
creator.createEmptyFile(partialPath + "/" + maxId + ".log.tmp"); | |
System.out.println("Completed creation of empty DLQ segments"); | |
} | |
private void createEmptyFile(String filename) throws Exception{ | |
FileOutputStream out = new FileOutputStream(new File(filename)); | |
out.write((byte)'1'); // DLQ version "1" | |
out.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment