Skip to content

Commit 8b9129b

Browse files
authored
Rename SchemaMetaDataNodePath (#34964)
1 parent 0424d58 commit 8b9129b

File tree

13 files changed

+76
-76
lines changed

13 files changed

+76
-76
lines changed

mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/SchemaMetaDataPersistService.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
2222
import org.apache.shardingsphere.mode.metadata.persist.version.VersionPersistService;
2323
import org.apache.shardingsphere.mode.node.path.engine.generator.NodePathGenerator;
24-
import org.apache.shardingsphere.mode.node.path.type.database.metadata.schema.SchemaMetadataNodePath;
25-
import org.apache.shardingsphere.mode.node.path.type.database.metadata.schema.TableMetadataNodePath;
24+
import org.apache.shardingsphere.mode.node.path.type.database.metadata.schema.SchemaMetaDataNodePath;
25+
import org.apache.shardingsphere.mode.node.path.type.database.metadata.schema.TableMetaDataNodePath;
2626
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
2727

2828
import java.util.Collection;
@@ -53,7 +53,7 @@ public SchemaMetaDataPersistService(final PersistRepository repository, final Ve
5353
* @param schemaName to be added schema name
5454
*/
5555
public void add(final String databaseName, final String schemaName) {
56-
repository.persist(NodePathGenerator.toPath(new TableMetadataNodePath(databaseName, schemaName, null), false), "");
56+
repository.persist(NodePathGenerator.toPath(new TableMetaDataNodePath(databaseName, schemaName, null), false), "");
5757
}
5858

5959
/**
@@ -63,7 +63,7 @@ public void add(final String databaseName, final String schemaName) {
6363
* @param schemaName to be dropped schema name
6464
*/
6565
public void drop(final String databaseName, final String schemaName) {
66-
repository.delete(NodePathGenerator.toPath(new SchemaMetadataNodePath(databaseName, schemaName), false));
66+
repository.delete(NodePathGenerator.toPath(new SchemaMetaDataNodePath(databaseName, schemaName), false));
6767
}
6868

6969
/**
@@ -113,7 +113,7 @@ public void alterByRuleDropped(final String databaseName, final ShardingSphereSc
113113
* @return schemas
114114
*/
115115
public Collection<ShardingSphereSchema> load(final String databaseName) {
116-
return repository.getChildrenKeys(NodePathGenerator.toPath(new SchemaMetadataNodePath(databaseName, null), false)).stream()
116+
return repository.getChildrenKeys(NodePathGenerator.toPath(new SchemaMetaDataNodePath(databaseName, null), false)).stream()
117117
.map(each -> new ShardingSphereSchema(each, tableMetaDataPersistService.load(databaseName, each), viewMetaDataPersistService.load(databaseName, each))).collect(Collectors.toList());
118118
}
119119
}

mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/TableMetaDataPersistService.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.apache.shardingsphere.infra.yaml.schema.swapper.YamlTableSwapper;
2525
import org.apache.shardingsphere.mode.metadata.persist.version.VersionPersistService;
2626
import org.apache.shardingsphere.mode.node.path.engine.generator.NodePathGenerator;
27-
import org.apache.shardingsphere.mode.node.path.type.database.metadata.schema.TableMetadataNodePath;
27+
import org.apache.shardingsphere.mode.node.path.type.database.metadata.schema.TableMetaDataNodePath;
2828
import org.apache.shardingsphere.mode.node.path.version.VersionNodePath;
2929
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
3030

@@ -51,7 +51,7 @@ public final class TableMetaDataPersistService {
5151
* @return loaded tables
5252
*/
5353
public Collection<ShardingSphereTable> load(final String databaseName, final String schemaName) {
54-
return repository.getChildrenKeys(NodePathGenerator.toPath(new TableMetadataNodePath(databaseName, schemaName, null), false)).stream()
54+
return repository.getChildrenKeys(NodePathGenerator.toPath(new TableMetaDataNodePath(databaseName, schemaName, null), false)).stream()
5555
.map(each -> load(databaseName, schemaName, each)).collect(Collectors.toList());
5656
}
5757

@@ -64,7 +64,7 @@ public Collection<ShardingSphereTable> load(final String databaseName, final Str
6464
* @return loaded table
6565
*/
6666
public ShardingSphereTable load(final String databaseName, final String schemaName, final String tableName) {
67-
VersionNodePath versionNodePath = new VersionNodePath(new TableMetadataNodePath(databaseName, schemaName, tableName));
67+
VersionNodePath versionNodePath = new VersionNodePath(new TableMetaDataNodePath(databaseName, schemaName, tableName));
6868
int activeVersion = Integer.parseInt(repository.query(versionNodePath.getActiveVersionPath()));
6969
String tableContent = repository.query(versionNodePath.getVersionPath(activeVersion));
7070
return swapper.swapToObject(YamlEngine.unmarshal(tableContent, YamlShardingSphereTable.class));
@@ -80,7 +80,7 @@ public ShardingSphereTable load(final String databaseName, final String schemaNa
8080
public void persist(final String databaseName, final String schemaName, final Collection<ShardingSphereTable> tables) {
8181
for (ShardingSphereTable each : tables) {
8282
String tableName = each.getName().toLowerCase();
83-
VersionNodePath versionNodePath = new VersionNodePath(new TableMetadataNodePath(databaseName, schemaName, tableName));
83+
VersionNodePath versionNodePath = new VersionNodePath(new TableMetaDataNodePath(databaseName, schemaName, tableName));
8484
versionPersistService.persist(versionNodePath, YamlEngine.marshal(swapper.swapToYamlConfiguration(each)));
8585
}
8686
}
@@ -93,7 +93,7 @@ public void persist(final String databaseName, final String schemaName, final Co
9393
* @param tableName to be dropped table name
9494
*/
9595
public void drop(final String databaseName, final String schemaName, final String tableName) {
96-
repository.delete(NodePathGenerator.toPath(new TableMetadataNodePath(databaseName, schemaName, tableName.toLowerCase()), false));
96+
repository.delete(NodePathGenerator.toPath(new TableMetaDataNodePath(databaseName, schemaName, tableName.toLowerCase()), false));
9797
}
9898

9999
/**

mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/ViewMetaDataPersistService.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.apache.shardingsphere.infra.yaml.schema.swapper.YamlViewSwapper;
2525
import org.apache.shardingsphere.mode.metadata.persist.version.VersionPersistService;
2626
import org.apache.shardingsphere.mode.node.path.engine.generator.NodePathGenerator;
27-
import org.apache.shardingsphere.mode.node.path.type.database.metadata.schema.ViewMetadataNodePath;
27+
import org.apache.shardingsphere.mode.node.path.type.database.metadata.schema.ViewMetaDataNodePath;
2828
import org.apache.shardingsphere.mode.node.path.version.VersionNodePath;
2929
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
3030

@@ -51,7 +51,7 @@ public final class ViewMetaDataPersistService {
5151
* @return loaded views
5252
*/
5353
public Collection<ShardingSphereView> load(final String databaseName, final String schemaName) {
54-
return repository.getChildrenKeys(NodePathGenerator.toPath(new ViewMetadataNodePath(databaseName, schemaName, null), false)).stream()
54+
return repository.getChildrenKeys(NodePathGenerator.toPath(new ViewMetaDataNodePath(databaseName, schemaName, null), false)).stream()
5555
.map(each -> load(databaseName, schemaName, each)).collect(Collectors.toList());
5656
}
5757

@@ -64,7 +64,7 @@ public Collection<ShardingSphereView> load(final String databaseName, final Stri
6464
* @return loaded view
6565
*/
6666
public ShardingSphereView load(final String databaseName, final String schemaName, final String viewName) {
67-
VersionNodePath versionNodePath = new VersionNodePath(new ViewMetadataNodePath(databaseName, schemaName, viewName));
67+
VersionNodePath versionNodePath = new VersionNodePath(new ViewMetaDataNodePath(databaseName, schemaName, viewName));
6868
int activeVersion = Integer.parseInt(repository.query(versionNodePath.getActiveVersionPath()));
6969
String view = repository.query(versionNodePath.getVersionPath(activeVersion));
7070
return swapper.swapToObject(YamlEngine.unmarshal(view, YamlShardingSphereView.class));
@@ -80,7 +80,7 @@ public ShardingSphereView load(final String databaseName, final String schemaNam
8080
public void persist(final String databaseName, final String schemaName, final Collection<ShardingSphereView> views) {
8181
for (ShardingSphereView each : views) {
8282
String viewName = each.getName().toLowerCase();
83-
VersionNodePath versionNodePath = new VersionNodePath(new ViewMetadataNodePath(databaseName, schemaName, viewName));
83+
VersionNodePath versionNodePath = new VersionNodePath(new ViewMetaDataNodePath(databaseName, schemaName, viewName));
8484
versionPersistService.persist(versionNodePath, YamlEngine.marshal(swapper.swapToYamlConfiguration(each)));
8585
}
8686
}
@@ -93,6 +93,6 @@ public void persist(final String databaseName, final String schemaName, final Co
9393
* @param viewName to be dropped view name
9494
*/
9595
public void drop(final String databaseName, final String schemaName, final String viewName) {
96-
repository.delete(NodePathGenerator.toPath(new ViewMetadataNodePath(databaseName, schemaName, viewName.toLowerCase()), false));
96+
repository.delete(NodePathGenerator.toPath(new ViewMetaDataNodePath(databaseName, schemaName, viewName.toLowerCase()), false));
9797
}
9898
}
+4-4
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
import org.apache.shardingsphere.mode.node.path.type.database.metadata.DatabaseMetaDataNodePath;
2626

2727
/**
28-
* Schema metadata node path.
28+
* Schema meta data node path.
2929
*/
3030
@NodePathEntity("${database}/schemas/${schemaName}")
3131
@Getter
32-
public final class SchemaMetadataNodePath implements NodePath {
32+
public final class SchemaMetaDataNodePath implements NodePath {
3333

3434
private final DatabaseMetaDataNodePath database;
3535

3636
private final String schemaName;
3737

38-
public SchemaMetadataNodePath(final String databaseName, final String schemaName) {
38+
public SchemaMetaDataNodePath(final String databaseName, final String schemaName) {
3939
database = new DatabaseMetaDataNodePath(databaseName);
4040
this.schemaName = schemaName;
4141
}
@@ -48,6 +48,6 @@ public SchemaMetadataNodePath(final String databaseName, final String schemaName
4848
* @return created search criteria
4949
*/
5050
public static NodePathSearchCriteria createSchemaSearchCriteria(final String databaseName, final boolean containsChildPath) {
51-
return new NodePathSearchCriteria(new SchemaMetadataNodePath(databaseName, NodePathPattern.IDENTIFIER), false, containsChildPath, 1);
51+
return new NodePathSearchCriteria(new SchemaMetaDataNodePath(databaseName, NodePathPattern.IDENTIFIER), false, containsChildPath, 1);
5252
}
5353
}

mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/database/metadata/schema/TableMetadataNodePath.java mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/database/metadata/schema/TableMetaDataNodePath.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@
2424
import org.apache.shardingsphere.mode.node.path.engine.searcher.NodePathSearchCriteria;
2525

2626
/**
27-
* Table metadata node path.
27+
* Table meta data node path.
2828
*/
2929
@NodePathEntity("${schema}/tables/${tableName}")
3030
@Getter
31-
public final class TableMetadataNodePath implements NodePath {
31+
public final class TableMetaDataNodePath implements NodePath {
3232

33-
private final SchemaMetadataNodePath schema;
33+
private final SchemaMetaDataNodePath schema;
3434

3535
private final String tableName;
3636

37-
public TableMetadataNodePath(final String databaseName, final String schemaName, final String tableName) {
38-
schema = new SchemaMetadataNodePath(databaseName, schemaName);
37+
public TableMetaDataNodePath(final String databaseName, final String schemaName, final String tableName) {
38+
schema = new SchemaMetaDataNodePath(databaseName, schemaName);
3939
this.tableName = tableName;
4040
}
4141

@@ -47,6 +47,6 @@ public TableMetadataNodePath(final String databaseName, final String schemaName,
4747
* @return created search criteria
4848
*/
4949
public static NodePathSearchCriteria createTableSearchCriteria(final String databaseName, final String schemaName) {
50-
return new NodePathSearchCriteria(new TableMetadataNodePath(databaseName, schemaName, NodePathPattern.IDENTIFIER), false, true, 1);
50+
return new NodePathSearchCriteria(new TableMetaDataNodePath(databaseName, schemaName, NodePathPattern.IDENTIFIER), false, true, 1);
5151
}
5252
}

mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/database/metadata/schema/ViewMetadataNodePath.java mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/database/metadata/schema/ViewMetaDataNodePath.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@
2525
import org.apache.shardingsphere.mode.node.path.engine.searcher.NodePathSearchCriteria;
2626

2727
/**
28-
* View metadata node path.
28+
* View meta data node path.
2929
*/
3030
@NodePathEntity("${schema}/views/${viewName}")
3131
@RequiredArgsConstructor
3232
@Getter
33-
public final class ViewMetadataNodePath implements NodePath {
33+
public final class ViewMetaDataNodePath implements NodePath {
3434

35-
private final SchemaMetadataNodePath schema;
35+
private final SchemaMetaDataNodePath schema;
3636

3737
private final String viewName;
3838

39-
public ViewMetadataNodePath(final String databaseName, final String schemaName, final String viewName) {
40-
schema = new SchemaMetadataNodePath(databaseName, schemaName);
39+
public ViewMetaDataNodePath(final String databaseName, final String schemaName, final String viewName) {
40+
schema = new SchemaMetaDataNodePath(databaseName, schemaName);
4141
this.viewName = viewName;
4242
}
4343

@@ -49,6 +49,6 @@ public ViewMetadataNodePath(final String databaseName, final String schemaName,
4949
* @return created search criteria
5050
*/
5151
public static NodePathSearchCriteria createViewSearchCriteria(final String databaseName, final String schemaName) {
52-
return new NodePathSearchCriteria(new ViewMetadataNodePath(databaseName, schemaName, NodePathPattern.IDENTIFIER), false, true, 1);
52+
return new NodePathSearchCriteria(new ViewMetaDataNodePath(databaseName, schemaName, NodePathPattern.IDENTIFIER), false, true, 1);
5353
}
5454
}
+8-8
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@
1919

2020
import org.apache.shardingsphere.mode.node.path.engine.generator.NodePathGenerator;
2121
import org.apache.shardingsphere.mode.node.path.engine.searcher.NodePathSearcher;
22-
import org.apache.shardingsphere.mode.node.path.type.database.metadata.schema.SchemaMetadataNodePath;
22+
import org.apache.shardingsphere.mode.node.path.type.database.metadata.schema.SchemaMetaDataNodePath;
2323
import org.junit.jupiter.api.Test;
2424

2525
import static org.hamcrest.CoreMatchers.is;
2626
import static org.hamcrest.MatcherAssert.assertThat;
2727
import static org.junit.jupiter.api.Assertions.assertFalse;
2828

29-
class SchemaMetadataNodePathTest {
29+
class SchemaMetaDataNodePathTest {
3030

3131
@Test
3232
void assertToPath() {
33-
assertThat(NodePathGenerator.toPath(new SchemaMetadataNodePath("foo_db", null), false), is("/metadata/foo_db/schemas"));
33+
assertThat(NodePathGenerator.toPath(new SchemaMetaDataNodePath("foo_db", null), false), is("/metadata/foo_db/schemas"));
3434
}
3535

3636
@Test
3737
void assertCreateSchemaSearchCriteria() {
38-
assertThat(NodePathSearcher.get("/metadata/foo_db/schemas/foo_schema", SchemaMetadataNodePath.createSchemaSearchCriteria("foo_db", false)), is("foo_schema"));
39-
assertThat(NodePathSearcher.get("/metadata/foo_db/schemas/foo_schema/tables", SchemaMetadataNodePath.createSchemaSearchCriteria("foo_db", true)), is("foo_schema"));
40-
assertFalse(NodePathSearcher.find("/metadata/foo_db/schemas/foo_schema/tables", SchemaMetadataNodePath.createSchemaSearchCriteria("foo_db", false)).isPresent());
41-
assertFalse(NodePathSearcher.find("/xxx/foo_db/schemas/foo_schema/tables", SchemaMetadataNodePath.createSchemaSearchCriteria("foo_db", true)).isPresent());
42-
assertFalse(NodePathSearcher.find("/metadata/bar_db/schemas/foo_schema", SchemaMetadataNodePath.createSchemaSearchCriteria("foo_db", false)).isPresent());
38+
assertThat(NodePathSearcher.get("/metadata/foo_db/schemas/foo_schema", SchemaMetaDataNodePath.createSchemaSearchCriteria("foo_db", false)), is("foo_schema"));
39+
assertThat(NodePathSearcher.get("/metadata/foo_db/schemas/foo_schema/tables", SchemaMetaDataNodePath.createSchemaSearchCriteria("foo_db", true)), is("foo_schema"));
40+
assertFalse(NodePathSearcher.find("/metadata/foo_db/schemas/foo_schema/tables", SchemaMetaDataNodePath.createSchemaSearchCriteria("foo_db", false)).isPresent());
41+
assertFalse(NodePathSearcher.find("/xxx/foo_db/schemas/foo_schema/tables", SchemaMetaDataNodePath.createSchemaSearchCriteria("foo_db", true)).isPresent());
42+
assertFalse(NodePathSearcher.find("/metadata/bar_db/schemas/foo_schema", SchemaMetaDataNodePath.createSchemaSearchCriteria("foo_db", false)).isPresent());
4343
}
4444
}
+9-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import org.apache.shardingsphere.mode.node.path.engine.generator.NodePathGenerator;
2121
import org.apache.shardingsphere.mode.node.path.engine.searcher.NodePathSearcher;
22-
import org.apache.shardingsphere.mode.node.path.type.database.metadata.schema.TableMetadataNodePath;
22+
import org.apache.shardingsphere.mode.node.path.type.database.metadata.schema.TableMetaDataNodePath;
2323
import org.apache.shardingsphere.mode.node.path.version.VersionNodePath;
2424
import org.junit.jupiter.api.Test;
2525

@@ -28,28 +28,28 @@
2828
import static org.junit.jupiter.api.Assertions.assertFalse;
2929
import static org.junit.jupiter.api.Assertions.assertTrue;
3030

31-
class TableMetadataNodePathTest {
31+
class TableMetaDataNodePathTest {
3232

3333
@Test
3434
void assertToPath() {
35-
assertThat(NodePathGenerator.toPath(new TableMetadataNodePath("foo_db", "foo_schema", null), false), is("/metadata/foo_db/schemas/foo_schema/tables"));
36-
assertThat(NodePathGenerator.toPath(new TableMetadataNodePath("foo_db", "foo_schema", "foo_tbl"), false),
35+
assertThat(NodePathGenerator.toPath(new TableMetaDataNodePath("foo_db", "foo_schema", null), false), is("/metadata/foo_db/schemas/foo_schema/tables"));
36+
assertThat(NodePathGenerator.toPath(new TableMetaDataNodePath("foo_db", "foo_schema", "foo_tbl"), false),
3737
is("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl"));
3838
}
3939

4040
@Test
4141
void assertToVersionPath() {
42-
VersionNodePath versionNodePath = new VersionNodePath(new TableMetadataNodePath("foo_db", "foo_schema", "foo_tbl"));
42+
VersionNodePath versionNodePath = new VersionNodePath(new TableMetaDataNodePath("foo_db", "foo_schema", "foo_tbl"));
4343
assertThat(versionNodePath.getActiveVersionPath(), is("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl/active_version"));
4444
assertThat(versionNodePath.getVersionsPath(), is("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl/versions"));
4545
assertThat(versionNodePath.getVersionPath(0), is("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl/versions/0"));
4646
}
4747

4848
@Test
4949
void assertCreateTableSearchCriteria() {
50-
assertThat(NodePathSearcher.get("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl", TableMetadataNodePath.createTableSearchCriteria("foo_db", "foo_schema")), is("foo_tbl"));
51-
assertFalse(NodePathSearcher.find("/xxx/foo_db/schemas/foo_schema/tables/foo_tbl", TableMetadataNodePath.createTableSearchCriteria("foo_db", "foo_schema")).isPresent());
52-
assertTrue(NodePathSearcher.isMatchedPath("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl", TableMetadataNodePath.createTableSearchCriteria("foo_db", "foo_schema")));
53-
assertTrue(NodePathSearcher.isMatchedPath("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl/versions/0", TableMetadataNodePath.createTableSearchCriteria("foo_db", "foo_schema")));
50+
assertThat(NodePathSearcher.get("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl", TableMetaDataNodePath.createTableSearchCriteria("foo_db", "foo_schema")), is("foo_tbl"));
51+
assertFalse(NodePathSearcher.find("/xxx/foo_db/schemas/foo_schema/tables/foo_tbl", TableMetaDataNodePath.createTableSearchCriteria("foo_db", "foo_schema")).isPresent());
52+
assertTrue(NodePathSearcher.isMatchedPath("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl", TableMetaDataNodePath.createTableSearchCriteria("foo_db", "foo_schema")));
53+
assertTrue(NodePathSearcher.isMatchedPath("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl/versions/0", TableMetaDataNodePath.createTableSearchCriteria("foo_db", "foo_schema")));
5454
}
5555
}

0 commit comments

Comments
 (0)