Skip to content

Commit

Permalink
Rename StorageUnitMetaData
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Oct 3, 2023
1 parent 63f338f commit 5f844de
Show file tree
Hide file tree
Showing 49 changed files with 155 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.NewStorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.metadata.persist.MetaDataPersistService;
import org.apache.shardingsphere.mode.manager.ContextManager;
Expand Down Expand Up @@ -75,7 +75,7 @@ void assertExportWithContextManager() {

private ContextManager mockContextManager() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getResourceMetaData().getStorageUnitMetaDataMap()).thenReturn(Collections.singletonMap("ds_0", mock(NewStorageUnitMetaData.class)));
when(database.getResourceMetaData().getStorageUnitMetaDataMap()).thenReturn(Collections.singletonMap("ds_0", mock(StorageUnitMetaData.class)));
when(database.getProtocolType()).thenReturn(TypedSPILoader.getService(DatabaseType.class, "FIXTURE"));
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
when(metaData.getDatabases()).thenReturn(Collections.singletonMap("sharding_db", database));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.NewStorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereRowData;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereTableData;
Expand Down Expand Up @@ -87,7 +87,7 @@ private void collectForShardingStatisticTable(final ShardingSphereDatabase datab
}
}

private void addTableRowsAndDataLength(final Map<String, NewStorageUnitMetaData> metaDataMap, final DataNode dataNode, final List<Object> row) throws SQLException {
private void addTableRowsAndDataLength(final Map<String, StorageUnitMetaData> metaDataMap, final DataNode dataNode, final List<Object> row) throws SQLException {
DatabaseType databaseType = metaDataMap.get(dataNode.getDataSourceName()).getStorageUnit().getStorageType();
Optional<DialectShardingStatisticsTableCollector> dialectCollector = DatabaseTypedSPILoader.findService(DialectShardingStatisticsTableCollector.class, databaseType);
boolean isAppended = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNode;
import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNodeName;
import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNodeUtils;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.NewStorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitNodeMapUtils;

import javax.sql.DataSource;
Expand All @@ -45,7 +45,7 @@ public final class ResourceMetaData {

private final Map<StorageNodeName, DataSource> dataSources;

private final Map<String, NewStorageUnitMetaData> storageUnitMetaDataMap;
private final Map<String, StorageUnitMetaData> storageUnitMetaDataMap;

public ResourceMetaData(final Map<String, DataSource> dataSources) {
this.dataSources = StorageNodeUtils.getStorageNodeDataSources(dataSources);
Expand All @@ -58,7 +58,7 @@ public ResourceMetaData(final Map<String, DataSource> dataSources) {
if (!(dataSource instanceof CatalogSwitchableDataSource)) {
dataSource = new CatalogSwitchableDataSource(dataSource, entry.getValue().getCatalog(), entry.getValue().getUrl());
}
storageUnitMetaDataMap.put(entry.getKey(), new NewStorageUnitMetaData(null, entry.getValue(), dataSourcePoolPropertiesMap.get(entry.getKey()), dataSource));
storageUnitMetaDataMap.put(entry.getKey(), new StorageUnitMetaData(null, entry.getValue(), dataSourcePoolPropertiesMap.get(entry.getKey()), dataSource));
}
}

Expand All @@ -71,7 +71,7 @@ public ResourceMetaData(final String databaseName, final Map<StorageNodeName, Da
if (!(dataSource instanceof CatalogSwitchableDataSource)) {
dataSource = new CatalogSwitchableDataSource(dataSource, entry.getValue().getCatalog(), entry.getValue().getUrl());
}
storageUnitMetaDataMap.put(entry.getKey(), new NewStorageUnitMetaData(databaseName, entry.getValue(), propsMap.get(entry.getKey()), dataSource));
storageUnitMetaDataMap.put(entry.getKey(), new StorageUnitMetaData(databaseName, entry.getValue(), propsMap.get(entry.getKey()), dataSource));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* Storage unit meta data.
*/
@Getter
public final class NewStorageUnitMetaData {
public final class StorageUnitMetaData {

private final StorageNode storageNode;

Expand All @@ -37,7 +37,7 @@ public final class NewStorageUnitMetaData {

private final StorageUnit storageUnit;

public NewStorageUnitMetaData(final String databaseName, final StorageNode storageNode, final DataSourcePoolProperties dataSourcePoolProperties, final DataSource dataSource) {
public StorageUnitMetaData(final String databaseName, final StorageNode storageNode, final DataSourcePoolProperties dataSourcePoolProperties, final DataSource dataSource) {
this.storageNode = storageNode;
this.dataSourcePoolProperties = dataSourcePoolProperties;
this.dataSource = dataSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.NewStorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;

import javax.sql.DataSource;
Expand Down Expand Up @@ -50,7 +50,7 @@ public final class GenericSchemaBuilderMaterial {

private final String defaultSchemaName;

public GenericSchemaBuilderMaterial(final DatabaseType protocolType, final Map<String, NewStorageUnitMetaData> storageUnitMetaDataMap,
public GenericSchemaBuilderMaterial(final DatabaseType protocolType, final Map<String, StorageUnitMetaData> storageUnitMetaDataMap,
final Collection<ShardingSphereRule> rules, final ConfigurationProperties props, final String defaultSchemaName) {
this(protocolType, storageUnitMetaDataMap.entrySet().stream()
.collect(Collectors.toMap(Entry::getKey, entry -> entry.getValue().getStorageUnit().getStorageType(), (oldValue, currentValue) -> oldValue, LinkedHashMap::new)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.NewStorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereRowData;
Expand Down Expand Up @@ -57,7 +57,7 @@ public static Collection<ShardingSphereRowData> collectRowData(final ShardingSph
return Collections.emptyList();
}
Collection<ShardingSphereRowData> result = new LinkedList<>();
for (NewStorageUnitMetaData each : database.getResourceMetaData().getStorageUnitMetaDataMap().values()) {
for (StorageUnitMetaData each : database.getResourceMetaData().getStorageUnitMetaDataMap().values()) {
try (
Connection connection = each.getDataSource().getConnection();
Statement statement = connection.createStatement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNode;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.NewStorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.infra.rule.identifier.type.ResourceHeldRule;
import org.apache.shardingsphere.test.fixture.jdbc.MockedDataSource;
Expand Down Expand Up @@ -90,7 +90,7 @@ private ShardingSphereDatabase mockDatabase(final ResourceMetaData resourceMetaD
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class);
when(result.getName()).thenReturn("foo_db");
when(result.getResourceMetaData()).thenReturn(resourceMetaData);
NewStorageUnitMetaData storageUnitMetaData = new NewStorageUnitMetaData("foo_db", mock(StorageNode.class, RETURNS_DEEP_STUBS), mock(DataSourcePoolProperties.class), dataSource);
StorageUnitMetaData storageUnitMetaData = new StorageUnitMetaData("foo_db", mock(StorageNode.class, RETURNS_DEEP_STUBS), mock(DataSourcePoolProperties.class), dataSource);
when(result.getResourceMetaData().getStorageUnitMetaDataMap()).thenReturn(Collections.singletonMap("foo_db", storageUnitMetaData));
when(result.getRuleMetaData()).thenReturn(new RuleMetaData(Collections.singleton(databaseResourceHeldRule)));
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.DriverExecutionUnit;
import org.apache.shardingsphere.infra.executor.sql.prepare.AbstractExecutionPrepareEngine;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.NewStorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;

Expand Down Expand Up @@ -55,11 +55,11 @@ public final class DriverExecutionPrepareEngine<T extends DriverExecutionUnit<?>
@SuppressWarnings("rawtypes")
private final SQLExecutionUnitBuilder sqlExecutionUnitBuilder;

private final Map<String, NewStorageUnitMetaData> storageUnitMetaDataMap;
private final Map<String, StorageUnitMetaData> storageUnitMetaDataMap;

public DriverExecutionPrepareEngine(final String type, final int maxConnectionsSizePerQuery, final DatabaseConnectionManager<C> databaseConnectionManager,
final ExecutorStatementManager<C, ?, ?> statementManager, final StorageResourceOption option, final Collection<ShardingSphereRule> rules,
final Map<String, NewStorageUnitMetaData> storageUnitMetaDataMap) {
final Map<String, StorageUnitMetaData> storageUnitMetaDataMap) {
super(maxConnectionsSizePerQuery, rules);
this.databaseConnectionManager = databaseConnectionManager;
this.statementManager = statementManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.hint.HintValueContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.NewStorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext;
import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContextDecorator;
Expand Down Expand Up @@ -77,7 +77,7 @@ public SQLRewriteResult rewrite(final String sql, final List<Object> params, fin
SQLRewriteContext sqlRewriteContext = createSQLRewriteContext(sql, params, sqlStatementContext, routeContext, connectionContext, hintValueContext);
SQLTranslatorRule rule = globalRuleMetaData.getSingleRule(SQLTranslatorRule.class);
DatabaseType protocolType = database.getProtocolType();
Map<String, NewStorageUnitMetaData> storageUnitMetaDataMap = database.getResourceMetaData().getStorageUnitMetaDataMap();
Map<String, StorageUnitMetaData> storageUnitMetaDataMap = database.getResourceMetaData().getStorageUnitMetaDataMap();
return routeContext.getRouteUnits().isEmpty()
? new GenericSQLRewriteEngine(rule, protocolType, storageUnitMetaDataMap).rewrite(sqlRewriteContext)
: new RouteSQLRewriteEngine(rule, protocolType, storageUnitMetaDataMap).rewrite(sqlRewriteContext, routeContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.NewStorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData;
import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext;
import org.apache.shardingsphere.infra.rewrite.engine.result.GenericSQLRewriteResult;
import org.apache.shardingsphere.infra.rewrite.engine.result.SQLRewriteUnit;
Expand All @@ -38,7 +38,7 @@ public final class GenericSQLRewriteEngine {

private final DatabaseType protocolType;

private final Map<String, NewStorageUnitMetaData> storageUnitMetaDataMap;
private final Map<String, StorageUnitMetaData> storageUnitMetaDataMap;

/**
* Rewrite SQL and parameters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.NewStorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData;
import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext;
import org.apache.shardingsphere.infra.rewrite.engine.result.RouteSQLRewriteResult;
import org.apache.shardingsphere.infra.rewrite.engine.result.SQLRewriteUnit;
Expand Down Expand Up @@ -54,7 +54,7 @@ public final class RouteSQLRewriteEngine {

private final DatabaseType protocolType;

private final Map<String, NewStorageUnitMetaData> storageUnitMetaDataMap;
private final Map<String, StorageUnitMetaData> storageUnitMetaDataMap;

/**
* Rewrite SQL and parameters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.shardingsphere.infra.hint.HintValueContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.NewStorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
Expand Down Expand Up @@ -88,10 +88,10 @@ private ResourceMetaData mockResourceMetaData() {
when(storageUnit1.getStorageType()).thenReturn(TypedSPILoader.getService(DatabaseType.class, "H2"));
StorageUnit storageUnit2 = mock(StorageUnit.class);
when(storageUnit2.getStorageType()).thenReturn(TypedSPILoader.getService(DatabaseType.class, "MySQL"));
Map<String, NewStorageUnitMetaData> metaDataMap = new LinkedHashMap<>(2, 1F);
NewStorageUnitMetaData storageUnitMetaData1 = mock(NewStorageUnitMetaData.class);
Map<String, StorageUnitMetaData> metaDataMap = new LinkedHashMap<>(2, 1F);
StorageUnitMetaData storageUnitMetaData1 = mock(StorageUnitMetaData.class);
when(storageUnitMetaData1.getStorageUnit()).thenReturn(storageUnit1);
NewStorageUnitMetaData storageUnitMetaData2 = mock(NewStorageUnitMetaData.class);
StorageUnitMetaData storageUnitMetaData2 = mock(StorageUnitMetaData.class);
when(storageUnitMetaData2.getStorageUnit()).thenReturn(storageUnit2);
metaDataMap.put("ds_0", storageUnitMetaData1);
metaDataMap.put("ds_1", storageUnitMetaData2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.hint.HintValueContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.NewStorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext;
import org.apache.shardingsphere.infra.rewrite.engine.result.GenericSQLRewriteResult;
Expand Down Expand Up @@ -63,8 +63,8 @@ void assertRewriteStorageTypeIsEmpty() {
assertThat(actual.getSqlRewriteUnit().getParameters(), is(Collections.emptyList()));
}

private Map<String, NewStorageUnitMetaData> mockStorageUnitMetaData(final DatabaseType databaseType) {
NewStorageUnitMetaData result = mock(NewStorageUnitMetaData.class, RETURNS_DEEP_STUBS);
private Map<String, StorageUnitMetaData> mockStorageUnitMetaData(final DatabaseType databaseType) {
StorageUnitMetaData result = mock(StorageUnitMetaData.class, RETURNS_DEEP_STUBS);
when(result.getStorageUnit().getStorageType()).thenReturn(databaseType);
return Collections.singletonMap("ds_0", result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.hint.HintValueContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.NewStorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext;
import org.apache.shardingsphere.infra.rewrite.engine.result.RouteSQLRewriteResult;
Expand Down Expand Up @@ -176,8 +176,8 @@ private ShardingSphereDatabase mockDatabase() {
return result;
}

private Map<String, NewStorageUnitMetaData> mockStorageUnitMetaData(final DatabaseType databaseType) {
NewStorageUnitMetaData result = mock(NewStorageUnitMetaData.class, RETURNS_DEEP_STUBS);
private Map<String, StorageUnitMetaData> mockStorageUnitMetaData(final DatabaseType databaseType) {
StorageUnitMetaData result = mock(StorageUnitMetaData.class, RETURNS_DEEP_STUBS);
when(result.getStorageUnit().getStorageType()).thenReturn(databaseType);
return Collections.singletonMap("ds_0", result);
}
Expand Down
Loading

0 comments on commit 5f844de

Please sign in to comment.