def start_workers(self, worker_factory, name, curr_items=None, deleted_items=None, current_hot_load_start=None, timer_elapse=None): curr_ops = Value('L', 0) lock = Lock() worker_type, total_workers = worker_factory(self.ws) if name == 'fts' and total_workers: auth = HTTPBasicAuth(self.ws.fts_config.username, self.ts.password) if self.ws.fts_config.elastic: self.ws.query_gen = ElasticGen(self.ts.node, self.ws.fts_config, auth) else: self.ws.query_gen = FtsGen(self.ts.node, self.ws.fts_config, auth) for sid in range(total_workers): args = (sid, lock, curr_ops, curr_items, deleted_items, current_hot_load_start, timer_elapse) worker = worker_type(self.ws, self.ts, self.shutdown_event) worker_process = Process(target=worker.run, args=args) worker_process.start() self.worker_processes.append(worker_process) if getattr(self.ws, 'async', False): time.sleep(2)
class ElasticStats(FtsCollector): COLLECTOR = "elastic_latency" METRICS = ("elastic_latency_get",) def __init__(self, settings, test_config, prefix=None): super(ElasticStats, self).__init__(settings, test_config) self.host = settings.master_node self.elastic_client = ElasticGen(self.host, test_config.fts_settings) self.elastic_client.prepare_query() def elastic_latency_get(self): cmd, query = self.elastic_client.next() t0 = time.time() cmd(**query) return 1000 * (time.time() - t0)
def __init__(self, workload_settings, target_settings, shutdown_event=None): super(FtsWorker, self).__init__(workload_settings, target_settings, shutdown_event) host, port = self.ts.node.split(':') if self.ws.fts_config.elastic: instance = ElasticGen(host, self.ws.fts_config) self.name = "ElasticWorker" else: instance = FtsGen(host, self.ws.fts_config) self.name = "FtsWorker" self.fts_es_query = instance self.fts_es_query.prepare_query()
def init_client(self, test_config): return ElasticGen(self.host, test_config.fts_settings)
def __init__(self, settings, test_config, prefix=None): super(ElasticStats, self).__init__(settings, test_config) self.host = settings.master_node self.elastic_client = ElasticGen(self.host, test_config.fts_settings) self.elastic_client.prepare_query()