Skip to content

Commit

Permalink
Fix wrong view zk path with new metadata structure
Browse files Browse the repository at this point in the history
  • Loading branch information
strongduanmu committed Oct 9, 2023
1 parent a2b0378 commit e7b9cee
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -67,16 +67,13 @@ public Collection<MetaDataVersion> persistSchemaMetaData(final String databaseNa
for (Entry<String, ShardingSphereView> entry : views.entrySet()) {
String viewName = entry.getKey().toLowerCase();
List<String> 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;
}
Expand Down

0 comments on commit e7b9cee

Please sign in to comment.