-
Notifications
You must be signed in to change notification settings - Fork 76
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
Conversation
import javax.validation.constraints.NotNull; | ||
|
||
import org.hibernate.validator.constraints.NotBlank; |
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.
Hibernate's @NotBlank
is deprecated. This is what the docs say:
@deprecated use the standard {@link javax.validation.constraints.NotBlank} constraint instead
return EMPTY_PREFIX; | ||
String prefix = super.getDatabasePrefix(); | ||
if (prefix == null) { | ||
prefix = ""; |
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.
maybe we keep using EMPTY_PREFIX
just so it is clear that it is a valid value
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.
Done :)
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). |
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.
README also needs an update probably.
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.
Done :)
checkArgument(isNotEmpty(name)); | ||
checkArgument(isNotEmpty(remoteMetaStoreUris)); | ||
primaryMetaStore = new PrimaryMetaStore(name, remoteMetaStoreUris, accessControlType, writableDatabaseWhiteList); | ||
primaryMetaStore.setLatency(8000L); |
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.
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;
}
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.
Ah, thank you! That's a great suggestion :)
I've just added it
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.
This looks good to me
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.
Looks good.
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’ve updated the PR with a change for |
@@ -767,12 +768,42 @@ public void flushCache() throws TException { | |||
|
|||
@Test | |||
public void get_all_functions() throws MetaException, TException { |
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.
remove this test it is not a good test anymore.
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.
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 { |
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.
rename to get_all_functions
The default is that all functions will have the DB transformed so that's what we should test.
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.
Ok, done :D
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? |
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 |
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.
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.| |
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.
this particular -> the primary
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.
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_ |
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.
Oh dear, was this wrong in our documentation all along?
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.
oops
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.
😅
Fixes #152