-
Notifications
You must be signed in to change notification settings - Fork 380
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
[#5066] refactor(drop-catalog): re-define drop catalog #5067
Conversation
fe68851
to
cb738a2
Compare
55b0e72
to
5f5e913
Compare
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.
Do you also need to update the doc?
api/src/main/java/org/apache/gravitino/exceptions/NonInUseEntityException.java
Outdated
Show resolved
Hide resolved
clients/client-java/src/main/java/org/apache/gravitino/client/ErrorHandlers.java
Show resolved
Hide resolved
clients/client-java/src/main/java/org/apache/gravitino/client/ErrorHandlers.java
Show resolved
Hide resolved
Just did a cursory review, I'm fine with the current implementation. I will spend more time to have a deep review. |
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/gravitino/server/web/rest/CatalogOperations.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java
Outdated
Show resolved
Hide resolved
|
||
if (!schemas.isEmpty() | ||
&& !force | ||
&& (!catalogEntity.getProvider().equals("kafka") || schemas.size() > 1)) { |
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.
Please optimize the condition, if the execution goes to !catalogEntity.getProvider().equals("kafka") || schemas.size() > 1
, schemas
must be NOT empty.
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.
no. schemas.size()
may equals 1
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 expression here is difficult to understand, maybe we can use multiple if
to describe the exception message for different cases.
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.
fixed
import com.google.errorprone.annotations.FormatString; | ||
|
||
/** Exception thrown when an entity is in use and cannot be deleted. */ | ||
public class EntityInUseException extends GravitinoRuntimeException { |
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.
Is it better to define a CatalogInUseException
and CatalogNotInUseException
clearly? This also applies to metalake.
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 error message will describe the reason exactly (what entity is not in use).
If we define CatalogInUseException
, CatalogNotInUseException
, MetalakeInUseException
and MetalakeInUseException
, then we also need SchemaNotInUseException
, TableNotInUseException
, TopicNotInUseException
, etc which will make the code more complicated, so I think current exception define is enough.
} | ||
|
||
public static Response inUse(String type, String message, Throwable throwable) { | ||
return Response.status(Response.Status.CONFLICT) |
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 I prefer 503. Just a discussion not a suggestion.
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.
SERVICE_UNAVAILABLE(503, "Service Unavailable")
means the server status, not the resource. So I think it's not suitable.
""" | ||
params = {"force": str(force)} |
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.
str(force)
will get "True/False" or "true/false"?
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.
In any case, the server side will ignore case sensitivity during query param conversion. So it's not a problem
common/src/main/java/org/apache/gravitino/dto/responses/ErrorResponse.java
Outdated
Show resolved
Hide resolved
Doc will be updated in final PR |
CatalogEntity catalogEntity = | ||
store.get(catalogIdent, EntityType.CATALOG, CatalogEntity.class); | ||
return (boolean) | ||
BASIC_CATALOG_PROPERTIES_METADATA.getOrDefault( |
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 a BASIC_CATALOG_PROPERTIES_METADATA
?
@@ -187,6 +187,70 @@ public Response testConnection( | |||
} | |||
} | |||
|
|||
@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.
Is it better to use PUT
or POST
?
protected Map<String, PropertyEntry<?>> specificPropertyEntries() { | ||
return Collections.emptyMap(); | ||
} | ||
}; |
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 can create a singleton in BaseCatalogPropertiesMetadata
and remove abstract
in this class to make it simple.
All comments are resolved, plz help to review again, thx! @yuqi1129 @jerryshao |
Can you please fix the CI failure? |
throws NonEmptyEntityException, CatalogInUseException; | ||
|
||
/** | ||
* Enable a catalog. If the catalog is already enable, this method does nothing. |
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.
"If the catalog is already enabled..."
if (catalogInUse) { | ||
// force is true, disable the catalog first | ||
disableCatalog(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.
Since the catalog will be deleted, I don't think it is necessary to do the disable 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.
The purpose of this operation is to modify the in-use
value in the backend store
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.
removed
@Override | ||
public void enableCatalog(NameIdentifier ident) | ||
throws NoSuchCatalogException, CatalogNotInUseException { | ||
// todo: support activate catalog event |
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 you do this in a different PR?
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
…5067) ### What changes were proposed in this pull request? - Add an `in-use` property to the catalog with the default value of true. - Only empty catalog with `in-use=false` can be dropped. - User can use `dorce` option to drop catalog - More drop catalog limitations please see the JavaDoc of `dropCatalog` in API module ### Why are the changes needed? Fix: apache#5066 ### Does this PR introduce _any_ user-facing change? yes, users now can not drop an in used catalog ### How was this patch tested? tests added
What changes were proposed in this pull request?
in-use
property to the catalog with the default value of true.in-use=false
can be dropped.dorce
option to drop catalogdropCatalog
in API moduleWhy are the changes needed?
Fix: #5066
Does this PR introduce any user-facing change?
yes, users now can not drop an in used catalog
How was this patch tested?
tests added