drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DRILL-5068) Create a system table for completed profiles - sys.profiles
Date Thu, 04 Jan 2018 01:43:00 GMT

    [ https://issues.apache.org/jira/browse/DRILL-5068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16310588#comment-16310588
] 

ASF GitHub Bot commented on DRILL-5068:
---------------------------------------

Github user kkhatua commented on a diff in the pull request:

    https://github.com/apache/drill/pull/1077#discussion_r159567582
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/ProfileIterator.java
---
    @@ -0,0 +1,216 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.drill.exec.store.sys;
    +
    +import com.google.common.base.Function;
    +import com.google.common.collect.Iterators;
    +
    +import org.apache.drill.exec.ExecConstants;
    +import org.apache.drill.exec.ops.FragmentContext;
    +import org.apache.drill.exec.ops.QueryContext;
    +import org.apache.drill.exec.proto.UserBitShared;
    +import org.apache.drill.exec.proto.UserBitShared.QueryProfile;
    +import org.apache.drill.exec.server.QueryProfileStoreContext;
    +import org.apache.drill.exec.server.options.QueryOptionManager;
    +import org.apache.drill.exec.util.ImpersonationUtil;
    +
    +import javax.annotation.Nullable;
    +import java.sql.Timestamp;
    +import java.util.Iterator;
    +import java.util.LinkedList;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Map.Entry;
    +
    +/**
    + * DRILL-5068: Add a new system table for completed profiles
    + */
    +public class ProfileIterator implements Iterator<Object> {
    +  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ProfileIterator.class);
    +
    +  private final QueryProfileStoreContext profileStoreContext;
    +  private final Iterator<?> itr;
    +  private final String queryingUsername;
    +  private final boolean isAdmin;
    +
    +  public ProfileIterator(FragmentContext context) {
    +    //Grab profile Store Context
    +    profileStoreContext = context
    +        .getDrillbitContext()
    +        .getProfileStoreContext();
    +
    +    queryingUsername = context.getQueryUserName();
    +    isAdmin = hasAdminPrivileges(context.getQueryContext());
    +
    +    itr = iterateProfileInfo(context);
    +  }
    +
    +  private boolean hasAdminPrivileges(QueryContext queryContext) {
    +    if (queryContext == null) {
    +      return false;
    +    }
    +    QueryOptionManager options = queryContext.getOptions();
    +    if (queryContext.isUserAuthenticationEnabled() &&
    +        !ImpersonationUtil.hasAdminPrivileges(
    +          queryContext.getQueryUserName(),
    +          ExecConstants.ADMIN_USERS_VALIDATOR.getAdminUsers(options),
    +          ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.getAdminUserGroups(options))) {
    +      return false;
    +    }
    +
    +    //Passed checks
    +    return true;
    +  }
    +
    +  private Iterator<ProfileInfo> iterateProfileInfo(FragmentContext context) {
    +    try {
    +      PersistentStore<UserBitShared.QueryProfile> profiles = profileStoreContext.getCompletedProfileStore();
    +
    +      return transform(getAuthorizedProfiles(profiles.getAll(), queryingUsername, isAdmin));
    +
    +    } catch (Exception e) {
    +      logger.error(String.format("Unable to get persistence store: %s, ", profileStoreContext.getProfileStoreConfig().getName(),
e));
    +      return Iterators.singletonIterator(ProfileInfo.getDefault());
    +    }
    +  }
    +
    +  //Returns an iterator for authorized profiles
    +  private Iterator<Entry<String, QueryProfile>> getAuthorizedProfiles (
    +      Iterator<Entry<String, QueryProfile>> allProfiles, String username,
boolean isAdministrator) {
    --- End diff --
    
    +1 . Moved  the authorizedProfiles method to base class.


> Create a system table for completed profiles - sys.profiles
> -----------------------------------------------------------
>
>                 Key: DRILL-5068
>                 URL: https://issues.apache.org/jira/browse/DRILL-5068
>             Project: Apache Drill
>          Issue Type: Sub-task
>          Components: Storage - Information Schema
>    Affects Versions: 1.8.0
>         Environment: Fedora 25
> OpenJDK 8
> Firefox 50.0
>            Reporter: Hongze Zhang
>            Assignee: Kunal Khatua
>             Fix For: 1.13.0
>
>
> Hi,
> Currently the profile page on UI is still not detailed enough for some complicated uses
 (eg. show all failed queries during these three days), we can only access latest 100 query
profiles on this page.
> We may sometimes need a specific system table for querying completed profiles.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message