-
Notifications
You must be signed in to change notification settings - Fork 337
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
[#4107] feat(all): Add testConnection API for catalog #4108
Conversation
api/src/main/java/com/datastrato/gravitino/exceptions/IllegalPropertyException.java
Outdated
Show resolved
Hide resolved
return exception; | ||
} | ||
} | ||
} |
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 have some comments on the API design:
- It is not necessary to have a new Interface, adding a new method in the existing interface should be fine.
testCatalogCreation
is a big weird, I thinktestConnection
should be OK.- The interface design is not Java-ish, it is more like a REST interface, especially
TestResult
, it is totally DTO related stuff, which is weird for Java API design. For Java, it is better like
boolean testConnection(xxxx);
or
void testConnection(xxxx) throws Exception;
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.
Internally, you can design a such interface, but for API which is used by Java users, we should design to be more Java-ish.
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.
okay, using void testConnection(xxxx) throws Exception;
to refactor the API, please help to review when you have time, thanks
I'm fine with the API and REST interface. For the details, I need to take a deep look. |
@@ -114,4 +114,23 @@ Catalog alterCatalog(String catalogName, CatalogChange... changes) | |||
* @return True if the catalog was dropped, false otherwise. | |||
*/ | |||
boolean dropCatalog(String catalogName); | |||
|
|||
/** | |||
* Test whether a catalog can be created successfully with the specified parameters, without |
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 believe, this should be 'Test whether we can connect to catalog engine(or something similar) with specified parameters'.
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.
updated
String comment, | ||
Map<String, String> properties) { | ||
try { | ||
adminClient.listTopics().names().get(); |
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 you use an already-created adminClient
to test Connection since you intend to test connection with the parameter?
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.
The adminClient
was initialized with the provided parameters
return; | ||
} | ||
|
||
ErrorHandlers.catalogErrorHandler().accept(resp); |
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 need to call this again?
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.
To throw the corresponding exception
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.
comment added
} | ||
}); | ||
if (store.exists(ident, EntityType.CATALOG)) { | ||
throw new CatalogAlreadyExistsException("Catalog %s already exists", ident); |
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.
Will it lead to test error?
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.
yes, whether the catalog name already exists is also a validation item.
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.
More precisely, this will cause the testConnection
method to throw a CatalogAlreadyExistsException
exception.
new CatalogCreateRequest(catalogName, type, provider, comment, properties); | ||
req.validate(); | ||
|
||
ErrorResponse resp = |
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 you use ErrorResponse here, I found that it returns BaseResponse
for normal scenario.
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.
Just one comment, can you please explain this @mchades
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.
It can be BaseResponse
(test successfully) or ErrorResponse
(test failed).
Since the ErrorResponse
can contain all fields of BaseResponse
(code
field only), so I use ErrorResponse
here. @jerryshao
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.
Can you please add a comment here?
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.
added
What changes were proposed in this pull request?
Add testConnection API for catalog
Why are the changes needed?
Fix: #4107
Does this PR introduce any user-facing change?
yes, add a new API
How was this patch tested?
tests added