You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2022/09/02 15:21:58 UTC

[GitHub] [hbase] Apache9 commented on a diff in pull request #4367: HBASE-26974 Introduce a LogRollProcedure

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


##########
hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/regionserver/LogRollCallable.java:
##########
@@ -0,0 +1,69 @@
+/**
+ * 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.regionserver;
+
+import org.apache.hadoop.hbase.backup.impl.BackupSystemTable;
+import org.apache.hadoop.hbase.executor.EventType;
+import org.apache.hadoop.hbase.procedure2.BaseRSProcedureCallable;
+import org.apache.hadoop.hbase.regionserver.wal.AbstractFSWAL;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.BackupProtos;
+
+@InterfaceAudience.Private
+public class LogRollCallable extends BaseRSProcedureCallable {
+
+  private static final Logger LOG = LoggerFactory.getLogger(LogRollCallable.class);
+
+  private String backupRoot;
+
+  @Override
+  protected void doCall() throws Exception {
+    long highest = rs.getWALs().stream()
+      .mapToLong(wal -> ((AbstractFSWAL<?>) wal).getFilenum()).max().orElse(-1L);
+    AbstractFSWAL<?> fsWAL = (AbstractFSWAL<?>) rs.getWAL(null);
+    long filenum = fsWAL.getFilenum();
+
+    LOG.info("Trying to roll log. Current log number={}, highest={}", filenum, highest);
+    rs.getWalRoller().requestRollAll();
+    rs.getWalRoller().waitUntilWalRollFinished();
+    LOG.info("After roll log, Current log number={}", fsWAL.getFilenum());
+
+    final String server = rs.getServerName().getAddress().toString();
+    final BackupSystemTable table = new BackupSystemTable(rs.getConnection());
+    Long sts = table.getRegionServerLastLogRollResult(server, backupRoot);

Review Comment:
   Then let's change it to return long instead of Long if it can not be null?



-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org