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.HashMap;
22  import java.util.Map;
23  import java.util.TreeMap;
24  
25  import org.apache.hadoop.hbase.classification.InterfaceAudience;
26  import org.apache.hadoop.hbase.classification.InterfaceStability;
27  import org.apache.hadoop.hbase.util.Bytes;
28  
29  /**
30   * A configuration for the replication peer cluster.
31   */
32  @InterfaceAudience.Public
33  @InterfaceStability.Evolving
34  public class ReplicationPeerConfig {
35  
36    private String clusterKey;
37    private String replicationEndpointImpl;
38    private final Map<byte[], byte[]> peerData;
39    private final Map<String, String> configuration;
40  
41  
42    public ReplicationPeerConfig() {
43      this.peerData = new TreeMap<byte[], byte[]>(Bytes.BYTES_COMPARATOR);
44      this.configuration = new HashMap<String, String>(0);
45    }
46  
47    /**
48     * Set the clusterKey which is the concatenation of the slave cluster's:
49     *          hbase.zookeeper.quorum:hbase.zookeeper.property.clientPort:zookeeper.znode.parent
50     */
51    public ReplicationPeerConfig setClusterKey(String clusterKey) {
52      this.clusterKey = clusterKey;
53      return this;
54    }
55  
56    /**
57     * Sets the ReplicationEndpoint plugin class for this peer.
58     * @param replicationEndpointImpl a class implementing ReplicationEndpoint
59     */
60    public ReplicationPeerConfig setReplicationEndpointImpl(String replicationEndpointImpl) {
61      this.replicationEndpointImpl = replicationEndpointImpl;
62      return this;
63    }
64  
65    public String getClusterKey() {
66      return clusterKey;
67    }
68  
69    public String getReplicationEndpointImpl() {
70      return replicationEndpointImpl;
71    }
72  
73    public Map<byte[], byte[]> getPeerData() {
74      return peerData;
75    }
76  
77    public Map<String, String> getConfiguration() {
78      return configuration;
79    }
80  
81    @Override
82    public String toString() {
83      StringBuilder builder = new StringBuilder("clusterKey=").append(clusterKey).append(",");
84      builder.append("replicationEndpointImpl=").append(replicationEndpointImpl);
85      return builder.toString();
86    }
87  }