def get(self): """ get method """ try: cluster = self.get_argument_cluster() role = self.get_argument_role() environ = self.get_argument_environ() topology_name = self.get_argument_topology() container = self.get_argument(constants.PARAM_CONTAINER) path = self.get_argument(constants.PARAM_PATH, default=".") topology_info = self.tracker.getTopologyInfo( topology_name, cluster, role, environ) stmgr_id = "stmgr-" + str(container) stmgr = topology_info["physical_plan"]["stmgrs"][stmgr_id] host = stmgr["host"] shell_port = stmgr["shell_port"] filestats_url = utils.make_shell_filestats_url( host, shell_port, path) http_client = tornado.httpclient.AsyncHTTPClient() response = yield http_client.fetch(filestats_url) self.write_success_response(json.loads(response.body)) self.finish() except Exception as e: Log.debug(traceback.format_exc()) self.write_error_response(e)
async def get_container_file_listing( # pylint: disable=too-many-arguments cluster: str, environ: str, container: str, path: str, topology_name: str = Query(..., alias="topology"), role: Optional[str] = None, ): """Return the stats for a given directory.""" topology = state.tracker.get_topology(cluster, role, environ, topology_name) stmgr = topology.info.physical_plan.stmgrs[f"stmgr-{container}"] url = utils.make_shell_filestats_url(stmgr.host, stmgr.shell_port, path) async with httpx.AsyncClient() as client: response = await client.get(url) return response.json()
def get(self): """ get method """ try: cluster = self.get_argument_cluster() role = self.get_argument_role() environ = self.get_argument_environ() topology_name = self.get_argument_topology() container = self.get_argument(constants.PARAM_CONTAINER) path = self.get_argument(constants.PARAM_PATH, default=".") topology_info = self.tracker.getTopologyInfo(topology_name, cluster, role, environ) stmgr_id = "stmgr-" + str(container) stmgr = topology_info["physical_plan"]["stmgrs"][stmgr_id] host = stmgr["host"] shell_port = stmgr["shell_port"] filestats_url = utils.make_shell_filestats_url(host, shell_port, path) http_client = tornado.httpclient.AsyncHTTPClient() response = yield http_client.fetch(filestats_url) self.write_success_response(json.loads(response.body)) self.finish() except Exception as e: Log.debug(traceback.format_exc()) self.write_error_response(e)