This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 f79758134c4 Add HighFrequencyInvocation (#30330)
f79758134c4 is described below
commit f79758134c48f72af7a91d710acf4d492be7a054
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Feb 28 14:03:15 2024 +0800
Add HighFrequencyInvocation (#30330)
---
.../infra/annotation/HighFrequencyInvocation.java | 38 ++++++++++++++++++++++
.../driver/ShardingSphereDriver.java | 2 ++
.../core/connection/ShardingSphereConnection.java | 2 ++
.../core/datasource/ShardingSphereDataSource.java | 3 ++
.../core/resultset/GeneratedKeysResultSet.java | 2 ++
.../core/resultset/ShardingSphereResultSet.java | 2 ++
.../statement/ShardingSpherePreparedStatement.java | 2 ++
.../core/statement/ShardingSphereStatement.java | 2 ++
8 files changed, 53 insertions(+)
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/annotation/HighFrequencyInvocation.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/annotation/HighFrequencyInvocation.java
new file mode 100644
index 00000000000..4d511a7ab6f
--- /dev/null
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/annotation/HighFrequencyInvocation.java
@@ -0,0 +1,38 @@
+/*
+ * 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.shardingsphere.infra.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * The class to which this annotation is applied is high frequency invocation.
+ */
+@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD,
ElementType.CONSTRUCTOR})
+@Retention(RetentionPolicy.CLASS)
+public @interface HighFrequencyInvocation {
+
+ /**
+ * Whether invocation of the method can be cached.
+ *
+ * @return can be cached or not
+ */
+ boolean canBeCached() default false;
+}
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/ShardingSphereDriver.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/ShardingSphereDriver.java
index cc445e558da..0a29feda432 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/ShardingSphereDriver.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/ShardingSphereDriver.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.driver;
import org.apache.shardingsphere.driver.jdbc.core.driver.DriverDataSourceCache;
+import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
import java.sql.Connection;
import java.sql.Driver;
@@ -48,6 +49,7 @@ public final class ShardingSphereDriver implements Driver {
}
}
+ @HighFrequencyInvocation(canCacheable = true)
@Override
public Connection connect(final String url, final Properties info) throws
SQLException {
return acceptsURL(url) ? dataSourceCache.get(url,
DRIVER_URL_PREFIX).getConnection() : null;
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
index 532a3743029..92b6d93853d 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
@@ -23,6 +23,7 @@ import
org.apache.shardingsphere.driver.jdbc.core.datasource.metadata.ShardingSp
import
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement;
import
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement;
import
org.apache.shardingsphere.driver.jdbc.exception.connection.ConnectionClosedException;
+import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
import
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.executor.sql.process.ProcessEngine;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
@@ -42,6 +43,7 @@ import java.sql.Statement;
/**
* ShardingSphere connection.
*/
+@HighFrequencyInvocation
public final class ShardingSphereConnection extends AbstractConnectionAdapter {
private final ProcessEngine processEngine = new ProcessEngine();
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
index 5deeda8268c..de351cb1b0b 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.driver.jdbc.core.datasource;
import org.apache.shardingsphere.driver.jdbc.adapter.AbstractDataSourceAdapter;
import org.apache.shardingsphere.driver.state.DriverStateContext;
+import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
import
org.apache.shardingsphere.infra.config.database.impl.DataSourceProvidedDatabaseConfiguration;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
@@ -89,11 +90,13 @@ public final class ShardingSphereDataSource extends
AbstractDataSourceAdapter im
}
}
+ @HighFrequencyInvocation(canCacheable = true)
@Override
public Connection getConnection() {
return DriverStateContext.getConnection(databaseName, contextManager);
}
+ @HighFrequencyInvocation(canCacheable = true)
@Override
public Connection getConnection(final String username, final String
password) {
return getConnection();
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/GeneratedKeysResultSet.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/GeneratedKeysResultSet.java
index 425857bfdc9..723365ca2ee 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/GeneratedKeysResultSet.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/GeneratedKeysResultSet.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.driver.jdbc.core.resultset;
import com.google.common.base.Preconditions;
import lombok.RequiredArgsConstructor;
import
org.apache.shardingsphere.driver.jdbc.unsupported.AbstractUnsupportedGeneratedKeysResultSet;
+import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -32,6 +33,7 @@ import java.util.Iterator;
/**
* ResultSet for generated keys.
*/
+@HighFrequencyInvocation
@RequiredArgsConstructor
public final class GeneratedKeysResultSet extends
AbstractUnsupportedGeneratedKeysResultSet {
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSet.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSet.java
index 5ed98a22b98..0197963b978 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSet.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSet.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.driver.jdbc.core.resultset;
import org.apache.shardingsphere.driver.jdbc.adapter.AbstractResultSetAdapter;
+import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionContext;
import
org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.util.ResultSetUtils;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
@@ -50,6 +51,7 @@ import java.util.Map;
/**
* ShardingSphere result set.
*/
+@HighFrequencyInvocation
public final class ShardingSphereResultSet extends AbstractResultSetAdapter {
private static final String ASCII = "Ascii";
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
index 81c58612823..a66db1b7ebe 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
@@ -31,6 +31,7 @@ import
org.apache.shardingsphere.driver.jdbc.core.resultset.ShardingSphereResult
import
org.apache.shardingsphere.driver.jdbc.core.resultset.ShardingSphereResultSetUtils;
import
org.apache.shardingsphere.driver.jdbc.core.statement.metadata.ShardingSphereParameterMetaData;
import
org.apache.shardingsphere.driver.jdbc.exception.syntax.EmptySQLException;
+import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
import org.apache.shardingsphere.infra.binder.context.aware.ParameterAware;
import
org.apache.shardingsphere.infra.binder.context.segment.insert.keygen.GeneratedKeyContext;
import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
@@ -109,6 +110,7 @@ import java.util.stream.Collectors;
/**
* ShardingSphere prepared statement.
*/
+@HighFrequencyInvocation
public final class ShardingSpherePreparedStatement extends
AbstractPreparedStatementAdapter {
@Getter
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
index 1bdc9d889ec..b9c4e06e896 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
@@ -30,6 +30,7 @@ import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConne
import
org.apache.shardingsphere.driver.jdbc.core.resultset.GeneratedKeysResultSet;
import
org.apache.shardingsphere.driver.jdbc.core.resultset.ShardingSphereResultSet;
import
org.apache.shardingsphere.driver.jdbc.exception.syntax.EmptySQLException;
+import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
import
org.apache.shardingsphere.infra.binder.context.segment.insert.keygen.GeneratedKeyContext;
import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import
org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext;
@@ -100,6 +101,7 @@ import java.util.stream.Collectors;
/**
* ShardingSphere statement.
*/
+@HighFrequencyInvocation
public final class ShardingSphereStatement extends AbstractStatementAdapter {
@Getter