Skip to content
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

Allow primary metastore to have prefix #161

Merged
merged 11 commits into from
Apr 23, 2019
Merged

Allow primary metastore to have prefix #161

merged 11 commits into from
Apr 23, 2019

Conversation

AnanaMJ
Copy link
Contributor

@AnanaMJ AnanaMJ commented Apr 17, 2019

Fixes #152

import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotBlank;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hibernate's @NotBlank is deprecated. This is what the docs say:

@deprecated use the standard {@link javax.validation.constraints.NotBlank} constraint instead

@AnanaMJ AnanaMJ requested a review from a team April 17, 2019 09:24
return EMPTY_PREFIX;
String prefix = super.getDatabasePrefix();
if (prefix == null) {
prefix = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we keep using EMPTY_PREFIX just so it is clear that it is a valid value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

@coveralls
Copy link

coveralls commented Apr 17, 2019

Coverage Status

Coverage increased (+0.02%) to 80.528% when pulling 2df1664 on primary-prefix into 1fadcb7 on master.

@patduin
Copy link
Contributor

patduin commented Apr 17, 2019

Could you add an WaggleDanceIntegrationTest test for this?

@@ -1,3 +1,7 @@
## TBD
### Changed
* Allow primary metastore to have a prefix. See [#152](https://github.com/HotelsDotCom/waggle-dance/issues/152).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README also needs an update probably.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

checkArgument(isNotEmpty(name));
checkArgument(isNotEmpty(remoteMetaStoreUris));
primaryMetaStore = new PrimaryMetaStore(name, remoteMetaStoreUris, accessControlType, writableDatabaseWhiteList);
primaryMetaStore.setLatency(8000L);
Copy link
Contributor

@patduin patduin Apr 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 182-185 can maybe be replaced with a call to primary(name, remoteMetaStoreUris......)
Or maybe rename/refactor this method into:

Builder withPrimaryPrefix(String prefix) {
   primaryMetaStore.setDatabasePrefix(prefix);
  return this;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thank you! That's a great suggestion :)
I've just added it

Copy link
Contributor

@patduin patduin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me

Copy link
Member

@abhimanyugupta07 abhimanyugupta07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link

@max-jacobs max-jacobs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@AnanaMJ
Copy link
Contributor Author

AnanaMJ commented Apr 18, 2019

I’ve updated the PR with a change for get_all_functions in FederatedHMSHandler and FederatedHMSHandlerTest. Do you mind taking a look at it in case there's anything that I've missed?

@@ -767,12 +768,42 @@ public void flushCache() throws TException {

@Test
public void get_all_functions() throws MetaException, TException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this test it is not a good test anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

GetAllFunctionsResponse response = new GetAllFunctionsResponse();
when(primaryClient.get_all_functions()).thenReturn(response);
GetAllFunctionsResponse result = handler.get_all_functions();
assertThat(result, is(response));
}

@Test
public void prefixedPrimary_get_all_functions() throws TException {
Copy link
Contributor

@patduin patduin Apr 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to get_all_functions The default is that all functions will have the DB transformed so that's what we should test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done :D

@patduin
Copy link
Contributor

patduin commented Apr 19, 2019

Could you make sure to test this with a view. Where the view references db's in the primary metastore and they get resolved correctly?

@AnanaMJ
Copy link
Contributor Author

AnanaMJ commented Apr 23, 2019

I tested this with a few views, and if they don't use functions, they work as expected. If they do use functions, an error like FAILED: SemanticException [Error 10011]: Invalid function <database>.<function> comes up. Just like the one in the issue you created (#165)

Copy link
Contributor

@massdosage massdosage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one tiny documentation change and then I'm happy to approve.

README.md Outdated
@@ -141,7 +141,7 @@ The table below describes all the available configuration values for Waggle Danc
| `primary-meta-store` | No | Primary MetaStore config. Can be empty but it is advised to configure it. |
| `primary-meta-store.remote-meta-store-uris` | Yes | Thrift URIs of the federated read-only metastore. |
| `primary-meta-store.name` | Yes | Database name that uniquely identifies this metastore. Used internally. Cannot be empty. |
| `primary-meta-store.database-prefix` | No | This will be ignored for the primary metastore and an empty string will always be used instead. |
| `primary-meta-store.database-prefix` | No | Prefix used to access this particular metastore and differentiate databases in it from databases in another metastore. The default prefix (i.e. if this value isn't explicitly set) is empty string.|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this particular -> the primary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

@@ -356,7 +356,7 @@ database is encountered that is not prefixed then the primary metastore is used
remote-meta-store-uris: thrift://primaryLocalMetastore:9083
federated-meta-stores:
- name: federated
prefix: waggle_prod_
database-prefix: waggle_prod_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh dear, was this wrong in our documentation all along?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅

@AnanaMJ AnanaMJ merged commit 45a8ff3 into master Apr 23, 2019
@AnanaMJ AnanaMJ deleted the primary-prefix branch April 23, 2019 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow primary metastore to have a prefix
6 participants