EdColeman commented on a change in pull request #2224: URL: https://github.com/apache/accumulo/pull/2224#discussion_r703597457
########## 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: The changes are propagated through ZooKeeper. On a data change, the watcher will fire, which the propagates the notification to those interested - that code is in the next layer up. This way, all processes on the "local" server and the tserver(s) and other processes only see "atomic" changes in properties - with ZooKeeper being the truth. Otherwise, say something in the manager was updating properties - until those changes are committed to ZooKeeper, all master processes will have the same, original values. Once stored, those processes will get updated values on next read from the cache. -- 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]
