HBASE-23723 Ensure MOB compaction works in optimized mode after snapshot clone (...
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / replication / ReplicationSourceDummy.java
bloba361c4470604e7860d10a3c90bdfbc05a9276aeb
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase.replication;
20 import java.io.IOException;
21 import java.util.List;
22 import java.util.UUID;
23 import java.util.concurrent.atomic.AtomicBoolean;
24 import org.apache.hadoop.conf.Configuration;
25 import org.apache.hadoop.fs.FileSystem;
26 import org.apache.hadoop.fs.Path;
27 import org.apache.hadoop.hbase.Server;
28 import org.apache.hadoop.hbase.ServerName;
29 import org.apache.hadoop.hbase.TableName;
30 import org.apache.hadoop.hbase.replication.regionserver.MetricsSource;
31 import org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceInterface;
32 import org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager;
33 import org.apache.hadoop.hbase.replication.regionserver.WALFileLengthProvider;
34 import org.apache.hadoop.hbase.util.Pair;
35 import org.apache.hadoop.hbase.wal.WAL.Entry;
37 /**
38 * Source that does nothing at all, helpful to test ReplicationSourceManager
40 public class ReplicationSourceDummy implements ReplicationSourceInterface {
42 private ReplicationSourceManager manager;
43 private ReplicationPeer replicationPeer;
44 private String peerClusterId;
45 private Path currentPath;
46 private MetricsSource metrics;
47 private WALFileLengthProvider walFileLengthProvider;
48 private AtomicBoolean startup = new AtomicBoolean(false);
50 @Override
51 public void init(Configuration conf, FileSystem fs, ReplicationSourceManager manager,
52 ReplicationQueueStorage rq, ReplicationPeer rp, Server server, String peerClusterId,
53 UUID clusterId, WALFileLengthProvider walFileLengthProvider, MetricsSource metrics)
54 throws IOException {
55 this.manager = manager;
56 this.peerClusterId = peerClusterId;
57 this.metrics = metrics;
58 this.walFileLengthProvider = walFileLengthProvider;
59 this.replicationPeer = rp;
62 @Override
63 public void enqueueLog(Path log) {
64 this.currentPath = log;
65 metrics.incrSizeOfLogQueue();
68 @Override
69 public Path getCurrentPath() {
70 return this.currentPath;
73 @Override
74 public void startup() {
75 startup.set(true);
78 public boolean isStartup() {
79 return startup.get();
82 @Override
83 public void terminate(String reason) {
84 terminate(reason, null);
87 @Override
88 public void terminate(String reason, Exception e) {
89 terminate(reason, e, true);
92 @Override
93 public void terminate(String reason, Exception e, boolean clearMetrics) {
94 if (clearMetrics) {
95 this.metrics.clear();
99 @Override
100 public String getQueueId() {
101 return peerClusterId;
104 @Override
105 public String getPeerId() {
106 String[] parts = peerClusterId.split("-", 2);
107 return parts.length != 1 ?
108 parts[0] : peerClusterId;
111 @Override
112 public String getStats() {
113 return "";
116 @Override
117 public void addHFileRefs(TableName tableName, byte[] family, List<Pair<Path, Path>> files)
118 throws ReplicationException {
119 return;
122 @Override
123 public boolean isPeerEnabled() {
124 return true;
127 @Override
128 public boolean isSourceActive() {
129 return true;
132 @Override
133 public MetricsSource getSourceMetrics() {
134 return metrics;
137 @Override
138 public ReplicationEndpoint getReplicationEndpoint() {
139 return null;
142 @Override
143 public ReplicationSourceManager getSourceManager() {
144 return manager;
147 @Override
148 public void tryThrottle(int batchSize) throws InterruptedException {
151 @Override
152 public void postShipEdits(List<Entry> entries, int batchSize) {
155 @Override
156 public WALFileLengthProvider getWALFileLengthProvider() {
157 return walFileLengthProvider;
160 @Override
161 public ServerName getServerWALsBelongTo() {
162 return null;
165 @Override
166 public ReplicationPeer getPeer() {
167 return replicationPeer;