forked from apache/hawq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HAWQ-1622. Cache UGI objects and clean them periodically
Co-authored-by: Lav Jain <[email protected]> Co-authored-by: Ben Christel <[email protected]> Co-authored-by: Alex Denissov <[email protected]> Co-authored-by: Shivram Mani <[email protected]> Co-authored-by: Francisco Guerrero <[email protected]> Co-authored-by: Divya Bhargov <[email protected]>
- Loading branch information
1 parent
845ffe8
commit 59133ea
Showing
8 changed files
with
1,138 additions
and
32 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/SessionId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package org.apache.hawq.pxf.service; | ||
|
||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* For the purposes of pxf-server, a session is the set of requests processed on a specific segment | ||
* on behalf of a particular user and transaction. Grouping requests together into a session allows | ||
* us to re-use the UserGroupInformation object (which is expensive to destroy) for each session. | ||
* <p> | ||
* SessionId is used as the cache key to look up the UserGroupInformation for a request. See {@link | ||
* UGICache}. | ||
*/ | ||
public class SessionId { | ||
|
||
private final String user; | ||
private final Integer segmentId; | ||
private final String sessionId; | ||
|
||
/** | ||
* Create a sessionId | ||
* | ||
* @param segmentId the calling segment | ||
* @param transactionId the identifier for the transaction | ||
* @param gpdbUser the GPDB username | ||
*/ | ||
public SessionId(Integer segmentId, String transactionId, String gpdbUser) { | ||
this.segmentId = segmentId; | ||
this.user = gpdbUser; | ||
this.sessionId = gpdbUser + ":" + transactionId + ":" + segmentId; | ||
} | ||
|
||
/** | ||
* @return the segment id | ||
*/ | ||
public Integer getSegmentId() { | ||
return segmentId; | ||
} | ||
|
||
/** | ||
* @return the gpdb user name | ||
*/ | ||
public String getUser() { | ||
return user; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public int hashCode() { | ||
return sessionId.hashCode(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) return false; | ||
if (obj == this) return true; | ||
if (obj.getClass() != getClass()) return false; | ||
|
||
SessionId that = (SessionId) obj; | ||
return this.sessionId.equals(that.sessionId); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String toString() { | ||
return "Session = " + sessionId; | ||
} | ||
} |
Oops, something went wrong.