Skip to content

Commit

Permalink
Added extensions and Rate limiting options (#314)
Browse files Browse the repository at this point in the history
* Added extensions and Rate limiting options
  • Loading branch information
Patrick Duin authored Apr 19, 2024
1 parent 252d642 commit 2524256
Show file tree
Hide file tree
Showing 59 changed files with 1,455 additions and 142 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
test:
name: Package and run all tests
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
release:
name: Release to Maven Central
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Checkout source code
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@

## [3.12.0] - 2023-02-08
## [3.13.0] - 2024-04-19
### Added
- Added `waggle-dance-extensions` module. See [extensions README](waggle-dance-extensions/README.md.)
- Added support to enable Rate Limiting in Waggle Dance.
### Changed
- Changed and added some log messages for better tracking of calls.
- Changed Integration Test WaggleDanceRunner to allow for reuse.

## [3.12.0] - 2024-02-08
### Added
- Added optional `primary-meta-store.read-only-remote-meta-store-uris` config to allow traffic to be diverted based on calls made. See README.md.

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ The table below describes all the available configuration values for Waggle Danc
| `configuration-properties` | No | Map of Hive properties that will be added to the HiveConf used when creating the Thrift clients (they will be shared among all the clients). |
| `queryFunctionsAcrossAllMetastores` | No | Controls if the Thrift `getAllFunctions` should be fired to all configured metastores or only the primary metastore. The advice is to set this to false. Executing `getAllFunctions` can have an unwanted performance impact when a metastore is slow to respond. The function call is typically only called when a client is initialized and is largely irrelevant. Default is `true` (to be backward compatible) |

Extensions (for instance Rate Limiting) are described here: [waggle-dance-extensions/README.md](waggle-dance-extensions/README.md)

### Federation

Federation config is by default located in: `$WAGGLE_DANCE_HOME/conf/waggle-dance-federation.yml`.
Expand Down Expand Up @@ -611,4 +613,4 @@ The Waggle Dance logo uses the [Beetype Filled font](http://www.1001fonts.com/be
## Legal
This project is available under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html).

Copyright 2016-2019 Expedia, Inc.
Copyright 2016-2024 Expedia, Inc.
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<groupId>com.hotels</groupId>
<artifactId>waggle-dance-parent</artifactId>
<version>3.12.1-SNAPSHOT</version>
<version>3.13.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Waggle Dance Parent</name>
<description>Hive Metastore federation service.</description>
Expand All @@ -24,6 +24,7 @@
</scm>

<modules>
<module>waggle-dance-extensions</module>
<module>waggle-dance-core</module>
<module>waggle-dance-api</module>
<module>waggle-dance-rest</module>
Expand Down Expand Up @@ -275,6 +276,11 @@
<artifactId>jackson-dataformat-cbor</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion waggle-dance-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.hotels</groupId>
<artifactId>waggle-dance-parent</artifactId>
<version>3.12.1-SNAPSHOT</version>
<version>3.13.0-SNAPSHOT</version>
</parent>

<artifactId>waggle-dance-api</artifactId>
Expand Down
7 changes: 6 additions & 1 deletion waggle-dance-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.hotels</groupId>
<artifactId>waggle-dance-parent</artifactId>
<version>3.12.1-SNAPSHOT</version>
<version>3.13.0-SNAPSHOT</version>
</parent>

<artifactId>waggle-dance-boot</artifactId>
Expand All @@ -25,6 +25,11 @@
<artifactId>waggle-dance-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.hotels</groupId>
<artifactId>waggle-dance-extensions</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
18 changes: 17 additions & 1 deletion waggle-dance-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.hotels</groupId>
<artifactId>waggle-dance-parent</artifactId>
<version>3.12.1-SNAPSHOT</version>
<version>3.13.0-SNAPSHOT</version>
</parent>

<artifactId>waggle-dance-core</artifactId>
Expand Down Expand Up @@ -158,6 +158,8 @@
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>${hive.version}</version>
<classifier>core</classifier>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
Expand All @@ -167,6 +169,10 @@
<groupId>org.pentaho</groupId>
<artifactId>pentaho-aggdesigner-algorithm</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down Expand Up @@ -194,6 +200,10 @@
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down Expand Up @@ -346,6 +356,12 @@
<groupId>com.hotels</groupId>
<artifactId>beeju</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>fm.last.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2016-2023 Expedia, Inc.
* Copyright (C) 2016-2024 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2016-2019 Expedia, Inc.
* Copyright (C) 2016-2024 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import com.hotels.hcommon.hive.metastore.conf.HiveConfFactory;
import com.hotels.hcommon.hive.metastore.util.MetaStoreUriNormaliser;

public class CloseableThriftHiveMetastoreIfaceClientFactory {
public class CloseableThriftHiveMetastoreIfaceClientFactory implements ThriftClientFactory {

private static final int DEFAULT_CLIENT_FACTORY_RECONNECTION_RETRY = 3;
private final TunnelingMetaStoreClientFactory tunnelingMetaStoreClientFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2016-2023 Expedia, Inc.
* Copyright (C) 2016-2024 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,11 @@
package com.hotels.bdp.waggledance.client;

import java.io.IOException;
import java.lang.reflect.*;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.List;

import org.apache.hadoop.hive.conf.HiveConf;
Expand Down Expand Up @@ -158,7 +162,6 @@ private SaslMetastoreClientHander(
this.clientManager = clientManager;
}

@SuppressWarnings("unchecked")
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (C) 2016-2024 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hotels.bdp.waggledance.client;

import com.hotels.bdp.waggledance.api.model.AbstractMetaStore;

public interface ThriftClientFactory {

/**
* @param metaStore (configuration object)
* @return client that will be used to query the metaStore.
*/
public CloseableThriftHiveMetastoreIface newInstance(AbstractMetaStore metaStore);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2016-2023 Expedia, Inc.
* Copyright (C) 2016-2024 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -121,7 +121,7 @@ void open(HiveUgiArgs ugiArgs) {

for (int attempt = 0; !isConnected && (attempt < retries); ++attempt) {
for (URI store : metastoreUris) {
LOG.info("Trying to connect to metastore with URI " + store);
LOG.debug("Trying to connect to metastore with URI " + store);
try {
transport = new TSocket(store.getHost(), store.getPort(), clientSocketTimeout, connectionTimeout);
if (useSasl) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2016-2019 Expedia, Inc.
* Copyright (C) 2016-2024 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2016-2021 Expedia, Inc.
* Copyright (C) 2016-2024 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2016-2023 Expedia, Inc.
* Copyright (C) 2016-2024 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -145,5 +145,4 @@ public boolean isQueryFunctionsAcrossAllMetastores() {
public void setQueryFunctionsAcrossAllMetastores(boolean queryFunctionsAcrossAllMetastores) {
this.queryFunctionsAcrossAllMetastores = queryFunctionsAcrossAllMetastores;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.conf.HiveConf;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

import com.hotels.bdp.waggledance.client.CloseableThriftHiveMetastoreIfaceClientFactory;
import com.hotels.bdp.waggledance.client.DefaultMetaStoreClientFactory;
import com.hotels.bdp.waggledance.client.GlueClientFactory;
import com.hotels.bdp.waggledance.client.SplitTrafficMetastoreClientFactory;
import com.hotels.bdp.waggledance.client.ThriftClientFactory;
import com.hotels.bdp.waggledance.client.tunnelling.TunnelingMetaStoreClientFactory;
import com.hotels.bdp.waggledance.conf.WaggleDanceConfiguration;
import com.hotels.bdp.waggledance.mapping.model.ASTQueryMapping;
Expand Down Expand Up @@ -59,13 +61,21 @@ public SplitTrafficMetastoreClientFactory splitTrafficMetaStoreClientFactory() {
return new SplitTrafficMetastoreClientFactory();
}


@Bean
public CloseableThriftHiveMetastoreIfaceClientFactory metaStoreClientFactory(
public ThriftClientFactory defaultWaggleDanceClientFactory(
WaggleDanceConfiguration waggleDanceConfiguration, SplitTrafficMetastoreClientFactory splitTrafficMetaStoreClientFactory) {
return new CloseableThriftHiveMetastoreIfaceClientFactory(new TunnelingMetaStoreClientFactory(),
new DefaultMetaStoreClientFactory(), new GlueClientFactory(), waggleDanceConfiguration, splitTrafficMetaStoreClientFactory);
}

//Only load when no other beans with this name can be found.
@ConditionalOnMissingBean
@Bean
public ThriftClientFactory thriftClientFactory(ThriftClientFactory defaultWaggleDanceClientFactory) {
return defaultWaggleDanceClientFactory;
}

@Bean
public QueryMapping queryMapping() {
return ASTQueryMapping.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2016-2022 Expedia, Inc.
* Copyright (C) 2016-2024 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,7 +33,7 @@
import com.hotels.bdp.waggledance.api.model.AbstractMetaStore;
import com.hotels.bdp.waggledance.api.model.DatabaseResolution;
import com.hotels.bdp.waggledance.client.CloseableThriftHiveMetastoreIface;
import com.hotels.bdp.waggledance.client.CloseableThriftHiveMetastoreIfaceClientFactory;
import com.hotels.bdp.waggledance.client.ThriftClientFactory;
import com.hotels.bdp.waggledance.conf.WaggleDanceConfiguration;
import com.hotels.bdp.waggledance.mapping.service.MetaStoreMappingFactory;
import com.hotels.bdp.waggledance.mapping.service.PrefixNamingStrategy;
Expand All @@ -46,24 +46,24 @@ public class MetaStoreMappingFactoryImpl implements MetaStoreMappingFactory {

private final WaggleDanceConfiguration waggleDanceConfiguration;
private final PrefixNamingStrategy prefixNamingStrategy;
private final CloseableThriftHiveMetastoreIfaceClientFactory metaStoreClientFactory;
private final ThriftClientFactory thriftClientFactory;
private final AccessControlHandlerFactory accessControlHandlerFactory;

@Autowired
public MetaStoreMappingFactoryImpl(
WaggleDanceConfiguration waggleDanceConfiguration,
PrefixNamingStrategy prefixNamingStrategy,
CloseableThriftHiveMetastoreIfaceClientFactory metaStoreClientFactory,
ThriftClientFactory thriftClientFactory,
AccessControlHandlerFactory accessControlHandlerFactory) {
this.waggleDanceConfiguration = waggleDanceConfiguration;
this.prefixNamingStrategy = prefixNamingStrategy;
this.metaStoreClientFactory = metaStoreClientFactory;
this.thriftClientFactory = thriftClientFactory;
this.accessControlHandlerFactory = accessControlHandlerFactory;
}

private CloseableThriftHiveMetastoreIface createClient(AbstractMetaStore metaStore) {
try {
return metaStoreClientFactory.newInstance(metaStore);
return thriftClientFactory.newInstance(metaStore);
} catch (Exception e) {
LOG.error("Can't create a client for metastore '{}':", metaStore.getName(), e);
return newUnreachableMetastoreClient(metaStore);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2016-2023 Expedia, Inc.
* Copyright (C) 2016-2024 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -99,7 +99,7 @@ private void add(AbstractMetaStore metaStore) {
primaryDatabaseMapping = databaseMapping;
if (!metaStoreMapping.isAvailable()) {
throw new WaggleDanceException(
String.format("Primary metastore is unavailable {}", metaStore.getRemoteMetaStoreUris())
String.format("Primary metastore is unavailable %s", metaStore.getRemoteMetaStoreUris())
);
}
}
Expand Down
Loading

0 comments on commit 2524256

Please sign in to comment.