GlenGeng commented on a change in pull request #1725: URL: https://github.com/apache/ozone/pull/1725#discussion_r557260195
########## File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMTransactionInfo.java ########## @@ -0,0 +1,145 @@ +/* + * 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 + * <p> + * <p>http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * <p>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.hdds.scm.ha; + +import com.google.common.base.Preconditions; +import org.apache.hadoop.hdds.StringUtils; +import org.apache.ratis.server.protocol.TermIndex; +import org.apache.ratis.statemachine.SnapshotInfo; + +import java.util.Objects; + +import static org.apache.hadoop.ozone.OzoneConsts.TRANSACTION_INFO_SPLIT_KEY; + +/** + * SCMTransactionInfo saves two fields for a transaction: + * 1. term, of which the transaction belongs to + * 2. transactionIndex, which is a monotonic increasing index + * (e.g. Raft Log index) + */ +final public class SCMTransactionInfo { + private long term; + private long transactionIndex; + + private SCMTransactionInfo(String transactionInfo) { + String[] tInfo = + transactionInfo.split(TRANSACTION_INFO_SPLIT_KEY); + Preconditions.checkState(tInfo.length == 2, + "Incorrect TransactionInfo value"); + + term = Long.parseLong(tInfo[0]); + transactionIndex = Long.parseLong(tInfo[1]); + } + + private SCMTransactionInfo(long currentTerm, long transactionIndex) { + this.term = currentTerm; + this.transactionIndex = transactionIndex; + } + + public boolean shouldUpdate() { Review comment: `shouldUpdate()` is not very intuitive in the context of `SCMTransactionInfo`, how about `isInitialized()` or something like this ? ########## File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineManagerV2Impl.java ########## @@ -111,15 +113,25 @@ private PipelineManagerV2Impl(ConfigurationSource conf, this.pipelineCreationAllowed = new AtomicBoolean(!this.isInSafeMode.get()); } - public static PipelineManagerV2Impl newPipelineManager( + public static PipelineManagerV2Impl newPipelineManagerWithMockBuffer( Review comment: `DBTransactionBuffer` can be fetched by calling `SCMHAManager#getDBTransactionBuffer`, so this function `newPipelineManagerWithMockBuffer` is not needed. ``` // Create PipelineStateManager StateManager stateManager = PipelineStateManagerV2Impl .newBuilder().setPipelineStore(pipelineStore) .setRatisServer(scmhaManager.getRatisServer()) .setNodeManager(nodeManager) .setSCMDBTransactionBuffer(scmhaManager.getDBTransactionBuffer()) .build() ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
