dbworkload 0.7.0__tar.gz → 0.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dbworkload-0.7.0 → dbworkload-0.8.0}/PKG-INFO +1 -1
- {dbworkload-0.7.0 → dbworkload-0.8.0}/dbworkload/models/run.py +52 -0
- {dbworkload-0.7.0 → dbworkload-0.8.0}/pyproject.toml +1 -1
- {dbworkload-0.7.0 → dbworkload-0.8.0}/LICENSE +0 -0
- {dbworkload-0.7.0 → dbworkload-0.8.0}/README.md +0 -0
- {dbworkload-0.7.0 → dbworkload-0.8.0}/dbworkload/__init__.py +0 -0
- {dbworkload-0.7.0 → dbworkload-0.8.0}/dbworkload/cli/dep.py +0 -0
- {dbworkload-0.7.0 → dbworkload-0.8.0}/dbworkload/cli/main.py +0 -0
- {dbworkload-0.7.0 → dbworkload-0.8.0}/dbworkload/cli/util.py +0 -0
- {dbworkload-0.7.0 → dbworkload-0.8.0}/dbworkload/models/util.py +0 -0
- {dbworkload-0.7.0 → dbworkload-0.8.0}/dbworkload/templates/stub.j2 +0 -0
- {dbworkload-0.7.0 → dbworkload-0.8.0}/dbworkload/utils/common.py +0 -0
- {dbworkload-0.7.0 → dbworkload-0.8.0}/dbworkload/utils/simplefaker.py +0 -0
|
@@ -16,6 +16,9 @@ import tabulate
|
|
|
16
16
|
from threading import Thread
|
|
17
17
|
import time
|
|
18
18
|
import traceback
|
|
19
|
+
import os
|
|
20
|
+
import errno
|
|
21
|
+
|
|
19
22
|
|
|
20
23
|
# from cassandra.cluster import Cluster, ExecutionProfile, EXEC_PROFILE_DEFAULT, Session
|
|
21
24
|
# from cassandra.policies import (
|
|
@@ -30,6 +33,8 @@ DEFAULT_SLEEP = 3
|
|
|
30
33
|
MAX_RETRIES = 3
|
|
31
34
|
FREQUENCY = 10
|
|
32
35
|
|
|
36
|
+
FIFO = "dbworkload.pipe"
|
|
37
|
+
|
|
33
38
|
logger = logging.getLogger("dbworkload")
|
|
34
39
|
|
|
35
40
|
|
|
@@ -106,6 +111,7 @@ def signal_handler(sig, frame):
|
|
|
106
111
|
sys.exit(1)
|
|
107
112
|
|
|
108
113
|
logger.debug("Sent poison pill to all procs")
|
|
114
|
+
os.remove(FIFO)
|
|
109
115
|
|
|
110
116
|
|
|
111
117
|
def cycle(iterable, backwards=False):
|
|
@@ -333,6 +339,20 @@ def run(
|
|
|
333
339
|
supervisors = {}
|
|
334
340
|
queues = {}
|
|
335
341
|
|
|
342
|
+
# start a separate thread for messages coming in via the pipe
|
|
343
|
+
# echo 5 > dbworkload.pipe # create 5 more connections
|
|
344
|
+
Thread(
|
|
345
|
+
target=listen_to_pipe,
|
|
346
|
+
daemon=True,
|
|
347
|
+
args=(
|
|
348
|
+
queues,
|
|
349
|
+
0,
|
|
350
|
+
procs,
|
|
351
|
+
None,
|
|
352
|
+
concurrency,
|
|
353
|
+
),
|
|
354
|
+
).start()
|
|
355
|
+
|
|
336
356
|
# launch supervisors in a dedicated OS process
|
|
337
357
|
for x in range(procs):
|
|
338
358
|
queues[x] = mp.Queue()
|
|
@@ -811,6 +831,38 @@ def worker(
|
|
|
811
831
|
return
|
|
812
832
|
|
|
813
833
|
|
|
834
|
+
def listen_to_pipe(queues, ramp_time, procs, iterations_per_thread, concurrency):
|
|
835
|
+
# https://stackoverflow.com/questions/39089776/python-read-named-pipe
|
|
836
|
+
|
|
837
|
+
try:
|
|
838
|
+
os.mkfifo(FIFO)
|
|
839
|
+
except OSError as oe:
|
|
840
|
+
if oe.errno != errno.EEXIST:
|
|
841
|
+
raise
|
|
842
|
+
|
|
843
|
+
while True:
|
|
844
|
+
with open(FIFO) as fifo:
|
|
845
|
+
for line in fifo:
|
|
846
|
+
try:
|
|
847
|
+
t = int(line)
|
|
848
|
+
except:
|
|
849
|
+
continue
|
|
850
|
+
|
|
851
|
+
logger.info(f"{'Adding' if t > 0 else 'Removing' } {abs(t)} threads.")
|
|
852
|
+
Thread(
|
|
853
|
+
target=launch_or_kill_workers,
|
|
854
|
+
daemon=True,
|
|
855
|
+
args=(
|
|
856
|
+
queues,
|
|
857
|
+
ramp_time,
|
|
858
|
+
t,
|
|
859
|
+
procs,
|
|
860
|
+
iterations_per_thread,
|
|
861
|
+
concurrency,
|
|
862
|
+
),
|
|
863
|
+
).start()
|
|
864
|
+
|
|
865
|
+
|
|
814
866
|
def log_and_sleep(e: Exception):
|
|
815
867
|
logger.error(f"error_type={e.__class__.__name__}, msg={e}")
|
|
816
868
|
logger.info("Sleeping for %s seconds" % (DEFAULT_SLEEP))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|