View Javadoc

1   /*
2    *
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
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
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.
18   */
19  package org.apache.hadoop.hbase.replication;
20  
21  import java.io.IOException;
22  import java.util.List;
23  import java.util.UUID;
24  
25  import org.apache.hadoop.conf.Configuration;
26  import org.apache.hadoop.fs.FileSystem;
27  import org.apache.hadoop.fs.Path;
28  import org.apache.hadoop.hbase.Stoppable;
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.util.Pair;
34  
35  /**
36   * Source that does nothing at all, helpful to test ReplicationSourceManager
37   */
38  public class ReplicationSourceDummy implements ReplicationSourceInterface {
39  
40    ReplicationSourceManager manager;
41    String peerClusterId;
42    Path currentPath;
43  
44    @Override
45    public void init(Configuration conf, FileSystem fs, ReplicationSourceManager manager,
46        ReplicationQueues rq, ReplicationPeers rp, Stoppable stopper, String peerClusterId,
47        UUID clusterId, ReplicationEndpoint replicationEndpoint, MetricsSource metrics)
48            throws IOException {
49  
50      this.manager = manager;
51      this.peerClusterId = peerClusterId;
52    }
53  
54    @Override
55    public void enqueueLog(Path log) {
56      this.currentPath = log;
57    }
58  
59    @Override
60    public Path getCurrentPath() {
61      return this.currentPath;
62    }
63  
64    @Override
65    public void startup() {
66  
67    }
68  
69    @Override
70    public void terminate(String reason) {
71  
72    }
73  
74    @Override
75    public void terminate(String reason, Exception e) {
76  
77    }
78  
79    @Override
80    public String getPeerClusterZnode() {
81      return peerClusterId;
82    }
83  
84    @Override
85    public String getPeerClusterId() {
86      String[] parts = peerClusterId.split("-", 2);
87      return parts.length != 1 ?
88          parts[0] : peerClusterId;
89    }
90  
91    @Override
92    public String getStats() {
93      return "";
94    }
95  
96    @Override
97    public void addHFileRefs(TableName tableName, byte[] family, List<Pair<Path, Path>> files)
98        throws ReplicationException {
99      return;
100   }
101 }