Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into deb5
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaojinchao95 committed May 23, 2024
2 parents bc5723e + bae03f1 commit 1755aba
Show file tree
Hide file tree
Showing 39 changed files with 90 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,13 @@ New issue Have a question about this project? Sign up for a free GitHub account
github.com
## Reference
**1. ShardingSphere-Proxy Quickstart: **[https://shardingsphere.apache.org/document/5.1.0/cn/quick-start/shardingsphere-proxy-quick-start/](https://shardingsphere.apache.org/document/5.1.0/en/quick-start/shardingsphere-proxy-quick-start/)
**1. ShardingSphere-Proxy Quickstart:** [https://shardingsphere.apache.org/document/5.1.0/cn/quick-start/shardingsphere-proxy-quick-start/](https://shardingsphere.apache.org/document/5.1.0/en/quick-start/shardingsphere-proxy-quick-start/)
**2.DistSQL RDL**https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-proxy/distsql/syntax/rdl/resource-definition/
**2.DistSQL RDL**https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-proxy/distsql/syntax/rdl/resource-definition/
**3.DistSQL RQL**https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-proxy/distsql/syntax/rql/resource-query/
**3.DistSQL RQL**https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-proxy/distsql/syntax/rql/resource-query/
**4.DistSQL RAL**https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-proxy/distsql/syntax/ral/
**4.DistSQL RAL**https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-proxy/distsql/syntax/ral/
**Apache ShardingSphere Project Links:**
[ShardingSphere Github](https://github.com/apache/shardingsphere/issues?page=1&q=is%3Aopen+is%3Aissue+label%3A%22project%3A+OpenForce+2022%22)
Expand Down
10 changes: 5 additions & 5 deletions docs/document/content/features/shadow/limitations.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ weight = 2
+++

## 基于 Hint 的影子算法

* 无。
*

## 基于列的影子算法
SQL 不支持列表:
* 不支持 DDL
* 不支持范围、分组和子查询,如:BETWEEN、GROUP BY ... HAVING 等

* 不支持 DDL;
* 不支持范围、分组和子查询,如:BETWEEN、GROUP BY ... HAVING 等。
SQL 支持列表:
SQL 支持列表:
- INSERT

| *SQL* | *是否支持* |
Expand Down
6 changes: 3 additions & 3 deletions docs/document/content/features/shadow/limitations.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ weight = 2
No

## Column based shadow algorithm
SQL does not support lists:
- Does not support DDL.

Does not support DDL.

Does not support scope, group, subqueries such as BETWEEN, GROUP BY ... HAVING, etc.
- Does not support scope, group, subqueries such as BETWEEN, GROUP BY ... HAVING, etc.

SQL support list

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ public final class MetaDataVersion {
private final String nextActiveVersion;

public MetaDataVersion(final String key) {
this.key = key;
currentActiveVersion = "";
nextActiveVersion = "";
this(key, "", "");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ public void clean(final String jobId, final int shardingItem) {
* @return error msg
*/
public String load(final String jobId, final int shardingItem) {
return Optional.ofNullable(repository.getDirectly(PipelineMetaDataNode.getJobItemErrorMessagePath(jobId, shardingItem))).orElse("");
return Optional.ofNullable(repository.query(PipelineMetaDataNode.getJobItemErrorMessagePath(jobId, shardingItem))).orElse("");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void update(final String jobId, final int shardingItem, final String prog
* @return job item progress
*/
public Optional<String> load(final String jobId, final int shardingItem) {
String text = repository.getDirectly(PipelineMetaDataNode.getJobOffsetItemPath(jobId, shardingItem));
String text = repository.query(PipelineMetaDataNode.getJobOffsetItemPath(jobId, shardingItem));
return Strings.isNullOrEmpty(text) ? Optional.empty() : Optional.of(text);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public final class PipelineJobCheckGovernanceRepository {
* @return check job id
*/
public Optional<String> findLatestCheckJobId(final String parentJobId) {
return Optional.ofNullable(repository.getDirectly(PipelineMetaDataNode.getLatestCheckJobIdPath(parentJobId)));
return Optional.ofNullable(repository.query(PipelineMetaDataNode.getLatestCheckJobIdPath(parentJobId)));
}

/**
Expand Down Expand Up @@ -91,7 +91,7 @@ public void deleteLatestCheckJobId(final String parentJobId) {
*/
@SuppressWarnings("unchecked")
public Map<String, TableDataConsistencyCheckResult> getCheckJobResult(final String parentJobId, final String checkJobId) {
String yamlCheckResultMapText = repository.getDirectly(PipelineMetaDataNode.getCheckJobResultPath(parentJobId, checkJobId));
String yamlCheckResultMapText = repository.query(PipelineMetaDataNode.getCheckJobResultPath(parentJobId, checkJobId));
if (Strings.isNullOrEmpty(yamlCheckResultMapText)) {
return Collections.emptyMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class PipelineJobConfigurationGovernanceRepository {
* @return pipeline job configuration exists or not
*/
public boolean isExisted(final String jobId) {
return null != repository.getDirectly(PipelineMetaDataNode.getJobConfigurationPath(jobId));
return null != repository.query(PipelineMetaDataNode.getJobConfigurationPath(jobId));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void persist(final String jobId, final JobOffsetInfo jobOffsetInfo) {
* @return job offset info
*/
public JobOffsetInfo load(final String jobId) {
String value = repository.getDirectly(PipelineMetaDataNode.getJobOffsetPath(jobId));
String value = repository.query(PipelineMetaDataNode.getJobOffsetPath(jobId));
return new YamlJobOffsetInfoSwapper().swapToObject(Strings.isNullOrEmpty(value) ? new YamlJobOffsetInfo() : YamlEngine.unmarshal(value, YamlJobOffsetInfo.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ public void persist(final String jobType, final String metaDataDataSources) {
* @return data source properties
*/
public String load(final String jobType) {
return repository.getDirectly(PipelineMetaDataNode.getMetaDataDataSourcesPath(jobType));
return repository.query(PipelineMetaDataNode.getMetaDataDataSourcesPath(jobType));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ public void persist(final String jobType, final String processConfigYamlText) {
* @return process configuration YAML text
*/
public String load(final String jobType) {
return repository.getDirectly(PipelineMetaDataNode.getMetaDataProcessConfigPath(jobType));
return repository.query(PipelineMetaDataNode.getMetaDataProcessConfigPath(jobType));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void loadNodes(final String toBeLoadedNode, final Collection<String> loa
}

private RepositoryTuple getRepositoryTuple(final String node) {
String activeRuleKey = node.replace(ACTIVE_VERSION_PATH, VERSIONS_PATH) + "/" + repository.getDirectly(node);
return new RepositoryTuple(activeRuleKey, repository.getDirectly(activeRuleKey));
String activeRuleKey = node.replace(ACTIVE_VERSION_PATH, VERSIONS_PATH) + "/" + repository.query(node);
return new RepositoryTuple(activeRuleKey, repository.query(activeRuleKey));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void persist(final String databaseName, final Map<String, DataSourcePoolP
public Map<String, DataSourcePoolProperties> load(final String databaseName) {
Map<String, DataSourcePoolProperties> result = new LinkedHashMap<>();
for (String each : repository.getChildrenKeys(DataSourceMetaDataNode.getDataSourceNodesNode(databaseName))) {
String dataSourceValue = repository.getDirectly(DataSourceMetaDataNode.getDataSourceNodeVersionNode(databaseName, each, getDataSourceActiveVersion(databaseName, each)));
String dataSourceValue = repository.query(DataSourceMetaDataNode.getDataSourceNodeVersionNode(databaseName, each, getDataSourceActiveVersion(databaseName, each)));
if (!Strings.isNullOrEmpty(dataSourceValue)) {
result.put(each, new YamlDataSourceConfigurationSwapper().swapToDataSourcePoolProperties(YamlEngine.unmarshal(dataSourceValue, Map.class)));
}
Expand All @@ -74,8 +74,8 @@ public Map<String, DataSourcePoolProperties> load(final String databaseName) {
@SuppressWarnings("unchecked")
@Override
public Map<String, DataSourcePoolProperties> load(final String databaseName, final String name) {
Map<String, DataSourcePoolProperties> result = new LinkedHashMap<>();
String dataSourceValue = repository.getDirectly(DataSourceMetaDataNode.getDataSourceNodeVersionNode(databaseName, name, getDataSourceActiveVersion(databaseName, name)));
Map<String, DataSourcePoolProperties> result = new LinkedHashMap<>(1, 1F);
String dataSourceValue = repository.query(DataSourceMetaDataNode.getDataSourceNodeVersionNode(databaseName, name, getDataSourceActiveVersion(databaseName, name)));
if (!Strings.isNullOrEmpty(dataSourceValue)) {
result.put(name, new YamlDataSourceConfigurationSwapper().swapToDataSourcePoolProperties(YamlEngine.unmarshal(dataSourceValue, Map.class)));
}
Expand Down Expand Up @@ -115,6 +115,6 @@ public Collection<MetaDataVersion> persistConfigurations(final String databaseNa
}

private String getDataSourceActiveVersion(final String databaseName, final String dataSourceName) {
return repository.getDirectly(DataSourceMetaDataNode.getDataSourceNodeActiveVersionNode(databaseName, dataSourceName));
return repository.query(DataSourceMetaDataNode.getDataSourceNodeActiveVersionNode(databaseName, dataSourceName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void persist(final String databaseName, final Map<String, DataSourcePoolP
public Map<String, DataSourcePoolProperties> load(final String databaseName) {
Map<String, DataSourcePoolProperties> result = new LinkedHashMap<>();
for (String each : repository.getChildrenKeys(DataSourceMetaDataNode.getDataSourceUnitsNode(databaseName))) {
String dataSourceValue = repository.getDirectly(DataSourceMetaDataNode.getDataSourceUnitVersionNode(databaseName, each, getDataSourceActiveVersion(databaseName, each)));
String dataSourceValue = repository.query(DataSourceMetaDataNode.getDataSourceUnitVersionNode(databaseName, each, getDataSourceActiveVersion(databaseName, each)));
if (!Strings.isNullOrEmpty(dataSourceValue)) {
result.put(each, new YamlDataSourceConfigurationSwapper().swapToDataSourcePoolProperties(YamlEngine.unmarshal(dataSourceValue, Map.class)));
}
Expand All @@ -74,8 +74,8 @@ public Map<String, DataSourcePoolProperties> load(final String databaseName) {
@SuppressWarnings("unchecked")
@Override
public Map<String, DataSourcePoolProperties> load(final String databaseName, final String name) {
Map<String, DataSourcePoolProperties> result = new LinkedHashMap<>();
String dataSourceValue = repository.getDirectly(DataSourceMetaDataNode.getDataSourceUnitVersionNode(databaseName, name, getDataSourceActiveVersion(databaseName, name)));
Map<String, DataSourcePoolProperties> result = new LinkedHashMap<>(1, 1F);
String dataSourceValue = repository.query(DataSourceMetaDataNode.getDataSourceUnitVersionNode(databaseName, name, getDataSourceActiveVersion(databaseName, name)));
if (!Strings.isNullOrEmpty(dataSourceValue)) {
result.put(name, new YamlDataSourceConfigurationSwapper().swapToDataSourcePoolProperties(YamlEngine.unmarshal(dataSourceValue, Map.class)));
}
Expand Down Expand Up @@ -115,6 +115,6 @@ public Collection<MetaDataVersion> persistConfigurations(final String databaseNa
}

private String getDataSourceActiveVersion(final String databaseName, final String dataSourceName) {
return repository.getDirectly(DataSourceMetaDataNode.getDataSourceUnitActiveVersionNode(databaseName, dataSourceName));
return repository.query(DataSourceMetaDataNode.getDataSourceUnitActiveVersionNode(databaseName, dataSourceName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,6 @@ private Collection<MetaDataVersion> deleteRepositoryTuples(final String database
}

private String getActiveVersion(final String databaseName, final String ruleName, final String key) {
return repository.getDirectly(DatabaseRuleMetaDataNode.getDatabaseRuleActiveVersionNode(databaseName, ruleName, key));
return repository.query(DatabaseRuleMetaDataNode.getDatabaseRuleActiveVersionNode(databaseName, ruleName, key));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ private Collection<MetaDataVersion> persistTuples(final Collection<RepositoryTup
List<String> versions = repository.getChildrenKeys(GlobalNode.getGlobalRuleVersionsNode(each.getKey()));
String nextActiveVersion = versions.isEmpty() ? DEFAULT_VERSION : String.valueOf(Integer.parseInt(versions.get(0)) + 1);
repository.persist(GlobalNode.getGlobalRuleVersionNode(each.getKey(), nextActiveVersion), each.getValue());
if (Strings.isNullOrEmpty(repository.getDirectly(GlobalNode.getGlobalRuleActiveVersionNode(each.getKey())))) {
if (Strings.isNullOrEmpty(repository.query(GlobalNode.getGlobalRuleActiveVersionNode(each.getKey())))) {
repository.persist(GlobalNode.getGlobalRuleActiveVersionNode(each.getKey()), DEFAULT_VERSION);
}
result.add(new MetaDataVersion(GlobalNode.getGlobalRuleNode(each.getKey()), repository.getDirectly(GlobalNode.getGlobalRuleActiveVersionNode(each.getKey())), nextActiveVersion));
result.add(new MetaDataVersion(GlobalNode.getGlobalRuleNode(each.getKey()), repository.query(GlobalNode.getGlobalRuleActiveVersionNode(each.getKey())), nextActiveVersion));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public void persist(final Properties props) {

@Override
public Properties load() {
String yamlContent = repository.getDirectly(GlobalNode.getPropsVersionNode(getActiveVersion()));
String yamlContent = repository.query(GlobalNode.getPropsVersionNode(getActiveVersion()));
return Strings.isNullOrEmpty(yamlContent) ? new Properties() : YamlEngine.unmarshal(yamlContent, Properties.class);
}

private String getActiveVersion() {
return repository.getDirectly(GlobalNode.getPropsActiveVersionNode());
return repository.query(GlobalNode.getPropsActiveVersionNode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public ShardingSphereTableData load(final String databaseName, final String sche
ShardingSphereTableData result = new ShardingSphereTableData(tableName);
YamlShardingSphereRowDataSwapper swapper = new YamlShardingSphereRowDataSwapper(new ArrayList<>(table.getColumnValues()));
for (String each : repository.getChildrenKeys(ShardingSphereDataNode.getTablePath(databaseName, schemaName, tableName))) {
String yamlRow = repository.getDirectly(ShardingSphereDataNode.getTableRowPath(databaseName, schemaName, tableName, each));
String yamlRow = repository.query(ShardingSphereDataNode.getTableRowPath(databaseName, schemaName, tableName, each));
if (!Strings.isNullOrEmpty(yamlRow)) {
result.getRows().add(swapper.swapToObject(YamlEngine.unmarshal(yamlRow, YamlShardingSphereRowData.class)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void persist(final String databaseName, final String schemaName, final Ma
}

private String getActiveVersion(final String databaseName, final String schemaName, final String tableName) {
return repository.getDirectly(TableMetaDataNode.getTableActiveVersionNode(databaseName, schemaName, tableName));
return repository.query(TableMetaDataNode.getTableActiveVersionNode(databaseName, schemaName, tableName));
}

@Override
Expand All @@ -83,8 +83,8 @@ public Map<String, ShardingSphereTable> load(final String databaseName, final St
private Map<String, ShardingSphereTable> getTableMetaDataByTableNames(final String databaseName, final String schemaName, final Collection<String> tableNames) {
Map<String, ShardingSphereTable> result = new LinkedHashMap<>(tableNames.size(), 1F);
tableNames.forEach(each -> {
String table = repository.getDirectly(TableMetaDataNode.getTableVersionNode(databaseName, schemaName, each,
repository.getDirectly(TableMetaDataNode.getTableActiveVersionNode(databaseName, schemaName, each))));
String table = repository.query(TableMetaDataNode.getTableVersionNode(databaseName, schemaName, each,
repository.query(TableMetaDataNode.getTableActiveVersionNode(databaseName, schemaName, each))));
if (!Strings.isNullOrEmpty(table)) {
result.put(each.toLowerCase(), new YamlTableSwapper().swapToObject(YamlEngine.unmarshal(table, YamlShardingSphereTable.class)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void persist(final String databaseName, final String schemaName, final Ma
}

private String getActiveVersion(final String databaseName, final String schemaName, final String viewName) {
return repository.getDirectly(ViewMetaDataNode.getViewActiveVersionNode(databaseName, schemaName, viewName));
return repository.query(ViewMetaDataNode.getViewActiveVersionNode(databaseName, schemaName, viewName));
}

@Override
Expand All @@ -83,8 +83,8 @@ public Map<String, ShardingSphereView> load(final String databaseName, final Str
private Map<String, ShardingSphereView> getViewMetaDataByViewNames(final String databaseName, final String schemaName, final Collection<String> viewNames) {
Map<String, ShardingSphereView> result = new LinkedHashMap<>(viewNames.size(), 1F);
viewNames.forEach(each -> {
String view = repository.getDirectly(ViewMetaDataNode.getViewVersionNode(databaseName, schemaName, each,
repository.getDirectly(ViewMetaDataNode.getViewActiveVersionNode(databaseName, schemaName, each))));
String view = repository.query(ViewMetaDataNode.getViewVersionNode(databaseName, schemaName, each,
repository.query(ViewMetaDataNode.getViewActiveVersionNode(databaseName, schemaName, each))));
if (!Strings.isNullOrEmpty(view)) {
result.put(each.toLowerCase(), new YamlViewSwapper().swapToObject(YamlEngine.unmarshal(view, YamlShardingSphereView.class)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public void switchActiveVersion(final Collection<MetaDataVersion> metaDataVersio

@Override
public String getActiveVersionByFullPath(final String fullPath) {
return repository.getDirectly(fullPath);
return repository.query(fullPath);
}

@Override
public String getVersionPathByActiveVersion(final String path, final String activeVersion) {
return repository.getDirectly(DatabaseMetaDataNode.getVersionNodeByActiveVersionPath(path, activeVersion));
return repository.query(DatabaseMetaDataNode.getVersionNodeByActiveVersionPath(path, activeVersion));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
/**
* Persist repository.
*/
public interface PersistRepository extends TypedSPI {
public interface PersistRepository extends TypedSPI, AutoCloseable {

/**
* Path separator.
*/
String PATH_SEPARATOR = "/";

/**
* Get value from registry center directly.
* Query data.
*
* @param key key
* @return value
* @param key key to be queried
* @return queryed data
*/
String getDirectly(String key);
String query(String key);

/**
* Get names of sub-node.
Expand All @@ -48,10 +48,10 @@ public interface PersistRepository extends TypedSPI {
List<String> getChildrenKeys(String key);

/**
* Judge node is exist or not.
* Judge node is existed or not.
*
* @param key key
* @return node is exist or not
* @return node is existed or not
*/
boolean isExisted(String key);

Expand Down Expand Up @@ -87,8 +87,6 @@ default void persistEphemeral(String key, String value) {
*/
void delete(String key);

/**
* Close.
*/
@Override
void close();
}
Loading

0 comments on commit 1755aba

Please sign in to comment.