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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 package org
.apache
.hadoop
.hbase
.replication
;
21 import java
.util
.List
;
25 import org
.apache
.hadoop
.hbase
.TableName
;
26 import org
.apache
.yetus
.audience
.InterfaceAudience
;
29 * For creating {@link ReplicationPeerConfig}.
31 @InterfaceAudience.Public
32 public interface ReplicationPeerConfigBuilder
{
35 * Set the clusterKey which is the concatenation of the slave cluster's:
36 * hbase.zookeeper.quorum:hbase.zookeeper.property.clientPort:zookeeper.znode.parent
38 ReplicationPeerConfigBuilder
setClusterKey(String clusterKey
);
41 * Sets the ReplicationEndpoint plugin class for this peer.
42 * @param replicationEndpointImpl a class implementing ReplicationEndpoint
44 ReplicationPeerConfigBuilder
setReplicationEndpointImpl(String replicationEndpointImpl
);
47 * Sets a "raw" configuration property for this replication peer. For experts only.
48 * @param key Configuration property key
49 * @param value Configuration property value
50 * @return {@code this}
52 @InterfaceAudience.Private
53 ReplicationPeerConfigBuilder
putConfiguration(String key
, String value
);
56 * Removes a "raw" configuration property for this replication peer. For experts only.
57 * @param key Configuration property key to ve removed
58 * @return {@code this}
60 @InterfaceAudience.Private
61 ReplicationPeerConfigBuilder
removeConfiguration(String key
);
65 * Adds all of the provided "raw" configuration entries to {@code this}.
66 * @param configuration A collection of raw configuration entries
67 * @return {@code this}
69 @InterfaceAudience.Private
70 default ReplicationPeerConfigBuilder
putAllConfiguration(Map
<String
, String
> configuration
) {
71 configuration
.forEach(this::putConfiguration
);
76 * Sets the serialized peer configuration data
77 * @return {@code this}
79 @InterfaceAudience.Private
80 ReplicationPeerConfigBuilder
putPeerData(byte[] key
, byte[] value
);
83 * Sets all of the provided serialized peer configuration data.
84 * @return {@code this}
86 @InterfaceAudience.Private
87 default ReplicationPeerConfigBuilder
putAllPeerData(Map
<byte[], byte[]> peerData
) {
88 peerData
.forEach(this::putPeerData
);
93 * Sets an explicit map of tables and column families in those tables that should be replicated
94 * to the given peer. Use {@link #setReplicateAllUserTables(boolean)} to replicate all tables
97 * @param tableCFsMap A map from tableName to column family names. An empty collection can be
98 * passed to indicate replicating all column families.
99 * @return {@code this}
100 * @see #setReplicateAllUserTables(boolean)
102 ReplicationPeerConfigBuilder
103 setTableCFsMap(Map
<TableName
, List
<String
>> tableCFsMap
);
106 * Sets a unique collection of HBase namespaces that should be replicated to this peer.
107 * @param namespaces A set of namespaces to be replicated to this peer.
108 * @return {@code this}
110 ReplicationPeerConfigBuilder
setNamespaces(Set
<String
> namespaces
);
113 * Sets the speed, in bytes per second, for any one RegionServer to replicate data to the peer.
114 * @param bandwidth Bytes per second
115 * @return {@code this}.
117 ReplicationPeerConfigBuilder
setBandwidth(long bandwidth
);
120 * Configures HBase to replicate all user tables (not system tables) to the peer. Default is
122 * @param replicateAllUserTables True if all user tables should be replicated, else false.
123 * @return {@code this}
125 ReplicationPeerConfigBuilder
setReplicateAllUserTables(boolean replicateAllUserTables
);
128 * Sets the mapping of table name to column families which should not be replicated. This
129 * method sets state which is mutually exclusive to {@link #setTableCFsMap(Map)}. Invoking this
130 * method is only relevant when all user tables are being replicated.
132 * @param tableCFsMap A mapping of table names to column families which should not be
133 * replicated. An empty list of column families implies all families for the table.
134 * @return {@code this}.
136 ReplicationPeerConfigBuilder
setExcludeTableCFsMap(Map
<TableName
, List
<String
>> tableCFsMap
);
139 * Sets the collection of namespaces which should not be replicated when all user tables are
140 * configured to be replicated. This method sets state which is mutually exclusive to
141 * {@link #setNamespaces(Set)}. Invoking this method is only relevant when all user tables are
144 * @param namespaces A set of namespaces whose tables should not be replicated.
145 * @return {@code this}
147 ReplicationPeerConfigBuilder
setExcludeNamespaces(Set
<String
> namespaces
);
151 * Sets whether we should preserve order when replicating, i.e, serial replication.
154 * Default {@code false}.
156 * @param serial {@code true} means preserve order, otherwise {@code false}.
157 * @return {@code this}
159 ReplicationPeerConfigBuilder
setSerial(boolean serial
);
162 * Set the remote peer cluster's wal directory. Used by synchronous replication.
163 * @param dir the remote peer cluster's wal directory
164 * @return {@code this}
166 ReplicationPeerConfigBuilder
setRemoteWALDir(String dir
);
169 * Builds the configuration object from the current state of {@code this}.
170 * @return A {@link ReplicationPeerConfig} instance.
172 ReplicationPeerConfig
build();