Modified: hive/branches/cbo/service/src/java/org/apache/hive/service/cli/CLIService.java URL: http://svn.apache.org/viewvc/hive/branches/cbo/service/src/java/org/apache/hive/service/cli/CLIService.java?rev=1622590&r1=1622589&r2=1622590&view=diff ============================================================================== --- hive/branches/cbo/service/src/java/org/apache/hive/service/cli/CLIService.java (original) +++ hive/branches/cbo/service/src/java/org/apache/hive/service/cli/CLIService.java Fri Sep 5 00:49:59 2014 @@ -30,12 +30,8 @@ import javax.security.auth.login.LoginEx import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; -import org.apache.hadoop.hive.conf.SystemVariables; import org.apache.hadoop.hive.metastore.HiveMetaStoreClient; import org.apache.hadoop.hive.metastore.IMetaStoreClient; import org.apache.hadoop.hive.ql.metadata.Hive; @@ -118,15 +114,6 @@ public class CLIService extends Composit @Override public synchronized void start() { super.start(); - - try { - // make sure that the base scratch directories exists and writable - setupStagingDir(hiveConf.getVar(HiveConf.ConfVars.SCRATCHDIR), false); - setupStagingDir(hiveConf.getVar(HiveConf.ConfVars.LOCALSCRATCHDIR), true); - setupStagingDir(hiveConf.getVar(HiveConf.ConfVars.DOWNLOADED_RESOURCES_DIR), true); - } catch (IOException eIO) { - throw new ServiceException("Error setting stage directories", eIO); - } // Initialize and test a connection to the metastore IMetaStoreClient metastoreClient = null; try { @@ -460,25 +447,6 @@ public class CLIService extends Composit } } - // create the give Path if doesn't exists and make it writable - private void setupStagingDir(String dirPath, boolean isLocal) throws IOException { - Path scratchDir = getStaticPath(new Path(dirPath)); - if (scratchDir == null) { - return; - } - FileSystem fs; - if (isLocal) { - fs = FileSystem.getLocal(hiveConf); - } else { - fs = scratchDir.getFileSystem(hiveConf); - } - if (!fs.exists(scratchDir)) { - fs.mkdirs(scratchDir); - } - FsPermission fsPermission = new FsPermission((short)0777); - fs.setPermission(scratchDir, fsPermission); - } - @Override public String getDelegationToken(SessionHandle sessionHandle, HiveAuthFactory authFactory, String owner, String renewer) throws HiveSQLException { @@ -502,16 +470,4 @@ public class CLIService extends Composit sessionManager.getSession(sessionHandle).renewDelegationToken(authFactory, tokenStr); LOG.info(sessionHandle + ": renewDelegationToken()"); } - - // DOWNLOADED_RESOURCES_DIR for example, which is by default ${system:java.io.tmpdir}/${hive.session.id}_resources, - // {system:java.io.tmpdir} would be already evaluated but ${hive.session.id} would be not in here. - // for that case, this returns evaluatd parts only, in this case, "/tmp" - // what for ${hive.session.id}_resources/${system:java.io.tmpdir}? just don't do that. - private Path getStaticPath(Path path) { - Path current = path; - for (; current != null && SystemVariables.containsVar(current.getName()); - current = current.getParent()) { - } - return current; - } }
Modified: hive/branches/cbo/service/src/java/org/apache/hive/service/cli/session/HiveSessionBase.java URL: http://svn.apache.org/viewvc/hive/branches/cbo/service/src/java/org/apache/hive/service/cli/session/HiveSessionBase.java?rev=1622590&r1=1622589&r2=1622590&view=diff ============================================================================== --- hive/branches/cbo/service/src/java/org/apache/hive/service/cli/session/HiveSessionBase.java (original) +++ hive/branches/cbo/service/src/java/org/apache/hive/service/cli/session/HiveSessionBase.java Fri Sep 5 00:49:59 2014 @@ -18,6 +18,8 @@ package org.apache.hive.service.cli.session; +import java.util.Map; + import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.ql.session.SessionState; import org.apache.hive.service.cli.SessionHandle; Modified: hive/branches/cbo/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java URL: http://svn.apache.org/viewvc/hive/branches/cbo/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java?rev=1622590&r1=1622589&r2=1622590&view=diff ============================================================================== --- hive/branches/cbo/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java (original) +++ hive/branches/cbo/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java Fri Sep 5 00:49:59 2014 @@ -69,7 +69,7 @@ public class HiveSessionImpl implements private String username; private final String password; - private final HiveConf hiveConf; + private HiveConf hiveConf; private final SessionState sessionState; private String ipAddress; @@ -240,6 +240,12 @@ public class HiveSessionImpl implements } @Override + /** + * Opens a new HiveServer2 session for the client connection. + * Note that if doAs is true, this call goes through a proxy object, + * which wraps the method logic in a UserGroupInformation#doAs. + * That is why it is important to call SessionState#start here rather than the constructor. + */ public void open() { SessionState.start(sessionState); } Modified: hive/branches/cbo/service/src/java/org/apache/hive/service/cli/session/SessionManager.java URL: http://svn.apache.org/viewvc/hive/branches/cbo/service/src/java/org/apache/hive/service/cli/session/SessionManager.java?rev=1622590&r1=1622589&r2=1622590&view=diff ============================================================================== --- hive/branches/cbo/service/src/java/org/apache/hive/service/cli/session/SessionManager.java (original) +++ hive/branches/cbo/service/src/java/org/apache/hive/service/cli/session/SessionManager.java Fri Sep 5 00:49:59 2014 @@ -233,11 +233,13 @@ public class SessionManager extends Comp Map<String, String> sessionConf, boolean withImpersonation, String delegationToken) throws HiveSQLException { HiveSession session; + // If doAs is set to true for HiveServer2, we will create a proxy object for the session impl. + // Within the proxy object, we wrap the method call in a UserGroupInformation#doAs if (withImpersonation) { - HiveSessionImplwithUGI hiveSessionUgi = new HiveSessionImplwithUGI(protocol, username, password, - hiveConf, ipAddress, delegationToken); - session = HiveSessionProxy.getProxy(hiveSessionUgi, hiveSessionUgi.getSessionUgi()); - hiveSessionUgi.setProxySession(session); + HiveSessionImplwithUGI sessionWithUGI = new HiveSessionImplwithUGI(protocol, username, password, + hiveConf, ipAddress, delegationToken); + session = HiveSessionProxy.getProxy(sessionWithUGI, sessionWithUGI.getSessionUgi()); + sessionWithUGI.setProxySession(session); } else { session = new HiveSessionImpl(protocol, username, password, hiveConf, ipAddress); } Modified: hive/branches/cbo/service/src/java/org/apache/hive/service/server/HiveServer2.java URL: http://svn.apache.org/viewvc/hive/branches/cbo/service/src/java/org/apache/hive/service/server/HiveServer2.java?rev=1622590&r1=1622589&r2=1622590&view=diff ============================================================================== --- hive/branches/cbo/service/src/java/org/apache/hive/service/server/HiveServer2.java (original) +++ hive/branches/cbo/service/src/java/org/apache/hive/service/server/HiveServer2.java Fri Sep 5 00:49:59 2014 @@ -131,6 +131,7 @@ public class HiveServer2 extends Composi } public static void main(String[] args) { + HiveConf.setLoadHiveServer2Config(true); try { ServerOptionsProcessor oproc = new ServerOptionsProcessor("hiveserver2"); if (!oproc.process(args)) {
