-
Notifications
You must be signed in to change notification settings - Fork 337
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
Showing
38 changed files
with
1,048 additions
and
49 deletions.
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
74 changes: 74 additions & 0 deletions
74
api/src/main/java/com/datastrato/gravitino/TestOperations.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,74 @@ | ||
/* | ||
* 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 com.datastrato.gravitino; | ||
|
||
import com.google.common.base.Preconditions; | ||
import java.util.Map; | ||
|
||
public interface TestOperations { | ||
/** | ||
* Test whether a catalog can be created with the specified parameters, without actually creating | ||
* it. | ||
* | ||
* @param catalogName the name of the catalog. | ||
* @param type the type of the catalog. | ||
* @param provider the provider of the catalog. | ||
* @param comment the comment of the catalog. | ||
* @param properties the properties of the catalog. | ||
* @return The test result. | ||
*/ | ||
TestResult testCatalogCreation( | ||
String catalogName, | ||
Catalog.Type type, | ||
String provider, | ||
String comment, | ||
Map<String, String> properties); | ||
|
||
interface TestResult { | ||
TestResult VALID = new TestResultImpl(true, null); | ||
|
||
static TestResult invalid(Exception exception) { | ||
return new TestResultImpl(false, exception); | ||
} | ||
|
||
boolean valid(); | ||
|
||
Exception exception(); | ||
} | ||
|
||
class TestResultImpl implements TestResult { | ||
private boolean valid; | ||
private Exception exception; | ||
|
||
private TestResultImpl(boolean valid, Exception exception) { | ||
Preconditions.checkArgument( | ||
valid || exception != null, "exception is required when valid is false"); | ||
this.valid = valid; | ||
this.exception = exception; | ||
} | ||
|
||
public boolean valid() { | ||
return valid; | ||
} | ||
|
||
public Exception exception() { | ||
return exception; | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
api/src/main/java/com/datastrato/gravitino/exceptions/ConnectionFailedException.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,49 @@ | ||
/* | ||
* 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 com.datastrato.gravitino.exceptions; | ||
|
||
import com.google.errorprone.annotations.FormatMethod; | ||
import com.google.errorprone.annotations.FormatString; | ||
|
||
/** An exception thrown when a connect to catalog failed. */ | ||
public class ConnectionFailedException extends GravitinoRuntimeException { | ||
/** | ||
* Constructs a new exception with the specified detail message. | ||
* | ||
* @param cause the cause. | ||
* @param errorMessageTemplate the detail message. | ||
* @param args the arguments to the message. | ||
*/ | ||
@FormatMethod | ||
public ConnectionFailedException( | ||
Throwable cause, @FormatString String errorMessageTemplate, Object... args) { | ||
super(cause, errorMessageTemplate, args); | ||
} | ||
|
||
/** | ||
* Constructs a new exception with the specified detail message. | ||
* | ||
* @param errorMessageTemplate the detail message. | ||
* @param args the arguments to the message. | ||
*/ | ||
@FormatMethod | ||
public ConnectionFailedException(@FormatString String errorMessageTemplate, Object... args) { | ||
super(errorMessageTemplate, args); | ||
} | ||
} |
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
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
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
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
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
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
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
Oops, something went wrong.