Skip to content

Commit

Permalink
rename active to enable and rename deactivate to disable
Browse files Browse the repository at this point in the history
  • Loading branch information
mchades committed Oct 17, 2024
1 parent f5b34b4 commit 33d7171
Show file tree
Hide file tree
Showing 22 changed files with 94 additions and 96 deletions.
16 changes: 8 additions & 8 deletions api/src/main/java/org/apache/gravitino/SupportsCatalogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ Catalog alterCatalog(String catalogName, CatalogChange... changes)
* <ul>
* <li>There is no schema in the catalog. Otherwise, a {@link NonEmptyEntityException} will be
* thrown.
* <li>The method {@link #deactivateCatalog(String)} has been called before dropping the
* catalog. Otherwise, a {@link CatalogInUseException} will be thrown.
* <li>The method {@link #disableCatalog(String)} has been called before dropping the catalog.
* Otherwise, a {@link CatalogInUseException} will be thrown.
* </ul>
*
* It is equivalent to calling {@code dropCatalog(ident, false)}.
Expand Down Expand Up @@ -154,19 +154,19 @@ boolean dropCatalog(String catalogName, boolean force)
throws NonEmptyEntityException, CatalogInUseException;

/**
* Activate a catalog. If the catalog is already activated, this method does nothing.
* Enable a catalog. If the catalog is already enable, this method does nothing.
*
* @param catalogName The identifier of the catalog.
* @throws NoSuchCatalogException If the catalog does not exist.
*/
void activateCatalog(String catalogName) throws NoSuchCatalogException;
void enableCatalog(String catalogName) throws NoSuchCatalogException;

/**
* Deactivate a catalog. If the catalog is already deactivated, this method does nothing. Once a
* catalog is deactivated:
* Disable a catalog. If the catalog is already disabled, this method does nothing. Once a catalog
* is disabled:
*
* <ul>
* <li>It can only be listed, loaded, dropped, or activated.
* <li>It can only be listed, loaded, dropped, or disable.
* <li>Any other operations on the catalog will throw an {@link CatalogNotInUseException}.
* <li>Any operation on the sub-entities (schemas, tables, etc.) will throw an {@link
* CatalogNotInUseException}.
Expand All @@ -175,7 +175,7 @@ boolean dropCatalog(String catalogName, boolean force)
* @param catalogName The identifier of the catalog.
* @throws NoSuchCatalogException If the catalog does not exist.
*/
void deactivateCatalog(String catalogName) throws NoSuchCatalogException;
void disableCatalog(String catalogName) throws NoSuchCatalogException;

/**
* Test whether the catalog with specified parameters can be connected to before creating it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void startup() throws IOException, SQLException {
@AfterAll
public void stop() {
clearTableAndSchema();
metalake.deactivateCatalog(catalogName);
metalake.disableCatalog(catalogName);
metalake.dropCatalog(catalogName);
client.dropMetalake(metalakeName);
mysqlService.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void stop() {
for (String schemaName : schemaNames) {
catalog.asSchemas().dropSchema(schemaName, true);
}
metalake.deactivateCatalog(catalogName);
metalake.disableCatalog(catalogName);
metalake.dropCatalog(catalogName);
client.dropMetalake(metalakeName);
postgreSqlService.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void shutdown() {
Arrays.stream(metalake.listCatalogs())
.forEach(
(catalogName -> {
metalake.deactivateCatalog(catalogName);
metalake.disableCatalog(catalogName);
metalake.dropCatalog(catalogName);
}));
client.dropMetalake(METALAKE_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void startup() throws Exception {
public void stop() throws Exception {
try {
clearTableAndSchema();
metalake.deactivateCatalog(catalogName);
metalake.disableCatalog(catalogName);
metalake.dropCatalog(catalogName);
client.dropMetalake(metalakeName);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void testIcebergWithKerberosAndUserImpersonation() throws IOException {
Assertions.assertFalse(catalog.asSchemas().schemaExists(SCHEMA_NAME));

// Drop catalog
Assertions.assertDoesNotThrow(() -> gravitinoMetalake.deactivateCatalog(CATALOG_NAME));
Assertions.assertDoesNotThrow(() -> gravitinoMetalake.disableCatalog(CATALOG_NAME));
Assertions.assertTrue(gravitinoMetalake.dropCatalog(CATALOG_NAME));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected void startNecessaryContainers() {
@AfterAll
public void stop() {
clearTableAndSchema();
metalake.deactivateCatalog(catalogName);
metalake.disableCatalog(catalogName);
metalake.dropCatalog(catalogName);
client.dropMetalake(metalakeName);
if (spark != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ public boolean dropCatalog(String catalogName, boolean force)
}

@Override
public void activateCatalog(String catalogName) throws NoSuchCatalogException {
getMetalake().activateCatalog(catalogName);
public void enableCatalog(String catalogName) throws NoSuchCatalogException {
getMetalake().enableCatalog(catalogName);
}

@Override
public void deactivateCatalog(String catalogName) throws NoSuchCatalogException {
getMetalake().deactivateCatalog(catalogName);
public void disableCatalog(String catalogName) throws NoSuchCatalogException {
getMetalake().disableCatalog(catalogName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public boolean dropCatalog(String catalogName, boolean force)
}

@Override
public void activateCatalog(String catalogName) throws NoSuchCatalogException {
public void enableCatalog(String catalogName) throws NoSuchCatalogException {
ErrorResponse resp =
restClient.get(
String.format(API_METALAKES_CATALOGS_PATH, this.name(), catalogName) + "/activate",
Expand All @@ -312,10 +312,10 @@ public void activateCatalog(String catalogName) throws NoSuchCatalogException {
}

@Override
public void deactivateCatalog(String catalogName) throws NoSuchCatalogException {
public void disableCatalog(String catalogName) throws NoSuchCatalogException {
ErrorResponse resp =
restClient.get(
String.format(API_METALAKES_CATALOGS_PATH, this.name(), catalogName) + "/deactivate",
String.format(API_METALAKES_CATALOGS_PATH, this.name(), catalogName) + "/disable",
ErrorResponse.class,
Collections.emptyMap(),
ErrorHandlers.catalogErrorHandler());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ public void testDropCatalog() {
Assertions.assertThrows(
CatalogInUseException.class, () -> metalake.dropCatalog(catalogName));
Assertions.assertTrue(
exception.getMessage().contains("please deactivate it first or use force option"),
exception.getMessage().contains("please disable it first or use force option"),
exception.getMessage());

Assertions.assertDoesNotThrow(() -> metalake.deactivateCatalog(catalogName));
Assertions.assertDoesNotThrow(() -> metalake.disableCatalog(catalogName));
Assertions.assertTrue(metalake.dropCatalog(catalogName), "catalog should be dropped");
Assertions.assertFalse(metalake.dropCatalog(catalogName), "catalog should be non-existent");
}
Expand All @@ -167,10 +167,10 @@ public void testCatalogAvailable() {
Assertions.assertThrows(
CatalogInUseException.class, () -> metalake.dropCatalog(catalogName));
Assertions.assertTrue(
exception.getMessage().contains("please deactivate it first or use force option"),
exception.getMessage().contains("please disable it first or use force option"),
exception.getMessage());

Assertions.assertDoesNotThrow(() -> metalake.deactivateCatalog(catalogName));
Assertions.assertDoesNotThrow(() -> metalake.disableCatalog(catalogName));
Catalog loadedCatalog = metalake.loadCatalog(catalogName);
Assertions.assertEquals("false", loadedCatalog.properties().get(PROPERTY_IN_USE));

Expand Down Expand Up @@ -235,7 +235,7 @@ public void testCreateCatalogWithoutProperties() {
Assertions.assertEquals("hadoop", catalog.provider());
Assertions.assertEquals("catalog comment", catalog.comment());
Assertions.assertEquals("true", catalog.properties().get(PROPERTY_IN_USE));
metalake.deactivateCatalog(catalogName);
metalake.disableCatalog(catalogName);
metalake.dropCatalog(catalogName);

// test cloud related properties
Expand Down Expand Up @@ -266,7 +266,7 @@ public void testCreateCatalogWithoutProperties() {
Assertions.assertFalse(catalog.properties().isEmpty());
Assertions.assertEquals("aws", catalog.properties().get("cloud.name"));
Assertions.assertEquals("us-west-2", catalog.properties().get("cloud.region-code"));
metalake.deactivateCatalog(catalogName);
metalake.disableCatalog(catalogName);
metalake.dropCatalog(catalogName);
}

Expand All @@ -286,7 +286,7 @@ public void testCreateCatalogWithChinese() {
Assertions.assertEquals("这是中文comment", catalog.comment());
Assertions.assertTrue(catalog.properties().containsKey("metastore.uris"));

metalake.deactivateCatalog(catalogName);
metalake.disableCatalog(catalogName);
metalake.dropCatalog(catalogName);
}

Expand Down Expand Up @@ -319,10 +319,10 @@ public void testListCatalogsInfo() {
Assertions.assertTrue(ArrayUtils.contains(catalogs, relCatalog));
Assertions.assertTrue(ArrayUtils.contains(catalogs, fileCatalog));

metalake.deactivateCatalog(relCatalogName);
metalake.disableCatalog(relCatalogName);
metalake.dropCatalog(relCatalogName);

metalake.deactivateCatalog(fileCatalogName);
metalake.disableCatalog(fileCatalogName);
metalake.dropCatalog(fileCatalogName);
}

Expand Down Expand Up @@ -358,7 +358,7 @@ public void testCreateCatalogWithPackage() {
Assertions.assertEquals("catalog comment", catalog.comment());
Assertions.assertTrue(catalog.properties().containsKey("package"));

metalake.deactivateCatalog(catalogName);
metalake.disableCatalog(catalogName);
metalake.dropCatalog(catalogName);

// Test using invalid package path
Expand Down Expand Up @@ -392,7 +392,7 @@ void testUpdateCatalogWithNullableComment() {
metalake.alterCatalog(catalogName, CatalogChange.updateComment("new catalog comment"));
Assertions.assertEquals("new catalog comment", updatedCatalog.comment());

metalake.deactivateCatalog(catalogName);
metalake.disableCatalog(catalogName);
metalake.dropCatalog(catalogName);
}

Expand Down Expand Up @@ -423,7 +423,7 @@ public void testAlterCatalogProperties() {
Assertions.assertEquals(alterCloudName, alteredCatalog.properties().get(Catalog.CLOUD_NAME));
Assertions.assertEquals(
alterRegionCode, alteredCatalog.properties().get(Catalog.CLOUD_REGION_CODE));
metalake.deactivateCatalog(catalogName);
metalake.disableCatalog(catalogName);
metalake.dropCatalog(catalogName);
}
}
8 changes: 4 additions & 4 deletions clients/client-python/gravitino/client/gravitino_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def alter_catalog(self, name: str, *changes: CatalogChange):
def drop_catalog(self, name: str, force: bool = False) -> bool:
return self.get_metalake().drop_catalog(name, force)

def activate_catalog(self, name: str):
return self.get_metalake().activate_catalog(name)
def enable_catalog(self, name: str):
return self.get_metalake().enable_catalog(name)

def deactivate_catalog(self, name: str):
return self.get_metalake().deactivate_catalog(name)
def disable_catalog(self, name: str):
return self.get_metalake().disable_catalog(name)
12 changes: 6 additions & 6 deletions clients/client-python/gravitino/client/gravitino_metalake.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,26 +206,26 @@ def drop_catalog(self, name: str, force: bool = False) -> bool:

return drop_response.dropped()

def activate_catalog(self, name: str):
"""Activate the catalog with specified name. If the catalog is already activated, this method does nothing.
def enable_catalog(self, name: str):
"""Enable the catalog with specified name. If the catalog is already in use, this method does nothing.
Args:
name: the name of the catalog.
Raises:
NoSuchCatalogException if the catalog with specified name does not exist.
"""
url = self.API_METALAKES_CATALOGS_PATH.format(self.name(), name) + "/activate"
url = self.API_METALAKES_CATALOGS_PATH.format(self.name(), name) + "/enable"
self.rest_client.get(url, error_handler=CATALOG_ERROR_HANDLER)

def deactivate_catalog(self, name: str):
"""Deactivate the catalog with specified name. If the catalog is already deactivated, this method does nothing.
def disable_catalog(self, name: str):
"""Disable the catalog with specified name. If the catalog is already disabled, this method does nothing.
Args:
name: the name of the catalog.
Raises:
NoSuchCatalogException if the catalog with specified name does not exist.
"""
url = self.API_METALAKES_CATALOGS_PATH.format(self.name(), name) + "/deactivate"
url = self.API_METALAKES_CATALOGS_PATH.format(self.name(), name) + "/disable"
self.rest_client.get(url, error_handler=CATALOG_ERROR_HANDLER)
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public void testConnection(
}

@Override
public void activateCatalog(NameIdentifier ident)
public void enableCatalog(NameIdentifier ident)
throws NoSuchCatalogException, CatalogNotInUseException {
try {
if (catalogInUse(store, ident)) {
Expand Down Expand Up @@ -518,7 +518,7 @@ public void activateCatalog(NameIdentifier ident)
}

@Override
public void deactivateCatalog(NameIdentifier ident) throws NoSuchCatalogException {
public void disableCatalog(NameIdentifier ident) throws NoSuchCatalogException {
try {
if (!catalogInUse(store, ident)) {
return;
Expand Down Expand Up @@ -559,8 +559,7 @@ public void deactivateCatalog(NameIdentifier ident) throws NoSuchCatalogExceptio
public Catalog alterCatalog(NameIdentifier ident, CatalogChange... changes)
throws NoSuchCatalogException, IllegalArgumentException {
if (!catalogInUse(store, ident)) {
throw new CatalogNotInUseException(
"Catalog %s is not in use, please activate it first", ident);
throw new CatalogNotInUseException("Catalog %s is not in use, please enable it first", ident);
}

// There could be a race issue that someone is using the catalog from cache while we are
Expand Down Expand Up @@ -633,7 +632,7 @@ public boolean dropCatalog(NameIdentifier ident, boolean force)
boolean catalogInUse = catalogInUse(store, ident);
if (catalogInUse && !force) {
throw new CatalogInUseException(
"Catalog %s is in use, please deactivate it first or use force option", ident);
"Catalog %s is in use, please disable it first or use force option", ident);
}

List<SchemaEntity> schemas =
Expand All @@ -652,8 +651,8 @@ public boolean dropCatalog(NameIdentifier ident, boolean force)

// If reached here, it implies that the catalog is not in use or force is true.
if (catalogInUse) {
// force is true, deactivate the catalog first
deactivateCatalog(ident);
// force is true, disable the catalog first
disableCatalog(ident);
}

catalogCache.invalidate(ident);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ public void testConnection(
}

@Override
public void activateCatalog(NameIdentifier ident) throws NoSuchCatalogException {
dispatcher.activateCatalog(ident);
public void enableCatalog(NameIdentifier ident) throws NoSuchCatalogException {
dispatcher.enableCatalog(ident);
}

@Override
public void deactivateCatalog(NameIdentifier ident) throws NoSuchCatalogException {
dispatcher.deactivateCatalog(ident);
public void disableCatalog(NameIdentifier ident) throws NoSuchCatalogException {
dispatcher.disableCatalog(ident);
}

private void validateCatalogName(String name) throws IllegalArgumentException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Catalog alterCatalog(NameIdentifier ident, CatalogChange... changes)
* <ul>
* <li>There is no schema in the catalog. Otherwise, a {@link NonEmptyEntityException} will be
* thrown.
* <li>The method {@link #deactivateCatalog(NameIdentifier)} has been called before dropping the
* <li>The method {@link #disableCatalog(NameIdentifier)} has been called before dropping the
* catalog.
* </ul>
*
Expand Down Expand Up @@ -177,21 +177,20 @@ void testConnection(
throws Exception;

/**
* Activate a catalog. If the catalog is already active, this method does nothing.
* Enable a catalog. If the catalog is already enable, this method does nothing.
*
* @param ident The identifier of the catalog.
* @throws NoSuchCatalogException If the catalog does not exist.
* @throws CatalogNotInUseException If its parent metalake is not active.
* @throws CatalogNotInUseException If its parent metalake is not in use.
*/
void activateCatalog(NameIdentifier ident)
throws NoSuchCatalogException, CatalogNotInUseException;
void enableCatalog(NameIdentifier ident) throws NoSuchCatalogException, CatalogNotInUseException;

/**
* Deactivate a catalog. If the catalog is already deactivated, this method does nothing. Once a
* catalog is deactivated:
* Disable a catalog. If the catalog is already disabled, this method does nothing. Once a catalog
* is disabled:
*
* <ul>
* <li>It can only be listed, loaded, dropped, or activated.
* <li>It can only be listed, loaded, dropped, or disable.
* <li>Any other operations on the catalog will throw an {@link CatalogNotInUseException}.
* <li>Any operation on the sub-entities (schemas, tables, etc.) will throw an {@link
* CatalogNotInUseException}.
Expand All @@ -200,5 +199,5 @@ void activateCatalog(NameIdentifier ident)
* @param ident The identifier of the catalog.
* @throws NoSuchCatalogException If the catalog does not exist.
*/
void deactivateCatalog(NameIdentifier ident) throws NoSuchCatalogException;
void disableCatalog(NameIdentifier ident) throws NoSuchCatalogException;
}
Loading

0 comments on commit 33d7171

Please sign in to comment.