-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support common jdbc catalog lock for filesystem catalog
- Loading branch information
1 parent
3237e1a
commit 11154c3
Showing
20 changed files
with
334 additions
and
21 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
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
29 changes: 29 additions & 0 deletions
29
paimon-core/src/main/java/org/apache/paimon/catalog/CatalogLockContextFactory.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,29 @@ | ||
/* | ||
* 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.paimon.catalog; | ||
|
||
import org.apache.paimon.factories.Factory; | ||
import org.apache.paimon.options.Options; | ||
|
||
import java.io.Serializable; | ||
|
||
/** Context for lock context factory to create lock. */ | ||
public interface CatalogLockContextFactory extends Factory, Serializable { | ||
CatalogLockContext createLockContext(Options lockOptions, boolean closeConnectionsUsed); | ||
} |
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
37 changes: 37 additions & 0 deletions
37
paimon-core/src/main/java/org/apache/paimon/jdbc/JdbcCatalogLockContextFactory.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,37 @@ | ||
/* | ||
* 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.paimon.jdbc; | ||
|
||
import org.apache.paimon.catalog.CatalogLockContext; | ||
import org.apache.paimon.catalog.CatalogLockContextFactory; | ||
import org.apache.paimon.options.Options; | ||
|
||
/** Factory for jdbc catalog lock context. */ | ||
public class JdbcCatalogLockContextFactory implements CatalogLockContextFactory { | ||
|
||
@Override | ||
public String identifier() { | ||
return JdbcCatalogLockFactory.IDENTIFIER; | ||
} | ||
|
||
@Override | ||
public CatalogLockContext createLockContext(Options lockOptions, boolean closeConnectionsUsed) { | ||
return new JdbcCatalogLockContext(lockOptions, closeConnectionsUsed); | ||
} | ||
} |
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
72 changes: 72 additions & 0 deletions
72
paimon-core/src/test/java/org/apache/paimon/catalog/FileSystemCatalogTest.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,72 @@ | ||
/* | ||
* 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.paimon.catalog; | ||
|
||
import org.apache.paimon.fs.Path; | ||
import org.apache.paimon.jdbc.JdbcCatalog; | ||
import org.apache.paimon.options.CatalogOptions; | ||
import org.apache.paimon.options.Options; | ||
|
||
import org.apache.paimon.shade.guava30.com.google.common.collect.Maps; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** Tests for {@link FileSystemCatalog}. */ | ||
public class FileSystemCatalogTest extends CatalogTestBase { | ||
|
||
@BeforeEach | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
catalog = initCatalog(Maps.newHashMap()); | ||
} | ||
|
||
private FileSystemCatalog initCatalog(Map<String, String> props) { | ||
Map<String, String> properties = Maps.newHashMap(); | ||
properties.put( | ||
AbstractCatalog.LOCK_PROP_PREFIX + CatalogOptions.URI.key(), | ||
"jdbc:sqlite:file::memory:?ic" + UUID.randomUUID().toString().replace("-", "")); | ||
|
||
properties.put( | ||
AbstractCatalog.LOCK_PROP_PREFIX + JdbcCatalog.PROPERTY_PREFIX + "username", | ||
"user"); | ||
properties.put( | ||
AbstractCatalog.LOCK_PROP_PREFIX + JdbcCatalog.PROPERTY_PREFIX + "password", | ||
"password"); | ||
properties.put(CatalogOptions.WAREHOUSE.key(), warehouse); | ||
properties.put(CatalogOptions.LOCK_ENABLED.key(), "true"); | ||
properties.put(CatalogOptions.LOCK_TYPE.key(), "jdbc"); | ||
properties.putAll(props); | ||
FileSystemCatalog catalog = | ||
new FileSystemCatalog(fileIO, new Path(warehouse), Options.fromMap(properties)); | ||
return catalog; | ||
} | ||
|
||
@Override | ||
public void testListDatabasesWhenNoDatabases() { | ||
List<String> databases = catalog.listDatabases(); | ||
assertThat(databases).isEqualTo(new ArrayList<>()); | ||
} | ||
} |
Oops, something went wrong.