Skip to content

Commit 0882ebf

Browse files
committed
review - 1
1 parent 57e720c commit 0882ebf

6 files changed

Lines changed: 29 additions & 22 deletions

File tree

itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.hadoop.hive.conf.HiveConf;
2626
import org.apache.hadoop.hive.conf.HiveConfForTest;
2727
import org.apache.hadoop.hive.metastore.api.MetaException;
28+
import org.apache.hadoop.hive.metastore.handler.BaseHandler;
2829
import org.apache.hadoop.hive.ql.DriverFactory;
2930
import org.apache.hadoop.hive.ql.IDriver;
3031
import org.apache.hadoop.hive.ql.metadata.Hive;
@@ -55,8 +56,7 @@ public class TestMetastoreVersion {
5556

5657
@Before
5758
public void setUp() throws Exception {
58-
59-
Field defDb = HMSHandler.class.getDeclaredField("currentUrl");
59+
Field defDb = BaseHandler.class.getDeclaredField("currentUrl");
6060
defDb.setAccessible(true);
6161
defDb.set(null, null);
6262
// reset defaults

standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,24 @@ public HMSHandler(String name, Configuration conf) {
135135
isInTest = MetastoreConf.getBoolVar(this.conf, HIVE_IN_TEST);
136136
}
137137

138+
@Override
139+
public void init() throws MetaException {
140+
super.init();
141+
DataConnectorProviderFactory.getInstance(this);
142+
}
143+
144+
/**
145+
* Get a cached RawStore.
146+
*
147+
* @return the cached RawStore
148+
* @throws MetaException
149+
*/
150+
@Override
151+
public RawStore getMS() throws MetaException {
152+
Configuration conf = getConf();
153+
return getMSForConf(conf);
154+
}
155+
138156
public static RawStore getMSForConf(Configuration conf) throws MetaException {
139157
RawStore ms = getRawStore();
140158
if (ms == null) {

standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public RetryingHMSHandler(Configuration conf, IHMSHandler baseHandler, boolean l
5555
try {
5656
//invoking init method of baseHandler this way since it adds the retry logic
5757
//in case of transient failures in init method
58-
invoke(baseHandler, baseHandler.getClass().getMethod("init", (Class<?>[]) null),
58+
invoke(baseHandler, baseHandler.getClass().getDeclaredMethod("init", (Class<?>[]) null),
5959
null);
6060
} catch (Throwable e) {
6161
LOG.error("HMSHandler Fatal error: " + ExceptionUtils.getStackTrace(e));

standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/BaseHandler.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import org.apache.hadoop.hive.metastore.AlterHandler;
4848
import org.apache.hadoop.hive.metastore.DefaultMetaStoreFilterHookImpl;
4949
import org.apache.hadoop.hive.metastore.FileMetadataManager;
50-
import org.apache.hadoop.hive.metastore.HMSHandler;
5150
import org.apache.hadoop.hive.metastore.HMSHandlerContext;
5251
import org.apache.hadoop.hive.metastore.HMSMetricsListener;
5352
import org.apache.hadoop.hive.metastore.HiveMetaStore;
@@ -235,7 +234,7 @@ public void init(Warehouse wh) throws MetaException {
235234
}
236235
if (conf.getBoolean(MetastoreConf.ConfVars.METASTORE_CACHE_CAN_USE_EVENT.getVarname(), false) &&
237236
!canCachedStoreCanUseEvent) {
238-
throw new MetaException("CahcedStore can not use events for invalidation as there is no " +
237+
throw new MetaException("CachedStore can not use events for invalidation as there is no " +
239238
" TransactionalMetaStoreEventListener to add events to notification table");
240239
}
241240

@@ -362,18 +361,6 @@ public AbstractMap<String, Long> getCounters() {
362361
return counters;
363362
}
364363

365-
/**
366-
* Get a cached RawStore.
367-
*
368-
* @return the cached RawStore
369-
* @throws MetaException
370-
*/
371-
@Override
372-
public RawStore getMS() throws MetaException {
373-
Configuration conf = getConf();
374-
return HMSHandler.getMSForConf(conf);
375-
}
376-
377364
@Override
378365
public TxnStore getTxnHandler() {
379366
return HMSHandlerContext.getTxnStore(conf);
@@ -390,7 +377,7 @@ protected static void logAndAudit(final String m) {
390377
}
391378

392379
// This will return null if the metastore is not being accessed from a metastore Thrift server,
393-
// or if the TTransport being used to connect is not an instance of TSocket, or if kereberos
380+
// or if the TTransport being used to connect is not an instance of TSocket, or if kerberos
394381
// is used
395382
public static String getThreadLocalIpAddress() {
396383
return HMSHandlerContext.getIpAddress().orElse(null);
@@ -952,7 +939,7 @@ public void setMetaConf(String key, String value) throws MetaException {
952939
new ConfigChangeEvent(this, key, oldValue, value));
953940
}
954941
if (MetastoreConf.ConfVars.TRY_DIRECT_SQL == confVar) {
955-
HMSHandler.LOG.info("Direct SQL optimization = {}", value);
942+
LOG.info("Direct SQL optimization = {}", value);
956943
}
957944
}
958945

standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/TransactionHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ public ReplayedTxnsForPolicyResult get_replayed_txns_for_policy(String policyNam
521521
ret = getTxnHandler().getReplayedTxnsForPolicy(policyName);
522522
} catch (Exception e) {
523523
ex = e;
524-
throw new MetaException("Failed to get replayed txns details for policy " + e.getMessage());
524+
throw new MetaException(
525+
"Failed to get replayed txns details for policy '" + policyName + "': " + e.getMessage());
525526
} finally {
526527
endFunction("get_replayed_txns_for_policy", ret != null, ex);
527528
}

standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreServerUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.hadoop.hive.metastore.utils;
1919

2020
import com.google.common.annotations.VisibleForTesting;
21-
import com.google.common.base.Preconditions;
2221
import com.google.common.base.Predicates;
2322
import com.google.common.collect.ImmutableListMultimap;
2423
import com.google.common.collect.Lists;
@@ -1827,7 +1826,9 @@ public static boolean canUpdateStats(Configuration conf, Table tbl) {
18271826

18281827
public static List<String> getPartValsFromName(Table t, String partName)
18291828
throws MetaException, InvalidObjectException {
1830-
Preconditions.checkArgument(t != null, "Table can not be null");
1829+
if (t == null) {
1830+
throw new MetaException("Table cannot be null");
1831+
}
18311832
// Unescape the partition name
18321833
LinkedHashMap<String, String> hm = Warehouse.makeSpecFromName(partName);
18331834

0 commit comments

Comments
 (0)