Skip to content

Commit 0b0cdca

Browse files
authored
HBASE-25522 Remove deprecated methods in ReplicationPeerConfig (#2898)
Signed-off-by: Viraj Jasani <[email protected]>
1 parent f39636c commit 0b0cdca

File tree

13 files changed

+125
-215
lines changed

13 files changed

+125
-215
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeerConfig.java

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -79,41 +79,6 @@ private ReplicationPeerConfig(ReplicationPeerConfigBuilderImpl builder) {
7979
return Collections.unmodifiableMap(newTableCFsMap);
8080
}
8181

82-
/**
83-
* @deprecated as release of 2.0.0, and it will be removed in 3.0.0. Use
84-
* {@link ReplicationPeerConfigBuilder} to create new ReplicationPeerConfig.
85-
*/
86-
@Deprecated
87-
public ReplicationPeerConfig() {
88-
this.peerData = new TreeMap<>(Bytes.BYTES_COMPARATOR);
89-
this.configuration = new HashMap<>(0);
90-
this.serial = false;
91-
}
92-
93-
/**
94-
* Set the clusterKey which is the concatenation of the slave cluster's:
95-
* hbase.zookeeper.quorum:hbase.zookeeper.property.clientPort:zookeeper.znode.parent
96-
* @deprecated as release of 2.0.0, and it will be removed in 3.0.0. Use
97-
* {@link ReplicationPeerConfigBuilder#setClusterKey(String)} instead.
98-
*/
99-
@Deprecated
100-
public ReplicationPeerConfig setClusterKey(String clusterKey) {
101-
this.clusterKey = clusterKey;
102-
return this;
103-
}
104-
105-
/**
106-
* Sets the ReplicationEndpoint plugin class for this peer.
107-
* @param replicationEndpointImpl a class implementing ReplicationEndpoint
108-
* @deprecated as release of 2.0.0, and it will be removed in 3.0.0. Use
109-
* {@link ReplicationPeerConfigBuilder#setReplicationEndpointImpl(String)} instead.
110-
*/
111-
@Deprecated
112-
public ReplicationPeerConfig setReplicationEndpointImpl(String replicationEndpointImpl) {
113-
this.replicationEndpointImpl = replicationEndpointImpl;
114-
return this;
115-
}
116-
11782
public String getClusterKey() {
11883
return clusterKey;
11984
}
@@ -134,88 +99,26 @@ public Map<TableName, List<String>> getTableCFsMap() {
13499
return (Map<TableName, List<String>>) tableCFsMap;
135100
}
136101

137-
/**
138-
* @deprecated as release of 2.0.0, and it will be removed in 3.0.0. Use
139-
* {@link ReplicationPeerConfigBuilder#setTableCFsMap(Map)} instead.
140-
*/
141-
@Deprecated
142-
public ReplicationPeerConfig setTableCFsMap(Map<TableName,
143-
? extends Collection<String>> tableCFsMap) {
144-
this.tableCFsMap = tableCFsMap;
145-
return this;
146-
}
147-
148102
public Set<String> getNamespaces() {
149103
return this.namespaces;
150104
}
151105

152-
/**
153-
* @deprecated as release of 2.0.0, and it will be removed in 3.0.0. Use
154-
* {@link ReplicationPeerConfigBuilder#setNamespaces(Set)} instead.
155-
*/
156-
@Deprecated
157-
public ReplicationPeerConfig setNamespaces(Set<String> namespaces) {
158-
this.namespaces = namespaces;
159-
return this;
160-
}
161-
162106
public long getBandwidth() {
163107
return this.bandwidth;
164108
}
165109

166-
/**
167-
* @deprecated as release of 2.0.0, and it will be removed in 3.0.0. Use
168-
* {@link ReplicationPeerConfigBuilder#setBandwidth(long)} instead.
169-
*/
170-
@Deprecated
171-
public ReplicationPeerConfig setBandwidth(long bandwidth) {
172-
this.bandwidth = bandwidth;
173-
return this;
174-
}
175-
176110
public boolean replicateAllUserTables() {
177111
return this.replicateAllUserTables;
178112
}
179113

180-
/**
181-
* @deprecated as release of 2.0.0, and it will be removed in 3.0.0. Use
182-
* {@link ReplicationPeerConfigBuilder#setReplicateAllUserTables(boolean)} instead.
183-
*/
184-
@Deprecated
185-
public ReplicationPeerConfig setReplicateAllUserTables(boolean replicateAllUserTables) {
186-
this.replicateAllUserTables = replicateAllUserTables;
187-
return this;
188-
}
189-
190114
public Map<TableName, List<String>> getExcludeTableCFsMap() {
191115
return (Map<TableName, List<String>>) excludeTableCFsMap;
192116
}
193117

194-
/**
195-
* @deprecated as release of 2.0.0, and it will be removed in 3.0.0. Use
196-
* {@link ReplicationPeerConfigBuilder#setExcludeTableCFsMap(Map)} instead.
197-
*/
198-
@Deprecated
199-
public ReplicationPeerConfig setExcludeTableCFsMap(Map<TableName,
200-
? extends Collection<String>> tableCFsMap) {
201-
this.excludeTableCFsMap = tableCFsMap;
202-
return this;
203-
}
204-
205118
public Set<String> getExcludeNamespaces() {
206119
return this.excludeNamespaces;
207120
}
208121

209-
/**
210-
* @deprecated as release of 2.0.0, and it will be removed in 3.0.0. Use
211-
* {@link ReplicationPeerConfigBuilder#setExcludeNamespaces(Set)} instead.
212-
*/
213-
@Deprecated
214-
public ReplicationPeerConfig setExcludeNamespaces(Set<String> namespaces) {
215-
this.excludeNamespaces = namespaces;
216-
return this;
217-
}
218-
219122
public String getRemoteWALDir() {
220123
return this.remoteWALDir;
221124
}

hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApi.java

Lines changed: 47 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.apache.hadoop.hbase.TableName;
4545
import org.apache.hadoop.hbase.replication.ReplicationException;
4646
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
47+
import org.apache.hadoop.hbase.replication.ReplicationPeerConfigBuilder;
4748
import org.apache.hadoop.hbase.replication.ReplicationPeerDescription;
4849
import org.apache.hadoop.hbase.replication.ReplicationQueueStorage;
4950
import org.apache.hadoop.hbase.replication.ReplicationStorageFactory;
@@ -108,10 +109,8 @@ public void clearPeerAndQueues() throws IOException, ReplicationException {
108109

109110
@Test
110111
public void testAddRemovePeer() throws Exception {
111-
ReplicationPeerConfig rpc1 = new ReplicationPeerConfig();
112-
rpc1.setClusterKey(KEY_ONE);
113-
ReplicationPeerConfig rpc2 = new ReplicationPeerConfig();
114-
rpc2.setClusterKey(KEY_TWO);
112+
ReplicationPeerConfig rpc1 = ReplicationPeerConfig.newBuilder().setClusterKey(KEY_ONE).build();
113+
ReplicationPeerConfig rpc2 = ReplicationPeerConfig.newBuilder().setClusterKey(KEY_TWO).build();
115114
// Add a valid peer
116115
admin.addReplicationPeer(ID_ONE, rpc1).join();
117116
// try adding the same (fails)
@@ -142,10 +141,11 @@ public void testAddRemovePeer() throws Exception {
142141

143142
@Test
144143
public void testPeerConfig() throws Exception {
145-
ReplicationPeerConfig config = new ReplicationPeerConfig();
146-
config.setClusterKey(KEY_ONE);
147-
config.getConfiguration().put("key1", "value1");
148-
config.getConfiguration().put("key2", "value2");
144+
ReplicationPeerConfig config = ReplicationPeerConfig.newBuilder()
145+
.setClusterKey(KEY_ONE)
146+
.putConfiguration("key1", "value1")
147+
.putConfiguration("key2", "value2")
148+
.build();
149149
admin.addReplicationPeer(ID_ONE, config).join();
150150

151151
List<ReplicationPeerDescription> peers = admin.listReplicationPeers().get();
@@ -160,8 +160,7 @@ public void testPeerConfig() throws Exception {
160160

161161
@Test
162162
public void testEnableDisablePeer() throws Exception {
163-
ReplicationPeerConfig rpc1 = new ReplicationPeerConfig();
164-
rpc1.setClusterKey(KEY_ONE);
163+
ReplicationPeerConfig rpc1 = ReplicationPeerConfig.newBuilder().setClusterKey(KEY_ONE).build();
165164
admin.addReplicationPeer(ID_ONE, rpc1).join();
166165
List<ReplicationPeerDescription> peers = admin.listReplicationPeers().get();
167166
assertEquals(1, peers.size());
@@ -176,8 +175,8 @@ public void testEnableDisablePeer() throws Exception {
176175

177176
@Test
178177
public void testAppendPeerTableCFs() throws Exception {
179-
ReplicationPeerConfig rpc1 = new ReplicationPeerConfig();
180-
rpc1.setClusterKey(KEY_ONE);
178+
ReplicationPeerConfigBuilder rpcBuilder =
179+
ReplicationPeerConfig.newBuilder().setClusterKey(KEY_ONE);
181180
final TableName tableName1 = TableName.valueOf(tableName.getNameAsString() + "t1");
182181
final TableName tableName2 = TableName.valueOf(tableName.getNameAsString() + "t2");
183182
final TableName tableName3 = TableName.valueOf(tableName.getNameAsString() + "t3");
@@ -186,9 +185,9 @@ public void testAppendPeerTableCFs() throws Exception {
186185
final TableName tableName6 = TableName.valueOf(tableName.getNameAsString() + "t6");
187186

188187
// Add a valid peer
189-
admin.addReplicationPeer(ID_ONE, rpc1).join();
190-
rpc1.setReplicateAllUserTables(false);
191-
admin.updateReplicationPeerConfig(ID_ONE, rpc1).join();
188+
admin.addReplicationPeer(ID_ONE, rpcBuilder.build()).join();
189+
rpcBuilder.setReplicateAllUserTables(false);
190+
admin.updateReplicationPeerConfig(ID_ONE, rpcBuilder.build()).join();
192191

193192
Map<TableName, List<String>> tableCFs = new HashMap<>();
194193

@@ -280,16 +279,16 @@ public void testAppendPeerTableCFs() throws Exception {
280279

281280
@Test
282281
public void testRemovePeerTableCFs() throws Exception {
283-
ReplicationPeerConfig rpc1 = new ReplicationPeerConfig();
284-
rpc1.setClusterKey(KEY_ONE);
282+
ReplicationPeerConfigBuilder rpcBuilder =
283+
ReplicationPeerConfig.newBuilder().setClusterKey(KEY_ONE);
285284
final TableName tableName1 = TableName.valueOf(tableName.getNameAsString() + "t1");
286285
final TableName tableName2 = TableName.valueOf(tableName.getNameAsString() + "t2");
287286
final TableName tableName3 = TableName.valueOf(tableName.getNameAsString() + "t3");
288287
final TableName tableName4 = TableName.valueOf(tableName.getNameAsString() + "t4");
289288
// Add a valid peer
290-
admin.addReplicationPeer(ID_ONE, rpc1).join();
291-
rpc1.setReplicateAllUserTables(false);
292-
admin.updateReplicationPeerConfig(ID_ONE, rpc1).join();
289+
admin.addReplicationPeer(ID_ONE, rpcBuilder.build()).join();
290+
rpcBuilder.setReplicateAllUserTables(false);
291+
admin.updateReplicationPeerConfig(ID_ONE, rpcBuilder.build()).join();
293292

294293
Map<TableName, List<String>> tableCFs = new HashMap<>();
295294
try {
@@ -369,30 +368,28 @@ public void testSetPeerNamespaces() throws Exception {
369368
String ns1 = "ns1";
370369
String ns2 = "ns2";
371370

372-
ReplicationPeerConfig rpc = new ReplicationPeerConfig();
373-
rpc.setClusterKey(KEY_ONE);
374-
admin.addReplicationPeer(ID_ONE, rpc).join();
375-
rpc.setReplicateAllUserTables(false);
376-
admin.updateReplicationPeerConfig(ID_ONE, rpc).join();
371+
ReplicationPeerConfigBuilder rpcBuilder =
372+
ReplicationPeerConfig.newBuilder().setClusterKey(KEY_ONE);
373+
admin.addReplicationPeer(ID_ONE, rpcBuilder.build()).join();
374+
rpcBuilder.setReplicateAllUserTables(false);
375+
admin.updateReplicationPeerConfig(ID_ONE, rpcBuilder.build()).join();
377376

378377
// add ns1 and ns2 to peer config
379-
rpc = admin.getReplicationPeerConfig(ID_ONE).get();
380378
Set<String> namespaces = new HashSet<>();
381379
namespaces.add(ns1);
382380
namespaces.add(ns2);
383-
rpc.setNamespaces(namespaces);
384-
admin.updateReplicationPeerConfig(ID_ONE, rpc).join();
381+
rpcBuilder.setNamespaces(namespaces);
382+
admin.updateReplicationPeerConfig(ID_ONE, rpcBuilder.build()).join();
385383
namespaces = admin.getReplicationPeerConfig(ID_ONE).get().getNamespaces();
386384
assertEquals(2, namespaces.size());
387385
assertTrue(namespaces.contains(ns1));
388386
assertTrue(namespaces.contains(ns2));
389387

390388
// update peer config only contains ns1
391-
rpc = admin.getReplicationPeerConfig(ID_ONE).get();
392389
namespaces = new HashSet<>();
393390
namespaces.add(ns1);
394-
rpc.setNamespaces(namespaces);
395-
admin.updateReplicationPeerConfig(ID_ONE, rpc).join();
391+
rpcBuilder.setNamespaces(namespaces);
392+
admin.updateReplicationPeerConfig(ID_ONE, rpcBuilder.build()).join();
396393
namespaces = admin.getReplicationPeerConfig(ID_ONE).get().getNamespaces();
397394
assertEquals(1, namespaces.size());
398395
assertTrue(namespaces.contains(ns1));
@@ -407,40 +404,36 @@ public void testNamespacesAndTableCfsConfigConflict() throws Exception {
407404
final TableName tableName1 = TableName.valueOf(ns1 + ":" + tableName.getNameAsString() + "1");
408405
final TableName tableName2 = TableName.valueOf(ns2 + ":" + tableName.getNameAsString() + "2");
409406

410-
ReplicationPeerConfig rpc = new ReplicationPeerConfig();
411-
rpc.setClusterKey(KEY_ONE);
412-
admin.addReplicationPeer(ID_ONE, rpc).join();
413-
rpc.setReplicateAllUserTables(false);
414-
admin.updateReplicationPeerConfig(ID_ONE, rpc).join();
407+
ReplicationPeerConfigBuilder rpcBuilder =
408+
ReplicationPeerConfig.newBuilder().setClusterKey(KEY_ONE);
409+
admin.addReplicationPeer(ID_ONE, rpcBuilder.build()).join();
410+
rpcBuilder.setReplicateAllUserTables(false);
411+
admin.updateReplicationPeerConfig(ID_ONE, rpcBuilder.build()).join();
415412

416-
rpc = admin.getReplicationPeerConfig(ID_ONE).get();
417413
Set<String> namespaces = new HashSet<String>();
418414
namespaces.add(ns1);
419-
rpc.setNamespaces(namespaces);
420-
admin.updateReplicationPeerConfig(ID_ONE, rpc).get();
421-
rpc = admin.getReplicationPeerConfig(ID_ONE).get();
415+
rpcBuilder.setNamespaces(namespaces);
416+
admin.updateReplicationPeerConfig(ID_ONE, rpcBuilder.build()).get();
422417
Map<TableName, List<String>> tableCfs = new HashMap<>();
423418
tableCfs.put(tableName1, new ArrayList<>());
424-
rpc.setTableCFsMap(tableCfs);
419+
rpcBuilder.setTableCFsMap(tableCfs);
425420
try {
426-
admin.updateReplicationPeerConfig(ID_ONE, rpc).join();
421+
admin.updateReplicationPeerConfig(ID_ONE, rpcBuilder.build()).join();
427422
fail(
428423
"Test case should fail, because table " + tableName1 + " conflict with namespace " + ns1);
429424
} catch (CompletionException e) {
430425
// OK
431426
}
432427

433-
rpc = admin.getReplicationPeerConfig(ID_ONE).get();
434428
tableCfs.clear();
435429
tableCfs.put(tableName2, new ArrayList<>());
436-
rpc.setTableCFsMap(tableCfs);
437-
admin.updateReplicationPeerConfig(ID_ONE, rpc).get();
438-
rpc = admin.getReplicationPeerConfig(ID_ONE).get();
430+
rpcBuilder.setTableCFsMap(tableCfs);
431+
admin.updateReplicationPeerConfig(ID_ONE, rpcBuilder.build()).get();
439432
namespaces.clear();
440433
namespaces.add(ns2);
441-
rpc.setNamespaces(namespaces);
434+
rpcBuilder.setNamespaces(namespaces);
442435
try {
443-
admin.updateReplicationPeerConfig(ID_ONE, rpc).join();
436+
admin.updateReplicationPeerConfig(ID_ONE, rpcBuilder.build()).join();
444437
fail(
445438
"Test case should fail, because namespace " + ns2 + " conflict with table " + tableName2);
446439
} catch (CompletionException e) {
@@ -452,15 +445,14 @@ public void testNamespacesAndTableCfsConfigConflict() throws Exception {
452445

453446
@Test
454447
public void testPeerBandwidth() throws Exception {
455-
ReplicationPeerConfig rpc = new ReplicationPeerConfig();
456-
rpc.setClusterKey(KEY_ONE);
448+
ReplicationPeerConfigBuilder rpcBuilder =
449+
ReplicationPeerConfig.newBuilder().setClusterKey(KEY_ONE);
457450

458-
admin.addReplicationPeer(ID_ONE, rpc).join();
459-
rpc = admin.getReplicationPeerConfig(ID_ONE).get();
460-
assertEquals(0, rpc.getBandwidth());
451+
admin.addReplicationPeer(ID_ONE, rpcBuilder.build()).join();;
452+
assertEquals(0, admin.getReplicationPeerConfig(ID_ONE).get().getBandwidth());
461453

462-
rpc.setBandwidth(2097152);
463-
admin.updateReplicationPeerConfig(ID_ONE, rpc).join();
454+
rpcBuilder.setBandwidth(2097152);
455+
admin.updateReplicationPeerConfig(ID_ONE, rpcBuilder.build()).join();
464456
assertEquals(2097152, admin.getReplicationPeerConfig(ID_ONE).join().getBandwidth());
465457

466458
admin.removeReplicationPeer(ID_ONE).join();

0 commit comments

Comments
 (0)