Skip to content

Commit

Permalink
Refactor ProxyBackendHandlerChecker to SQLExecutionChecker (#32349)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Jul 31, 2024
1 parent 65290dc commit 9b4bb5b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.proxy.backend.handler.checker;
package org.apache.shardingsphere.infra.executor.checker;

import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
Expand All @@ -24,13 +24,13 @@
import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;

/**
* Proxy backend handler checker.
* SQL execution checker.
*/
@SingletonSPI
public interface ProxyBackendHandlerChecker {
public interface SQLExecutionChecker {

/**
* Check.
* Check before SQL execute.
*
* @param metaData ShardingSphere meta data
* @param grantee grantee
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
* limitations under the License.
*/

package org.apache.shardingsphere.proxy.backend.handler.checker;
package org.apache.shardingsphere.authority.checker;

import org.apache.shardingsphere.authority.checker.AuthorityChecker;
import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.UnknownDatabaseException;
import org.apache.shardingsphere.infra.executor.checker.SQLExecutionChecker;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.session.query.QueryContext;

/**
* Authority proxy backend handler checker.
* Authority SQL execution checker.
*/
public final class AuthorityProxyBackendHandlerChecker implements ProxyBackendHandlerChecker {
public final class AuthoritySQLExecutionChecker implements SQLExecutionChecker {

@Override
public void check(final ShardingSphereMetaData metaData, final Grantee grantee, final QueryContext queryContext, final ShardingSphereDatabase database) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
# limitations under the License.
#

org.apache.shardingsphere.proxy.backend.handler.checker.AuthorityProxyBackendHandlerChecker
org.apache.shardingsphere.proxy.backend.handler.checker.AuditProxyBackendHandlerChecker
org.apache.shardingsphere.authority.checker.AuthoritySQLExecutionChecker
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.distsql.DistSQLStatementContext;
import org.apache.shardingsphere.proxy.backend.handler.admin.DatabaseAdminBackendHandlerFactory;
import org.apache.shardingsphere.proxy.backend.handler.checker.ProxyBackendHandlerChecker;
import org.apache.shardingsphere.infra.executor.checker.SQLExecutionChecker;
import org.apache.shardingsphere.proxy.backend.handler.data.DatabaseBackendHandlerFactory;
import org.apache.shardingsphere.proxy.backend.handler.database.DatabaseOperateBackendHandlerFactory;
import org.apache.shardingsphere.proxy.backend.handler.distsql.DistSQLBackendHandlerFactory;
Expand Down Expand Up @@ -147,7 +147,7 @@ public static ProxyBackendHandler newInstance(final DatabaseType databaseType, f
Grantee grantee = connectionSession.getConnectionContext().getGrantee();
ShardingSphereMetaData metaData = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData();
ShardingSphereDatabase database = metaData.getDatabase(databaseName);
for (ProxyBackendHandlerChecker each : ShardingSphereServiceLoader.getServiceInstances(ProxyBackendHandlerChecker.class)) {
for (SQLExecutionChecker each : ShardingSphereServiceLoader.getServiceInstances(SQLExecutionChecker.class)) {
each.check(metaData, grantee, queryContext, database);
}
return DatabaseAdminBackendHandlerFactory.newInstance(databaseType, sqlStatementContext, connectionSession)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
package org.apache.shardingsphere.proxy.backend.handler.checker;

import org.apache.shardingsphere.infra.executor.audit.SQLAuditEngine;
import org.apache.shardingsphere.infra.executor.checker.SQLExecutionChecker;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.session.query.QueryContext;

/**
* Audit proxy backend handler checker.
* Audit SQL execution checker.
*/
public final class AuditProxyBackendHandlerChecker implements ProxyBackendHandlerChecker {
public final class AuditSQLExecutionChecker implements SQLExecutionChecker {

@Override
public void check(final ShardingSphereMetaData metaData, final Grantee grantee, final QueryContext queryContext, final ShardingSphereDatabase database) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# 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.
#

org.apache.shardingsphere.proxy.backend.handler.checker.AuditSQLExecutionChecker

0 comments on commit 9b4bb5b

Please sign in to comment.