def alanize(request): response = {'status': -1} cluster = json.loads(request.POST.get('cluster', '{}')) query_id = json.loads(request.POST.get('query_id')) api = _get_api(request.user, cluster=cluster) if query_id: LOG.debug("Attempting to get Impala query profile for query ID: %s" % (query_id)) doc = Document2.objects.get(id=query_id) snippets = doc.data_dict.get('snippets', []) secret = snippets[0]['result']['handle']['secret'] impala_query_id = unpack_guid(base64.decodestring(secret)) query_profile = api.get_query_profile_encoded(impala_query_id) profile = analyzer.analyze(analyzer.parse_data(query_profile)) ANALYZER.pre_process(profile) result = ANALYZER.run(profile) heatmap = {} summary = analyzer.summary(profile) heatmapMetrics = ['AverageThreadTokens', 'BloomFilterBytes', 'PeakMemoryUsage', 'PerHostPeakMemUsage', 'PrepareTime', 'RowsProduced', 'TotalCpuTime', 'TotalNetworkReceiveTime', 'TotalNetworkSendTime', 'TotalStorageWaitTime', 'TotalTime'] for key in heatmapMetrics: metrics = analyzer.heatmap_by_host(profile, key) if metrics['data']: heatmap[key] = metrics response['data'] = { 'query': { 'healthChecks' : result[0]['result'], 'summary': summary, 'heatmap': heatmap, 'heatmapMetrics': sorted(list(heatmap.iterkeys())) } } response['status'] = 0 return JsonResponse(response)
def alanize(request): response = {'status': -1} cluster = json.loads(request.POST.get('cluster', '{}')) query_id = json.loads(request.POST.get('query_id')) api = _get_api(request.user, cluster=cluster) if query_id: LOG.debug("Attempting to get Impala query profile for query ID: %s" % (query_id)) doc = Document2.objects.get(id=query_id) snippets = doc.data_dict.get('snippets', []) secret = snippets[0]['result']['handle']['secret'] impala_query_id = unpack_guid(base64.decodestring(secret)) query_profile = api.get_query_profile_encoded(impala_query_id) profile = analyzer.analyze(analyzer.parse_data(query_profile)) ANALYZER.pre_process(profile) result = ANALYZER.run(profile) heatmap = {} summary = analyzer.summary(profile) heatmapMetrics = ['AverageThreadTokens', 'BloomFilterBytes', 'PeakMemoryUsage', 'PerHostPeakMemUsage', 'PrepareTime', 'RowsProduced', 'TotalCpuTime', 'TotalNetworkReceiveTime', 'TotalNetworkSendTime', 'TotalStorageWaitTime', 'TotalTime'] for key in heatmapMetrics: metrics = analyzer.heatmap_by_host(profile, key) if metrics['data']: heatmap[key] = metrics response['data'] = { 'query': { 'healthChecks' : result[0]['result'], 'summary': summary, 'heatmap': heatmap, 'heatmapMetrics': sorted(list(heatmap.keys())) } } response['status'] = 0 return JsonResponse(response)
def alanize(request): response = {'status': -1} cluster = json.loads(request.POST.get('cluster', '{}')) query_id = json.loads(request.POST.get('query_id')) application = _get_server_name(cluster) query_server = dbms.get_query_server_config() session = Session.objects.get_session(request.user, query_server['server_name']) server_url = _get_impala_server_url(session) if query_id: LOG.debug( "Attempting to get Impala query profile at server_url %s for query ID: %s" % (server_url, query_id)) doc = Document2.objects.get(id=query_id) snippets = doc.data_dict.get('snippets', []) secret = snippets[0]['result']['handle']['secret'] api = get_impalad_api(user=request.user, url=server_url) impala_query_id = "%x:%x" % struct.unpack(b"QQ", base64.decodestring(secret)) api.kill( impala_query_id ) # There are many statistics that are not present when the query is open. Close it first. query_profile = api.get_query_profile_encoded(impala_query_id) profile = analyzer.analyze(analyzer.parse_data(query_profile)) result = ANALYZER.run(profile) heatmap = {} summary = analyzer.summary(profile) heatmapMetrics = [ 'AverageThreadTokens', 'BloomFilterBytes', 'PeakMemoryUsage', 'PerHostPeakMemUsage', 'PrepareTime', 'RowsProduced', 'TotalCpuTime', 'TotalNetworkReceiveTime', 'TotalNetworkSendTime', 'TotalStorageWaitTime', 'TotalTime' ] for key in heatmapMetrics: metrics = analyzer.heatmap_by_host(profile, key) if metrics['data']: heatmap[key] = metrics response['data'] = { 'query': { 'healthChecks': result[0]['result'], 'summary': summary, 'heatmap': heatmap, 'heatmapMetrics': sorted(list(heatmap.iterkeys())) } } response['status'] = 0 return JsonResponse(response)