hawq-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denalex <...@git.apache.org>
Subject [GitHub] incubator-hawq pull request #1379: WIP: Cache UGI objects and clean them per...
Date Mon, 02 Jul 2018 18:04:20 GMT
Github user denalex commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/1379#discussion_r199577452
  
    --- Diff: pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/servlet/SecurityServletFilter.java
---
    @@ -42,8 +52,51 @@
     
         private static final Log LOG = LogFactory.getLog(SecurityServletFilter.class);
         private static final String USER_HEADER = "X-GP-USER";
    -    private static final String MISSING_HEADER_ERROR = String.format("Header %s is missing
in the request", USER_HEADER);
    -    private static final String EMPTY_HEADER_ERROR = String.format("Header %s is empty
in the request", USER_HEADER);
    +    private static final String SEGMENT_INDEX_HEADER = "X-GP-SEGMENT-ID";
    +    private static final String TRANSACTION_ID_HEADER = "X-GP-XID";
    +    private static final String MISSING_HEADER_ERROR = "Header %s is missing in the request";
    +    private static final String EMPTY_HEADER_ERROR = "Header %s is empty in the request";
    +    private static Map<SegmentTransactionId, TimedProxyUGI> cache = new ConcurrentHashMap<>();
    +    private static DelayQueue<TimedProxyUGI> delayQueue = new DelayQueue<>();
    +    private static long UGI_CACHE_EXPIRY = 15 * 60 * 1000L; // 15 Minutes
    +
    +
    +    private static class TimedProxyUGI implements Delayed {
    +        long startTime;
    +        UserGroupInformation proxyUGI;
    +        SegmentTransactionId session;
    +
    +        public TimedProxyUGI(UserGroupInformation proxyUGI, SegmentTransactionId session)
{
    +            this.startTime = System.currentTimeMillis();
    +            this.proxyUGI = proxyUGI;
    +            this.session = session;
    +        }
    +
    +        @Override
    +        public long getDelay(TimeUnit unit) {
    +            return unit.convert(getDelayMillis(), TimeUnit.MILLISECONDS);
    +        }
    +
    +        @Override
    +        public int compareTo(Delayed other) {
    +            return Long.compare(this.getDelayMillis(), ((TimedProxyUGI)other).getDelayMillis());
    +        }
    +
    +        private long getDelayMillis() {
    +            return (startTime + UGI_CACHE_EXPIRY) - System.currentTimeMillis();
    +        }
    +    }
    +
    +    private static class SegmentTransactionId {
    +        String segmentIndex;
    --- End diff --
    
    I think that's what we decided on the meeting, even though I don't remember why transactionID
only is not enough. I believe we decided no need for close() call also.


---

Mime
View raw message