Skip to content

Commit e844b8e

Browse files
committed
HIVE-29209: Remove unnecessary usage of LoginException
1 parent d90574c commit e844b8e

23 files changed

Lines changed: 53 additions & 139 deletions

File tree

common/src/java/org/apache/hadoop/hive/common/FileUtils.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@
7777
import org.slf4j.Logger;
7878
import org.slf4j.LoggerFactory;
7979

80-
import javax.security.auth.login.LoginException;
81-
8280
/**
8381
* Collection of file manipulation utilities common across Hive.
8482
*/
@@ -520,7 +518,7 @@ private static void addChildren(FileSystem fsAsUser, Path path, List<FileStatus>
520518
}
521519
}
522520

523-
public static UserGroupInformation getProxyUser(final String user) throws LoginException, IOException {
521+
public static UserGroupInformation getProxyUser(final String user) throws IOException {
524522
UserGroupInformation ugi = Utils.getUGI();
525523
String currentUser = ugi.getShortUserName();
526524
UserGroupInformation proxyUser = null;

common/src/java/org/apache/hadoop/hive/conf/HiveConf.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
import org.slf4j.Logger;
5050
import org.slf4j.LoggerFactory;
5151

52-
import javax.security.auth.login.LoginException;
53-
5452
import java.io.ByteArrayOutputStream;
5553
import java.io.File;
5654
import java.io.IOException;
@@ -7050,12 +7048,8 @@ public static URL getHiveServer2SiteLocation() {
70507048
* @throws IOException
70517049
*/
70527050
public String getUser() throws IOException {
7053-
try {
7054-
UserGroupInformation ugi = Utils.getUGI();
7055-
return ugi.getUserName();
7056-
} catch (LoginException le) {
7057-
throw new IOException(le);
7058-
}
7051+
UserGroupInformation ugi = Utils.getUGI();
7052+
return ugi.getUserName();
70597053
}
70607054

70617055
public static String getColumnInternalName(int pos) {

hcatalog/core/src/main/java/org/apache/hive/hcatalog/common/HCatUtil.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
import java.util.Map;
3434
import java.util.Properties;
3535

36-
import javax.security.auth.login.LoginException;
37-
3836
import com.google.common.collect.Maps;
3937
import org.apache.commons.codec.binary.Base64;
4038
import org.apache.commons.lang3.StringUtils;
@@ -551,11 +549,7 @@ public static IMetaStoreClient getHiveMetastoreClient(HiveConf hiveConf)
551549
}
552550
}
553551
}
554-
try {
555-
return hiveClientCache.get(hiveConf);
556-
} catch (LoginException e) {
557-
throw new IOException("Couldn't create hiveMetaStoreClient, Error getting UGI for user", e);
558-
}
552+
return hiveClientCache.get(hiveConf);
559553
}
560554

561555
/**

itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCleanerWithReplication.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.junit.BeforeClass;
3939
import org.junit.Test;
4040

41-
import javax.security.auth.login.LoginException;
4241
import java.io.IOException;
4342

4443
import static org.junit.Assert.assertEquals;
@@ -65,7 +64,7 @@ public void setup() throws Exception {
6564
}
6665

6766
@BeforeClass
68-
public static void classLevelSetup() throws LoginException, IOException {
67+
public static void classLevelSetup() throws IOException {
6968
Configuration hadoopConf = new Configuration();
7069
hadoopConf.set("dfs.client.use.datanode.hostname", "true");
7170
hadoopConf.set("hadoop.proxyuser." + Utils.getUGI().getShortUserName() + ".hosts", "*");

metastore/src/java/org/apache/hadoop/hive/metastore/HiveClientCache.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import java.util.concurrent.TimeUnit;
2929
import java.util.concurrent.atomic.AtomicInteger;
3030

31-
import javax.security.auth.login.LoginException;
32-
3331
import org.apache.commons.lang3.builder.EqualsBuilder;
3432
import org.apache.commons.lang3.builder.HashCodeBuilder;
3533
import org.apache.hadoop.hive.common.classification.InterfaceAudience;
@@ -250,9 +248,8 @@ public void cleanup() {
250248
* @return the hive client
251249
* @throws MetaException
252250
* @throws IOException
253-
* @throws LoginException
254251
*/
255-
public IMetaStoreClient get(final HiveConf hiveConf) throws MetaException, IOException, LoginException {
252+
public IMetaStoreClient get(final HiveConf hiveConf) throws MetaException, IOException {
256253
final HiveClientCacheKey cacheKey = HiveClientCacheKey.fromHiveConf(hiveConf, getThreadId());
257254
ICacheableMetaStoreClient cacheableHiveMetaStoreClient = null;
258255

@@ -279,10 +276,9 @@ public IMetaStoreClient get(final HiveConf hiveConf) throws MetaException, IOExc
279276
* @return
280277
* @throws IOException
281278
* @throws MetaException
282-
* @throws LoginException
283279
*/
284280
private ICacheableMetaStoreClient getOrCreate(final HiveClientCacheKey cacheKey)
285-
throws IOException, MetaException, LoginException {
281+
throws IOException, MetaException {
286282
try {
287283
return hiveCache.get(cacheKey, new Callable<ICacheableMetaStoreClient>() {
288284
@Override
@@ -301,8 +297,6 @@ public ICacheableMetaStoreClient call() throws MetaException {
301297
throw (IOException) t;
302298
} else if (t instanceof MetaException) {
303299
throw (MetaException) t;
304-
} else if (t instanceof LoginException) {
305-
throw (LoginException) t;
306300
} else {
307301
throw new IOException("Error creating hiveMetaStoreClient", t);
308302
}
@@ -321,14 +315,14 @@ static class HiveClientCacheKey {
321315
final private HiveConf hiveConf;
322316
final private int threadId;
323317

324-
private HiveClientCacheKey(HiveConf hiveConf, final int threadId) throws IOException, LoginException {
318+
private HiveClientCacheKey(HiveConf hiveConf, final int threadId) throws IOException {
325319
this.metaStoreURIs = hiveConf.getVar(HiveConf.ConfVars.METASTORE_URIS);
326320
ugi = Utils.getUGI();
327321
this.hiveConf = hiveConf;
328322
this.threadId = threadId;
329323
}
330324

331-
public static HiveClientCacheKey fromHiveConf(HiveConf hiveConf, final int threadId) throws IOException, LoginException {
325+
public static HiveClientCacheKey fromHiveConf(HiveConf hiveConf, final int threadId) throws IOException {
332326
return new HiveClientCacheKey(hiveConf, threadId);
333327
}
334328

metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreUtils.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import java.util.List;
2525
import java.util.Properties;
2626

27-
import javax.security.auth.login.LoginException;
28-
2927
import org.apache.hadoop.hive.conf.HiveConf;
3028
import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
3129
import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
@@ -248,11 +246,7 @@ public static IMetaStoreClient getHiveMetastoreClient(HiveConf hiveConf)
248246
}
249247
}
250248
}
251-
try {
252-
return hiveClientCache.get(hiveConf);
253-
} catch (LoginException e) {
254-
throw new IOException("Couldn't create hiveMetaStoreClient, Error getting UGI for user", e);
255-
}
249+
return hiveClientCache.get(hiveConf);
256250
}
257251

258252
}

metastore/src/test/org/apache/hadoop/hive/metastore/TestHiveClientCache.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
3131
import org.junit.Test;
3232

33-
import javax.security.auth.login.LoginException;
3433
import java.io.IOException;
3534
import java.util.concurrent.Callable;
3635
import java.util.concurrent.ExecutionException;
@@ -42,7 +41,7 @@ public class TestHiveClientCache {
4241
final HiveConf hiveConf = new HiveConf();
4342

4443
@Test
45-
public void testCacheHit() throws IOException, MetaException, LoginException {
44+
public void testCacheHit() throws IOException, MetaException {
4645
HiveClientCache cache = new HiveClientCache(1000);
4746
HiveClientCache.ICacheableMetaStoreClient client =
4847
(HiveClientCache.ICacheableMetaStoreClient) cache.get(hiveConf);
@@ -60,7 +59,7 @@ public void testCacheHit() throws IOException, MetaException, LoginException {
6059
}
6160

6261
@Test
63-
public void testCacheMiss() throws IOException, MetaException, LoginException {
62+
public void testCacheMiss() throws IOException, MetaException {
6463
HiveClientCache cache = new HiveClientCache(1000);
6564
IMetaStoreClient client = cache.get(hiveConf);
6665
assertNotNull(client);
@@ -77,7 +76,7 @@ public void testCacheMiss() throws IOException, MetaException, LoginException {
7776
* Also verify that the expiry time configuration is honoured
7877
*/
7978
@Test
80-
public void testCacheExpiry() throws IOException, MetaException, LoginException, InterruptedException {
79+
public void testCacheExpiry() throws IOException, MetaException, InterruptedException {
8180
HiveClientCache cache = new HiveClientCache(1);
8281
HiveClientCache.ICacheableMetaStoreClient client =
8382
(HiveClientCache.ICacheableMetaStoreClient) cache.get(hiveConf);
@@ -105,7 +104,7 @@ public void testMultipleThreadAccess() throws ExecutionException, InterruptedExc
105104

106105
class GetHiveClient implements Callable<IMetaStoreClient> {
107106
@Override
108-
public IMetaStoreClient call() throws IOException, MetaException, LoginException {
107+
public IMetaStoreClient call() throws IOException, MetaException {
109108
return cache.get(hiveConf);
110109
}
111110
}
@@ -126,7 +125,7 @@ public IMetaStoreClient call() throws IOException, MetaException, LoginException
126125
}
127126

128127
@Test
129-
public void testCloseAllClients() throws IOException, MetaException, LoginException {
128+
public void testCloseAllClients() throws IOException, MetaException {
130129
final HiveClientCache cache = new HiveClientCache(1000);
131130
HiveClientCache.ICacheableMetaStoreClient client1 =
132131
(HiveClientCache.ICacheableMetaStoreClient) cache.get(hiveConf);

ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DagUtils.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import com.google.common.collect.Iterators;
2929
import com.google.common.collect.Lists;
3030

31-
import javax.security.auth.login.LoginException;
32-
3331
import java.io.File;
3432
import java.io.FileNotFoundException;
3533
import java.io.FileOutputStream;
@@ -1059,11 +1057,10 @@ public PreWarmVertex createPreWarmVertex(TezConfiguration conf,
10591057
/**
10601058
* @param conf
10611059
* @return path to destination directory on hdfs
1062-
* @throws LoginException if we are unable to figure user information
10631060
* @throws IOException when any dfs operation fails.
10641061
*/
10651062
@SuppressWarnings("deprecation")
1066-
public Path getDefaultDestDir(Configuration conf) throws LoginException, IOException {
1063+
public Path getDefaultDestDir(Configuration conf) throws IOException {
10671064
UserGroupInformation ugi = Utils.getUGI();
10681065
String userName = ugi.getShortUserName();
10691066
String userPathStr = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_USER_INSTALL_DIR);
@@ -1097,10 +1094,9 @@ public Path getDefaultDestDir(Configuration conf) throws LoginException, IOExcep
10971094
* @param conf
10981095
* @return List&lt;LocalResource&gt; local resources to add to execution
10991096
* @throws IOException when hdfs operation fails
1100-
* @throws LoginException when getDefaultDestDir fails with the same exception
11011097
*/
11021098
public List<LocalResource> localizeTempFilesFromConf(
1103-
String hdfsDirPathStr, Configuration conf) throws IOException, LoginException {
1099+
String hdfsDirPathStr, Configuration conf) throws IOException {
11041100
List<LocalResource> tmpResources = new ArrayList<LocalResource>();
11051101

11061102
if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_ADD_FILES_USE_HDFS_LOCATION)) {
@@ -1233,7 +1229,7 @@ private Map<String, LocalResource> addTempResources(Configuration conf, String h
12331229
return tmpResourcesMap;
12341230
}
12351231

1236-
public FileStatus getHiveJarDirectory(Configuration conf) throws IOException, LoginException {
1232+
public FileStatus getHiveJarDirectory(Configuration conf) throws IOException {
12371233
FileStatus fstatus = null;
12381234
String hdfsDirPathStr = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_JAR_DIRECTORY, (String)null);
12391235
if (hdfsDirPathStr != null) {
@@ -1612,14 +1608,8 @@ public Vertex createVertex(JobConf conf, BaseWork workUnit, Path scratchDir,
16121608
*/
16131609
public Path createTezDir(Path scratchDir, Configuration conf)
16141610
throws IOException {
1615-
UserGroupInformation ugi;
1616-
String userName = System.getProperty("user.name");
1617-
try {
1618-
ugi = Utils.getUGI();
1619-
userName = ugi.getShortUserName();
1620-
} catch (LoginException e) {
1621-
throw new IOException(e);
1622-
}
1611+
UserGroupInformation ugi = Utils.getUGI();
1612+
String userName = ugi.getShortUserName();
16231613

16241614
scratchDir = new Path(scratchDir, userName);
16251615

ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPoolSession.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
import java.util.concurrent.TimeUnit;
2626
import java.util.concurrent.atomic.AtomicInteger;
2727

28-
import javax.security.auth.login.LoginException;
29-
3028
import org.apache.hadoop.hive.conf.HiveConf;
3129
import org.apache.hadoop.hive.ql.session.SessionState.LogHelper;
3230
import org.apache.hadoop.hive.registry.impl.TezAmInstance;
@@ -120,7 +118,7 @@ void close(boolean keepTmpDir) throws Exception {
120118
@Override
121119
protected void openInternal(String[] additionalFiles,
122120
boolean isAsync, LogHelper console, HiveResources resources)
123-
throws IOException, LoginException, URISyntaxException, TezException {
121+
throws IOException, URISyntaxException, TezException {
124122
super.openInternal(additionalFiles, isAsync, console, resources);
125123
parent.registerOpenSession(this);
126124
if (expirationTracker != null) {

ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import java.util.concurrent.TimeUnit;
4040
import java.util.concurrent.TimeoutException;
4141
import java.util.concurrent.atomic.AtomicReference;
42-
import javax.security.auth.login.LoginException;
4342

4443
import org.apache.commons.codec.digest.DigestUtils;
4544
import org.apache.commons.io.FilenameUtils;
@@ -236,7 +235,7 @@ public static String makeSessionId() {
236235
return UUID.randomUUID().toString();
237236
}
238237

239-
public void open() throws IOException, LoginException, URISyntaxException, TezException {
238+
public void open() throws IOException, URISyntaxException, TezException {
240239
String[] noFiles = null;
241240
open(noFiles);
242241
}
@@ -246,24 +245,24 @@ public void open() throws IOException, LoginException, URISyntaxException, TezEx
246245
* submit multiple DAGs against a session (as long as they are executed serially).
247246
*/
248247
public void open(String[] additionalFilesNotFromConf)
249-
throws IOException, LoginException, URISyntaxException, TezException {
248+
throws IOException, URISyntaxException, TezException {
250249
openInternal(additionalFilesNotFromConf, false, null, null);
251250
}
252251

253252

254253
public void open(HiveResources resources)
255-
throws LoginException, IOException, URISyntaxException, TezException {
254+
throws IOException, URISyntaxException, TezException {
256255
openInternal(null, false, null, resources);
257256
}
258257

259258
public void beginOpen(String[] additionalFiles, LogHelper console)
260-
throws IOException, LoginException, URISyntaxException, TezException {
259+
throws IOException, URISyntaxException, TezException {
261260
openInternal(additionalFiles, true, console, null);
262261
}
263262

264263
protected void openInternal(String[] additionalFilesNotFromConf,
265264
boolean isAsync, LogHelper console, HiveResources resources)
266-
throws IOException, LoginException, URISyntaxException, TezException {
265+
throws IOException, URISyntaxException, TezException {
267266
// TODO Why is the queue name set again. It has already been setup via setQueueName. Do only one of the two.
268267
String confQueueName = conf.get(TezConfiguration.TEZ_QUEUE_NAME);
269268
if (queueName != null && !queueName.equals(confQueueName)) {
@@ -634,7 +633,7 @@ private void setupSessionAcls(Configuration tezConf, HiveConf hiveConf) throws
634633

635634
/** This is called in openInternal and in TezTask.updateSession to localize conf resources. */
636635
public void ensureLocalResources(Configuration conf, String[] newFilesNotFromConf)
637-
throws IOException, LoginException, URISyntaxException, TezException {
636+
throws IOException, URISyntaxException, TezException {
638637
if (resources == null) {
639638
throw new AssertionError("Ensure called on an unitialized (or closed) session " + sessionId);
640639
}
@@ -820,12 +819,11 @@ private Path createTezDir(String sessionId, String suffix) throws IOException {
820819
* @param localJarPath Local path to the jar to be localized.
821820
* @return LocalResource corresponding to the localized hive exec resource.
822821
* @throws IOException when any file system related call fails.
823-
* @throws LoginException when we are unable to determine the user.
824822
* @throws URISyntaxException when current jar location cannot be determined.
825823
*/
826824
@VisibleForTesting
827825
LocalResource createJarLocalResource(String localJarPath)
828-
throws IOException, LoginException, IllegalArgumentException {
826+
throws IOException, IllegalArgumentException {
829827
// TODO Reduce the number of lookups that happen here. This shouldn't go to HDFS for each call.
830828
// The hiveJarDir can be determined once per client.
831829
FileStatus destDirStatus = utils.getHiveJarDirectory(conf);
@@ -854,19 +852,7 @@ private String getKey(final FileStatus fileStatus) {
854852
return fileStatus.getPath() + ":" + fileStatus.getLen() + ":" + fileStatus.getModificationTime();
855853
}
856854

857-
private void addJarLRByClassName(String className, final Map<String, LocalResource> lrMap) throws
858-
IOException, LoginException {
859-
Class<?> clazz;
860-
try {
861-
clazz = Class.forName(className);
862-
} catch (ClassNotFoundException e) {
863-
throw new IOException("Cannot find " + className + " in classpath", e);
864-
}
865-
addJarLRByClass(clazz, lrMap);
866-
}
867-
868-
private void addJarLRByClass(Class<?> clazz, final Map<String, LocalResource> lrMap) throws IOException,
869-
LoginException {
855+
private void addJarLRByClass(Class<?> clazz, final Map<String, LocalResource> lrMap) throws IOException {
870856
String jarPath = Utilities.jarFinderGetJar(clazz);
871857
if (jarPath == null) {
872858
throw new IOException("Can't find jar for: " + clazz);

0 commit comments

Comments
 (0)