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 8fe8be930b3 Unify xxxID to xxxId (#25444) 8fe8be930b3 is described below commit 8fe8be930b3ba2a542ad95baf694c71c396270fe Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Thu May 4 00:19:25 2023 +0800 Unify xxxID to xxxId (#25444) --- ...ler.java => MySQLSequenceIdInboundHandler.java} | 2 +- ...java => MySQLSequenceIdInboundHandlerTest.java} | 4 +-- .../kernel/model/ExecutionGroupReportContext.java | 4 +-- .../raw/callback/RawSQLExecutorCallback.java | 4 +-- .../infra/executor/sql/process/Process.java | 2 +- .../infra/executor/sql/process/ProcessEngine.java | 22 ++++++------- ...ProcessIDContext.java => ProcessIdContext.java} | 8 ++--- .../executor/sql/process/ProcessRegistry.java | 18 +++++------ .../executor/sql/process/ProcessEngineTest.java | 8 ++--- ...DContextTest.java => ProcessIdContextTest.java} | 36 +++++++++++----------- .../pipeline/mysql/ingest/client/MySQLClient.java | 4 +-- .../transaction/core/ResourceDataSource.java | 2 +- ...ceIDGenerator.java => ResourceIdGenerator.java} | 6 ++-- ...ratorTest.java => ResourceIdGeneratorTest.java} | 4 +-- .../proxy/frontend/mysql/MySQLFrontendEngine.java | 8 ++--- .../authentication/MySQLAuthenticationEngine.java | 4 +-- ...nerator.java => MySQLStatementIdGenerator.java} | 6 ++-- .../prepare/MySQLComStmtPrepareExecutor.java | 4 +-- .../frontend/mysql/MySQLFrontendEngineTest.java | 10 +++--- ...est.java => MySQLStatementIdGeneratorTest.java} | 10 +++--- .../prepare/MySQLComStmtPrepareExecutorTest.java | 18 +++++------ 21 files changed, 92 insertions(+), 92 deletions(-) diff --git a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/netty/MySQLSequenceIDInboundHandler.java b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/netty/MySQLSequenceIdInboundHandler.java similarity index 96% rename from db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/netty/MySQLSequenceIDInboundHandler.java rename to db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/netty/MySQLSequenceIdInboundHandler.java index ec7d6cf1b5a..a1c3ec4ade6 100644 --- a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/netty/MySQLSequenceIDInboundHandler.java +++ b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/netty/MySQLSequenceIdInboundHandler.java @@ -25,7 +25,7 @@ import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConstants; /** * Handle MySQL sequence ID before sending to downstream. */ -public final class MySQLSequenceIDInboundHandler extends ChannelInboundHandlerAdapter { +public final class MySQLSequenceIdInboundHandler extends ChannelInboundHandlerAdapter { @Override public void channelRead(final ChannelHandlerContext context, final Object msg) { diff --git a/db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/netty/MySQLSequenceIDInboundHandlerTest.java b/db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/netty/MySQLSequenceIdInboundHandlerTest.java similarity index 97% rename from db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/netty/MySQLSequenceIDInboundHandlerTest.java rename to db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/netty/MySQLSequenceIdInboundHandlerTest.java index d64d0d54fca..8d24be50a85 100644 --- a/db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/netty/MySQLSequenceIDInboundHandlerTest.java +++ b/db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/netty/MySQLSequenceIdInboundHandlerTest.java @@ -34,11 +34,11 @@ import java.util.concurrent.atomic.AtomicInteger; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -class MySQLSequenceIDInboundHandlerTest { +class MySQLSequenceIdInboundHandlerTest { @Test void assertChannelReadWithFlowControl() { - EmbeddedChannel channel = new EmbeddedChannel(new FixtureOutboundHandler(), new ProxyFlowControlHandler(), new MySQLSequenceIDInboundHandler(), new FixtureInboundHandler()); + EmbeddedChannel channel = new EmbeddedChannel(new FixtureOutboundHandler(), new ProxyFlowControlHandler(), new MySQLSequenceIdInboundHandler(), new FixtureInboundHandler()); channel.attr(MySQLConstants.MYSQL_SEQUENCE_ID).set(new AtomicInteger()); channel.writeInbound(Unpooled.wrappedBuffer(new byte[1]), Unpooled.wrappedBuffer(new byte[1]), Unpooled.wrappedBuffer(new byte[1])); assertThat(channel.<ByteBuf>readOutbound().readUnsignedByte(), is((short) 1)); diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/model/ExecutionGroupReportContext.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/model/ExecutionGroupReportContext.java index 5d16acf4377..7ba1014c3f0 100644 --- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/model/ExecutionGroupReportContext.java +++ b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/model/ExecutionGroupReportContext.java @@ -35,8 +35,8 @@ public final class ExecutionGroupReportContext { private final Grantee grantee; - // TODO processID should same with connectionID - private final String processID; + // TODO processID should same with connectionId + private final String processId; public ExecutionGroupReportContext(final String databaseName) { this(databaseName, new Grantee("", "")); diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/raw/callback/RawSQLExecutorCallback.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/raw/callback/RawSQLExecutorCallback.java index 8edc78144ee..512c4d043f1 100644 --- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/raw/callback/RawSQLExecutorCallback.java +++ b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/raw/callback/RawSQLExecutorCallback.java @@ -21,7 +21,7 @@ import com.google.common.base.Preconditions; import org.apache.shardingsphere.infra.executor.kernel.model.ExecutorCallback; import org.apache.shardingsphere.infra.executor.sql.execute.engine.raw.RawSQLExecutionUnit; import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult; -import org.apache.shardingsphere.infra.executor.sql.process.ProcessIDContext; +import org.apache.shardingsphere.infra.executor.sql.process.ProcessIdContext; import org.apache.shardingsphere.infra.executor.sql.process.ProcessEngine; import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader; @@ -47,7 +47,7 @@ public final class RawSQLExecutorCallback implements ExecutorCallback<RawSQLExec @Override public Collection<ExecuteResult> execute(final Collection<RawSQLExecutionUnit> inputs, final boolean isTrunkThread) throws SQLException { Collection<ExecuteResult> result = callbacks.iterator().next().execute(inputs, isTrunkThread); - if (!ProcessIDContext.isEmpty()) { + if (!ProcessIdContext.isEmpty()) { for (int i = 0; i < inputs.size(); i++) { processEngine.completeSQLUnitExecution(); } diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/Process.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/Process.java index 1d09b5ccf8e..a7432c56815 100644 --- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/Process.java +++ b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/Process.java @@ -64,7 +64,7 @@ public final class Process { } private Process(final String sql, final ExecutionGroupContext<? extends SQLExecutionUnit> executionGroupContext, final boolean idle) { - id = executionGroupContext.getReportContext().getProcessID(); + id = executionGroupContext.getReportContext().getProcessId(); startMillis = System.currentTimeMillis(); this.sql = sql; databaseName = executionGroupContext.getReportContext().getDatabaseName(); diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngine.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngine.java index 0dc47d491ff..11a5bcbcbdb 100644 --- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngine.java +++ b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngine.java @@ -45,16 +45,16 @@ public final class ProcessEngine { ExecutionGroupContext<? extends SQLExecutionUnit> executionGroupContext = new ExecutionGroupContext<>(Collections.emptyList(), new ExecutionGroupReportContext(databaseName, grantee)); Process process = new Process(executionGroupContext); ProcessRegistry.getInstance().putProcess(process.getId(), process); - return executionGroupContext.getReportContext().getProcessID(); + return executionGroupContext.getReportContext().getProcessId(); } /** * Disconnect. * - * @param processID process ID + * @param processId process ID */ - public void disconnect(final String processID) { - ProcessRegistry.getInstance().removeProcess(processID); + public void disconnect(final String processId) { + ProcessRegistry.getInstance().removeProcess(processId); } @@ -66,7 +66,7 @@ public final class ProcessEngine { */ public void executeSQL(final ExecutionGroupContext<? extends SQLExecutionUnit> executionGroupContext, final QueryContext queryContext) { if (isMySQLDDLOrDMLStatement(queryContext.getSqlStatementContext().getSqlStatement())) { - ProcessIDContext.set(executionGroupContext.getReportContext().getProcessID()); + ProcessIdContext.set(executionGroupContext.getReportContext().getProcessId()); Process process = new Process(queryContext.getSql(), executionGroupContext); ProcessRegistry.getInstance().putProcess(process.getId(), process); } @@ -76,27 +76,27 @@ public final class ProcessEngine { * Complete SQL unit execution. */ public void completeSQLUnitExecution() { - if (ProcessIDContext.isEmpty()) { + if (ProcessIdContext.isEmpty()) { return; } - ProcessRegistry.getInstance().getProcess(ProcessIDContext.get()).completeExecutionUnit(); + ProcessRegistry.getInstance().getProcess(ProcessIdContext.get()).completeExecutionUnit(); } /** * Complete SQL execution. */ public void completeSQLExecution() { - if (ProcessIDContext.isEmpty()) { + if (ProcessIdContext.isEmpty()) { return; } - Process process = ProcessRegistry.getInstance().getProcess(ProcessIDContext.get()); + Process process = ProcessRegistry.getInstance().getProcess(ProcessIdContext.get()); if (null == process) { return; } ExecutionGroupContext<? extends SQLExecutionUnit> executionGroupContext = new ExecutionGroupContext<>( Collections.emptyList(), new ExecutionGroupReportContext(process.getDatabaseName(), new Grantee(process.getUsername(), process.getHostname()))); - ProcessRegistry.getInstance().putProcess(ProcessIDContext.get(), new Process(executionGroupContext)); - ProcessIDContext.remove(); + ProcessRegistry.getInstance().putProcess(ProcessIdContext.get(), new Process(executionGroupContext)); + ProcessIdContext.remove(); } private boolean isMySQLDDLOrDMLStatement(final SQLStatement sqlStatement) { diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessIDContext.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessIdContext.java similarity index 91% rename from infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessIDContext.java rename to infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessIdContext.java index c444515ec9d..efe872f4f2e 100644 --- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessIDContext.java +++ b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessIdContext.java @@ -26,7 +26,7 @@ import lombok.NoArgsConstructor; * Process ID context. */ @NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class ProcessIDContext { +public final class ProcessIdContext { private static final TransmittableThreadLocal<String> PROCESS_ID = new TransmittableThreadLocal<>(); @@ -51,10 +51,10 @@ public final class ProcessIDContext { /** * Set process ID. * - * @param executeId process ID + * @param processId process ID */ - public static void set(final String executeId) { - PROCESS_ID.set(executeId); + public static void set(final String processId) { + PROCESS_ID.set(processId); } /** diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessRegistry.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessRegistry.java index fb0a49b99ea..87cd6a7cd10 100644 --- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessRegistry.java +++ b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessRegistry.java @@ -51,30 +51,30 @@ public final class ProcessRegistry { /** * Put process. * - * @param processID process ID + * @param processId process ID * @param process process */ - public void putProcess(final String processID, final Process process) { - processes.put(processID, process); + public void putProcess(final String processId, final Process process) { + processes.put(processId, process); } /** * Get process. * - * @param processID process ID + * @param processId process ID * @return process */ - public Process getProcess(final String processID) { - return processes.get(processID); + public Process getProcess(final String processId) { + return processes.get(processId); } /** * Remove process. * - * @param processID process ID + * @param processId process ID */ - public void removeProcess(final String processID) { - processes.remove(processID); + public void removeProcess(final String processId) { + processes.remove(processId); } /** diff --git a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngineTest.java b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngineTest.java index 9ae5283c414..3d1ab0341a3 100644 --- a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngineTest.java +++ b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngineTest.java @@ -59,14 +59,14 @@ class ProcessEngineTest { void assertExecuteSQL() { ExecutionGroupContext<? extends SQLExecutionUnit> executionGroupContext = mockExecutionGroupContext(); new ProcessEngine().executeSQL(executionGroupContext, new QueryContext(new UpdateStatementContext(getSQLStatement()), null, null)); - verify(processRegistry).putProcess(eq(executionGroupContext.getReportContext().getProcessID()), any()); + verify(processRegistry).putProcess(eq(executionGroupContext.getReportContext().getProcessId()), any()); } @SuppressWarnings("unchecked") private ExecutionGroupContext<? extends SQLExecutionUnit> mockExecutionGroupContext() { ExecutionGroupContext<? extends SQLExecutionUnit> result = mock(ExecutionGroupContext.class); ExecutionGroupReportContext reportContext = mock(ExecutionGroupReportContext.class); - when(reportContext.getProcessID()).thenReturn(UUID.randomUUID().toString()); + when(reportContext.getProcessId()).thenReturn(UUID.randomUUID().toString()); when(result.getReportContext()).thenReturn(reportContext); return result; } @@ -80,10 +80,10 @@ class ProcessEngineTest { @Test void assertCompleteSQLUnitExecution() { - ProcessIDContext.set("foo_id"); + ProcessIdContext.set("foo_id"); when(processRegistry.getProcess("foo_id")).thenReturn(mock(Process.class)); new ProcessEngine().completeSQLUnitExecution(); verify(processRegistry).getProcess("foo_id"); - ProcessIDContext.remove(); + ProcessIdContext.remove(); } } diff --git a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessIDContextTest.java b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessIdContextTest.java similarity index 64% rename from infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessIDContextTest.java rename to infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessIdContextTest.java index a0e61c6c793..5a70bc485ba 100644 --- a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessIDContextTest.java +++ b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessIdContextTest.java @@ -26,42 +26,42 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -class ProcessIDContextTest { +class ProcessIdContextTest { @AfterEach void tearDown() { - ProcessIDContext.remove(); + ProcessIdContext.remove(); } @Test void assertIsEmpty() { - assertTrue(ProcessIDContext.isEmpty()); - ProcessIDContext.set("123e4567e89b12d3a456426655440000"); - assertFalse(ProcessIDContext.isEmpty()); + assertTrue(ProcessIdContext.isEmpty()); + ProcessIdContext.set("123e4567e89b12d3a456426655440000"); + assertFalse(ProcessIdContext.isEmpty()); } @Test void assertGet() { - assertNull(ProcessIDContext.get()); - ProcessIDContext.set("123e4567e89b12d3a456426655440000"); - assertThat(ProcessIDContext.get(), is("123e4567e89b12d3a456426655440000")); + assertNull(ProcessIdContext.get()); + ProcessIdContext.set("123e4567e89b12d3a456426655440000"); + assertThat(ProcessIdContext.get(), is("123e4567e89b12d3a456426655440000")); } @Test void assertSet() { - assertNull(ProcessIDContext.get()); - ProcessIDContext.set("123e4567e89b12d3a456426655440000"); - assertThat(ProcessIDContext.get(), is("123e4567e89b12d3a456426655440000")); - ProcessIDContext.set("123e4567e89b12d3a456426655440001"); - assertThat(ProcessIDContext.get(), is("123e4567e89b12d3a456426655440001")); + assertNull(ProcessIdContext.get()); + ProcessIdContext.set("123e4567e89b12d3a456426655440000"); + assertThat(ProcessIdContext.get(), is("123e4567e89b12d3a456426655440000")); + ProcessIdContext.set("123e4567e89b12d3a456426655440001"); + assertThat(ProcessIdContext.get(), is("123e4567e89b12d3a456426655440001")); } @Test void assertRemove() { - assertNull(ProcessIDContext.get()); - ProcessIDContext.set("123e4567e89b12d3a456426655440000"); - assertThat(ProcessIDContext.get(), is("123e4567e89b12d3a456426655440000")); - ProcessIDContext.remove(); - assertNull(ProcessIDContext.get()); + assertNull(ProcessIdContext.get()); + ProcessIdContext.set("123e4567e89b12d3a456426655440000"); + assertThat(ProcessIdContext.get(), is("123e4567e89b12d3a456426655440000")); + ProcessIdContext.remove(); + assertNull(ProcessIdContext.get()); } } diff --git a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java index 97427a29292..0558378c79e 100644 --- a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java +++ b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java @@ -44,7 +44,7 @@ import org.apache.shardingsphere.data.pipeline.mysql.ingest.client.netty.MySQLNe import org.apache.shardingsphere.db.protocol.codec.PacketCodec; import org.apache.shardingsphere.db.protocol.mysql.codec.MySQLPacketCodecEngine; import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConstants; -import org.apache.shardingsphere.db.protocol.mysql.netty.MySQLSequenceIDInboundHandler; +import org.apache.shardingsphere.db.protocol.mysql.netty.MySQLSequenceIdInboundHandler; import org.apache.shardingsphere.db.protocol.mysql.packet.command.binlog.MySQLComBinlogDumpCommandPacket; import org.apache.shardingsphere.db.protocol.mysql.packet.command.binlog.MySQLComRegisterSlaveCommandPacket; import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.query.MySQLComQueryPacket; @@ -103,7 +103,7 @@ public final class MySQLClient { socketChannel.attr(MySQLConstants.MYSQL_SEQUENCE_ID).set(new AtomicInteger()); socketChannel.pipeline().addLast(new ChannelAttrInitializer()); socketChannel.pipeline().addLast(new PacketCodec(new MySQLPacketCodecEngine())); - socketChannel.pipeline().addLast(new MySQLSequenceIDInboundHandler()); + socketChannel.pipeline().addLast(new MySQLSequenceIdInboundHandler()); socketChannel.pipeline().addLast(new MySQLNegotiatePackageDecoder()); socketChannel.pipeline().addLast(new MySQLCommandPacketDecoder()); socketChannel.pipeline().addLast(new MySQLNegotiateHandler(connectInfo.getUsername(), connectInfo.getPassword(), responseCallback)); diff --git a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/core/ResourceDataSource.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/core/ResourceDataSource.java index 0aa18b5d921..68de600b28b 100644 --- a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/core/ResourceDataSource.java +++ b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/core/ResourceDataSource.java @@ -43,7 +43,7 @@ public final class ResourceDataSource { Preconditions.checkState(2 == databaseAndDataSourceName.length, String.format("Database and data source name must be provided,`%s`.", originalName)); this.originalName = originalName; this.dataSource = dataSource; - uniqueResourceName = ResourceIDGenerator.getInstance().nextId() + databaseAndDataSourceName[1]; + uniqueResourceName = ResourceIdGenerator.getInstance().nextId() + databaseAndDataSourceName[1]; ShardingSpherePreconditions.checkState(uniqueResourceName.getBytes().length <= MAX_RESOURCE_NAME_LENGTH, () -> new XAResourceNameLengthExceededException(uniqueResourceName)); } } diff --git a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/core/ResourceIDGenerator.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/core/ResourceIdGenerator.java similarity index 88% rename from kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/core/ResourceIDGenerator.java rename to kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/core/ResourceIdGenerator.java index bb65f0e6c54..43d50d1a3b8 100644 --- a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/core/ResourceIDGenerator.java +++ b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/core/ResourceIdGenerator.java @@ -26,9 +26,9 @@ import java.util.concurrent.atomic.AtomicInteger; * Resource ID generator. */ @NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class ResourceIDGenerator { +public final class ResourceIdGenerator { - private static final ResourceIDGenerator INSTANCE = new ResourceIDGenerator(); + private static final ResourceIdGenerator INSTANCE = new ResourceIdGenerator(); private final AtomicInteger count = new AtomicInteger(); @@ -37,7 +37,7 @@ public final class ResourceIDGenerator { * * @return instance */ - public static ResourceIDGenerator getInstance() { + public static ResourceIdGenerator getInstance() { return INSTANCE; } diff --git a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceIDGeneratorTest.java b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceIdGeneratorTest.java similarity index 92% rename from kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceIDGeneratorTest.java rename to kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceIdGeneratorTest.java index 7795a606a6b..f2088d5f987 100644 --- a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceIDGeneratorTest.java +++ b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceIdGeneratorTest.java @@ -23,11 +23,11 @@ import java.util.regex.Pattern; import static org.junit.jupiter.api.Assertions.assertTrue; -class ResourceIDGeneratorTest { +class ResourceIdGeneratorTest { @Test void assertNextIdProperly() { - assertTrue(isStartWithNumber(ResourceIDGenerator.getInstance().nextId())); + assertTrue(isStartWithNumber(ResourceIdGenerator.getInstance().nextId())); } private boolean isStartWithNumber(final String resourceId) { diff --git a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngine.java b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngine.java index 5fd08a44dff..95ee7fc5069 100644 --- a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngine.java +++ b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngine.java @@ -23,14 +23,14 @@ import org.apache.shardingsphere.db.protocol.codec.DatabasePacketCodecEngine; import org.apache.shardingsphere.db.protocol.mysql.codec.MySQLPacketCodecEngine; import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConstants; import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLServerInfo; -import org.apache.shardingsphere.db.protocol.mysql.netty.MySQLSequenceIDInboundHandler; +import org.apache.shardingsphere.db.protocol.mysql.netty.MySQLSequenceIdInboundHandler; import org.apache.shardingsphere.db.protocol.mysql.packet.MySQLPacket; import org.apache.shardingsphere.proxy.backend.session.ConnectionSession; import org.apache.shardingsphere.proxy.frontend.authentication.AuthenticationEngine; import org.apache.shardingsphere.proxy.frontend.command.CommandExecuteEngine; import org.apache.shardingsphere.proxy.frontend.mysql.authentication.MySQLAuthenticationEngine; import org.apache.shardingsphere.proxy.frontend.mysql.command.MySQLCommandExecuteEngine; -import org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLStatementIDGenerator; +import org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLStatementIdGenerator; import org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler; import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine; @@ -51,7 +51,7 @@ public final class MySQLFrontendEngine implements DatabaseProtocolFrontendEngine @Override public void initChannel(final Channel channel) { channel.attr(MySQLConstants.MYSQL_SEQUENCE_ID).set(new AtomicInteger()); - channel.pipeline().addBefore(FrontendChannelInboundHandler.class.getSimpleName(), MySQLSequenceIDInboundHandler.class.getSimpleName(), new MySQLSequenceIDInboundHandler()); + channel.pipeline().addBefore(FrontendChannelInboundHandler.class.getSimpleName(), MySQLSequenceIdInboundHandler.class.getSimpleName(), new MySQLSequenceIdInboundHandler()); } @Override @@ -61,7 +61,7 @@ public final class MySQLFrontendEngine implements DatabaseProtocolFrontendEngine @Override public void release(final ConnectionSession connectionSession) { - MySQLStatementIDGenerator.getInstance().unregisterConnection(connectionSession.getConnectionId()); + MySQLStatementIdGenerator.getInstance().unregisterConnection(connectionSession.getConnectionId()); } @Override diff --git a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngine.java b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngine.java index 398589a2d70..9d3667491f7 100644 --- a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngine.java +++ b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngine.java @@ -52,7 +52,7 @@ import org.apache.shardingsphere.proxy.frontend.authentication.Authenticator; import org.apache.shardingsphere.proxy.frontend.authentication.AuthenticatorFactory; import org.apache.shardingsphere.proxy.frontend.connection.ConnectionIdGenerator; import org.apache.shardingsphere.proxy.frontend.mysql.authentication.authenticator.MySQLAuthenticatorType; -import org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLStatementIDGenerator; +import org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLStatementIdGenerator; import org.apache.shardingsphere.proxy.frontend.mysql.ssl.MySQLSSLRequestHandler; import org.apache.shardingsphere.proxy.frontend.ssl.ProxySSLContext; @@ -83,7 +83,7 @@ public final class MySQLAuthenticationEngine implements AuthenticationEngine { context.pipeline().addFirst(MySQLSSLRequestHandler.class.getSimpleName(), new MySQLSSLRequestHandler()); } context.writeAndFlush(new MySQLHandshakePacket(result, sslEnabled, authPluginData)); - MySQLStatementIDGenerator.getInstance().registerConnection(result); + MySQLStatementIdGenerator.getInstance().registerConnection(result); return result; } diff --git a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLStatementIDGenerator.java b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLStatementIdGenerator.java similarity index 91% rename from proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLStatementIDGenerator.java rename to proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLStatementIdGenerator.java index d43619c7a99..53ce77b2f86 100644 --- a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLStatementIDGenerator.java +++ b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLStatementIdGenerator.java @@ -28,9 +28,9 @@ import java.util.concurrent.atomic.AtomicInteger; * Statement ID generator for MySQL. */ @NoArgsConstructor(access = AccessLevel.NONE) -public final class MySQLStatementIDGenerator { +public final class MySQLStatementIdGenerator { - private static final MySQLStatementIDGenerator INSTANCE = new MySQLStatementIDGenerator(); + private static final MySQLStatementIdGenerator INSTANCE = new MySQLStatementIdGenerator(); private final Map<Integer, AtomicInteger> connectionRegistry = new ConcurrentHashMap<>(); @@ -39,7 +39,7 @@ public final class MySQLStatementIDGenerator { * * @return prepared statement registry instance */ - public static MySQLStatementIDGenerator getInstance() { + public static MySQLStatementIdGenerator getInstance() { return INSTANCE; } diff --git a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java index 695e2aa6017..4f50618ee67 100644 --- a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java +++ b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java @@ -46,7 +46,7 @@ import org.apache.shardingsphere.proxy.backend.session.ConnectionSession; import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor; import org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator; import org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLServerPreparedStatement; -import org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLStatementIDGenerator; +import org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLStatementIdGenerator; import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.ParameterMarkerSegment; import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement; import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement; @@ -82,7 +82,7 @@ public final class MySQLComStmtPrepareExecutor implements CommandExecutor { } SQLStatementContext<?> sqlStatementContext = SQLStatementContextFactory.newInstance(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData(), sqlStatement, connectionSession.getDefaultDatabaseName()); - int statementId = MySQLStatementIDGenerator.getInstance().nextStatementId(connectionSession.getConnectionId()); + int statementId = MySQLStatementIdGenerator.getInstance().nextStatementId(connectionSession.getConnectionId()); MySQLServerPreparedStatement serverPreparedStatement = new MySQLServerPreparedStatement(packet.getSql(), sqlStatementContext, new CopyOnWriteArrayList<>()); connectionSession.getServerPreparedStatementRegistry().addPreparedStatement(statementId, serverPreparedStatement); return createPackets(sqlStatementContext, statementId, serverPreparedStatement); diff --git a/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java b/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java index b9bc4fd00e9..6e234a5ed3e 100644 --- a/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java +++ b/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java @@ -20,10 +20,10 @@ package org.apache.shardingsphere.proxy.frontend.mysql; import io.netty.channel.Channel; import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConstants; import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLServerInfo; -import org.apache.shardingsphere.db.protocol.mysql.netty.MySQLSequenceIDInboundHandler; +import org.apache.shardingsphere.db.protocol.mysql.netty.MySQLSequenceIdInboundHandler; import org.apache.shardingsphere.proxy.backend.context.ProxyContext; import org.apache.shardingsphere.proxy.backend.session.ConnectionSession; -import org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLStatementIDGenerator; +import org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLStatementIdGenerator; import org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler; import org.apache.shardingsphere.test.mock.AutoMockExtension; import org.apache.shardingsphere.test.mock.StaticMockSettings; @@ -47,7 +47,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @ExtendWith(AutoMockExtension.class) -@StaticMockSettings({ProxyContext.class, MySQLStatementIDGenerator.class}) +@StaticMockSettings({ProxyContext.class, MySQLStatementIdGenerator.class}) @MockitoSettings(strictness = Strictness.LENIENT) class MySQLFrontendEngineTest { @@ -66,7 +66,7 @@ class MySQLFrontendEngineTest { engine.initChannel(channel); verify(channel.attr(MySQLConstants.MYSQL_SEQUENCE_ID)).set(any(AtomicInteger.class)); verify(channel.pipeline()) - .addBefore(eq(FrontendChannelInboundHandler.class.getSimpleName()), eq(MySQLSequenceIDInboundHandler.class.getSimpleName()), isA(MySQLSequenceIDInboundHandler.class)); + .addBefore(eq(FrontendChannelInboundHandler.class.getSimpleName()), eq(MySQLSequenceIdInboundHandler.class.getSimpleName()), isA(MySQLSequenceIdInboundHandler.class)); } @Test @@ -85,6 +85,6 @@ class MySQLFrontendEngineTest { int connectionId = 1; when(connectionSession.getConnectionId()).thenReturn(connectionId); engine.release(connectionSession); - verify(MySQLStatementIDGenerator.getInstance()).unregisterConnection(connectionId); + verify(MySQLStatementIdGenerator.getInstance()).unregisterConnection(connectionId); } } diff --git a/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLStatementIDGeneratorTest.java b/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLStatementIdGeneratorTest.java similarity index 82% rename from proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLStatementIDGeneratorTest.java rename to proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLStatementIdGeneratorTest.java index 2c3e39c239b..a3e3597c997 100644 --- a/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLStatementIDGeneratorTest.java +++ b/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLStatementIdGeneratorTest.java @@ -24,23 +24,23 @@ import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -class MySQLStatementIDGeneratorTest { +class MySQLStatementIdGeneratorTest { private static final int CONNECTION_ID = 1; @BeforeEach void setup() { - MySQLStatementIDGenerator.getInstance().registerConnection(CONNECTION_ID); + MySQLStatementIdGenerator.getInstance().registerConnection(CONNECTION_ID); } @AfterEach void tearDown() { - MySQLStatementIDGenerator.getInstance().unregisterConnection(CONNECTION_ID); + MySQLStatementIdGenerator.getInstance().unregisterConnection(CONNECTION_ID); } @Test void assertNextStatementId() { - assertThat(MySQLStatementIDGenerator.getInstance().nextStatementId(CONNECTION_ID), is(1)); - assertThat(MySQLStatementIDGenerator.getInstance().nextStatementId(CONNECTION_ID), is(2)); + assertThat(MySQLStatementIdGenerator.getInstance().nextStatementId(CONNECTION_ID), is(1)); + assertThat(MySQLStatementIdGenerator.getInstance().nextStatementId(CONNECTION_ID), is(2)); } } diff --git a/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutorTest.java b/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutorTest.java index 545b2d5cede..20c5795ebbf 100644 --- a/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutorTest.java +++ b/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutorTest.java @@ -46,7 +46,7 @@ import org.apache.shardingsphere.proxy.backend.context.ProxyContext; import org.apache.shardingsphere.proxy.backend.session.ConnectionSession; import org.apache.shardingsphere.proxy.backend.session.ServerPreparedStatementRegistry; import org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLServerPreparedStatement; -import org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLStatementIDGenerator; +import org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLStatementIdGenerator; import org.apache.shardingsphere.sql.parser.api.CacheOption; import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLInsertStatement; import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLSelectStatement; @@ -105,7 +105,7 @@ class MySQLComStmtPrepareExecutorTest { String sql = "select name from foo_db.user where id = ?"; when(packet.getSql()).thenReturn(sql); when(connectionSession.getConnectionId()).thenReturn(1); - MySQLStatementIDGenerator.getInstance().registerConnection(1); + MySQLStatementIdGenerator.getInstance().registerConnection(1); ContextManager contextManager = mockContextManager(); when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager); Iterator<DatabasePacket<?>> actualIterator = new MySQLComStmtPrepareExecutor(packet, connectionSession).execute().iterator(); @@ -119,7 +119,7 @@ class MySQLComStmtPrepareExecutorTest { assertThat(actualPreparedStatement.getSql(), is(sql)); assertThat(actualPreparedStatement.getSqlStatementContext(), instanceOf(SelectStatementContext.class)); assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), instanceOf(MySQLSelectStatement.class)); - MySQLStatementIDGenerator.getInstance().unregisterConnection(1); + MySQLStatementIdGenerator.getInstance().unregisterConnection(1); } @Test @@ -128,7 +128,7 @@ class MySQLComStmtPrepareExecutorTest { when(packet.getSql()).thenReturn(sql); int connectionId = 2; when(connectionSession.getConnectionId()).thenReturn(connectionId); - MySQLStatementIDGenerator.getInstance().registerConnection(connectionId); + MySQLStatementIdGenerator.getInstance().registerConnection(connectionId); ContextManager contextManager = mockContextManager(); when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager); Iterator<DatabasePacket<?>> actualIterator = new MySQLComStmtPrepareExecutor(packet, connectionSession).execute().iterator(); @@ -150,7 +150,7 @@ class MySQLComStmtPrepareExecutorTest { assertThat(actualPreparedStatement.getSql(), is(sql)); assertThat(actualPreparedStatement.getSqlStatementContext(), instanceOf(SelectStatementContext.class)); assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), instanceOf(MySQLSelectStatement.class)); - MySQLStatementIDGenerator.getInstance().unregisterConnection(connectionId); + MySQLStatementIdGenerator.getInstance().unregisterConnection(connectionId); } @Test @@ -160,7 +160,7 @@ class MySQLComStmtPrepareExecutorTest { int connectionId = 2; when(connectionSession.getConnectionId()).thenReturn(connectionId); when(connectionSession.getDefaultDatabaseName()).thenReturn("foo_db"); - MySQLStatementIDGenerator.getInstance().registerConnection(connectionId); + MySQLStatementIdGenerator.getInstance().registerConnection(connectionId); ContextManager contextManager = mockContextManager(); when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager); Iterator<DatabasePacket<?>> actualIterator = new MySQLComStmtPrepareExecutor(packet, connectionSession).execute().iterator(); @@ -182,7 +182,7 @@ class MySQLComStmtPrepareExecutorTest { assertThat(actualPreparedStatement.getSql(), is(sql)); assertThat(actualPreparedStatement.getSqlStatementContext(), instanceOf(InsertStatementContext.class)); assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), instanceOf(MySQLInsertStatement.class)); - MySQLStatementIDGenerator.getInstance().unregisterConnection(connectionId); + MySQLStatementIdGenerator.getInstance().unregisterConnection(connectionId); } private int getColumnDefinitionFlag(final MySQLColumnDefinition41Packet packet) { @@ -197,7 +197,7 @@ class MySQLComStmtPrepareExecutorTest { when(packet.getSql()).thenReturn(sql); when(connectionSession.getConnectionId()).thenReturn(1); when(connectionSession.getDefaultDatabaseName()).thenReturn("foo_db"); - MySQLStatementIDGenerator.getInstance().registerConnection(1); + MySQLStatementIdGenerator.getInstance().registerConnection(1); ContextManager contextManager = mockContextManager(); when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager); Iterator<DatabasePacket<?>> actualIterator = new MySQLComStmtPrepareExecutor(packet, connectionSession).execute().iterator(); @@ -211,7 +211,7 @@ class MySQLComStmtPrepareExecutorTest { assertThat(actualPreparedStatement.getSql(), is(sql)); assertThat(actualPreparedStatement.getSqlStatementContext(), instanceOf(UpdateStatementContext.class)); assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), instanceOf(MySQLUpdateStatement.class)); - MySQLStatementIDGenerator.getInstance().unregisterConnection(1); + MySQLStatementIdGenerator.getInstance().unregisterConnection(1); } @Test