0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 package org.apache.hive.service.cli;
0020
0021 import java.util.UUID;
0022
0023 import org.apache.hive.service.rpc.thrift.TProtocolVersion;
0024 import org.apache.hive.service.rpc.thrift.TSessionHandle;
0025
0026
0027
0028
0029
0030
0031 public class SessionHandle extends Handle {
0032
0033 private final TProtocolVersion protocol;
0034
0035 public SessionHandle(TProtocolVersion protocol) {
0036 this.protocol = protocol;
0037 }
0038
0039
0040 public SessionHandle(TSessionHandle tSessionHandle) {
0041 this(tSessionHandle, TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V1);
0042 }
0043
0044 public SessionHandle(TSessionHandle tSessionHandle, TProtocolVersion protocol) {
0045 super(tSessionHandle.getSessionId());
0046 this.protocol = protocol;
0047 }
0048
0049 public SessionHandle(HandleIdentifier handleId, TProtocolVersion protocol) {
0050 super(handleId);
0051 this.protocol = protocol;
0052 }
0053
0054 public UUID getSessionId() {
0055 return getHandleIdentifier().getPublicId();
0056 }
0057
0058 public TSessionHandle toTSessionHandle() {
0059 TSessionHandle tSessionHandle = new TSessionHandle();
0060 tSessionHandle.setSessionId(getHandleIdentifier().toTHandleIdentifier());
0061 return tSessionHandle;
0062 }
0063
0064 public TProtocolVersion getProtocolVersion() {
0065 return protocol;
0066 }
0067
0068 @Override
0069 public String toString() {
0070 return "SessionHandle [" + getHandleIdentifier() + "]";
0071 }
0072 }