pkumarsinha commented on a change in pull request #2121: URL: https://github.com/apache/hive/pull/2121#discussion_r672078360
########## File path: ql/src/java/org/apache/hadoop/hive/ql/parse/repl/load/FailoverMetaData.java ########## @@ -0,0 +1,207 @@ +/* + * 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.hadoop.hive.ql.parse.repl.load; + +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.ql.parse.SemanticException; +import org.apache.hadoop.hive.ql.parse.repl.dump.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class FailoverMetaData { + public static final String FAILOVER_METADATA = "_failovermetadata"; + private static final Logger LOG = LoggerFactory.getLogger(FailoverMetaData.class); + + private static ObjectMapper JSON_OBJECT_MAPPER = new ObjectMapper(); + + @JsonProperty + private Long failoverEventId = null; + @JsonProperty + private Long cursorPoint = null; + @JsonProperty + private List<Long> abortedTxns; + @JsonProperty + private List<Long> openTxns; + @JsonProperty + private List<Long> txnsWithoutLock; + + @JsonIgnore + private boolean initialized = false; + @JsonIgnore + private final Path dumpFile; + @JsonIgnore + private final HiveConf hiveConf; + + public FailoverMetaData() { + //to be instantiated by JSON ObjectMapper. + dumpFile = null; + hiveConf = null; + } + + public FailoverMetaData(Path dumpDir, HiveConf hiveConf) { + this.hiveConf = hiveConf; + this.dumpFile = new Path(dumpDir, FAILOVER_METADATA); + } + + private void initializeIfNot() throws SemanticException { + if (!initialized) { + loadMetadataFromFile(); + initialized = true; + } + } + + public void setMetaData(FailoverMetaData otherDMD) throws SemanticException { + otherDMD.initializeIfNot(); + this.failoverEventId = otherDMD.failoverEventId; + this.abortedTxns = otherDMD.abortedTxns; + this.openTxns = otherDMD.openTxns; + this.cursorPoint = otherDMD.cursorPoint; + this.txnsWithoutLock = otherDMD.txnsWithoutLock; + this.initialized = true; + } + + private void loadMetadataFromFile() throws SemanticException { Review comment: Check if we need to synchronize this -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
