View Javadoc

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
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
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.
17   */
18  
19  package org.apache.hadoop.hbase.replication;
20  
21  import java.util.Collection;
22  import java.util.HashMap;
23  import java.util.List;
24  import java.util.Map;
25  import java.util.TreeMap;
26  
27  import org.apache.hadoop.hbase.TableName;
28  import org.apache.hadoop.hbase.classification.InterfaceAudience;
29  import org.apache.hadoop.hbase.classification.InterfaceStability;
30  import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
31  import org.apache.hadoop.hbase.util.Bytes;
32  
33  /**
34   * A configuration for the replication peer cluster.
35   */
36  @InterfaceAudience.Public
37  @InterfaceStability.Evolving
38  public class ReplicationPeerConfig {
39  
40    private String clusterKey;
41    private String replicationEndpointImpl;
42    private final Map<byte[], byte[]> peerData;
43    private final Map<String, String> configuration;
44    private Map<TableName, ? extends Collection<String>> tableCFsMap = null;
45  
46  
47    public ReplicationPeerConfig() {
48      this.peerData = new TreeMap<byte[], byte[]>(Bytes.BYTES_COMPARATOR);
49      this.configuration = new HashMap<String, String>(0);
50    }
51  
52    /**
53     * Set the clusterKey which is the concatenation of the slave cluster's:
54     *          hbase.zookeeper.quorum:hbase.zookeeper.property.clientPort:zookeeper.znode.parent
55     */
56    public ReplicationPeerConfig setClusterKey(String clusterKey) {
57      this.clusterKey = clusterKey;
58      return this;
59    }
60  
61    /**
62     * Sets the ReplicationEndpoint plugin class for this peer.
63     * @param replicationEndpointImpl a class implementing ReplicationEndpoint
64     */
65    public ReplicationPeerConfig setReplicationEndpointImpl(String replicationEndpointImpl) {
66      this.replicationEndpointImpl = replicationEndpointImpl;
67      return this;
68    }
69  
70    public String getClusterKey() {
71      return clusterKey;
72    }
73  
74    public String getReplicationEndpointImpl() {
75      return replicationEndpointImpl;
76    }
77  
78    public Map<byte[], byte[]> getPeerData() {
79      return peerData;
80    }
81  
82    public Map<String, String> getConfiguration() {
83      return configuration;
84    }
85  
86    public Map<TableName, List<String>> getTableCFsMap() {
87      return (Map<TableName, List<String>>) tableCFsMap;
88    }
89  
90    public ReplicationPeerConfig setTableCFsMap(Map<TableName,
91                                                ? extends Collection<String>> tableCFsMap) {
92      this.tableCFsMap = tableCFsMap;
93      return this;
94    }
95  
96    @Override
97    public String toString() {
98      StringBuilder builder = new StringBuilder("clusterKey=").append(clusterKey).append(",");
99      builder.append("replicationEndpointImpl=").append(replicationEndpointImpl).append(",");
100     if (tableCFsMap != null) {
101       builder.append("tableCFs=").append(tableCFsMap.toString());
102     }
103     return builder.toString();
104   }
105 }