Back to home page

OSCL-LXR

 
 

    


0001 /**
0002  * Licensed to the Apache Software Foundation (ASF) under one
0003  * or more contributor license agreements.  See the NOTICE file
0004  * distributed with this work for additional information
0005  * regarding copyright ownership.  The ASF licenses this file
0006  * to you under the Apache License, Version 2.0 (the
0007  * "License"); you may not use this file except in compliance
0008  * with the License.  You may obtain a copy of the License at
0009  *
0010  *     http://www.apache.org/licenses/LICENSE-2.0
0011  *
0012  * Unless required by applicable law or agreed to in writing, software
0013  * distributed under the License is distributed on an "AS IS" BASIS,
0014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0015  * See the License for the specific language governing permissions and
0016  * limitations under the License.
0017  */
0018 
0019 package org.apache.hive.service.cli;
0020 
0021 import java.util.UUID;
0022 
0023 import org.apache.hive.service.cli.thrift.TProtocolVersion;
0024 import org.apache.hive.service.cli.thrift.TSessionHandle;
0025 
0026 
0027 /**
0028  * SessionHandle.
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   // dummy handle for ThriftCLIService
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 UUID getSessionId() {
0050     return getHandleIdentifier().getPublicId();
0051   }
0052 
0053   public TSessionHandle toTSessionHandle() {
0054     TSessionHandle tSessionHandle = new TSessionHandle();
0055     tSessionHandle.setSessionId(getHandleIdentifier().toTHandleIdentifier());
0056     return tSessionHandle;
0057   }
0058 
0059   public TProtocolVersion getProtocolVersion() {
0060     return protocol;
0061   }
0062 
0063   @Override
0064   public String toString() {
0065     return "SessionHandle [" + getHandleIdentifier() + "]";
0066   }
0067 }