-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added extra option to add readOnly thrift HMS uri #308
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cfcb1bc
Added extra option to add readOnly thrift HMS uri which will be calle…
patduin 1d02536
fix return
patduin 92dae35
Added test and readme update
patduin aff018c
prepping release
patduin dd48d00
typos
patduin 6dd8bbf
Added logging
patduin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
@@ -44,16 +44,19 @@ public class CloseableThriftHiveMetastoreIfaceClientFactory { | |
private final int defaultConnectionTimeout = (int) TimeUnit.SECONDS.toMillis(2L); | ||
private final WaggleDanceConfiguration waggleDanceConfiguration; | ||
private final GlueClientFactory glueClientFactory; | ||
private final SplitTrafficMetastoreClientFactory splitTrafficMetaStoreClientFactory; | ||
|
||
public CloseableThriftHiveMetastoreIfaceClientFactory( | ||
TunnelingMetaStoreClientFactory tunnelingMetaStoreClientFactory, | ||
DefaultMetaStoreClientFactory defaultMetaStoreClientFactory, | ||
GlueClientFactory glueClientFactory, | ||
WaggleDanceConfiguration waggleDanceConfiguration) { | ||
WaggleDanceConfiguration waggleDanceConfiguration, | ||
SplitTrafficMetastoreClientFactory splitTrafficMetaStoreClientFactory) { | ||
this.tunnelingMetaStoreClientFactory = tunnelingMetaStoreClientFactory; | ||
this.defaultMetaStoreClientFactory = defaultMetaStoreClientFactory; | ||
this.glueClientFactory = glueClientFactory; | ||
this.waggleDanceConfiguration = waggleDanceConfiguration; | ||
this.splitTrafficMetaStoreClientFactory = splitTrafficMetaStoreClientFactory; | ||
} | ||
|
||
public CloseableThriftHiveMetastoreIface newInstance(AbstractMetaStore metaStore) { | ||
|
@@ -64,14 +67,24 @@ public CloseableThriftHiveMetastoreIface newInstance(AbstractMetaStore metaStore | |
if (metaStore.getGlueConfig() != null) { | ||
return newGlueInstance(metaStore, properties); | ||
} | ||
return newHiveInstance(metaStore, properties); | ||
String name = metaStore.getName().toLowerCase(Locale.ROOT); | ||
if (metaStore.getReadOnlyRemoteMetaStoreUris() != null) { | ||
CloseableThriftHiveMetastoreIface readWrite = newHiveInstance(metaStore, name, metaStore.getRemoteMetaStoreUris(), | ||
properties); | ||
CloseableThriftHiveMetastoreIface readOnly = newHiveInstance(metaStore, name+"_ro", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space missing before and after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. formatted |
||
metaStore.getReadOnlyRemoteMetaStoreUris(), properties); | ||
return splitTrafficMetaStoreClientFactory.newInstance(readWrite, readOnly); | ||
|
||
} | ||
return newHiveInstance(metaStore, name, metaStore.getRemoteMetaStoreUris(), properties); | ||
} | ||
|
||
private CloseableThriftHiveMetastoreIface newHiveInstance( | ||
AbstractMetaStore metaStore, | ||
String name, | ||
String metaStoreUris, | ||
Map<String, String> properties) { | ||
String uris = MetaStoreUriNormaliser.normaliseMetaStoreUris(metaStore.getRemoteMetaStoreUris()); | ||
String name = metaStore.getName().toLowerCase(Locale.ROOT); | ||
String uris = MetaStoreUriNormaliser.normaliseMetaStoreUris(metaStoreUris); | ||
// Connection timeout should not be less than 1 | ||
// A timeout of zero is interpreted as an infinite timeout, so this is avoided | ||
int connectionTimeout = Math.max(1, defaultConnectionTimeout + (int) metaStore.getLatency()); | ||
|
87 changes: 87 additions & 0 deletions
87
...e/src/main/java/com/hotels/bdp/waggledance/client/SplitTrafficMetastoreClientFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* 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 java.lang.reflect.InvocationHandler; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.lang.reflect.Proxy; | ||
|
||
/** | ||
* This class splits the traffic for read only calls (get* for instance getTable, getPartition) to the readOnly client | ||
* and everything else will go to readWrite client. | ||
*/ | ||
public class SplitTrafficMetastoreClientFactory { | ||
patduin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
static final Class<?>[] INTERFACES = new Class<?>[] { CloseableThriftHiveMetastoreIface.class }; | ||
|
||
private static class SplitTrafficClientInvocationHandler implements InvocationHandler { | ||
|
||
private final CloseableThriftHiveMetastoreIface readWrite; | ||
private final CloseableThriftHiveMetastoreIface readOnly; | ||
|
||
public SplitTrafficClientInvocationHandler( | ||
CloseableThriftHiveMetastoreIface readWrite, | ||
CloseableThriftHiveMetastoreIface readOnly) { | ||
this.readWrite = readWrite; | ||
this.readOnly = readOnly; | ||
} | ||
|
||
@Override | ||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { | ||
switch (method.getName()) { | ||
case "isOpen": | ||
jmnunezizu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return readWrite.isOpen() && readOnly.isOpen(); | ||
case "close": | ||
try { | ||
readWrite.close(); | ||
} finally { | ||
readOnly.close(); | ||
} | ||
return null; | ||
case "set_ugi": | ||
Object result = doRealCall(readWrite, method, args); | ||
// we skip the result for readOnly (it should always be the same). | ||
doRealCall(readOnly, method, args); | ||
return result; | ||
default: | ||
if (method.getName().startsWith("get")) { | ||
return doRealCall(readOnly, method, args); | ||
jmnunezizu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return doRealCall(readWrite, method, args); | ||
} | ||
} | ||
|
||
private Object doRealCall(CloseableThriftHiveMetastoreIface client, Method method, Object[] args) | ||
throws IllegalAccessException, Throwable { | ||
try { | ||
return method.invoke(client, args); | ||
} catch (InvocationTargetException e) { | ||
Throwable realException = e.getTargetException(); | ||
throw realException; | ||
} | ||
} | ||
} | ||
|
||
public CloseableThriftHiveMetastoreIface newInstance( | ||
CloseableThriftHiveMetastoreIface readWrite, | ||
CloseableThriftHiveMetastoreIface readOnly) { | ||
return (CloseableThriftHiveMetastoreIface) Proxy | ||
.newProxyInstance(getClass().getClassLoader(), INTERFACES, | ||
new SplitTrafficClientInvocationHandler(readWrite, readOnly)); | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...e-core/src/main/java/com/hotels/bdp/waggledance/client/adapter/MetastoreIfaceAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/bdp/waggledance/client/compatibility/HiveCompatibleThriftHiveMetastoreIfaceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
waggle-dance-core/src/main/java/com/hotels/bdp/waggledance/server/FederatedHMSHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
differentiated
ordiverted
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vote for
diverted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diverted 🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You gave us a mashup of both! Haha.