3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 package org
.apache
.hadoop
.hbase
.regionserver
;
21 import java
.util
.List
;
24 import org
.apache
.hadoop
.hbase
.wal
.AbstractWALRoller
;
25 import org
.apache
.hadoop
.hbase
.wal
.WAL
;
26 import org
.apache
.yetus
.audience
.InterfaceAudience
;
27 import org
.slf4j
.Logger
;
28 import org
.slf4j
.LoggerFactory
;
31 * Runs periodically to determine if the WAL should be rolled.
33 * NOTE: This class extends Thread rather than Chore because the sleep time
34 * can be interrupted when there is something to do, rather than the Chore
35 * sleep time which is invariant.
37 * TODO: change to a pool of threads
39 @InterfaceAudience.Private
40 public class LogRoller
extends AbstractWALRoller
<RegionServerServices
> {
41 private static final Logger LOG
= LoggerFactory
.getLogger(LogRoller
.class);
43 public LogRoller(RegionServerServices services
) {
44 super("LogRoller", services
.getConfiguration(), services
);
47 protected void scheduleFlush(String encodedRegionName
, List
<byte[]> families
) {
48 RegionServerServices services
= this.abortable
;
49 HRegion r
= (HRegion
) services
.getRegion(encodedRegionName
);
51 LOG
.warn("Failed to schedule flush of {}, because it is not online on us", encodedRegionName
);
54 FlushRequester requester
= services
.getFlushRequester();
55 if (requester
== null) {
56 LOG
.warn("Failed to schedule flush of {}, region={}, because FlushRequester is null",
57 encodedRegionName
, r
);
60 // flush specified stores to clean old logs
61 requester
.requestFlush(r
, families
, FlushLifeCycleTracker
.DUMMY
);
64 Map
<WAL
, RollController
> getWalNeedsRoll() {