Search in sources :

Example 1 with ExitCode

use of org.apache.zookeeper.server.ExitCode in project zookeeper by apache.

the class LogChopper method main.

public static void main(String[] args) {
    ExitCode rc = ExitCode.INVALID_INVOCATION;
    if (args.length != 3) {
        System.out.println("Usage: LogChopper zxid_to_chop_to txn_log_to_chop chopped_filename");
        System.out.println("    this program will read the txn_log_to_chop file and copy all the transactions");
        System.out.println("    from it up to (and including) the given zxid into chopped_filename.");
        ServiceUtils.requestSystemExit(rc.getValue());
    }
    String txnLog = args[1];
    String choppedLog = args[2];
    try (InputStream is = new BufferedInputStream(new FileInputStream(txnLog));
        OutputStream os = new BufferedOutputStream(new FileOutputStream(choppedLog))) {
        long zxid = Long.decode(args[0]);
        if (chop(is, os, zxid)) {
            rc = ExitCode.EXECUTION_FINISHED;
        }
    } catch (Exception e) {
        System.out.println("Got exception: " + e.getMessage());
    }
    ServiceUtils.requestSystemExit(rc.getValue());
}
Also used : BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ExitCode(org.apache.zookeeper.server.ExitCode) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) EOFException(java.io.EOFException)

Aggregations

BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 EOFException (java.io.EOFException)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 ExitCode (org.apache.zookeeper.server.ExitCode)1