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

Implementation of Dynamo Admin module #301

Merged
merged 23 commits into from
Sep 16, 2021
Merged

Implementation of Dynamo Admin module #301

merged 23 commits into from
Sep 16, 2021

Conversation

thongdk8
Copy link
Contributor

@thongdk8 thongdk8 commented Sep 7, 2021

This PR contains the implementation of the Dynamo Admin module and tests for it.

@thongdk8 thongdk8 self-assigned this Sep 7, 2021
@thongdk8 thongdk8 added the enhancement New feature or request label Sep 7, 2021
Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

Thank you! I did the first review for this and left some comments/suggestions. Please check them when you have time!

I will review it again later. Thanks.

@thongdk8
Copy link
Contributor Author

thongdk8 commented Sep 8, 2021

Thank you! I did the first review for this and left some comments/suggestions. Please check them when you have time!

I will review it again later. Thanks.

Thank you. I'll mark this PR as ready when I finish the tests.

@thongdk8 thongdk8 requested a review from brfrn169 September 8, 2021 09:40
@thongdk8 thongdk8 changed the title [WIP] Implementation of Dynamo Admin module Implementation of Dynamo Admin module Sep 8, 2021
@thongdk8 thongdk8 marked this pull request as ready for review September 8, 2021 09:40
Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

Thank you! I took a look at this again and left some comments/suggestions. Please take a look!

Maybe, I think I will take a look at it once again later. Thanks.

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

Thank you!
Let me start off by leaving comments on the superficial parts of the code.
I will look into it later.

for (String column : metadata.getClusteringKeyNames()) {
if (metadata.getColumnDataType(column) == DataType.BOOLEAN) {
throw new ExecutionException(
"BOOLEAN type is not supported for a clustering key or a secondary index in DynamoDB");
Copy link
Contributor

Choose a reason for hiding this comment

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

This limitation is still there? I did a quick search but I can't find it.

Copy link
Contributor Author

@thongdk8 thongdk8 Sep 10, 2021

Choose a reason for hiding this comment

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

It still is a limitation. There is no attribute type likes ScalarAttributeType.BOOL came from SDK.

throw new UnsupportedOperationException("implement later");
public void createNamespace(String namespace, Map<String, String> options) {
// In Dynamo DB storage, namespace will be added to table name as prefix along with dot
// separator.
}

@Override
public void createTable(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this method is too big.
The code seems to have several logical units (for each component to build), so can you make them turn to methods and call them to make this method slim?

Copy link
Contributor

@feeblefakie feeblefakie Sep 16, 2021

Choose a reason for hiding this comment

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

@thongdk8 Somehow it is resolved without checked but was it done (doesn't look like it though) or was it difficult/giving much benefit so not done or it was unintentionally resolved by another change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I did split the method to make it slimmer in 166ec54.
This was marked as resolved because I did apply it, I mentioned here. All the suggestions that were marked as resolved were applied.

Copy link
Contributor

@feeblefakie feeblefakie Sep 16, 2021

Choose a reason for hiding this comment

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

I meant, please reply back to all the comments respectively. Otherwise, it's pretty hard to identify since there are many comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. I'll do it from now on. Sorry about that.

Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

Thank you! Just left some comments. Please take a look when you have time!

I found one different behavior from the original schema loader. Just in case, can you please re-check if there are any other different behaviors in this new implementation? And if you find them, please correct them. Thank you.

Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

Thank you! I left one question and some minor suggestions. Please check them when you have time!

BTW, did you re-check if there are any other different behaviors from the original schema loader in this new implementation? And was it good?

@thongdk8
Copy link
Contributor Author

BTW, did you re-check if there are any other different behaviors from the original schema loader in this new implementation? And was it good?

Thank you. I did check the behaviors, they are fine.

Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

LGTM except what I commented. Thank you!

brfrn169
brfrn169 previously approved these changes Sep 16, 2021
Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

Left additional comments and suggestions.

throw new StorageRuntimeException("creating meta data table failed");
}

while (true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This block is redundant with the block in Admin.
(CREATING_WAITING_TIME is also redundantly defined)
It would be great if the redundancy is removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, indeed. I created a static function for waiting table creation. Applied in 391f30b

private static final String PARTITION_KEY = "concatenatedPartitionKey";
private static final String CLUSTERING_KEY = "concatenatedClusteringKey";
private static final String GLOBAL_INDEX_NAME_PREFIX = "global_index";
private static final int CREATING_WAITING_TIME = 3000;
Copy link
Contributor

Choose a reason for hiding this comment

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

The variable names are not consistent.
It is is ms then should it end with _MS or something to be consistent with _SEC?

I would suggest to have the same time unit and adjust for each case like below.

CREATE_WAIT_DURATION_MILLIS
COOL_DOWN_DURATION_MILLIS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cause the cooldown time is accepted in seconds so I change variables' name with postfix _SECS. Apply in 391f30b

Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

@thongdk8 Sorry, I missed one thing. Just left some suggestions. Please check them!

brfrn169
brfrn169 previously approved these changes Sep 16, 2021
Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for your patience.

.build();
}

protected static void waitForTableCreation(DynamoDbClient client, String tableFullName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can it be package private instead of protected?
(Any reason for protected?)

Copy link
Contributor Author

@thongdk8 thongdk8 Sep 16, 2021

Choose a reason for hiding this comment

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

It was used in DynamoTableMetadataManager when creating the metadata table so I made it protected.

Copy link
Contributor

@feeblefakie feeblefakie Sep 16, 2021

Choose a reason for hiding this comment

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

So, it can be package-private, right?
I've checked the code and DynamoTableMetadataManager in the same package is the only one that uses this method except for this Admin class, so please make it package-private.
Restricted scope is usually better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I removed the protected identifier 90037fd

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

Looking good except for the comments I additionally made.
Thank you!

.build();
}

protected static void waitForTableCreation(DynamoDbClient client, String tableFullName) {
Copy link
Contributor

@feeblefakie feeblefakie Sep 16, 2021

Choose a reason for hiding this comment

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

So, it can be package-private, right?
I've checked the code and DynamoTableMetadataManager in the same package is the only one that uses this method except for this Admin class, so please make it package-private.
Restricted scope is usually better.

@@ -1,22 +1,44 @@
package com.scalar.db.storage.dynamo;

import static com.scalar.db.storage.dynamo.DynamoAdmin.waitForTableCreation;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not use static import for 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.

Updated in 90037fd

@@ -25,11 +47,14 @@
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

It's basically rewritten, so please put your name on it!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in 90037fd

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

@feeblefakie feeblefakie merged commit c9a7290 into master Sep 16, 2021
@feeblefakie feeblefakie deleted the dynamo-admin branch September 16, 2021 12:43
brfrn169 pushed a commit that referenced this pull request Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants