Package org.apache.gravitino.client
Class GravitinoAdminClient
java.lang.Object
org.apache.gravitino.client.GravitinoClientBase
org.apache.gravitino.client.GravitinoAdminClient
- All Implemented Interfaces:
Closeable
,AutoCloseable
,SupportsMetalakes
Apache Gravitino Client for the administrator to interact with the Gravitino API, allowing the
client to list, load, create, and alter Metalakes.
Normal users should use GravitinoClient
to connect with the Gravitino server.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builder class for constructing a GravitinoAdminClient.Nested classes/interfaces inherited from class org.apache.gravitino.client.GravitinoClientBase
GravitinoClientBase.Builder<T>
-
Field Summary
Fields inherited from class org.apache.gravitino.client.GravitinoClientBase
API_METALAKES_IDENTIFIER_PATH, API_METALAKES_LIST_PATH, restClient
-
Method Summary
Modifier and TypeMethodDescriptionalterMetalake
(String name, MetalakeChange... changes) Alters a specific Metalake using the Gravitino API.Creates a new builder for constructing a GravitinoClient.Creates a new Metalake using the Gravitino API.void
disableMetalake
(String name) Disable a metalake.boolean
dropMetalake
(String name, boolean force) Drop a metalake with specified name.void
enableMetalake
(String name) Enable a metalake.Retrieves a list of Metalakes from the Gravitino API.Methods inherited from class org.apache.gravitino.client.GravitinoClientBase
checkMetalakeName, checkVersion, clientVersion, close, getVersion, loadMetalake, serverVersion
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.gravitino.SupportsMetalakes
dropMetalake, loadMetalake, metalakeExists
-
Method Details
-
listMetalakes
Retrieves a list of Metalakes from the Gravitino API.- Specified by:
listMetalakes
in interfaceSupportsMetalakes
- Returns:
- An array of GravitinoMetalake objects representing the Metalakes.
-
createMetalake
public GravitinoMetalake createMetalake(String name, String comment, Map<String, String> properties) throws MetalakeAlreadyExistsExceptionCreates a new Metalake using the Gravitino API.- Specified by:
createMetalake
in interfaceSupportsMetalakes
- Parameters:
name
- The name of the new Metalake.comment
- The comment for the new Metalake.properties
- The properties of the new Metalake.- Returns:
- A GravitinoMetalake instance representing the newly created Metalake.
- Throws:
MetalakeAlreadyExistsException
- If a Metalake with the specified identifier already exists.
-
alterMetalake
public GravitinoMetalake alterMetalake(String name, MetalakeChange... changes) throws NoSuchMetalakeException, IllegalArgumentException Alters a specific Metalake using the Gravitino API.- Specified by:
alterMetalake
in interfaceSupportsMetalakes
- Parameters:
name
- The name of the Metalake to be altered.changes
- The changes to be applied to the Metalake.- Returns:
- A GravitinoMetalake instance representing the updated Metalake.
- Throws:
NoSuchMetalakeException
- If the specified Metalake does not exist.IllegalArgumentException
- If the provided changes are invalid or not applicable.
-
dropMetalake
public boolean dropMetalake(String name, boolean force) throws NonEmptyEntityException, MetalakeInUseException Drop a metalake with specified name. If the force flag is true, it will:- Cascade drop all sub-entities (tags, catalogs, schemas, tables, etc.) of the metalake in Gravitino store.
- Drop the metalake even if it is in use.
- External resources (e.g. database, table, etc.) associated with sub-entities will not be deleted unless it is managed (such as managed fileset).
SupportsMetalakes.dropMetalake(String)
.- Specified by:
dropMetalake
in interfaceSupportsMetalakes
- Parameters:
name
- The name of the metalake.force
- Whether to force the drop.- Returns:
- True if the metalake was dropped, false if the metalake does not exist.
- Throws:
NonEmptyEntityException
- If the metalake is not empty and force is false.MetalakeInUseException
- If the metalake is in use and force is false.
-
enableMetalake
Description copied from interface:SupportsMetalakes
Enable a metalake. If the metalake is already in use, this method does nothing.- Specified by:
enableMetalake
in interfaceSupportsMetalakes
- Parameters:
name
- The name of the metalake.- Throws:
NoSuchMetalakeException
- If the metalake does not exist.
-
disableMetalake
Description copied from interface:SupportsMetalakes
Disable a metalake. If the metalake is already disabled, this method does nothing. Once a metalake is disable:- It can only be listed, loaded, dropped, or enable.
- Any other operations on the metalake will throw an
MetalakeNotInUseException
. - Any operation on the sub-entities (catalogs, schemas, tables, etc.) will throw an
MetalakeNotInUseException
.
- Specified by:
disableMetalake
in interfaceSupportsMetalakes
- Parameters:
name
- The name of the metalake.- Throws:
NoSuchMetalakeException
- If the metalake does not exist.
-
builder
Creates a new builder for constructing a GravitinoClient.- Parameters:
uri
- The base URI for the Gravitino API.- Returns:
- A new instance of the Builder class for constructing a GravitinoClient.
-