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
;
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);
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
)
55 this.manager
= manager
;
56 this.peerClusterId
= peerClusterId
;
57 this.metrics
= metrics
;
58 this.walFileLengthProvider
= walFileLengthProvider
;
59 this.replicationPeer
= rp
;
63 public void enqueueLog(Path log
) {
64 this.currentPath
= log
;
65 metrics
.incrSizeOfLogQueue();
69 public Path
getCurrentPath() {
70 return this.currentPath
;
74 public void startup() {
78 public boolean isStartup() {
83 public void terminate(String reason
) {
84 terminate(reason
, null);
88 public void terminate(String reason
, Exception e
) {
89 terminate(reason
, e
, true);
93 public void terminate(String reason
, Exception e
, boolean clearMetrics
) {
100 public String
getQueueId() {
101 return peerClusterId
;
105 public String
getPeerId() {
106 String
[] parts
= peerClusterId
.split("-", 2);
107 return parts
.length
!= 1 ?
108 parts
[0] : peerClusterId
;
112 public String
getStats() {
117 public void addHFileRefs(TableName tableName
, byte[] family
, List
<Pair
<Path
, Path
>> files
)
118 throws ReplicationException
{
123 public boolean isPeerEnabled() {
128 public boolean isSourceActive() {
133 public MetricsSource
getSourceMetrics() {
138 public ReplicationEndpoint
getReplicationEndpoint() {
143 public ReplicationSourceManager
getSourceManager() {
148 public void tryThrottle(int batchSize
) throws InterruptedException
{
152 public void postShipEdits(List
<Entry
> entries
, int batchSize
) {
156 public WALFileLengthProvider
getWALFileLengthProvider() {
157 return walFileLengthProvider
;
161 public ServerName
getServerWALsBelongTo() {
166 public ReplicationPeer
getPeer() {
167 return replicationPeer
;