diff --git a/paimon-core/src/main/java/org/apache/paimon/AbstractFileStore.java b/paimon-core/src/main/java/org/apache/paimon/AbstractFileStore.java index a6da6d58aa7a..d9a1929dec17 100644 --- a/paimon-core/src/main/java/org/apache/paimon/AbstractFileStore.java +++ b/paimon-core/src/main/java/org/apache/paimon/AbstractFileStore.java @@ -267,8 +267,7 @@ public FileStoreCommitImpl newCommit(String commitUser, List cal SnapshotManager snapshotManager = snapshotManager(); SnapshotCommit snapshotCommit = catalogEnvironment.snapshotCommit(snapshotManager); if (snapshotCommit == null) { - snapshotCommit = - new RenamingSnapshotCommit(snapshotManager, Lock.emptyFactory().create()); + snapshotCommit = new RenamingSnapshotCommit(snapshotManager, Lock.empty()); } return new FileStoreCommitImpl( snapshotCommit, diff --git a/paimon-core/src/main/java/org/apache/paimon/catalog/FileSystemCatalog.java b/paimon-core/src/main/java/org/apache/paimon/catalog/FileSystemCatalog.java index 38b1214829f3..c1cc5bc230e1 100644 --- a/paimon-core/src/main/java/org/apache/paimon/catalog/FileSystemCatalog.java +++ b/paimon-core/src/main/java/org/apache/paimon/catalog/FileSystemCatalog.java @@ -134,7 +134,7 @@ public T runWithLock(Identifier identifier, Callable callable) throws Exc lockFactory .map(factory -> factory.createLock(lockContext().orElse(null))) .map(l -> Lock.fromCatalog(l, identifier)) - .orElseGet(() -> Lock.emptyFactory().create())) { + .orElseGet(Lock::empty)) { return lock.runWithLock(callable); } } diff --git a/paimon-core/src/main/java/org/apache/paimon/catalog/RenamingSnapshotCommit.java b/paimon-core/src/main/java/org/apache/paimon/catalog/RenamingSnapshotCommit.java index 5575252c05af..cc7e4d06b5f3 100644 --- a/paimon-core/src/main/java/org/apache/paimon/catalog/RenamingSnapshotCommit.java +++ b/paimon-core/src/main/java/org/apache/paimon/catalog/RenamingSnapshotCommit.java @@ -99,7 +99,7 @@ public SnapshotCommit create(Identifier identifier, SnapshotManager snapshotMana Optional.ofNullable(lockFactory) .map(factory -> factory.createLock(lockContext)) .map(l -> Lock.fromCatalog(l, identifier)) - .orElseGet(() -> Lock.emptyFactory().create()); + .orElseGet(Lock::empty); return new RenamingSnapshotCommit(snapshotManager, lock); } diff --git a/paimon-core/src/main/java/org/apache/paimon/operation/Lock.java b/paimon-core/src/main/java/org/apache/paimon/operation/Lock.java index 76cd8b178d2c..b65e3c3d0c59 100644 --- a/paimon-core/src/main/java/org/apache/paimon/operation/Lock.java +++ b/paimon-core/src/main/java/org/apache/paimon/operation/Lock.java @@ -20,13 +20,8 @@ import org.apache.paimon.annotation.Public; import org.apache.paimon.catalog.CatalogLock; -import org.apache.paimon.catalog.CatalogLockContext; -import org.apache.paimon.catalog.CatalogLockFactory; import org.apache.paimon.catalog.Identifier; -import javax.annotation.Nullable; - -import java.io.Serializable; import java.util.concurrent.Callable; /** @@ -40,57 +35,8 @@ public interface Lock extends AutoCloseable { /** Run with lock. */ T runWithLock(Callable callable) throws Exception; - /** A factory to create {@link Lock}. */ - interface Factory extends Serializable { - Lock create(); - } - - static Factory factory( - @Nullable CatalogLockFactory lockFactory, - @Nullable CatalogLockContext lockContext, - Identifier tablePath) { - return lockFactory == null - ? new EmptyFactory() - : new LockFactory(lockFactory, lockContext, tablePath); - } - - static Factory emptyFactory() { - return new EmptyFactory(); - } - - /** A {@link Factory} creating lock from catalog. */ - class LockFactory implements Factory { - - private static final long serialVersionUID = 1L; - - private final CatalogLockFactory lockFactory; - private final CatalogLockContext lockContext; - private final Identifier tablePath; - - public LockFactory( - CatalogLockFactory lockFactory, - CatalogLockContext lockContext, - Identifier tablePath) { - this.lockFactory = lockFactory; - this.lockContext = lockContext; - this.tablePath = tablePath; - } - - @Override - public Lock create() { - return fromCatalog(lockFactory.createLock(lockContext), tablePath); - } - } - - /** A {@link Factory} creating empty lock. */ - class EmptyFactory implements Factory { - - private static final long serialVersionUID = 1L; - - @Override - public Lock create() { - return new EmptyLock(); - } + static Lock empty() { + return new EmptyLock(); } /** An empty lock. */ diff --git a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java index 91024867b7ea..7faa853be9d4 100644 --- a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java +++ b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java @@ -318,7 +318,7 @@ private static MockResponse commitTableApiHandler( FileStoreTable table = (FileStoreTable) catalog.getTable(Identifier.create(databaseName, tableName)); RenamingSnapshotCommit commit = - new RenamingSnapshotCommit(table.snapshotManager(), Lock.emptyFactory().create()); + new RenamingSnapshotCommit(table.snapshotManager(), Lock.empty()); String branchName = requestBody.getIdentifier().getBranchName(); if (branchName == null) { branchName = "main";