]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-replay: Add command-line arguments to prep-for-replay.py
authorAdam Crume <adamcrume@gmail.com>
Mon, 21 Jul 2014 21:40:29 +0000 (14:40 -0700)
committerSage Weil <sage@redhat.com>
Thu, 21 Aug 2014 17:57:30 +0000 (10:57 -0700)
Includes:
--print-on-read
--print-on-write
--window

Signed-off-by: Adam Crume <adamcrume@gmail.com>
src/rbd_replay/prep-for-replay.py

index c8a5557eee38a7478dbd09b0ee7ff5e396894f6d..e9a06500e76fb1cd17b1dd7f03c12bd6ded21183 100755 (executable)
@@ -13,6 +13,7 @@
 #
 #
 
+import argparse
 from babeltrace import *
 import datetime
 import struct
@@ -288,14 +289,22 @@ class Processor(object):
     def completed(self, io):
        self.recentCompletions.append(io)
        self.recentCompletions[:] = [x for x in self.recentCompletions if x.start_time > io.start_time - self.window]
-    def run(self, args):
-       inputFileName = args[0]
-       outputFileName = args[1]
+    def run(self, raw_args):
+       parser = argparse.ArgumentParser(description='convert librbd trace output to an rbd-replay input file.')
+       parser.add_argument('--print-on-read', action="store_true", help='print events as they are read in (for debugging)')
+       parser.add_argument('--print-on-write', action="store_true", help='print events as they are written out (for debugging)')
+       parser.add_argument('--window', default=1, type=float, help='size of the window, in seconds.  Larger values slow down processing, and smaller values may miss dependencies.  Default: 1')
+       parser.add_argument('input', help='trace to read')
+       parser.add_argument('output', help='replay file to write')
+       args = parser.parse_args(raw_args)
+       self.window = 1e9 * args.window
+       inputFileName = args.input
+       outputFileName = args.output
         ios = []
         pendingIOs = {}
         limit = 100000000000
-        printOnRead = False
-        printOnWrite = False
+        printOnRead = args.print_on_read
+        printOnWrite = args.print_on_write
         threads = {}
         traces = TraceCollection()
         traces.add_trace(inputFileName, "ctf")