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.util.Bytes;
31  
32  /**
33   * A configuration for the replication peer cluster.
34   */
35  @InterfaceAudience.Public
36  @InterfaceStability.Evolving
37  public class ReplicationPeerConfig {
38  
39    private String clusterKey;
40    private String replicationEndpointImpl;
41    private final Map<byte[], byte[]> peerData;
42    private final Map<String, String> configuration;
43    private Map<TableName, ? extends Collection<String>> tableCFsMap = null;
44    private long bandwidth = 0;
45  
46    public ReplicationPeerConfig() {
47      this.peerData = new TreeMap<byte[], byte[]>(Bytes.BYTES_COMPARATOR);
48      this.configuration = new HashMap<String, String>(0);
49    }
50  
51    /**
52     * Set the clusterKey which is the concatenation of the slave cluster's:
53     *          hbase.zookeeper.quorum:hbase.zookeeper.property.clientPort:zookeeper.znode.parent
54     */
55    public ReplicationPeerConfig setClusterKey(String clusterKey) {
56      this.clusterKey = clusterKey;
57      return this;
58    }
59  
60    /**
61     * Sets the ReplicationEndpoint plugin class for this peer.
62     * @param replicationEndpointImpl a class implementing ReplicationEndpoint
63     */
64    public ReplicationPeerConfig setReplicationEndpointImpl(String replicationEndpointImpl) {
65      this.replicationEndpointImpl = replicationEndpointImpl;
66      return this;
67    }
68  
69    public String getClusterKey() {
70      return clusterKey;
71    }
72  
73    public String getReplicationEndpointImpl() {
74      return replicationEndpointImpl;
75    }
76  
77    public Map<byte[], byte[]> getPeerData() {
78      return peerData;
79    }
80  
81    public Map<String, String> getConfiguration() {
82      return configuration;
83    }
84  
85    public Map<TableName, List<String>> getTableCFsMap() {
86      return (Map<TableName, List<String>>) tableCFsMap;
87    }
88  
89    public void setTableCFsMap(Map<TableName, ? extends Collection<String>> tableCFsMap) {
90      this.tableCFsMap = tableCFsMap;
91    }
92  
93    public long getBandwidth() {
94      return this.bandwidth;
95    }
96  
97    public ReplicationPeerConfig setBandwidth(long bandwidth) {
98      this.bandwidth = bandwidth;
99      return this;
100   }
101 
102   @Override
103   public String toString() {
104     StringBuilder builder = new StringBuilder("clusterKey=").append(clusterKey).append(",");
105     builder.append("replicationEndpointImpl=").append(replicationEndpointImpl);
106     if (tableCFsMap != null) {
107       builder.append(tableCFsMap.toString()).append(",");
108     }
109     builder.append("bandwidth=").append(bandwidth);
110     return builder.toString();
111   }
112 }