47
47
import org .apache .hadoop .hbase .HBaseTestingUtility ;
48
48
import org .apache .hadoop .hbase .HConstants ;
49
49
import org .apache .hadoop .hbase .KeyValue ;
50
+ import org .apache .hadoop .hbase .TableName ;
50
51
import org .apache .hadoop .hbase .client .Admin ;
51
52
import org .apache .hadoop .hbase .client .ColumnFamilyDescriptor ;
52
53
import org .apache .hadoop .hbase .client .ColumnFamilyDescriptorBuilder ;
@@ -122,8 +123,8 @@ public class TestBulkLoadReplication extends TestReplicationBase {
122
123
private static AtomicInteger BULK_LOADS_COUNT ;
123
124
private static CountDownLatch BULK_LOAD_LATCH ;
124
125
125
- private static final HBaseTestingUtility UTIL3 = new HBaseTestingUtility ();
126
- private static final Configuration CONF3 = UTIL3 .getConfiguration ();
126
+ protected static final HBaseTestingUtility UTIL3 = new HBaseTestingUtility ();
127
+ protected static final Configuration CONF3 = UTIL3 .getConfiguration ();
127
128
128
129
private static final Path BULK_LOAD_BASE_DIR = new Path ("/bulk_dir" );
129
130
@@ -220,7 +221,7 @@ public void tearDownBase() throws Exception {
220
221
UTIL3 .getAdmin ().removeReplicationPeer (PEER_ID2 );
221
222
}
222
223
223
- private static void setupBulkLoadConfigsForCluster (Configuration config ,
224
+ protected static void setupBulkLoadConfigsForCluster (Configuration config ,
224
225
String clusterReplicationId ) throws Exception {
225
226
config .setBoolean (HConstants .REPLICATION_BULKLOAD_ENABLE_KEY , true );
226
227
config .set (REPLICATION_CLUSTER_ID , clusterReplicationId );
@@ -238,13 +239,16 @@ public void testBulkLoadReplicationActiveActive() throws Exception {
238
239
Table peer3TestTable = UTIL3 .getConnection ().getTable (TestReplicationBase .tableName );
239
240
byte [] row = Bytes .toBytes ("001" );
240
241
byte [] value = Bytes .toBytes ("v1" );
241
- assertBulkLoadConditions (row , value , UTIL1 , peer1TestTable , peer2TestTable , peer3TestTable );
242
+ assertBulkLoadConditions (tableName , row , value , UTIL1 , peer1TestTable ,
243
+ peer2TestTable , peer3TestTable );
242
244
row = Bytes .toBytes ("002" );
243
245
value = Bytes .toBytes ("v2" );
244
- assertBulkLoadConditions (row , value , UTIL2 , peer1TestTable , peer2TestTable , peer3TestTable );
246
+ assertBulkLoadConditions (tableName , row , value , UTIL2 , peer1TestTable ,
247
+ peer2TestTable , peer3TestTable );
245
248
row = Bytes .toBytes ("003" );
246
249
value = Bytes .toBytes ("v3" );
247
- assertBulkLoadConditions (row , value , UTIL3 , peer1TestTable , peer2TestTable , peer3TestTable );
250
+ assertBulkLoadConditions (tableName , row , value , UTIL3 , peer1TestTable ,
251
+ peer2TestTable , peer3TestTable );
248
252
//Additional wait to make sure no extra bulk load happens
249
253
Thread .sleep (400 );
250
254
//We have 3 bulk load events (1 initiated on each cluster).
@@ -278,18 +282,18 @@ public void testPartionedMOBCompactionBulkLoadDoesntReplicate() throws Exception
278
282
}
279
283
280
284
281
- private void assertBulkLoadConditions (byte [] row , byte [] value ,
285
+ protected void assertBulkLoadConditions (TableName tableName , byte [] row , byte [] value ,
282
286
HBaseTestingUtility utility , Table ...tables ) throws Exception {
283
287
BULK_LOAD_LATCH = new CountDownLatch (3 );
284
- bulkLoadOnCluster (row , value , utility );
288
+ bulkLoadOnCluster (tableName , row , value , utility );
285
289
assertTrue (BULK_LOAD_LATCH .await (1 , TimeUnit .MINUTES ));
286
290
assertTableHasValue (tables [0 ], row , value );
287
291
assertTableHasValue (tables [1 ], row , value );
288
292
assertTableHasValue (tables [2 ], row , value );
289
293
}
290
294
291
- private void bulkLoadOnCluster (byte [] row , byte [] value ,
292
- HBaseTestingUtility cluster ) throws Exception {
295
+ protected void bulkLoadOnCluster (TableName tableName , byte [] row , byte [] value ,
296
+ HBaseTestingUtility cluster ) throws Exception {
293
297
String bulkLoadFilePath = createHFileForFamilies (row , value , cluster .getConfiguration ());
294
298
copyToHdfs (bulkLoadFilePath , cluster .getDFSCluster ());
295
299
BulkLoadHFilesTool bulkLoadHFilesTool = new BulkLoadHFilesTool (cluster .getConfiguration ());
@@ -302,13 +306,19 @@ private void copyToHdfs(String bulkLoadFilePath, MiniDFSCluster cluster) throws
302
306
cluster .getFileSystem ().copyFromLocalFile (new Path (bulkLoadFilePath ), bulkLoadDir );
303
307
}
304
308
305
- private void assertTableHasValue (Table table , byte [] row , byte [] value ) throws Exception {
309
+ protected void assertTableHasValue (Table table , byte [] row , byte [] value ) throws Exception {
306
310
Get get = new Get (row );
307
311
Result result = table .get (get );
308
312
assertTrue (result .advance ());
309
313
assertEquals (Bytes .toString (value ), Bytes .toString (result .value ()));
310
314
}
311
315
316
+ protected void assertTableNoValue (Table table , byte [] row , byte [] value ) throws Exception {
317
+ Get get = new Get (row );
318
+ Result result = table .get (get );
319
+ assertTrue (result .isEmpty ());
320
+ }
321
+
312
322
private String createHFileForFamilies (byte [] row , byte [] value ,
313
323
Configuration clusterConfig ) throws IOException {
314
324
CellBuilder cellBuilder = CellBuilderFactory .create (CellBuilderType .DEEP_COPY );
0 commit comments