(self, pre_20_mode, tags)
return running_apps
Return a dictionary of {app_id: (app_name, tracking_url)} for the running Spark applications
Return a dictionary of {app_id: (app_name, tracking_url)} for the running Spark applications
Return a dictionary of { app_id : ( app_name tracking_url ) } for the running Spark applications
def _standalone_init(self, pre_20_mode, tags):
        """
        Return a dictionary of {app_id: (app_name, tracking_url)} for the running Spark applications
        """
        metrics_json = self._rest_request_to_json(
            self.master_address, SPARK_MASTER_STATE_PATH, SPARK_STANDALONE_SERVICE_CHECK, tags
        )

        running_apps = {}
        version_set = False

        if metrics_json.get('activeapps'):
            for app in metrics_json['activeapps']:
                app_id = app.get('id')
                app_name = app.get('name')

                # Parse through the HTML to grab the application driver's link
                try:
                    app_url = self._get_standalone_app_url(app_id, tags)

                    if app_id and app_name and app_url:
                        if not version_set:
                            version_set = self._collect_version(app_url, tags)
                        if pre_20_mode:
                            self.log.debug('Getting application list in pre-20 mode')
                            applist = self._rest_request_to_json(
                                app_url, SPARK_APPS_PATH, SPARK_STANDALONE_SERVICE_CHECK, tags
                            )
                            for appl in applist:
                                aid = appl.get('id')
                                aname = appl.get('name')
                                running_apps[aid] = (aname, app_url)
                        else:
                            running_apps[app_id] = (app_name, app_url)
                except Exception:
                    # it's possible for the requests to fail if the job
                    # completed since we got the list of apps.  Just continue
                    pass

        # Report success after gathering metrics from Spark master
        self.service_check(
            SPARK_STANDALONE_SERVICE_CHECK,
            AgentCheck.OK,
            tags=['url:%s' % self.master_address] + tags,
        )
        self.log.info("Returning running apps %s", running_apps)
        return running_apps
def _standalone_init ( self , pre_20_mode , tags ) : metrics_json = self . _rest_request_to_json ( self . master_address , SPARK_MASTER_STATE_PATH , SPARK_STANDALONE_SERVICE_CHECK , tags ) running_apps = { } version_set = False if metrics_json . get ( 'activeapps' ) : for app in metrics_json [ 'activeapps' ] : app_id = app . get ( 'id' ) app_name = app . get ( 'name' ) # Parse through the HTML to grab the application driver's link try : app_url = self . _get_standalone_app_url ( app_id , tags ) if app_id and app_name and app_url : if not version_set : version_set = self . _collect_version ( app_url , tags ) if pre_20_mode : self . log . debug ( 'Getting application list in pre-20 mode' ) applist = self . _rest_request_to_json ( app_url , SPARK_APPS_PATH , SPARK_STANDALONE_SERVICE_CHECK , tags ) for appl in applist : aid = appl . get ( 'id' ) aname = appl . get ( 'name' ) running_apps [ aid ] = ( aname , app_url ) else : running_apps [ app_id ] = ( app_name , app_url ) except Exception : # it's possible for the requests to fail if the job # completed since we got the list of apps.  Just continue pass # Report success after gathering metrics from Spark master self . service_check ( SPARK_STANDALONE_SERVICE_CHECK , AgentCheck . OK , tags = [ 'url:%s' % self . master_address ] + tags , ) self . log . info ( "Returning running apps %s" , running_apps ) return running_apps