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  
34  /**
35   * Source that does nothing at all, helpful to test ReplicationSourceManager
36   */
37  public class ReplicationSourceDummy implements ReplicationSourceInterface {
38  
39    ReplicationSourceManager manager;
40    String peerClusterId;
41    Path currentPath;
42    MetricsSource metrics;
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      this.metrics = metrics;
53    }
54  
55    @Override
56    public void enqueueLog(Path log) {
57      this.currentPath = log;
58      metrics.incrSizeOfLogQueue();
59    }
60  
61    @Override
62    public Path getCurrentPath() {
63      return this.currentPath;
64    }
65  
66    @Override
67    public void startup() {
68  
69    }
70  
71    @Override
72    public void terminate(String reason) {
73  
74    }
75  
76    @Override
77    public void terminate(String reason, Exception e) {
78  
79    }
80  
81    @Override
82    public String getPeerClusterZnode() {
83      return peerClusterId;
84    }
85  
86    @Override
87    public String getPeerClusterId() {
88      String[] parts = peerClusterId.split("-", 2);
89      return parts.length != 1 ?
90          parts[0] : peerClusterId;
91    }
92  
93    @Override
94    public String getStats() {
95      return "";
96    }
97  
98    @Override
99    public void addHFileRefs(TableName tableName, byte[] family, List<String> files)
100       throws ReplicationException {
101     return;
102   }
103 
104   @Override
105   public MetricsSource getSourceMetrics() {
106     return metrics;
107   }
108 }