dlmarion commented on a change in pull request #2224:
URL: https://github.com/apache/accumulo/pull/2224#discussion_r703419153



##########
File path: 
server/base/src/main/java/org/apache/accumulo/server/conf/codec/VersionedProperties.java
##########
@@ -0,0 +1,258 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.server.conf.codec;
+
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.TreeMap;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Version properties maintain a {@code Map<String,String>}; of property k,v 
pairs along with
+ * versioning information metadata.
+ * <p>
+ * The metadata used to verify cached values match stored values. Storing the 
metadata with the
+ * properties allows for comparison of properties and can be used to ensure 
that values being
+ * written to the backend store have not changed. This metadata should be 
written / appear early in
+ * the encoded bytes and be uncompressed so that decisions can be made that 
may make deserialization
+ * unnecessary.
+ * <p>
+ * Note: Avoid using -1 because that has significance in ZooKeeper - writing a 
ZooKeeper node with a
+ * version of -1 disables the ZooKeeper expected version checking and just 
overwrites the node.
+ * <p>
+ * Instances of this class are immutable.
+ */
+public class VersionedProperties {
+
+  public static final DateTimeFormatter tsFormatter =
+      
DateTimeFormatter.ISO_OFFSET_DATE_TIME.withZone(ZoneId.from(ZoneOffset.UTC));
+  // flag value for initialization - on store both the version and next 
version should be 0.
+  private static final int NO_VERSION = -2;
+  private final int dataVersion;
+  private final Instant timestamp;
+  private final ImmutableMap<String,String> props;

Review comment:
       Just curious - what's the advantage of ImmutableMap over Map.of() or 
Map.ofEntries()?




-- 
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]


Reply via email to