def delete(self) -> Response: """Stop the workload generator and empty database queues.""" message = Request(header=Header(message="stop workload"), body={}) response = _send_message(generator_socket, message) if response["header"]["status"] != 200: return get_error_response( 400, response["body"].get("error", "Error during stopping of generator") ) message = Request(header=Header(message="close worker"), body={}) response = _send_message(db_manager_socket, message) if response["header"]["status"] != 200: return get_error_response( 400, response["body"].get("error", "Error during closing of worker") ) return response
def delete(self) -> Response: """Delete pregenerated tables from all databases.""" message = Request( header=Header(message="delete data"), body={"folder_name": control.payload["folder_name"]}, ) response = _send_message(db_manager_socket, message) return response
def delete(self) -> Response: """Delete a database.""" message = Request( header=Header(message="delete database"), body={"id": control.payload["id"]}, ) response = _send_message(db_manager_socket, message) return response
def post(self) -> Response: """Activate a plugin in a database.""" message = Request( header=Header(message="activate plugin"), body={"id": control.payload["id"], "plugin": control.payload["plugin"]}, ) response = _send_message(db_manager_socket, message) return response
def post(self) -> Response: """Set settings for plugins.""" message = Request( header=Header(message="set plugin setting"), body={ "id": control.payload["id"], "name": control.payload["name"], "value": control.payload["value"], }, ) response = _send_message(db_manager_socket, message) return response
def post(self) -> Response: """Start the workload generator.""" message = Request(header=Header(message="start worker"), body={}) response = _send_message(db_manager_socket, message) if response["header"]["status"] != 200: return get_error_response( 400, response["body"].get("error", "Error during starting of worker") ) message = Request( header=Header(message="start workload"), body={ "folder_name": control.payload["folder_name"], "frequency": control.payload.get("frequency", 200), }, ) response = _send_message(generator_socket, message) if response["header"]["status"] != 200: return get_error_response( 400, response["body"].get("error", "Error during starting of the workload"), ) return get_response(200)
def post(self) -> Response: """Add a database.""" message = Request( header=Header(message="add database"), body={ "number_workers": control.payload["number_workers"], "id": control.payload["id"], "user": control.payload["user"], "password": control.payload["password"], "host": control.payload["host"], "port": control.payload["port"], "dbname": control.payload["dbname"], }, ) response = _send_message(db_manager_socket, message) return response
def get(self) -> Response: """Get all databases.""" message = Request(header=Header(message="get databases"), body={}) response = _send_message(db_manager_socket, message) return response["body"]["databases"]
def get(self) -> List[Dict]: """Return status of databases.""" return _send_message( db_manager_socket, Request(header=Header(message="status"), body={}), )["body"]["status"]
def get(self) -> Response: """Read settings for plugins.""" message = Request(header=Header(message="get plugin setting"), body={},) response = _send_message(db_manager_socket, message) return response
def get(self) -> Union[Dict, List[Dict[str, List[str]]]]: """Return activated plugins in each database.""" message = Request(header=Header(message="get plugins"), body={}) response = _send_message(db_manager_socket, message) return response["body"]["plugins"]