frostruan commented on code in PR #4367:
URL: https://github.com/apache/hbase/pull/4367#discussion_r861502072


##########
hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/master/LogRollProcedure.java:
##########
@@ -0,0 +1,168 @@
+/**
+ * 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.hbase.backup.master;
+
+import static 
org.apache.hadoop.hbase.backup.BackupRestoreConstants.BACKUP_ENABLE_DEFAULT;
+import static 
org.apache.hadoop.hbase.backup.BackupRestoreConstants.BACKUP_ENABLE_KEY;
+import static 
org.apache.hadoop.hbase.backup.master.LogRollMasterProcedureManager.LOGROLL_PROCEDURE_ENABLED;
+import static 
org.apache.hadoop.hbase.backup.master.LogRollMasterProcedureManager.LOGROLL_PROCEDURE_ENABLED_DEFAULT;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.backup.impl.BackupSystemTable;
+import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
+import org.apache.hadoop.hbase.master.procedure.TableProcedureInterface;
+import org.apache.hadoop.hbase.procedure2.ProcedureStateSerializer;
+import org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException;
+import org.apache.hadoop.hbase.procedure2.ProcedureYieldException;
+import org.apache.hadoop.hbase.procedure2.StateMachineProcedure;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import 
org.apache.hadoop.hbase.shaded.protobuf.generated.BackupProtos.LogRollData;
+import 
org.apache.hadoop.hbase.shaded.protobuf.generated.BackupProtos.LogRollState;
+
[email protected]
+public class LogRollProcedure
+  extends StateMachineProcedure<MasterProcedureEnv, LogRollState>
+  implements TableProcedureInterface {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(RSLogRollProcedure.class);
+
+  private Configuration conf;
+
+  private String backupRoot;
+
+  public LogRollProcedure() {
+  }
+
+  public LogRollProcedure(final String backupRoot, final Configuration conf) {
+    this.backupRoot = backupRoot;
+    this.conf = conf;
+  }
+
+  @Override
+  protected Flow executeFromState(MasterProcedureEnv env, LogRollState state)
+    throws ProcedureSuspendedException, ProcedureYieldException, 
InterruptedException {
+    LOG.info("{} execute state={}", this, state);
+
+    try {
+      switch (state) {
+        case LOG_ROLL_ROLL_LOG_ON_EACH_RS:

Review Comment:
   It's just a way to make the procedure idempotent. Because this procedure 
obviously has subprocedures, its execute method will be executed multiple 
times. We can think of the state here as a flag bit. If not make it 
StateMachineProcedure, we can use a boolean flag and persist it to the state 
data. In contrast, I think StateMachineProcedure is better. Maybe there are 
better solutions. What do you think is better here?



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