rmdmattingly commented on code in PR #6484:
URL: https://github.com/apache/hbase/pull/6484#discussion_r1855465935
##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationPeerConfigUtil.java:
##########
@@ -249,6 +289,41 @@ public static Map<TableName, List<String>>
convert2Map(ReplicationProtos.TableCF
return tableCFsMap;
}
+ /**
+ * Convert sourceToSinkTableOverrides Object to Map.
+ */
+ public static Map<TableName, TableName>
+ convert2Map(ReplicationProtos.SourceToSinkTableOverride[]
sourceToSinkTableOverrides) {
Review Comment:
nit: rename to `convertTableOverridesToMap`?
##########
hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeerConfigBuilder.java:
##########
@@ -97,13 +97,39 @@ default ReplicationPeerConfigBuilder
putAllPeerData(Map<byte[], byte[]> peerData
*/
ReplicationPeerConfigBuilder setTableCFsMap(Map<TableName, List<String>>
tableCFsMap);
+ /**
+ * Sets an explicit map of source to sink tables that should be replicated
to the given peer. If
+ * the map is empty for a table, the source table is used for the given peer.
+ * @param sourceToSinkTableOverrides A map from a source tableName to sink
tableName. By default,
+ * edits will be replicated to the same
target table as the
+ * source table. A null or empty
collection can be passed to
+ * indicate there are no overrides.
+ * @return {@code this}
+ */
+ ReplicationPeerConfigBuilder
+ setSourceToSinkTableOverrides(Map<TableName, TableName>
sourceToSinkTableOverrides);
Review Comment:
Can these keys and values be TableNames instead? That would allow you to
make fewer assumptions about the namespace, and simplify down to only one map
of overrides
##########
hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeerConfigBuilder.java:
##########
@@ -97,13 +97,39 @@ default ReplicationPeerConfigBuilder
putAllPeerData(Map<byte[], byte[]> peerData
*/
ReplicationPeerConfigBuilder setTableCFsMap(Map<TableName, List<String>>
tableCFsMap);
+ /**
+ * Sets an explicit map of source to sink tables that should be replicated
to the given peer. If
+ * the map is empty for a table, the source table is used for the given peer.
+ * @param sourceToSinkTableOverrides A map from a source tableName to sink
tableName. By default,
+ * edits will be replicated to the same
target table as the
+ * source table. A null or empty
collection can be passed to
+ * indicate there are no overrides.
+ * @return {@code this}
+ */
+ ReplicationPeerConfigBuilder
+ setSourceToSinkTableOverrides(Map<TableName, TableName>
sourceToSinkTableOverrides);
+
/**
* Sets a unique collection of HBase namespaces that should be replicated to
this peer.
* @param namespaces A set of namespaces to be replicated to this peer.
* @return {@code this}
*/
ReplicationPeerConfigBuilder setNamespaces(Set<String> namespaces);
+ /**
+ * Sets an explicit map of source to sink namespaces that should be
replicated to the given peer.
+ * If the map is empty for a namespace, the source namespace is used for the
given peer. Use
+ * {@link #setSourceToSinkTableOverrides} to override the namespace
overrides set in this method
+ * for a given table.
+ * @param sourceToSinkNamespaceOverrides A map from a source namespace to
sink namespace. By
+ * default, edits will be replicated
to the same namespace
+ * as the source namespace. A null or
empty collection can
+ * be passed to indicate there are no
overrides.
Review Comment:
What happens if the map of table overrides only covers a subset of the
peer's tables? I wonder whether this method should throw in that case so that
we don't need to explicitly support it
##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationPeerConfigUtil.java:
##########
@@ -249,6 +289,41 @@ public static Map<TableName, List<String>>
convert2Map(ReplicationProtos.TableCF
return tableCFsMap;
}
+ /**
+ * Convert sourceToSinkTableOverrides Object to Map.
+ */
+ public static Map<TableName, TableName>
+ convert2Map(ReplicationProtos.SourceToSinkTableOverride[]
sourceToSinkTableOverrides) {
+ if (sourceToSinkTableOverrides == null ||
sourceToSinkTableOverrides.length == 0) {
+ return null;
+ }
+ Map<TableName, TableName> sourceToSinkTableOverridesMap = new HashMap<>();
Review Comment:
you could pre-size this map at _n_ entries
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]