keith-turner commented on code in PR #4996:
URL: https://github.com/apache/accumulo/pull/4996#discussion_r1828584178
##########
server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader11to12.java:
##########
@@ -117,6 +122,27 @@ public void upgradeZookeeper(@NonNull ServerContext
context) {
zrw.overwritePersistentData(rootBase, rtm.toJson().getBytes(UTF_8),
stat.getVersion());
log.info("Root metadata in ZooKeeper after upgrade: {}", rtm.toJson());
}
+
+ String zPath = Constants.ZROOT + "/" + context.getInstanceID() +
Constants.ZNAMESPACES;
+ byte[] namespacesData = zrw.getData(zPath);
+ if (namespacesData.length != 0) {
+ throw new IllegalStateException(
+ "Unexpected data found under namespaces node: " + new
String(namespacesData, UTF_8));
+ }
+ List<String> namespaceIdList = zrw.getChildren(zPath);
+ Map<String,String> namespaceMap = new HashMap<>();
+ for (String namespaceId : namespaceIdList) {
+ String namespaceNamePath = zPath + "/" + namespaceId + ZNAMESPACE_NAME;
+ namespaceMap.put(namespaceId, new
String(zrw.getData(namespaceNamePath), UTF_8));
+ }
+ byte[] mapping = NamespaceMapping.serialize(namespaceMap);
+ zrw.putPersistentData(zPath, mapping,
ZooUtil.NodeExistsPolicy.OVERWRITE);
Review Comment:
Could the following be done?
```suggestion
if (namespacesData.length == 0) {
List<String> namespaceIdList = zrw.getChildren(zPath);
Map<String,String> namespaceMap = new HashMap<>();
for (String namespaceId : namespaceIdList) {
String namespaceNamePath = zPath + "/" + namespaceId +
ZNAMESPACE_NAME;
namespaceMap.put(namespaceId, new
String(zrw.getData(namespaceNamePath), UTF_8));
}
byte[] mapping = NamespaceMapping.serialize(namespaceMap);
zrw.putPersistentData(zPath, mapping,
ZooUtil.NodeExistsPolicy.OVERWRITE);
} else {
// assume this code is running a second time so just validate
before deleting anything
NamespaceMapping.deserialize(namespacesData);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]