You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ed...@apache.org on 2022/10/25 20:14:40 UTC
[accumulo] branch 2.1 updated: fix upgrade utility - resolves #3041 (#3043)
This is an automated email from the ASF dual-hosted git repository.
edcoleman pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push:
new cf32e3d17a fix upgrade utility - resolves #3041 (#3043)
cf32e3d17a is described below
commit cf32e3d17af41cee84a3c1ad4cc510798bccd5e9
Author: EdColeman <de...@etcoleman.com>
AuthorDate: Tue Oct 25 16:14:34 2022 -0400
fix upgrade utility - resolves #3041 (#3043)
---
.../server/conf/util/ConfigTransformer.java | 43 +++++++++++++++++-----
1 file changed, 33 insertions(+), 10 deletions(-)
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/util/ConfigTransformer.java b/server/base/src/main/java/org/apache/accumulo/server/conf/util/ConfigTransformer.java
index 4a28c061b4..f02c32aee7 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/util/ConfigTransformer.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/util/ConfigTransformer.java
@@ -107,6 +107,10 @@ public class ConfigTransformer {
*/
public VersionedProperties transform(final PropStoreKey<?> propStoreKey, final String legacyPath,
final boolean deleteLegacyNode) {
+ VersionedProperties exists = checkNeedsTransform(propStoreKey);
+ if (exists != null) {
+ return exists;
+ }
TransformToken token = TransformToken.createToken(legacyPath, zrw);
return transform(propStoreKey, token, legacyPath, deleteLegacyNode);
}
@@ -119,12 +123,10 @@ public class ConfigTransformer {
VersionedProperties results;
Instant start = Instant.now();
try {
+
// check for node - just return if it exists.
- results = ZooPropStore.readFromZk(propStoreKey, propStoreWatcher, zrw);
+ results = checkNeedsTransform(propStoreKey);
if (results != null) {
- log.trace(
- "Found existing node with properties at {}. skipping legacy prop conversion - version: {}, timestamp: {}",
- propStoreKey, results.getDataVersion(), results.getTimestamp());
return results;
}
@@ -198,6 +200,32 @@ public class ConfigTransformer {
return null;
}
+ /**
+ * If the config node exists, return the properties, otherwise return null. ZooKeeper exceptions
+ * are ignored. Interrupt exceptions will be propagated as IllegalStateExceptions.
+ *
+ * @param propStoreKey
+ * the prop key for that identifies the configuration node.
+ * @return the existing encoded properties if present, null if they do not.
+ */
+ private VersionedProperties checkNeedsTransform(PropStoreKey<?> propStoreKey) {
+ try { // check for node - just return if it exists.
+ VersionedProperties results = ZooPropStore.readFromZk(propStoreKey, propStoreWatcher, zrw);
+ if (results != null) {
+ log.trace(
+ "Found existing node with properties at {}. skipping legacy prop conversion - version: {}, timestamp: {}",
+ propStoreKey, results.getDataVersion(), results.getTimestamp());
+ return results;
+ }
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ throw new IllegalStateException("Interrupted during zookeeper read", ex);
+ } catch (IOException | KeeperException ex) {
+ log.trace("node for {} not found for upgrade", propStoreKey);
+ }
+ return null;
+ }
+
private Set<LegacyPropNode> convertDeprecatedProps(PropStoreKey<?> propStoreKey,
Set<LegacyPropNode> upgradeNodes) {
@@ -321,17 +349,12 @@ public class ConfigTransformer {
vProps = new VersionedProperties(props);
zrw.putPrivatePersistentData(path, codec.toBytes(vProps),
ZooUtil.NodeExistsPolicy.OVERWRITE);
- // re-read to update property version
- vProps = ZooPropStore.readFromZk(propStoreKey, propStoreWatcher, zrw);
- } else {
- // props exist - return stored value
- vProps = ZooPropStore.readFromZk(propStoreKey, propStoreWatcher, zrw);
}
+ return ZooPropStore.readFromZk(propStoreKey, propStoreWatcher, zrw);
} catch (IOException ex) {
throw new IllegalStateException(
"failed to create node for " + propStoreKey + " on conversion", ex);
}
- return vProps;
}
private boolean validateWrite(final PropStoreKey<?> propStoreKey,