diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index 1ff749e..e04bbfc 100644 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -533,30 +533,40 @@ private void open() throws MetaException { for (int attempt = 0; !isConnected && attempt < retries; ++attempt) { for (URI store : metastoreUris) { - LOG.info("Trying to connect to metastore with URI " + store); + LOG.info("Trying to connect to metastore with URI {}", store); try { if (useSSL) { try { - String trustStorePath = MetastoreConf.getVar(conf, ConfVars.SSL_TRUSTSTORE_PATH).trim(); + String trustStorePath = MetastoreConf + .getVar(conf, ConfVars.SSL_TRUSTSTORE_PATH).trim(); + if (trustStorePath.isEmpty()) { - throw new IllegalArgumentException(ConfVars.SSL_TRUSTSTORE_PATH.toString() + throw new IllegalArgumentException(ConfVars.SSL_TRUSTSTORE_PATH + " Not configured for SSL connection"); } - String trustStorePassword = - MetastoreConf.getPassword(conf, MetastoreConf.ConfVars.SSL_TRUSTSTORE_PASSWORD); + + String trustStorePassword = MetastoreConf.getPassword(conf, + MetastoreConf.ConfVars.SSL_TRUSTSTORE_PASSWORD); // Create an SSL socket and connect - transport = SecurityUtils.getSSLSocket(store.getHost(), store.getPort(), clientSocketTimeout, - trustStorePath, trustStorePassword ); - LOG.info("Opened an SSL connection to metastore, current connections: " + connCount.incrementAndGet()); + transport = + SecurityUtils.getSSLSocket(store.getHost(), store.getPort(), + clientSocketTimeout, trustStorePath, trustStorePassword); + + LOG.info( + "Opened an SSL connection to metastore, current connections: {}", + connCount.incrementAndGet()); + if (LOG.isTraceEnabled()) { - LOG.trace("", new LogUtils.StackTraceLogger("METASTORE SSL CONNECTION TRACE - open - " + - System.identityHashCode(this))); + LOG.trace("", + new LogUtils.StackTraceLogger( + "METASTORE SSL CONNECTION TRACE - open - " + + System.identityHashCode(this))); } - } catch(IOException e) { + } catch (IOException e) { throw new IllegalArgumentException(e); - } catch(TTransportException e) { + } catch (TTransportException e) { tte = e; throw new MetaException(e.toString()); } @@ -579,7 +589,7 @@ private void open() throws MetaException { // tokenSig could be null tokenStrForm = SecurityUtils.getTokenStrForm(tokenSig); - if(tokenStrForm != null) { + if (tokenStrForm != null) { LOG.info("HMSC::open(): Found delegation token. Creating DIGEST-based thrift connection."); // authenticate using delegation tokens via the "DIGEST" mechanism transport = authBridge.createClientTransport(null, store.getHost(), @@ -594,7 +604,6 @@ private void open() throws MetaException { transport, MetaStoreUtils.getMetaStoreSaslProperties(conf, useSSL)); } } catch (IOException ioe) { - LOG.error("Couldn't create client transport", ioe); throw new MetaException(ioe.toString()); } } else { @@ -613,21 +622,21 @@ private void open() throws MetaException { try { if (!transport.isOpen()) { transport.open(); - LOG.info("Opened a connection to metastore, current connections: " + connCount.incrementAndGet()); + LOG.info( + "Opened a connection to metastore, current connections: {}", + connCount.incrementAndGet()); if (LOG.isTraceEnabled()) { - LOG.trace("", new LogUtils.StackTraceLogger("METASTORE CONNECTION TRACE - open - " + - System.identityHashCode(this))); + LOG.trace("", + new LogUtils.StackTraceLogger( + "METASTORE CONNECTION TRACE - open - " + + System.identityHashCode(this))); } } isConnected = true; } catch (TTransportException e) { tte = e; - if (LOG.isDebugEnabled()) { - LOG.warn("Failed to connect to the MetaStore Server...", e); - } else { - // Don't print full exception trace if DEBUG is not on. - LOG.warn("Failed to connect to the MetaStore Server..."); - } + LOG.warn("Failed to connect to the MetaStore Server"); + LOG.debug("Failed to connect to the MetaStore Server", e); } if (isConnected && !useSasl && MetastoreConf.getBoolVar(conf, ConfVars.EXECUTE_SET_UGI)){ @@ -647,8 +656,8 @@ private void open() throws MetaException { } } } catch (MetaException e) { - LOG.error("Unable to connect to metastore with URI " + store - + " in attempt " + attempt, e); + LOG.error("Unable to connect to metastore with URI {} in attempt {}", + store, attempt, e); } if (isConnected) { break; @@ -657,7 +666,8 @@ private void open() throws MetaException { // Wait before launching the next round of connection retries. if (!isConnected && retryDelaySeconds > 0) { try { - LOG.info("Waiting " + retryDelaySeconds + " seconds before next connection attempt."); + LOG.info("Waiting {} seconds before next connection attempt.", + retryDelaySeconds); Thread.sleep(retryDelaySeconds * 1000); } catch (InterruptedException ignore) {} }