HBASE-26921 Rewrite the counting cells part in TestMultiVersions (#4316)
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / replication / ReplicationSourceDummy.java
blobcab01d6fa6e63b99796f2a6986e37a5a1dbe2de8
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 ReplicationSourceInterface startup() {
75 startup.set(true);
76 return this;
79 public boolean isStartup() {
80 return startup.get();
83 @Override
84 public void terminate(String reason) {
85 terminate(reason, null);
88 @Override
89 public void terminate(String reason, Exception e) {
90 terminate(reason, e, true);
93 @Override
94 public void terminate(String reason, Exception e, boolean clearMetrics) {
95 if (clearMetrics) {
96 this.metrics.clear();
100 @Override
101 public String getQueueId() {
102 return peerClusterId;
105 @Override
106 public String getPeerId() {
107 String[] parts = peerClusterId.split("-", 2);
108 return parts.length != 1 ?
109 parts[0] : peerClusterId;
112 @Override
113 public String getStats() {
114 return "";
117 @Override
118 public void addHFileRefs(TableName tableName, byte[] family, List<Pair<Path, Path>> files)
119 throws ReplicationException {
120 return;
123 @Override
124 public boolean isPeerEnabled() {
125 return true;
128 @Override
129 public boolean isSourceActive() {
130 return true;
133 @Override
134 public MetricsSource getSourceMetrics() {
135 return metrics;
138 @Override
139 public ReplicationEndpoint getReplicationEndpoint() {
140 return null;
143 @Override
144 public ReplicationSourceManager getSourceManager() {
145 return manager;
148 @Override
149 public void tryThrottle(int batchSize) throws InterruptedException {
152 @Override
153 public void postShipEdits(List<Entry> entries, int batchSize) {
156 @Override
157 public WALFileLengthProvider getWALFileLengthProvider() {
158 return walFileLengthProvider;
161 @Override
162 public ServerName getServerWALsBelongTo() {
163 return null;
166 @Override
167 public ReplicationQueueStorage getReplicationQueueStorage() {
168 return null;
171 @Override
172 public ReplicationPeer getPeer() {
173 return replicationPeer;