From 3fd291a9c66f59aee7481f15d82459cb1829cb08 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Sun, 10 May 2020 17:46:06 +0800 Subject: [PATCH] rename ShardingSchema to ShardingSphereSchema (#5514) --- .../OrchestrationShardingSphereDataSource.java | 8 ++++---- ...chestrationShardingSphereDataSourceTest.java | 6 +++--- .../core/registrycenter/RegistryCenterNode.java | 6 +++--- .../event/DisabledStateChangedEvent.java | 4 ++-- .../DataSourceStateChangedListener.java | 4 ++-- ...dingSchema.java => OrchestrationSchema.java} | 6 +++--- .../OrchestrationShardingSchemaGroup.java | 2 +- .../DataSourceStateChangedListenerTest.java | 6 +++--- .../OrchestrationShardingSchemaGroupTest.java | 8 ++++---- .../schema/OrchestrationShardingSchemaTest.java | 4 ++-- .../jdbc/JDBCDatabaseCommunicationEngine.java | 4 ++-- .../PreparedStatementExecutorWrapper.java | 4 ++-- .../jdbc/wrapper/StatementExecutorWrapper.java | 4 ++-- .../backend/schema/LogicSchemaFactory.java | 10 +++++----- ...ingSchema.java => ShardingSphereSchema.java} | 14 +++++++------- .../backend/response/query/QueryHeaderTest.java | 6 +++--- ...emaDTO.java => ShardingSphereSchemaDTO.java} | 4 ++-- .../controller/ShardingSchemaController.java | 17 +++++++++-------- 18 files changed, 59 insertions(+), 58 deletions(-) rename sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/{OrchestrationShardingSchema.java => OrchestrationSchema.java} (91%) rename sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/impl/{ShardingSchema.java => ShardingSphereSchema.java} (89%) rename shardingsphere-ui/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/dto/{ShardingSchemaDTO.java => ShardingSphereSchemaDTO.java} (93%) diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/org/apache/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationShardingSphereDataSource.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/org/apache/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationShardingSphereDataSource.java index 0b461cc829..239cd8ef8a 100644 --- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/org/apache/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationShardingSphereDataSource.java +++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/org/apache/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationShardingSphereDataSource.java @@ -31,7 +31,7 @@ import org.apache.shardingsphere.orchestration.core.configcenter.ConfigCenter; import org.apache.shardingsphere.orchestration.core.facade.ShardingOrchestrationFacade; import org.apache.shardingsphere.orchestration.core.metadatacenter.event.MetaDataChangedEvent; import org.apache.shardingsphere.orchestration.core.registrycenter.event.DisabledStateChangedEvent; -import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationShardingSchema; +import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationSchema; import org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.ShardingSphereDataSource; import org.apache.shardingsphere.shardingjdbc.orchestration.internal.util.DataSourceConverter; import org.apache.shardingsphere.underlying.common.config.DataSourceConfiguration; @@ -143,11 +143,11 @@ public class OrchestrationShardingSphereDataSource extends AbstractOrchestration */ @Subscribe public synchronized void renew(final DisabledStateChangedEvent disabledStateChangedEvent) { - OrchestrationShardingSchema shardingSchema = disabledStateChangedEvent.getShardingSchema(); - if (DefaultSchema.LOGIC_NAME.equals(shardingSchema.getSchemaName())) { + OrchestrationSchema orchestrationSchema = disabledStateChangedEvent.getOrchestrationSchema(); + if (DefaultSchema.LOGIC_NAME.equals(orchestrationSchema.getSchemaName())) { for (ShardingSphereRule each : dataSource.getRuntimeContext().getRules()) { if (each instanceof MasterSlaveRule) { - ((MasterSlaveRule) each).updateDisabledDataSourceNames(shardingSchema.getDataSourceName(), disabledStateChangedEvent.isDisabled()); + ((MasterSlaveRule) each).updateDisabledDataSourceNames(orchestrationSchema.getDataSourceName(), disabledStateChangedEvent.isDisabled()); } } } diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/test/java/org/apache/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationShardingSphereDataSourceTest.java b/sharding-jdbc/sharding-jdbc-orchestration/src/test/java/org/apache/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationShardingSphereDataSourceTest.java index 8c8e4f5a46..b7ecc8d592 100644 --- a/sharding-jdbc/sharding-jdbc-orchestration/src/test/java/org/apache/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationShardingSphereDataSourceTest.java +++ b/sharding-jdbc/sharding-jdbc-orchestration/src/test/java/org/apache/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationShardingSphereDataSourceTest.java @@ -31,7 +31,7 @@ import org.apache.shardingsphere.orchestration.core.common.event.DataSourceChang import org.apache.shardingsphere.orchestration.core.common.event.PropertiesChangedEvent; import org.apache.shardingsphere.orchestration.core.common.event.ShardingRuleChangedEvent; import org.apache.shardingsphere.orchestration.core.registrycenter.event.DisabledStateChangedEvent; -import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationShardingSchema; +import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationSchema; import org.apache.shardingsphere.shardingjdbc.api.yaml.YamlShardingSphereDataSourceFactory; import org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.ShardingSphereDataSource; import org.apache.shardingsphere.underlying.common.config.DataSourceConfiguration; @@ -167,7 +167,7 @@ public final class OrchestrationShardingSphereDataSourceTest { } private DisabledStateChangedEvent getDisabledStateChangedEvent() { - OrchestrationShardingSchema shardingSchema = new OrchestrationShardingSchema("logic_db.ds_s"); - return new DisabledStateChangedEvent(shardingSchema, true); + OrchestrationSchema orchestrationSchema = new OrchestrationSchema("logic_db.ds_s"); + return new DisabledStateChangedEvent(orchestrationSchema, true); } } diff --git a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/RegistryCenterNode.java b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/RegistryCenterNode.java index 2188b6343c..4ffb89af91 100644 --- a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/RegistryCenterNode.java +++ b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/RegistryCenterNode.java @@ -19,7 +19,7 @@ package org.apache.shardingsphere.orchestration.core.registrycenter; import com.google.common.base.Joiner; import lombok.RequiredArgsConstructor; -import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationShardingSchema; +import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationSchema; /** * RegistryCenter node. @@ -70,7 +70,7 @@ public final class RegistryCenterNode { * @param dataSourceNodeFullPath data source node full path * @return orchestration sharding schema */ - public OrchestrationShardingSchema getOrchestrationShardingSchema(final String dataSourceNodeFullPath) { - return new OrchestrationShardingSchema(dataSourceNodeFullPath.replace(getDataSourcesNodeFullRootPath() + '/', "")); + public OrchestrationSchema getOrchestrationShardingSchema(final String dataSourceNodeFullPath) { + return new OrchestrationSchema(dataSourceNodeFullPath.replace(getDataSourcesNodeFullRootPath() + '/', "")); } } diff --git a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/event/DisabledStateChangedEvent.java b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/event/DisabledStateChangedEvent.java index 11a06d3b3a..d790c9f073 100644 --- a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/event/DisabledStateChangedEvent.java +++ b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/event/DisabledStateChangedEvent.java @@ -20,7 +20,7 @@ package org.apache.shardingsphere.orchestration.core.registrycenter.event; import lombok.Getter; import lombok.RequiredArgsConstructor; import org.apache.shardingsphere.orchestration.core.common.event.ShardingOrchestrationEvent; -import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationShardingSchema; +import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationSchema; /** * Disabled state event. @@ -29,7 +29,7 @@ import org.apache.shardingsphere.orchestration.core.registrycenter.schema.Orches @Getter public final class DisabledStateChangedEvent implements ShardingOrchestrationEvent { - private final OrchestrationShardingSchema shardingSchema; + private final OrchestrationSchema orchestrationSchema; private final boolean disabled; } diff --git a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/listener/DataSourceStateChangedListener.java b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/listener/DataSourceStateChangedListener.java index a6d51e2251..2e8e997732 100644 --- a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/listener/DataSourceStateChangedListener.java +++ b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/listener/DataSourceStateChangedListener.java @@ -24,7 +24,7 @@ import org.apache.shardingsphere.orchestration.core.common.listener.PostSharding import org.apache.shardingsphere.orchestration.core.registrycenter.event.DisabledStateChangedEvent; import org.apache.shardingsphere.orchestration.core.registrycenter.RegistryCenterNode; import org.apache.shardingsphere.orchestration.core.registrycenter.RegistryCenterNodeStatus; -import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationShardingSchema; +import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationSchema; import java.util.Collections; @@ -45,7 +45,7 @@ public final class DataSourceStateChangedListener extends PostShardingCenterRepo return new DisabledStateChangedEvent(getShardingSchema(event.getKey()), isDataSourceDisabled(event)); } - private OrchestrationShardingSchema getShardingSchema(final String dataSourceNodeFullPath) { + private OrchestrationSchema getShardingSchema(final String dataSourceNodeFullPath) { return registryCenterNode.getOrchestrationShardingSchema(dataSourceNodeFullPath); } diff --git a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchema.java b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationSchema.java similarity index 91% rename from sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchema.java rename to sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationSchema.java index a354f76449..0a94b624f5 100644 --- a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchema.java +++ b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationSchema.java @@ -25,17 +25,17 @@ import org.apache.shardingsphere.underlying.common.database.DefaultSchema; import java.util.List; /** - * Orchestration sharding schema. + * Orchestration schema. */ @RequiredArgsConstructor @Getter -public final class OrchestrationShardingSchema { +public final class OrchestrationSchema { private final String schemaName; private final String dataSourceName; - public OrchestrationShardingSchema(final String value) { + public OrchestrationSchema(final String value) { if (value.contains(".")) { List values = Splitter.on(".").splitToList(value); schemaName = values.get(0); diff --git a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchemaGroup.java b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchemaGroup.java index 57a9f9024e..95edac3203 100644 --- a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchemaGroup.java +++ b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/main/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchemaGroup.java @@ -35,7 +35,7 @@ public final class OrchestrationShardingSchemaGroup { * * @param orchestrationShardingSchema orchestration sharding schema */ - public void add(final OrchestrationShardingSchema orchestrationShardingSchema) { + public void add(final OrchestrationSchema orchestrationShardingSchema) { String schemaName = orchestrationShardingSchema.getSchemaName(); if (!schemaGroup.containsKey(schemaName)) { schemaGroup.put(schemaName, new LinkedList<>()); diff --git a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/test/java/org/apache/shardingsphere/orchestration/core/registrycenter/listener/DataSourceStateChangedListenerTest.java b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/test/java/org/apache/shardingsphere/orchestration/core/registrycenter/listener/DataSourceStateChangedListenerTest.java index c10ec73ee3..9ceb57f817 100644 --- a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/test/java/org/apache/shardingsphere/orchestration/core/registrycenter/listener/DataSourceStateChangedListenerTest.java +++ b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/test/java/org/apache/shardingsphere/orchestration/core/registrycenter/listener/DataSourceStateChangedListenerTest.java @@ -20,7 +20,7 @@ package org.apache.shardingsphere.orchestration.core.registrycenter.listener; import org.apache.shardingsphere.orchestration.center.RegistryCenterRepository; import org.apache.shardingsphere.orchestration.center.listener.DataChangedEvent; import org.apache.shardingsphere.orchestration.center.listener.DataChangedEvent.ChangedType; -import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationShardingSchema; +import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationSchema; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -45,8 +45,8 @@ public final class DataSourceStateChangedListenerTest { @Test public void assertCreateShardingOrchestrationEvent() { - OrchestrationShardingSchema expected = new OrchestrationShardingSchema("master_slave_db", "slave_ds_0"); + OrchestrationSchema expected = new OrchestrationSchema("master_slave_db", "slave_ds_0"); DataChangedEvent dataChangedEvent = new DataChangedEvent("/test/registry/datasources/master_slave_db.slave_ds_0", "disabled", ChangedType.UPDATED); - assertThat(dataSourceStateChangedListener.createShardingOrchestrationEvent(dataChangedEvent).getShardingSchema().getSchemaName(), is(expected.getSchemaName())); + assertThat(dataSourceStateChangedListener.createShardingOrchestrationEvent(dataChangedEvent).getOrchestrationSchema().getSchemaName(), is(expected.getSchemaName())); } } diff --git a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/test/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchemaGroupTest.java b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/test/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchemaGroupTest.java index 2defc5ae45..505662f362 100644 --- a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/test/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchemaGroupTest.java +++ b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/test/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchemaGroupTest.java @@ -30,8 +30,8 @@ public final class OrchestrationShardingSchemaGroupTest { @Test public void assertAddWithExistedSchemaName() { OrchestrationShardingSchemaGroup actual = new OrchestrationShardingSchemaGroup(); - actual.add(new OrchestrationShardingSchema("test_0.ds_0")); - actual.add(new OrchestrationShardingSchema("test_0.ds_1")); + actual.add(new OrchestrationSchema("test_0.ds_0")); + actual.add(new OrchestrationSchema("test_0.ds_1")); assertThat(actual.getDataSourceNames("test_0").size(), is(2)); assertTrue(actual.getDataSourceNames("test_0").contains("ds_0")); assertTrue(actual.getDataSourceNames("test_0").contains("ds_1")); @@ -40,8 +40,8 @@ public final class OrchestrationShardingSchemaGroupTest { @Test public void assertAddWithoutExistedSchemaName() { OrchestrationShardingSchemaGroup actual = new OrchestrationShardingSchemaGroup(); - actual.add(new OrchestrationShardingSchema("test_0.ds_0")); - actual.add(new OrchestrationShardingSchema("test_1.ds_1")); + actual.add(new OrchestrationSchema("test_0.ds_0")); + actual.add(new OrchestrationSchema("test_1.ds_1")); assertThat(actual.getDataSourceNames("test_0").size(), is(1)); assertTrue(actual.getDataSourceNames("test_0").contains("ds_0")); assertThat(actual.getDataSourceNames("test_1").size(), is(1)); diff --git a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/test/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchemaTest.java b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/test/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchemaTest.java index 39ec802b21..9761c0354f 100644 --- a/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/test/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchemaTest.java +++ b/sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-registrycenter/src/test/java/org/apache/shardingsphere/orchestration/core/registrycenter/schema/OrchestrationShardingSchemaTest.java @@ -27,14 +27,14 @@ public final class OrchestrationShardingSchemaTest { @Test public void assertNewOrchestrationSchemaWithDataSourceNameOnly() { - OrchestrationShardingSchema actual = new OrchestrationShardingSchema("test_ds"); + OrchestrationSchema actual = new OrchestrationSchema("test_ds"); assertThat(actual.getSchemaName(), is(DefaultSchema.LOGIC_NAME)); assertThat(actual.getDataSourceName(), is("test_ds")); } @Test public void assertNewOrchestrationSchemaWithSchemaNameAndDataSourceName() { - OrchestrationShardingSchema actual = new OrchestrationShardingSchema("test_schema.test_ds"); + OrchestrationSchema actual = new OrchestrationSchema("test_schema.test_ds"); assertThat(actual.getSchemaName(), is("test_schema")); assertThat(actual.getDataSourceName(), is("test_ds")); } diff --git a/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java b/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java index 58d36c4a99..b7bcaf1623 100644 --- a/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java +++ b/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java @@ -31,7 +31,7 @@ import org.apache.shardingsphere.shardingproxy.backend.response.query.QueryRespo import org.apache.shardingsphere.shardingproxy.backend.response.update.UpdateResponse; import org.apache.shardingsphere.shardingproxy.backend.schema.LogicSchema; import org.apache.shardingsphere.shardingproxy.backend.schema.LogicSchemas; -import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShardingSchema; +import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShardingSphereSchema; import org.apache.shardingsphere.shardingproxy.context.ShardingProxyContext; import org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext; import org.apache.shardingsphere.sql.parser.binder.type.TableAvailable; @@ -90,7 +90,7 @@ public final class JDBCDatabaseCommunicationEngine implements DatabaseCommunicat } response = executeEngine.execute(executionContext); // TODO refresh non-sharding table meta data - if (logicSchema instanceof ShardingSchema) { + if (logicSchema instanceof ShardingSphereSchema) { logicSchema.refreshTableMetaData(executionContext.getSqlStatementContext()); } return merge(executionContext.getSqlStatementContext()); diff --git a/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/wrapper/PreparedStatementExecutorWrapper.java b/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/wrapper/PreparedStatementExecutorWrapper.java index af24656517..41c7a83e47 100644 --- a/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/wrapper/PreparedStatementExecutorWrapper.java +++ b/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/wrapper/PreparedStatementExecutorWrapper.java @@ -23,7 +23,7 @@ import org.apache.shardingsphere.shadow.rewrite.judgement.ShadowJudgementEngine; import org.apache.shardingsphere.shadow.rewrite.judgement.impl.PreparedJudgementEngine; import org.apache.shardingsphere.shardingproxy.backend.schema.LogicSchema; import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShadowSchema; -import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShardingSchema; +import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShardingSphereSchema; import org.apache.shardingsphere.shardingproxy.context.ShardingProxyContext; import org.apache.shardingsphere.sql.parser.binder.SQLStatementContextFactory; import org.apache.shardingsphere.sql.parser.binder.metadata.schema.SchemaMetaData; @@ -69,7 +69,7 @@ public final class PreparedStatementExecutorWrapper implements JDBCExecutorWrapp @Override public ExecutionContext route(final String sql) { - if (logicSchema instanceof ShardingSchema) { + if (logicSchema instanceof ShardingSphereSchema) { return doShardingRoute(sql); } if (logicSchema instanceof ShadowSchema) { diff --git a/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/wrapper/StatementExecutorWrapper.java b/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/wrapper/StatementExecutorWrapper.java index 4de0a807d0..52aa259970 100644 --- a/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/wrapper/StatementExecutorWrapper.java +++ b/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/communication/jdbc/wrapper/StatementExecutorWrapper.java @@ -23,7 +23,7 @@ import org.apache.shardingsphere.shadow.rewrite.judgement.ShadowJudgementEngine; import org.apache.shardingsphere.shadow.rewrite.judgement.impl.SimpleJudgementEngine; import org.apache.shardingsphere.shardingproxy.backend.schema.LogicSchema; import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShadowSchema; -import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShardingSchema; +import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShardingSphereSchema; import org.apache.shardingsphere.shardingproxy.context.ShardingProxyContext; import org.apache.shardingsphere.sql.parser.binder.SQLStatementContextFactory; import org.apache.shardingsphere.sql.parser.binder.metadata.schema.SchemaMetaData; @@ -66,7 +66,7 @@ public final class StatementExecutorWrapper implements JDBCExecutorWrapper { @Override public ExecutionContext route(final String sql) { - if (logicSchema instanceof ShardingSchema) { + if (logicSchema instanceof ShardingSphereSchema) { return doShardingRoute(sql); } if (logicSchema instanceof ShadowSchema) { diff --git a/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/LogicSchemaFactory.java b/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/LogicSchemaFactory.java index b8442f5229..c01bfa4d63 100644 --- a/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/LogicSchemaFactory.java +++ b/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/LogicSchemaFactory.java @@ -24,7 +24,7 @@ import org.apache.shardingsphere.api.config.shadow.ShadowRuleConfiguration; import org.apache.shardingsphere.api.config.sharding.ShardingRuleConfiguration; import org.apache.shardingsphere.encrypt.api.EncryptRuleConfiguration; import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShadowSchema; -import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShardingSchema; +import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShardingSphereSchema; import org.apache.shardingsphere.shardingproxy.backend.schema.impl.TransparentSchema; import org.apache.shardingsphere.shardingproxy.config.yaml.YamlDataSourceParameter; import org.apache.shardingsphere.underlying.common.config.RuleConfiguration; @@ -52,20 +52,20 @@ public final class LogicSchemaFactory { public static LogicSchema newInstance(final String schemaName, final Map> schemaDataSources, final Collection ruleConfigurations) throws SQLException { if (ruleConfigurations.size() > 1) { - return new ShardingSchema(schemaName, schemaDataSources.get(schemaName), ruleConfigurations); + return new ShardingSphereSchema(schemaName, schemaDataSources.get(schemaName), ruleConfigurations); } if (ruleConfigurations.isEmpty()) { return new TransparentSchema(schemaName, schemaDataSources.get(schemaName)); } RuleConfiguration ruleConfiguration = ruleConfigurations.iterator().next(); if (ruleConfiguration instanceof ShardingRuleConfiguration) { - return new ShardingSchema(schemaName, schemaDataSources.get(schemaName), Collections.singleton(ruleConfiguration)); + return new ShardingSphereSchema(schemaName, schemaDataSources.get(schemaName), Collections.singleton(ruleConfiguration)); } if (ruleConfiguration instanceof MasterSlaveRuleConfiguration) { - return new ShardingSchema(schemaName, schemaDataSources.get(schemaName), Collections.singleton(ruleConfiguration)); + return new ShardingSphereSchema(schemaName, schemaDataSources.get(schemaName), Collections.singleton(ruleConfiguration)); } if (ruleConfiguration instanceof EncryptRuleConfiguration) { - return new ShardingSchema(schemaName, schemaDataSources.get(schemaName), Collections.singleton(ruleConfiguration)); + return new ShardingSphereSchema(schemaName, schemaDataSources.get(schemaName), Collections.singleton(ruleConfiguration)); } if (ruleConfiguration instanceof ShadowRuleConfiguration) { return new ShadowSchema(schemaName, schemaDataSources.get(schemaName), (ShadowRuleConfiguration) ruleConfiguration); diff --git a/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/impl/ShardingSchema.java b/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/impl/ShardingSphereSchema.java similarity index 89% rename from sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/impl/ShardingSchema.java rename to sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/impl/ShardingSphereSchema.java index 208d7ac4da..1d5f500993 100644 --- a/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/impl/ShardingSchema.java +++ b/sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/impl/ShardingSphereSchema.java @@ -23,7 +23,7 @@ import org.apache.shardingsphere.core.rule.MasterSlaveRule; import org.apache.shardingsphere.orchestration.core.common.event.ShardingRuleChangedEvent; import org.apache.shardingsphere.orchestration.core.facade.ShardingOrchestrationFacade; import org.apache.shardingsphere.orchestration.core.registrycenter.event.DisabledStateChangedEvent; -import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationShardingSchema; +import org.apache.shardingsphere.orchestration.core.registrycenter.schema.OrchestrationSchema; import org.apache.shardingsphere.shardingproxy.backend.schema.LogicSchema; import org.apache.shardingsphere.shardingproxy.backend.schema.LogicSchemas; import org.apache.shardingsphere.shardingproxy.config.yaml.YamlDataSourceParameter; @@ -43,11 +43,11 @@ import java.util.Map; import java.util.Optional; /** - * Sharding schema. + * ShardingSphere schema. */ -public final class ShardingSchema extends LogicSchema { +public final class ShardingSphereSchema extends LogicSchema { - public ShardingSchema(final String name, final Map dataSources, final Collection ruleConfigurations) throws SQLException { + public ShardingSphereSchema(final String name, final Map dataSources, final Collection ruleConfigurations) throws SQLException { super(name, dataSources, ShardingSphereRulesBuilder.build(ruleConfigurations, dataSources.keySet())); } @@ -71,11 +71,11 @@ public final class ShardingSchema extends LogicSchema { */ @Subscribe public synchronized void renew(final DisabledStateChangedEvent disabledStateChangedEvent) { - OrchestrationShardingSchema shardingSchema = disabledStateChangedEvent.getShardingSchema(); - if (getName().equals(shardingSchema.getSchemaName())) { + OrchestrationSchema orchestrationSchema = disabledStateChangedEvent.getOrchestrationSchema(); + if (getName().equals(orchestrationSchema.getSchemaName())) { for (ShardingSphereRule each : getRules()) { if (each instanceof MasterSlaveRule) { - ((MasterSlaveRule) each).updateDisabledDataSourceNames(shardingSchema.getDataSourceName(), disabledStateChangedEvent.isDisabled()); + ((MasterSlaveRule) each).updateDisabledDataSourceNames(orchestrationSchema.getDataSourceName(), disabledStateChangedEvent.isDisabled()); } } } diff --git a/sharding-proxy/sharding-proxy-backend/src/test/java/org/apache/shardingsphere/shardingproxy/backend/response/query/QueryHeaderTest.java b/sharding-proxy/sharding-proxy-backend/src/test/java/org/apache/shardingsphere/shardingproxy/backend/response/query/QueryHeaderTest.java index bc5565a6ba..bb54bac385 100644 --- a/sharding-proxy/sharding-proxy-backend/src/test/java/org/apache/shardingsphere/shardingproxy/backend/response/query/QueryHeaderTest.java +++ b/sharding-proxy/sharding-proxy-backend/src/test/java/org/apache/shardingsphere/shardingproxy/backend/response/query/QueryHeaderTest.java @@ -18,7 +18,7 @@ package org.apache.shardingsphere.shardingproxy.backend.response.query; import org.apache.shardingsphere.core.rule.ShardingRule; -import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShardingSchema; +import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShardingSphereSchema; import org.apache.shardingsphere.sql.parser.binder.metadata.column.ColumnMetaData; import org.apache.shardingsphere.sql.parser.binder.metadata.index.IndexMetaData; import org.apache.shardingsphere.sql.parser.binder.metadata.schema.SchemaMetaData; @@ -125,8 +125,8 @@ public final class QueryHeaderTest { assertTrue(header.isAutoIncrement()); } - private ShardingSchema getShardingSchema() { - ShardingSchema result = mock(ShardingSchema.class); + private ShardingSphereSchema getShardingSchema() { + ShardingSphereSchema result = mock(ShardingSphereSchema.class); ColumnMetaData columnMetaData = new ColumnMetaData("order_id", Types.INTEGER, "int", true, false, false); SchemaMetaData schemaMetaData = mock(SchemaMetaData.class); when(schemaMetaData.get("t_logic_order")).thenReturn(new TableMetaData(Collections.singletonList(columnMetaData), Collections.singletonList(new IndexMetaData("order_id")))); diff --git a/shardingsphere-ui/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/dto/ShardingSchemaDTO.java b/shardingsphere-ui/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/dto/ShardingSphereSchemaDTO.java similarity index 93% rename from shardingsphere-ui/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/dto/ShardingSchemaDTO.java rename to shardingsphere-ui/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/dto/ShardingSphereSchemaDTO.java index 9b5516dd87..ee85e601d5 100644 --- a/shardingsphere-ui/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/dto/ShardingSchemaDTO.java +++ b/shardingsphere-ui/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/common/dto/ShardingSphereSchemaDTO.java @@ -23,13 +23,13 @@ import lombok.NoArgsConstructor; import lombok.Setter; /** - * Sharding schema DTO. + * ShardingSphere schema DTO. */ @Setter @Getter @NoArgsConstructor @AllArgsConstructor -public final class ShardingSchemaDTO { +public final class ShardingSphereSchemaDTO { private String name; diff --git a/shardingsphere-ui/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/ShardingSchemaController.java b/shardingsphere-ui/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/ShardingSchemaController.java index a79b29e993..8d00a845f6 100644 --- a/shardingsphere-ui/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/ShardingSchemaController.java +++ b/shardingsphere-ui/shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/ShardingSchemaController.java @@ -17,17 +17,17 @@ package org.apache.shardingsphere.ui.web.controller; -import org.apache.shardingsphere.ui.common.dto.ShardingSchemaDTO; +import org.apache.shardingsphere.ui.common.dto.ShardingSphereSchemaDTO; import org.apache.shardingsphere.ui.servcie.ShardingSchemaService; import org.apache.shardingsphere.ui.web.response.ResponseResult; import org.apache.shardingsphere.ui.web.response.ResponseResultUtil; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; import java.util.Collection; import java.util.Map; @@ -38,7 +38,7 @@ import java.util.Map; @RequestMapping("/api/schema") public final class ShardingSchemaController { - @Autowired + @Resource private ShardingSchemaService shardingSchemaService; /** @@ -54,19 +54,20 @@ public final class ShardingSchemaController { /** * Add schema configuration. * - * @param shardingSchema sharding schema DTO. + * @param schemaDTO schema DTO * @return response result */ @RequestMapping(value = "", method = RequestMethod.POST) - public ResponseResult addSchema(final @RequestBody ShardingSchemaDTO shardingSchema) { - shardingSchemaService.addSchemaConfiguration(shardingSchema.getName(), shardingSchema.getRuleConfiguration(), shardingSchema.getDataSourceConfiguration()); + public ResponseResult addSchema(final @RequestBody ShardingSphereSchemaDTO schemaDTO) { + shardingSchemaService.addSchemaConfiguration(schemaDTO.getName(), schemaDTO.getRuleConfiguration(), schemaDTO.getDataSourceConfiguration()); return ResponseResultUtil.success(); } /** - * Delete schema configuration + * Delete schema configuration. + * * @param schemaName schema name - * @return + * @return response result */ @RequestMapping(value = "/{schemaName}", method = RequestMethod.DELETE) public ResponseResult deleteSchema(@PathVariable("schemaName") final String schemaName) { -- GitLab