Exemplo n.º 1
0
 def get_hive_user_demo(self, from_time, to_time, condition):
     filter_str = "hive_query_id RLIKE \".*\" and " + condition
     return get_service(self._api, cluster_name="cluster",
                        name="yarn").get_yarn_applications(
                            start_time=from_time,
                            end_time=to_time,
                            filter_str=filter_str)
Exemplo n.º 2
0
 def get_top_user_demo(self, from_time, to_time, duration=900):
     filter_str = "hive_query_id RLIKE \".*\" and application_duration >= %s" % duration
     return get_service(self._api, cluster_name="cluster",
                        name="yarn").get_yarn_applications(
                            start_time=from_time,
                            end_time=to_time,
                            filter_str=filter_str)
Exemplo n.º 3
0
    def get_service(self, name):
        """
    Lookup a service by name.

    @param name: Service name
    @return: An ApiService object
    """
        return services.get_service(self._get_resource_root(), name, self.name)
Exemplo n.º 4
0
  def get_service(self, name):
    """
    Lookup a service by name.

    @param name: Service name
    @return: An ApiService object
    """
    return services.get_service(self._get_resource_root(), name, self.name)
Exemplo n.º 5
0
 def get_top_user_demo(self):
     return get_service(self._api, cluster_name="cluster",
                        name="impala").get_impala_queries(
                            start_time=get_n_day_ago_from(n=1),
                            end_time=get_now(),
                            filter_str="")
Exemplo n.º 6
0
        def _build_host_inventory(hostRef,inv,meta_hostvars):
            host = hosts.get_host(self.cm, hostRef.hostId)
            #print host.hostname

            self._add_host(inv, 'all', host.hostname)
            if meta_hostvars:
                inv['_meta']['hostvars'][host.hostname] = host.to_json_dict(preserve_ro=True)
            self._put_cache(host.hostname, host.to_json_dict(preserve_ro=True))

            # Group by cluster
            if host.clusterRef:
                cluster = clusters.get_cluster(self.cm, host.clusterRef.clusterName)
                self._add_child(inv, 'all', cluster.displayName)
                self._add_host(inv, cluster.displayName, host.hostname)

                if host.roleRefs:
                    for roleRef in host.roleRefs:
                        role = roles.get_role(self.cm, roleRef.serviceName, roleRef.roleName, roleRef.clusterName)

                        # Group by service
                        service = services.get_service(self.cm, roleRef.serviceName, roleRef.clusterName)

                        # There is no way to ensure that service display name is unique across clusters
                        # The only simple and unique representation of the service that can be used
                        # is the concatination of the service name and the cluster's name
                        service_group = cluster.displayName + '-' + service.displayName
                        self._add_child(inv, 'all', service.type)
                        self._add_child(inv, service.type, service_group)
                        self._add_child(inv, cluster.displayName, service_group)
                        self._add_host(inv, service_group, host.hostname)

                        # Group by role, roles depend on services and clusters, so the only unique and
                        # simple representation of a Group is the concatination of the role type, service
                        # name and the cluster name
                        role_group = cluster.displayName + '-' + service.displayName + '-' + role.type
                        self._add_child(inv, 'all', role.type)
                        #self._add_child(inv, role.type, service_group)
                        #self._add_child(inv, service_group, role_group)
                        self._add_child(inv, role.type, role_group)
                        self._add_host(inv, role_group, host.hostname)

                        # Group by role Group
                        role_group = role.roleConfigGroupRef.roleConfigGroupName
                        self._add_child(inv, role.type, role_group)
                        self._add_host(inv, role_group, host.hostname)

                        # Group by role template
                        for template in host_templates.get_all_host_templates(self.cm, host.clusterRef.clusterName):
                            self._add_child(inv, 'all', template.name)
                            for group in template.roleConfigGroupRefs:
                                if role_group == group.roleConfigGroupName:
                                    self._add_child(inv, template.name, role_group)
                    else:
                        self._add_child(inv, 'all', 'no_role')
                        self._add_host(inv, 'no_role', host.hostname)

                # Group by Rack
                self._add_child(inv, 'all', host.rackId)
                self._add_host(inv, host.rackId, host.clusterRef.clusterName)
            else:
                cluster_group = "no_cluster"
                self._add_child(inv, 'all', cluster_group)
                self._add_host(inv, cluster_group, host.hostname)