This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new bfde8d8dd6a Rename ConnectionResourceLock (#34117)
bfde8d8dd6a is described below
commit bfde8d8dd6aa3d52db5beb5fb897b3e5b37d5e11
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Dec 22 00:23:32 2024 +0800
Rename ConnectionResourceLock (#34117)
---
.../backend/connector/ProxyDatabaseConnectionManager.java | 4 ++--
.../{ResourceLock.java => ConnectionResourceLock.java} | 4 ++--
...sourceLockTest.java => ConnectionResourceLockTest.java} | 14 +++++++-------
.../frontend/netty/FrontendChannelInboundHandler.java | 2 +-
.../frontend/mysql/command/MySQLCommandExecuteEngine.java | 2 +-
.../postgresql/command/PostgreSQLCommandExecuteEngine.java | 2 +-
.../command/PostgreSQLCommandExecuteEngineTest.java | 8 ++++----
7 files changed, 18 insertions(+), 18 deletions(-)
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManager.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManager.java
index 9ff69eb0ccd..c82dd4c01ab 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManager.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManager.java
@@ -28,7 +28,7 @@ import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.DatabaseConne
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
import
org.apache.shardingsphere.proxy.backend.connector.jdbc.connection.ConnectionPostProcessor;
-import
org.apache.shardingsphere.proxy.backend.connector.jdbc.connection.ResourceLock;
+import
org.apache.shardingsphere.proxy.backend.connector.jdbc.connection.ConnectionResourceLock;
import
org.apache.shardingsphere.proxy.backend.connector.jdbc.transaction.BackendTransactionManager;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import
org.apache.shardingsphere.proxy.backend.exception.BackendConnectionException;
@@ -67,7 +67,7 @@ public final class ProxyDatabaseConnectionManager implements
DatabaseConnectionM
private final Collection<ConnectionPostProcessor> connectionPostProcessors
= new LinkedList<>();
- private final ResourceLock resourceLock = new ResourceLock();
+ private final ConnectionResourceLock connectionResourceLock = new
ConnectionResourceLock();
private final AtomicBoolean closed = new AtomicBoolean(false);
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/connection/ResourceLock.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/connection/ConnectionResourceLock.java
similarity index 96%
rename from
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/connection/ResourceLock.java
rename to
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/connection/ConnectionResourceLock.java
index 2eaf8c17ffb..6a8a04312e0 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/connection/ResourceLock.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/connection/ConnectionResourceLock.java
@@ -26,9 +26,9 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
- * Resource lock.
+ * Connection resource lock.
*/
-public final class ResourceLock {
+public final class ConnectionResourceLock {
private static final long DEFAULT_TIMEOUT_MILLISECONDS = 200L;
diff --git
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/connection/ResourceLockTest.java
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/connection/ConnectionResourceLockTest.java
similarity index 84%
rename from
proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/connection/ResourceLockTest.java
rename to
proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/connection/ConnectionResourceLockTest.java
index 7d3ac071914..fae1d2924ae 100644
---
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/connection/ResourceLockTest.java
+++
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/connection/ConnectionResourceLockTest.java
@@ -40,7 +40,7 @@ import static org.mockito.Mockito.when;
@ExtendWith(AutoMockExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
-class ResourceLockTest {
+class ConnectionResourceLockTest {
@Mock
private ChannelHandlerContext channelHandlerContext;
@@ -49,7 +49,7 @@ class ResourceLockTest {
private Channel channel;
@Mock
- private ResourceLock resourceLock;
+ private ConnectionResourceLock connectionResourceLock;
@Test
void assertDoAwait() throws NoSuchFieldException, IllegalAccessException {
@@ -57,10 +57,10 @@ class ResourceLockTest {
when(channel.isActive()).thenReturn(true);
when(channelHandlerContext.channel()).thenReturn(channel);
ExecutorService executorService = Executors.newFixedThreadPool(1);
- executorService.submit(() ->
resourceLock.doAwait(channelHandlerContext));
+ executorService.submit(() ->
connectionResourceLock.doAwait(channelHandlerContext));
Awaitility.await().pollDelay(200L, TimeUnit.MILLISECONDS).until(() ->
true);
-
Plugins.getMemberAccessor().set(ResourceLock.class.getDeclaredField("condition"),
resourceLock, new ReentrantLock().newCondition());
- verify(resourceLock, times(1)).doAwait(channelHandlerContext);
+
Plugins.getMemberAccessor().set(ConnectionResourceLock.class.getDeclaredField("condition"),
connectionResourceLock, new ReentrantLock().newCondition());
+ verify(connectionResourceLock,
times(1)).doAwait(channelHandlerContext);
}
@Test
@@ -72,9 +72,9 @@ class ResourceLockTest {
ExecutorService executorService = Executors.newFixedThreadPool(1);
executorService.submit(() -> {
Awaitility.await().pollDelay(50L, TimeUnit.MILLISECONDS).until(()
-> true);
- resourceLock.doNotify();
+ connectionResourceLock.doNotify();
});
- resourceLock.doAwait(channelHandlerContext);
+ connectionResourceLock.doAwait(channelHandlerContext);
assertTrue(System.currentTimeMillis() >= startTime);
}
}
diff --git
a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
index fcfb4300252..d3ea1b3a4b0 100644
---
a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
+++
b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
@@ -113,7 +113,7 @@ public final class FrontendChannelInboundHandler extends
ChannelInboundHandlerAd
@Override
public void channelWritabilityChanged(final ChannelHandlerContext context)
{
if (context.channel().isWritable()) {
-
connectionSession.getDatabaseConnectionManager().getResourceLock().doNotify();
+
connectionSession.getDatabaseConnectionManager().getConnectionResourceLock().doNotify();
}
}
}
diff --git
a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
index 2782618fb81..6d508b74477 100644
---
a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
+++
b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
@@ -74,7 +74,7 @@ public final class MySQLCommandExecuteEngine implements
CommandExecuteEngine {
int flushThreshold =
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD);
while (queryCommandExecutor.next()) {
count++;
- databaseConnectionManager.getResourceLock().doAwait(context);
+
databaseConnectionManager.getConnectionResourceLock().doAwait(context);
DatabasePacket dataValue =
queryCommandExecutor.getQueryRowPacket();
context.write(dataValue);
if (flushThreshold == count) {
diff --git
a/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
b/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
index 3ac5579faee..bb086836d66 100644
---
a/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
+++
b/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
@@ -108,7 +108,7 @@ public final class PostgreSQLCommandExecuteEngine
implements CommandExecuteEngin
.getContextManager().getMetaDataContexts().getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD);
while (queryCommandExecutor.next()) {
flushCount++;
- databaseConnectionManager.getResourceLock().doAwait(context);
+
databaseConnectionManager.getConnectionResourceLock().doAwait(context);
DatabasePacket resultValue =
queryCommandExecutor.getQueryRowPacket();
context.write(resultValue);
if (proxyFrontendFlushThreshold == flushCount) {
diff --git
a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
index 0d7481105e7..7171cbedbca 100644
---
a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
+++
b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
@@ -30,7 +30,7 @@ import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory;
import org.apache.shardingsphere.mode.spi.PersistRepository;
import
org.apache.shardingsphere.proxy.backend.connector.ProxyDatabaseConnectionManager;
-import
org.apache.shardingsphere.proxy.backend.connector.jdbc.connection.ResourceLock;
+import
org.apache.shardingsphere.proxy.backend.connector.jdbc.connection.ConnectionResourceLock;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import
org.apache.shardingsphere.proxy.backend.session.transaction.TransactionStatus;
@@ -114,9 +114,9 @@ class PostgreSQLCommandExecuteEngineTest {
when(channel.isActive()).thenReturn(true);
when(queryCommandExecutor.next()).thenReturn(true, false);
when(channel.isWritable()).thenReturn(false, true);
- ResourceLock resourceLock = mock(ResourceLock.class);
+ ConnectionResourceLock connectionResourceLock =
mock(ConnectionResourceLock.class);
ProxyDatabaseConnectionManager databaseConnectionManager =
mock(ProxyDatabaseConnectionManager.class);
-
when(databaseConnectionManager.getResourceLock()).thenReturn(resourceLock);
+
when(databaseConnectionManager.getConnectionResourceLock()).thenReturn(connectionResourceLock);
when(databaseConnectionManager.getConnectionSession()).thenReturn(connectionSession);
PostgreSQLPacket packet = mock(PostgreSQLPacket.class);
when(queryCommandExecutor.getQueryRowPacket()).thenReturn(packet);
@@ -127,7 +127,7 @@ class PostgreSQLCommandExecuteEngineTest {
new ShardingSphereMetaData()), computeNodeInstanceContext,
mock(PersistRepository.class));
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
commandExecuteEngine.writeQueryData(channelHandlerContext,
databaseConnectionManager, queryCommandExecutor, 0);
- verify(resourceLock).doAwait(channelHandlerContext);
+ verify(connectionResourceLock).doAwait(channelHandlerContext);
verify(channelHandlerContext).write(packet);
verify(channelHandlerContext).write(isA(PostgreSQLCommandCompletePacket.class));
verify(channelHandlerContext).write(isA(PostgreSQLReadyForQueryPacket.class));