Beispiel #1
0
 def __init__(self, options):
     self.db = options["db"]
     self.table = options["table"]
     self.cid_dist = x_stress_util.Pareto(1000)
     self.typ_dist = x_stress_util.Pareto(10)
     self.time_dist = x_stress_util.TimeDistribution(
         os.getenv("X_END_DATE"), os.getenv("X_DATE_INTERVAL"))
Beispiel #2
0
    def __init__(self, options):
        self.db = options["db"]
        self.table = options["table"]
        self.count = 1

        # Get the current max key from environment variables
        max_key = os.getenv("X_MAX_KEY")
        max_key_file = os.getenv("X_MAX_KEY_FILE")

        if max_key is None:
            if max_key_file is None:
                raise RuntimeError("X_MAX_KEY and X_MAX_KEY_FILE are both undefined")
            elif not os.path.isfile(max_key_file):
                raise RuntimeError("X_MAX_KEY not defined, and key file '%s' does not exist" % max_key_file)
            else:
                with open(max_key_file, "r") as f:
                    max_key = int(f.readline())
        else:
            if os.path.isfile(max_key_file):
                with open(max_key_file, "r") as f:
                    max_key = int(f.readline())
            else:
                max_key = int(max_key)

        if max_key_file is not None:
            self.key_file = open(max_key_file, "r")
        else:
            self.key_file = None

        self.key_dist = x_stress_util.Pareto(max_key)
Beispiel #3
0
 def update_max_key(self):
     if self.count % 1000 == 0:
         self.count = 1
         if self.key_file is not None:
             self.key_file.seek(0)
             new_max_key = x_stress_util.perform_ignore_interrupt(lambda: self.key_file.readline())
             self.key_dist = x_stress_util.Pareto(int(new_max_key))
     else:
         self.count += 1
Beispiel #4
0
    def __init__(self, options):
        self.db = options["db"]
        self.table = options["table"]
        self.cid_dist = x_stress_util.Pareto(1000)
        self.typ_dist = x_stress_util.Pareto(10)

        # Get the batch size to use
        self.batch_size = os.getenv("X_WRITE_BATCH_SIZE")
        if self.batch_size is None:
            self.batch_size = 1
        else:
            self.batch_size = int(self.batch_size)

        # Get the current max key from environment variables
        max_key = os.getenv("X_MAX_KEY")
        max_key_file = os.getenv("X_MAX_KEY_FILE")

        if max_key is None:
            if max_key_file is None:
                raise RuntimeError(
                    "X_MAX_KEY and X_MAX_KEY_FILE are both undefined")
            elif not os.path.isfile(max_key_file):
                raise RuntimeError(
                    "X_MAX_KEY not defined, and key file '%s' does not exist" %
                    max_key_file)
            else:
                with open(max_key_file, "r") as f:
                    max_key = int(f.readline())
        else:
            if os.path.isfile(max_key_file):
                with open(max_key_file, "r") as f:
                    max_key = int(f.readline())
            else:
                max_key = int(max_key)

        # We use a multiprocessing shared value to store the latest key
        self.max_key = multiprocessing.Value('L', max_key)

        if max_key_file is not None:
            self.key_file = open(max_key_file, "w")
            self.update_max_key(max_key)
        else:
            self.key_file = None
Beispiel #5
0
 def __init__(self, options):
     self.db = options["db"]
     self.table = options["table"]
     self.cid_dist = x_stress_util.Pareto(1000)