From e7b9ceef899e2ddbf57bbb78c9adf2885cbbd0a2 Mon Sep 17 00:00:00 2001 From: duanzhengqiang Date: Mon, 9 Oct 2023 17:10:26 +0800 Subject: [PATCH] Fix wrong view zk path with new metadata structure --- .../service/schema/NewViewMetaDataPersistService.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/schema/NewViewMetaDataPersistService.java b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/schema/NewViewMetaDataPersistService.java index c70d342629378..c20818d96c091 100644 --- a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/schema/NewViewMetaDataPersistService.java +++ b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/schema/NewViewMetaDataPersistService.java @@ -32,8 +32,8 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedList; -import java.util.Map; import java.util.List; +import java.util.Map; import java.util.Map.Entry; /** @@ -67,16 +67,13 @@ public Collection persistSchemaMetaData(final String databaseNa for (Entry entry : views.entrySet()) { String viewName = entry.getKey().toLowerCase(); List versions = repository.getChildrenKeys(NewDatabaseMetaDataNode.getViewVersionsNode(databaseName, schemaName, viewName)); - String nextActiveVersion = NewDatabaseMetaDataNode.getViewVersionNode(databaseName, schemaName, viewName, versions.isEmpty() - ? DEFAULT_VERSION - : String.valueOf(Integer.parseInt(versions.get(0)) + 1)); + String nextActiveVersion = versions.isEmpty() ? DEFAULT_VERSION : String.valueOf(Integer.parseInt(versions.get(0)) + 1); repository.persist(NewDatabaseMetaDataNode.getViewVersionNode(databaseName, schemaName, viewName, nextActiveVersion), YamlEngine.marshal(new YamlViewSwapper().swapToYamlConfiguration(entry.getValue()))); if (Strings.isNullOrEmpty(getActiveVersion(databaseName, schemaName, viewName))) { repository.persist(NewDatabaseMetaDataNode.getViewActiveVersionNode(databaseName, schemaName, viewName), DEFAULT_VERSION); } - result.add(new MetaDataVersion(NewDatabaseMetaDataNode.getViewNode(databaseName, schemaName, viewName), - getActiveVersion(databaseName, schemaName, viewName), nextActiveVersion)); + result.add(new MetaDataVersion(NewDatabaseMetaDataNode.getViewNode(databaseName, schemaName, viewName), getActiveVersion(databaseName, schemaName, viewName), nextActiveVersion)); } return result; }