OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 import logging | 2 import logging |
3 import subprocess | 3 import subprocess |
4 import json | 4 import json |
5 import os | 5 import os |
6 from time import sleep | 6 from time import sleep |
7 | 7 |
8 import systems.cassandra.setup as cas | 8 import systems.cassandra.setup as cas |
9 from systems.cassandra.launch_cassandra import launch_cassandras | 9 from systems.cassandra.launch_cassandra import launch_cassandras |
10 import systems.ycsb.ycsb_wrapper as ycsb | 10 import systems.ycsb.ycsb_wrapper as ycsb |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 setup_ycsb(FLAGS, conf) | 58 setup_ycsb(FLAGS, conf) |
59 | 59 |
60 logging.info("PREPARE END") | 60 logging.info("PREPARE END") |
61 | 61 |
62 | 62 |
63 def experiment_launch_systems(FLAGS, conf, net): | 63 def experiment_launch_systems(FLAGS, conf, net): |
64 logging.info("LAUNCHING SYSTEMS START") | 64 logging.info("LAUNCHING SYSTEMS START") |
65 launch_cassandras(FLAGS, conf, net) | 65 launch_cassandras(FLAGS, conf, net) |
66 logging.info("LAUNCHING SYSTEMS END") | 66 logging.info("LAUNCHING SYSTEMS END") |
67 | 67 |
| 68 execution = True |
68 | 69 |
69 def _execute_update_latencies(conf, net, numhosts, frequency): | 70 def _execute_update_latencies(conf, net, numhosts, frequency): |
70 for i in range(0, numhosts): | 71 # Execute latency changes until the execution var is set to· |
| 72 # False by experiment run function |
| 73 global execution |
| 74 i = 0 |
| 75 while execution: |
71 print("*******************************************") | 76 print("*******************************************") |
72 print("Latency changes of iteration: {}".format(i)) | 77 print("Latency changes of iteration: {}".format(i)) |
73 change_link_latencies(i, net, conf) | 78 change_link_latencies(i, net, conf) |
74 print("*******************************************") | 79 print("*******************************************") |
75 sleep(frequency) | 80 sleep(frequency) |
| 81 i = 0 if i == numhosts else i + 1· |
76 | 82 |
| 83 # Reset global var for future runs |
| 84 execution = True |
| 85 return |
77 | 86 |
78 def execute_update_latencies(FLAGS, conf, net, frequency): | 87 def execute_update_latencies(FLAGS, conf, net, frequency): |
79 # Call helper function that should repeat itself | 88 # Call helper function that should repeat itself |
80 return _execute_update_latencies( | 89 return _execute_update_latencies( |
81 conf=conf, net=net, numhosts=conf['topology']['host2dc_map'][0], | 90 conf=conf, net=net, numhosts=conf['topology']['host2dc_map'][0], |
82 frequency=frequency | 91 frequency=frequency |
83 ) | 92 ) |
84 | 93 |
85 | 94 |
86 def execute_update_jitter(FLAGS, conf, net, jitter_level, distribution): | 95 def execute_update_jitter(FLAGS, conf, net, jitter_level, distribution): |
87 return change_link_jitter( | 96 return change_link_jitter( |
88 net, conf, jitter_level, distribution=distribution | 97 net, conf, jitter_level, distribution=distribution |
89 ) | 98 ) |
90 | 99 |
91 | 100 |
92 def experiment_run(FLAGS, conf, net, exp_name="sample"): | 101 def experiment_run(FLAGS, conf, net, exp_name="sample"): |
| 102 # used to stop the dynamic latency change after experiment is done |
| 103 global execution |
| 104 |
93 # Run experiment only if it configured to be run! | 105 # Run experiment only if it configured to be run! |
94 if not conf["cassandra"]["setup"]["cas_run_experiment"]: | 106 if not conf["cassandra"]["setup"]["cas_run_experiment"]: |
95 return | 107 return |
96 | 108 |
97 logging.info("EXPERIMENT START") | 109 logging.info("EXPERIMENT START") |
98 | 110 |
99 out_fldr = setup_experiment_folder( | 111 out_fldr = setup_experiment_folder( |
100 exp_name=exp_name, where=conf["env"]["out_exp_dir"] | 112 exp_name=exp_name, where=conf["env"]["out_exp_dir"] |
101 ) | 113 ) |
102 | 114 |
103 with open(os.path.join(out_fldr, "config.json"), "w") as jfile: | 115 with open(os.path.join(out_fldr, "config.json"), "w") as jfile: |
104 jfile.write(json.dumps(conf, indent=4)) | 116 jfile.write(json.dumps(conf, indent=4)) |
105 | 117 |
106 experiment_cleanup_ycsb(FLAGS, conf) | 118 experiment_cleanup_ycsb(FLAGS, conf) |
107 ycsb.run_ycsb(FLAGS, conf, net, out_fldr) | 119 ycsb.run_ycsb(FLAGS, conf, net, out_fldr) |
108 | 120 |
| 121 # Stop dynamic latency change |
| 122 execution = False |
| 123 |
109 logging.info("EXPERIMENT END") | 124 logging.info("EXPERIMENT END") |
110 return out_fldr | 125 return out_fldr |
111 | 126 |
112 | 127 |
113 def experiment_setup_keyspace(FLAGS, conf, net): | 128 def experiment_setup_keyspace(FLAGS, conf, net): |
114 # If we reuse existing data folder, then we should not recreate keyspace! | 129 # If we reuse existing data folder, then we should not recreate keyspace! |
115 if not conf["cassandra"]["setup"]["cas_rm_data"]: | 130 if not conf["cassandra"]["setup"]["cas_rm_data"]: |
116 return | 131 return |
117 | 132 |
118 logging.info("Creating Keyspace START") | 133 logging.info("Creating Keyspace START") |
119 cas.create_ycsb_keyspace(FLAGS, conf, net) | 134 cas.create_ycsb_keyspace(FLAGS, conf, net) |
120 logging.info("Creating Keyspace END") | 135 logging.info("Creating Keyspace END") |
121 | 136 |
122 | 137 |
123 logging.info("YCSB Loading START") | 138 logging.info("YCSB Loading START") |
124 | 139 |
125 out_fldr = setup_experiment_folder( | 140 out_fldr = setup_experiment_folder( |
126 exp_name="ycsb_load", where=conf["env"]["out_exp_dir"]) | 141 exp_name="ycsb_load", where=conf["env"]["out_exp_dir"]) |
127 | 142 |
128 # If system just boots up some insertions might fail, hence we do it twice. | 143 # If system just boots up some insertions might fail, hence we do it twice. |
129 experiment_cleanup_ycsb(FLAGS, conf) | 144 experiment_cleanup_ycsb(FLAGS, conf) |
130 ycsb.load_ycsb(FLAGS, conf, net, out_fldr) | 145 ycsb.load_ycsb(FLAGS, conf, net, out_fldr) |
131 ycsb.load_ycsb(FLAGS, conf, net, out_fldr) | 146 ycsb.load_ycsb(FLAGS, conf, net, out_fldr) |
132 | 147 |
133 logging.info("YCSB Loading END") | 148 logging.info("YCSB Loading END") |
134 return out_fldr | 149 return out_fldr |
135 | 150 |
136 | 151 # THIS SHOULD BE DELETED!? |
137 def plot_ycsb_data_from_output_folder( | 152 def plot_ycsb_data_from_output_folder( |
138 output_folder, where_to_save=None, label=None | 153 output_folder, where_to_save=None, label=None |
139 ): | 154 ): |
140 read_and_plot_data_from_folder( | 155 read_and_plot_data_from_folder( |
141 folder_name=output_folder, where_to_save=where_to_save, label=label | 156 folder_name=output_folder, where_to_save=where_to_save, label=label |
142 ) | 157 ) |
143 | 158 |
144 | |
145 def get_yscb_data_from_output_folder(output_folder): | 159 def get_yscb_data_from_output_folder(output_folder): |
146 return get_yscb_data_from_folder(output_folder) | 160 return get_yscb_data_from_folder(output_folder) |
147 | 161 |
148 | 162 |
149 def get_ycsb_plot_from_list( | 163 def get_ycsb_plot_from_list( |
150 result_for_experiments, where_to_save=None, label=None | 164 result_for_experiments, where_to_save=None, label=None |
151 ): | 165 ): |
152 # Write the function to really take things from the list and do the plot | 166 # Write the function to really take things from the list and do the plot |
153 return plot_ycsb_data_from_list( | 167 return plot_ycsb_data_from_list( |
154 result_for_experiments, where_to_save, label | 168 result_for_experiments, where_to_save, label |
155 ) | 169 ) |
OLD | NEW |