Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxiaojian committed Mar 1, 2024
1 parent fec51fd commit 558025f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.sql.SQLException;

/** Jdbc distributed lock interface. */
public abstract class AbstractDistributedLockTable implements JdbcDistributedLockTable {
public abstract class AbstractDistributedLockDialect implements JdbcDistributedLockDialect {

@Override
public void createTable(JdbcClientPool connections) throws SQLException, InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

package org.apache.paimon.jdbc;

class DistributedLockFactory {
static JdbcDistributedLockTable create(String protocol) {
class DistributedLockDialectFactory {
static JdbcDistributedLockDialect create(String protocol) {
JdbcProtocol type = JdbcProtocol.valueOf(protocol.toUpperCase());
switch (type) {
case SQLITE:
return new SqlLiteDistributedLockTable();
return new SqlLiteDistributedLockDialect();
case MYSQL:
return new MysqlDistributedLockTable();
return new MysqlDistributedLockDialect();
default:
throw new UnsupportedOperationException(
String.format("Distributed locks based on %s are not supported", protocol));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.sql.SQLException;

/** Jdbc distributed lock interface. */
public interface JdbcDistributedLockTable {
public interface JdbcDistributedLockDialect {
void createTable(JdbcClientPool connections) throws SQLException, InterruptedException;

boolean lockAcquire(JdbcClientPool connections, String lockId, long timeoutMillSeconds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,14 @@ private static String insertPropertiesStatement(int size) {

public static void createDistributedLockTable(JdbcClientPool connections)
throws SQLException, InterruptedException {
DistributedLockFactory.create(connections.getProtocol()).createTable(connections);
DistributedLockDialectFactory.create(connections.getProtocol()).createTable(connections);
}

public static boolean acquire(
JdbcClientPool connections, String lockId, long timeoutMillSeconds)
throws SQLException, InterruptedException {
JdbcDistributedLockTable jdbcDistributedLockTable =
DistributedLockFactory.create(connections.getProtocol());
JdbcDistributedLockDialect jdbcDistributedLockTable =
DistributedLockDialectFactory.create(connections.getProtocol());
// Check and clear expire lock.
int affectedRows = jdbcDistributedLockTable.tryReleaseTimedOutLock(connections, lockId);
if (affectedRows > 0) {
Expand All @@ -425,6 +425,7 @@ public static boolean acquire(

public static void release(JdbcClientPool connections, String lockId)
throws SQLException, InterruptedException {
DistributedLockFactory.create(connections.getProtocol()).releaseLock(connections, lockId);
DistributedLockDialectFactory.create(connections.getProtocol())
.releaseLock(connections, lockId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.apache.paimon.jdbc;

/** Distributed lock implementation based on sqlite table. */
public class MysqlDistributedLockTable extends AbstractDistributedLockTable {
public class MysqlDistributedLockDialect extends AbstractDistributedLockDialect {

@Override
public String getCreateTableSql() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.apache.paimon.jdbc;

/** Distributed lock implementation based on sqlite table. */
public class SqlLiteDistributedLockTable extends AbstractDistributedLockTable {
public class SqlLiteDistributedLockDialect extends AbstractDistributedLockDialect {

@Override
public String getCreateTableSql() {
Expand Down

0 comments on commit 558025f

Please sign in to comment.