@Override public SessionHandle openSession(String username, String password, Map<String, String> configuration) throws HiveSQLException { try { TOpenSessionReq req = new TOpenSessionReq(); req.setUsername(username); req.setPassword(password); req.setConfiguration(configuration); TOpenSessionResp resp = cliService.OpenSession(req); checkStatus(resp.getStatus()); return new SessionHandle(resp.getSessionHandle(), resp.getServerProtocolVersion()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
public Object getFieldValue(_Fields field) { switch (field) { case CLIENT_PROTOCOL: return getClient_protocol(); case USERNAME: return getUsername(); case PASSWORD: return getPassword(); case CONFIGURATION: return getConfiguration(); } throw new IllegalStateException(); }
case CLIENT_PROTOCOL: if (value == null) { unsetClient_protocol(); } else { setClient_protocol((TProtocolVersion)value); unsetUsername(); } else { setUsername((String)value); unsetPassword(); } else { setPassword((String)value); unsetConfiguration(); } else { setConfiguration((Map<String,String>)value);
@Override public void read(org.apache.thrift.protocol.TProtocol prot, OpenSession_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.req = new TOpenSessionReq(); struct.req.read(iprot); struct.setReqIsSet(true); } } }
/** * Create a session handle * @param req * @param res * @return * @throws HiveSQLException * @throws LoginException * @throws IOException */ SessionHandle getSessionHandle(TOpenSessionReq req, TOpenSessionResp res) throws HiveSQLException, LoginException, IOException { String userName = getUserName(req); String ipAddress = getIpAddress(); TProtocolVersion protocol = getMinVersion(CLIService.SERVER_VERSION, req.getClient_protocol()); SessionHandle sessionHandle; if (cliService.getHiveConf().getBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS) && (userName != null)) { String delegationTokenStr = getDelegationToken(userName); sessionHandle = cliService.openSessionWithImpersonation(protocol, userName, req.getPassword(), ipAddress, req.getConfiguration(), delegationTokenStr); } else { sessionHandle = cliService.openSession(protocol, userName, req.getPassword(), ipAddress, req.getConfiguration()); } res.setServerProtocolVersion(protocol); return sessionHandle; }
public TOpenSessionReq deepCopy() { return new TOpenSessionReq(this); }
userName = req.getUsername(); String effectiveClientUser = getProxyUser(userName, req.getConfiguration(), getIpAddress()); LOG.debug("Client's username: " + effectiveClientUser); return effectiveClientUser;
@Override public TOpenSessionResp OpenSession(TOpenSessionReq req) throws TException { LOG.info("Client protocol version: " + req.getClient_protocol()); TOpenSessionResp resp = new TOpenSessionResp(); try { SessionHandle sessionHandle = getSessionHandle(req, resp); resp.setSessionHandle(sessionHandle.toTSessionHandle()); Map<String, String> configurationMap = new HashMap<String, String>(); // Set the updated fetch size from the server into the configuration map for the client HiveConf sessionConf = cliService.getSessionConf(sessionHandle); configurationMap.put( HiveConf.ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_DEFAULT_FETCH_SIZE.varname, Integer.toString(sessionConf != null ? sessionConf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_DEFAULT_FETCH_SIZE) : hiveConf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_DEFAULT_FETCH_SIZE))); resp.setConfiguration(configurationMap); resp.setStatus(OK_STATUS); ThriftCLIServerContext context = (ThriftCLIServerContext)currentServerContext.get(); if (context != null) { context.setSessionHandle(sessionHandle); } } catch (Exception e) { LOG.warn("Error opening session: ", e); resp.setStatus(HiveSQLException.toTStatus(e)); } return resp; }
/** * Create a session handle * @param req * @param res * @return * @throws HiveSQLException * @throws LoginException * @throws IOException */ SessionHandle getSessionHandle(TOpenSessionReq req, TOpenSessionResp res) throws HiveSQLException, LoginException, IOException { String userName = getUserName(req); String ipAddress = getIpAddress(); TProtocolVersion protocol = getMinVersion(CLIService.SERVER_VERSION, req.getClient_protocol()); SessionHandle sessionHandle; if (cliService.getHiveConf().getBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS) && (userName != null)) { String delegationTokenStr = getDelegationToken(userName); sessionHandle = cliService.openSessionWithImpersonation(protocol, userName, req.getPassword(), ipAddress, req.getConfiguration(), delegationTokenStr); } else { sessionHandle = cliService.openSession(protocol, userName, req.getPassword(), ipAddress, req.getConfiguration()); } res.setServerProtocolVersion(protocol); return sessionHandle; }
public void read(org.apache.thrift.protocol.TProtocol iprot, OpenSession_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // REQ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.req = new TOpenSessionReq(); struct.req.read(iprot); struct.setReqIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); struct.validate(); }
/** * Performs a deep copy on <i>other</i>. */ public OpenSession_args(OpenSession_args other) { if (other.isSetReq()) { this.req = new TOpenSessionReq(other.req); } }
userName = req.getUsername(); String effectiveClientUser = getProxyUser(userName, req.getConfiguration(), getIpAddress()); LOG.debug("Client's username: " + effectiveClientUser); return effectiveClientUser;
@Override public TOpenSessionResp OpenSession(TOpenSessionReq req) throws TException { LOG.info("Client protocol version: " + req.getClient_protocol()); TOpenSessionResp resp = new TOpenSessionResp(); try { SessionHandle sessionHandle = getSessionHandle(req, resp); resp.setSessionHandle(sessionHandle.toTSessionHandle()); Map<String, String> configurationMap = new HashMap<String, String>(); // Set the updated fetch size from the server into the configuration map for the client HiveConf sessionConf = cliService.getSessionConf(sessionHandle); configurationMap.put( HiveConf.ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_DEFAULT_FETCH_SIZE.varname, Integer.toString(sessionConf != null ? sessionConf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_DEFAULT_FETCH_SIZE) : hiveConf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_DEFAULT_FETCH_SIZE))); resp.setConfiguration(configurationMap); resp.setStatus(OK_STATUS); ThriftCLIServerContext context = (ThriftCLIServerContext)currentServerContext.get(); if (context != null) { context.setSessionHandle(sessionHandle); } } catch (Exception e) { LOG.warn("Error opening session: ", e); resp.setStatus(HiveSQLException.toTStatus(e)); } return resp; }
private void openSession() throws SQLException { TOpenSessionReq openReq = new TOpenSessionReq(); sessVars.get(HiveAuthConstants.HS2_PROXY_USER)); openReq.setConfiguration(openConf); openReq.setUsername(sessConfMap.get(JdbcConnectionParams.AUTH_USER)); openReq.setPassword(sessConfMap.get(JdbcConnectionParams.AUTH_PASSWD));
TOpenSessionReq openReq = new TOpenSessionReq(); TOpenSessionResp openResp = client.OpenSession(openReq); TSessionHandle sessHandle = openResp.getSessionHandle();
@Override public SessionHandle openSession(String username, String password, Map<String, String> configuration) throws HiveSQLException { try { TOpenSessionReq req = new TOpenSessionReq(); req.setUsername(username); req.setPassword(password); req.setConfiguration(configuration); TOpenSessionResp resp = cliService.OpenSession(req); checkStatus(resp.getStatus()); return new SessionHandle(resp.getSessionHandle(), resp.getServerProtocolVersion()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
private void openSession() throws SQLException { TOpenSessionReq openReq = new TOpenSessionReq(); sessVars.get(HiveAuthConstants.HS2_PROXY_USER)); openReq.setConfiguration(openConf); openReq.setUsername(sessConfMap.get(JdbcConnectionParams.AUTH_USER)); openReq.setPassword(sessConfMap.get(JdbcConnectionParams.AUTH_PASSWD));