From 971b749d5cb2b3a3946cac885d414a76962006a1 Mon Sep 17 00:00:00 2001 From: paduin Date: Thu, 3 Oct 2024 17:20:01 +0200 Subject: [PATCH 1/2] replaced isAvailable call --- CHANGELOG.md | 7 ++++++- .../impl/PrefixBasedDatabaseMappingService.java | 5 ----- .../server/TSetIpAddressProcessorFactory.java | 10 +++++++++- .../server/TSetIpAddressProcessorFactoryTest.java | 15 ++++++++++++++- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be7a07bb..48a244b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ +## [3.13.4] - 2024-10-03 +### Fix +- Removed call to primary and made it only when Kerberos (SASL) is enabled. +- Fixed Handler creation for SASL. + ## [3.13.3] - 2024-10-02 ### Added -- Metric for monitoring open transports. `.open_transports_gauge` +- Metric for monitoring open transports. `.com_hotels_bdp_waggledance_open_transports_gauge` ### Changed - Removed RetryingHMSHandler. Retries are done in the client there should be no need to wrap everything in retry logic again. diff --git a/waggle-dance-core/src/main/java/com/hotels/bdp/waggledance/mapping/service/impl/PrefixBasedDatabaseMappingService.java b/waggle-dance-core/src/main/java/com/hotels/bdp/waggledance/mapping/service/impl/PrefixBasedDatabaseMappingService.java index 4f7c4f29..a2e793ec 100644 --- a/waggle-dance-core/src/main/java/com/hotels/bdp/waggledance/mapping/service/impl/PrefixBasedDatabaseMappingService.java +++ b/waggle-dance-core/src/main/java/com/hotels/bdp/waggledance/mapping/service/impl/PrefixBasedDatabaseMappingService.java @@ -97,11 +97,6 @@ private void add(AbstractMetaStore metaStore) { if (metaStore.getFederationType() == PRIMARY) { primaryDatabaseMapping = databaseMapping; - if (!metaStoreMapping.isAvailable()) { - throw new WaggleDanceException( - String.format("Primary metastore is unavailable %s", metaStore.getRemoteMetaStoreUris()) - ); - } } mappingsByPrefix.put(metaStoreMapping.getDatabasePrefix(), databaseMapping); diff --git a/waggle-dance-core/src/main/java/com/hotels/bdp/waggledance/server/TSetIpAddressProcessorFactory.java b/waggle-dance-core/src/main/java/com/hotels/bdp/waggledance/server/TSetIpAddressProcessorFactory.java index a11260cb..6aec20c8 100644 --- a/waggle-dance-core/src/main/java/com/hotels/bdp/waggledance/server/TSetIpAddressProcessorFactory.java +++ b/waggle-dance-core/src/main/java/com/hotels/bdp/waggledance/server/TSetIpAddressProcessorFactory.java @@ -20,6 +20,7 @@ import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.metastore.IHMSHandler; import org.apache.hadoop.hive.metastore.TSetIpAddressProcessor; +import org.apache.thrift.TException; import org.apache.thrift.TProcessor; import org.apache.thrift.TProcessorFactory; import org.apache.thrift.transport.TSocket; @@ -59,7 +60,14 @@ public TProcessor getProcessor(TTransport transport) { boolean useSASL = hiveConf.getBoolVar(HiveConf.ConfVars.METASTORE_USE_THRIFT_SASL); if (useSASL) { - IHMSHandler handler = TokenWrappingHMSHandler.newProxyInstance(baseHandler, useSASL); + try { + baseHandler.getStatus(); + } catch (TException e) { + throw new RuntimeException("Error creating TProcessor. Could not get status.", e); + } + IHMSHandler tokenHandler = TokenWrappingHMSHandler.newProxyInstance(baseHandler, useSASL); + IHMSHandler handler = ExceptionWrappingHMSHandler.newProxyInstance(tokenHandler); + transportMonitor.monitor(transport, baseHandler); return new TSetIpAddressProcessor<>(handler); } else { IHMSHandler handler = ExceptionWrappingHMSHandler.newProxyInstance(baseHandler); diff --git a/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/server/TSetIpAddressProcessorFactoryTest.java b/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/server/TSetIpAddressProcessorFactoryTest.java index 3b0df83b..04e28d13 100644 --- a/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/server/TSetIpAddressProcessorFactoryTest.java +++ b/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/server/TSetIpAddressProcessorFactoryTest.java @@ -42,12 +42,13 @@ public class TSetIpAddressProcessorFactoryTest { private @Mock TTransportMonitor transportMonitor; private @Mock TTransport transport; - private final HiveConf hiveConf = new HiveConf(); + private HiveConf hiveConf; private TSetIpAddressProcessorFactory factory; @Before public void init() { when(federatedHMSHandlerFactory.create()).thenReturn(federatedHMSHandler); + hiveConf = new HiveConf(); factory = new TSetIpAddressProcessorFactory(hiveConf, federatedHMSHandlerFactory, transportMonitor); } @@ -67,4 +68,16 @@ public void connectionIsMonitored() throws Exception { assertThat(transportCaptor.getValue(), is(transport)); assertThat(handlerCaptor.getValue(), is(instanceOf(FederatedHMSHandler.class))); } + + @Test + public void connectionIsMonitoredSasl() throws Exception { + hiveConf.setBoolVar(HiveConf.ConfVars.METASTORE_USE_THRIFT_SASL, Boolean.TRUE); + factory.getProcessor(transport); + + ArgumentCaptor transportCaptor = ArgumentCaptor.forClass(TTransport.class); + ArgumentCaptor handlerCaptor = ArgumentCaptor.forClass(Closeable.class); + verify(transportMonitor).monitor(transportCaptor.capture(), handlerCaptor.capture()); + assertThat(transportCaptor.getValue(), is(transport)); + assertThat(handlerCaptor.getValue(), is(instanceOf(FederatedHMSHandler.class))); + } } From 3cd069d1df23d5bf7d3af02ee6b6baad7501fb85 Mon Sep 17 00:00:00 2001 From: Jay Green-Stevens Date: Fri, 4 Oct 2024 10:58:02 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48a244b4..4407605f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [3.13.4] - 2024-10-03 +## [3.13.4] - 2024-10-04 ### Fix - Removed call to primary and made it only when Kerberos (SASL) is enabled. - Fixed Handler creation for SASL.