Search in sources :

Example 1 with ReplicateContext

use of org.apache.hadoop.hbase.replication.ReplicationEndpoint.ReplicateContext in project hbase by apache.

the class TestRegionReplicaReplicationEndpointNoMaster method testRegionReplicaReplicationEndpointReplicate.

@Test(timeout = 240000)
public void testRegionReplicaReplicationEndpointReplicate() throws Exception {
    // tests replaying the edits to a secondary region replica using the RRRE.replicate()
    openRegion(HTU, rs0, hriSecondary);
    ClusterConnection connection = (ClusterConnection) ConnectionFactory.createConnection(HTU.getConfiguration());
    RegionReplicaReplicationEndpoint replicator = new RegionReplicaReplicationEndpoint();
    ReplicationEndpoint.Context context = mock(ReplicationEndpoint.Context.class);
    when(context.getConfiguration()).thenReturn(HTU.getConfiguration());
    when(context.getMetrics()).thenReturn(mock(MetricsSource.class));
    replicator.init(context);
    replicator.start();
    //load some data to primary
    HTU.loadNumericRows(table, f, 0, 1000);
    Assert.assertEquals(1000, entries.size());
    // replay the edits to the secondary using replay callable
    final String fakeWalGroupId = "fakeWALGroup";
    replicator.replicate(new ReplicateContext().setEntries(Lists.newArrayList(entries)).setWalGroupId(fakeWalGroupId));
    Region region = rs0.getFromOnlineRegions(hriSecondary.getEncodedName());
    HTU.verifyNumericRows(region, f, 0, 1000);
    HTU.deleteNumericRows(table, f, 0, 1000);
    closeRegion(HTU, rs0, hriSecondary);
    connection.close();
}
Also used : ClusterConnection(org.apache.hadoop.hbase.client.ClusterConnection) ReplicationEndpoint(org.apache.hadoop.hbase.replication.ReplicationEndpoint) ReplicateContext(org.apache.hadoop.hbase.replication.ReplicationEndpoint.ReplicateContext) Region(org.apache.hadoop.hbase.regionserver.Region) TestRegionServerNoMaster.closeRegion(org.apache.hadoop.hbase.regionserver.TestRegionServerNoMaster.closeRegion) TestRegionServerNoMaster.openRegion(org.apache.hadoop.hbase.regionserver.TestRegionServerNoMaster.openRegion) Test(org.junit.Test)

Aggregations

ClusterConnection (org.apache.hadoop.hbase.client.ClusterConnection)1 Region (org.apache.hadoop.hbase.regionserver.Region)1 TestRegionServerNoMaster.closeRegion (org.apache.hadoop.hbase.regionserver.TestRegionServerNoMaster.closeRegion)1 TestRegionServerNoMaster.openRegion (org.apache.hadoop.hbase.regionserver.TestRegionServerNoMaster.openRegion)1 ReplicationEndpoint (org.apache.hadoop.hbase.replication.ReplicationEndpoint)1 ReplicateContext (org.apache.hadoop.hbase.replication.ReplicationEndpoint.ReplicateContext)1 Test (org.junit.Test)1