-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b5453d
commit 19cc513
Showing
3 changed files
with
198 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
clients/cli/src/main/java/org/apache/gravitino/cli/commands/UpdateFilesetComment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.gravitino.cli.commands; | ||
|
||
import org.apache.gravitino.NameIdentifier; | ||
import org.apache.gravitino.cli.ErrorMessages; | ||
import org.apache.gravitino.client.GravitinoClient; | ||
import org.apache.gravitino.exceptions.NoSuchCatalogException; | ||
import org.apache.gravitino.exceptions.NoSuchFilesetException; | ||
import org.apache.gravitino.exceptions.NoSuchMetalakeException; | ||
import org.apache.gravitino.exceptions.NoSuchSchemaException; | ||
import org.apache.gravitino.file.FilesetChange; | ||
|
||
/** Update the comment of a catalog. */ | ||
public class UpdateFilesetComment extends Command { | ||
|
||
protected final String metalake; | ||
protected final String catalog; | ||
protected final String schema; | ||
protected final String fileset; | ||
protected final String comment; | ||
|
||
/** | ||
* Update the comment of a fileset. | ||
* | ||
* @param url The URL of the Gravitino server. | ||
* @param ignoreVersions If true don't check the client/server versions match. | ||
* @param metalake The name of the metalake. | ||
* @param catalog The name of the catalog. | ||
* @param schema The name of the schema. | ||
* @param fileset The name of the fileset. | ||
* @param comment New metalake comment. | ||
*/ | ||
public UpdateFilesetComment( | ||
String url, | ||
boolean ignoreVersions, | ||
String metalake, | ||
String catalog, | ||
String schema, | ||
String fileset, | ||
String comment) { | ||
super(url, ignoreVersions); | ||
this.metalake = metalake; | ||
this.catalog = catalog; | ||
this.schema = schema; | ||
this.fileset = fileset; | ||
this.comment = comment; | ||
} | ||
|
||
/** Update the comment of a catalog. */ | ||
public void handle() { | ||
try { | ||
NameIdentifier filesetName = NameIdentifier.of(schema, fileset); | ||
GravitinoClient client = buildClient(metalake); | ||
FilesetChange change = FilesetChange.updateComment(comment); | ||
|
||
client.loadCatalog(catalog).asFilesetCatalog().alterFileset(filesetName, change); | ||
} catch (NoSuchMetalakeException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_METALAKE); | ||
return; | ||
} catch (NoSuchCatalogException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_CATALOG); | ||
return; | ||
} catch (NoSuchSchemaException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_SCHEMA); | ||
return; | ||
} catch (NoSuchFilesetException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_FILESET); | ||
return; | ||
} catch (Exception exp) { | ||
System.err.println(exp.getMessage()); | ||
return; | ||
} | ||
|
||
System.out.println(fileset + " comment changed."); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
clients/cli/src/main/java/org/apache/gravitino/cli/commands/UpdateFilesetName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.gravitino.cli.commands; | ||
|
||
import org.apache.gravitino.NameIdentifier; | ||
import org.apache.gravitino.cli.ErrorMessages; | ||
import org.apache.gravitino.client.GravitinoClient; | ||
import org.apache.gravitino.exceptions.NoSuchCatalogException; | ||
import org.apache.gravitino.exceptions.NoSuchFilesetException; | ||
import org.apache.gravitino.exceptions.NoSuchMetalakeException; | ||
import org.apache.gravitino.exceptions.NoSuchSchemaException; | ||
import org.apache.gravitino.file.FilesetChange; | ||
|
||
/** Update the name of a fileset. */ | ||
public class UpdateFilesetName extends Command { | ||
|
||
protected final String metalake; | ||
protected final String catalog; | ||
protected final String schema; | ||
protected final String fileset; | ||
protected final String name; | ||
|
||
/** | ||
* Update the name of a fileset. | ||
* | ||
* @param url The URL of the Gravitino server. | ||
* @param ignoreVersions If true don't check the client/server versions match. | ||
* @param metalake The name of the metalake. | ||
* @param catalog The name of the catalog. | ||
* @param schema The name of the schema. | ||
* @param fileset The name of the fileset. | ||
* @param name The new metalake name. | ||
*/ | ||
public UpdateFilesetName( | ||
String url, | ||
boolean ignoreVersions, | ||
String metalake, | ||
String catalog, | ||
String schema, | ||
String fileset, | ||
String name) { | ||
super(url, ignoreVersions); | ||
this.metalake = metalake; | ||
this.catalog = catalog; | ||
this.schema = schema; | ||
this.fileset = fileset; | ||
this.name = name; | ||
} | ||
|
||
/** Update the name of a catalog. */ | ||
public void handle() { | ||
try { | ||
NameIdentifier filesetName = NameIdentifier.of(schema, fileset); | ||
GravitinoClient client = buildClient(metalake); | ||
FilesetChange change = FilesetChange.rename(name); | ||
client.loadCatalog(catalog).asFilesetCatalog().alterFileset(filesetName, change); | ||
} catch (NoSuchMetalakeException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_METALAKE); | ||
return; | ||
} catch (NoSuchCatalogException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_CATALOG); | ||
return; | ||
} catch (NoSuchSchemaException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_SCHEMA); | ||
return; | ||
} catch (NoSuchFilesetException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_FILESET); | ||
return; | ||
} catch (Exception exp) { | ||
System.err.println(exp.getMessage()); | ||
return; | ||
} | ||
|
||
System.out.println(fileset + " name changed."); | ||
} | ||
} |