-
Notifications
You must be signed in to change notification settings - Fork 280
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
Adding internal hive connector #68
Conversation
@@ -95,7 +99,11 @@ private void init() { | |||
private IMetacatHiveClient createLocalClient() throws MetaException { | |||
final HiveConf conf = getDefaultConf(); | |||
configuration.forEach(conf::set); | |||
return new EmbeddedHiveClient(MetacatHMSHandler.newRetryingHMSHandler("metacat", conf, true)); | |||
DataSourceManager.get().load(catalogName, configuration); |
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.
We will have to rethink the use of DataSourceManager. For now, lets add a TODO item.
@@ -0,0 +1,45 @@ | |||
/* |
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.
Why do we need this class? We can use QualifiedName.
@@ -0,0 +1,45 @@ | |||
/* |
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.
Why do we need this class? We can use QualifiedName.
@@ -0,0 +1,227 @@ | |||
/* |
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.
We should use https://github.com/rholder/guava-retrying.
How are we handling sorting and pagination in the embedded hive client? They are handled at the service layer. |
@@ -108,6 +110,24 @@ public void delete(@Nonnull final ConnectorContext requestContext, @Nonnull fina | |||
* {@inheritDoc}. | |||
*/ | |||
@Override | |||
public void update(@Nonnull final ConnectorContext context, @Nonnull final DatabaseInfo databaseInfo) { |
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'd recommend adding Lombok @NonNull
to these fields so your code is precondition checked to avoid NPE
@@ -108,6 +110,24 @@ public void delete(@Nonnull final ConnectorContext requestContext, @Nonnull fina | |||
* {@inheritDoc}. | |||
*/ | |||
@Override | |||
public void update(@Nonnull final ConnectorContext context, @Nonnull final DatabaseInfo databaseInfo) { | |||
try { | |||
this.metacatHiveClient.alterDatabase(databaseInfo.getName().getDatabaseName(), |
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 call getName()
a lot in here. Might be better to save it to a local variable. The compiler probably optimizes this to squash the function call but if we ever change the implementation of getName
to do some processing under the hood you would replicate executing that functionality multiple times this way. If you put it in a local variable you only have to do it one time. good overall advice
@@ -75,17 +79,17 @@ public HiveConnectorFactory(final String name, final Map<String, String> configu | |||
private void init() { |
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'm not sure I understand the purpose of an init()
method that is only called from the constructor anyway. Why not just do the logic in the constructor? I've seen @ajoymajumdar do this as well so he might have a reason
} | ||
final Module hiveModule = new HiveConnectorModule(name, configuration, infoConverter, client); | ||
final Module hiveModule = new HiveConnectorModule(catalogName, configuration, infoConverter, client); | ||
final Injector injector = Guice.createInjector(hiveModule); | ||
this.databaseService = injector.getInstance(ConnectorDatabaseService.class); |
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.
While this is probably fine cause we know the inner workings of the module/injector and you're just going to return a singleton it's probably a bad practice in general because if the injector really returns a different instance every time with different logic (e.g. a provider method) then users wouldn't get new updated versions of the database service every time. They'd be stuck with the old one.
@@ -106,15 +114,17 @@ private static HiveConf getDefaultConf() { | |||
result.setInt("javax.jdo.option.DatastoreWriteTimeoutMillis", 60000); |
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'd make all these strings constants with names as well as their default values you're setting here. That way we can quickly change them in one place if we have to use them in multiple places.
} | ||
|
||
@Override | ||
public void stop() { | ||
try { | ||
client.shutdown(); | ||
} catch (TException e) { | ||
log.warn(String.format("Failed shutting down the catalog: %s", name), e); | ||
log.warn(String.format("Failed shutting down the catalog: %s", catalogName), e); |
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 don't have to embed a String.format inside the slf4j logs if you're just doing string replacement. It's redundant. you could change this to be "Failed shutting down the catalog: {}", catalogName, e
and it would be the same.
final DataSource dataSource = DataSourceManager.get().get(name); | ||
final String jdoTimeout = JDO_TIMEOUT.get(); | ||
final Map<String, Object> properties = Maps.newHashMap(); | ||
properties.put("datanucleus.autoCreateSchema", props.get("datanucleus.autoCreateSchema")); |
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.
These should all probably be constants.
* @return set of hive privilege | ||
*/ | ||
public static Set<HivePrivilege> parsePrivilege(final PrivilegeGrantInfo userGrant) { | ||
final String name = userGrant.getPrivilege().toUpperCase(java.util.Locale.ENGLISH); |
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 don't quite understand this switch statement. It seems you can either have 1 or all but no other permutations?
* package name refactor * package name refactor * adding embedded client * fixing the functionTest * fixing check style * removing the port setting in function test * fixing the thrif functional test with embedded hive store * fixing checkstyple * removing commented code in functionalTest * fixing the hardcode string to constants * removing unused property * removing the guava-retrying in dependencies
* package name refactor * package name refactor * adding embedded client * fixing the functionTest * fixing check style * removing the port setting in function test * fixing the thrif functional test with embedded hive store * fixing checkstyple * removing commented code in functionalTest * fixing the hardcode string to constants * removing unused property * removing the guava-retrying in dependencies
No description provided.