use of org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager in project hbase by apache.
the class TestReplicationSource method testTerminateTimeout.
/**
* Tests that {@link ReplicationSource#terminate(String)} will timeout properly
*/
@Test
public void testTerminateTimeout() throws Exception {
ReplicationSource source = new ReplicationSource();
ReplicationEndpoint replicationEndpoint = new HBaseInterClusterReplicationEndpoint() {
@Override
protected void doStart() {
notifyStarted();
}
@Override
protected void doStop() {
// not calling notifyStopped() here causes the caller of stop() to get a Future that never
// completes
}
};
replicationEndpoint.start();
ReplicationPeers mockPeers = Mockito.mock(ReplicationPeers.class);
ReplicationPeer mockPeer = Mockito.mock(ReplicationPeer.class);
Mockito.when(mockPeer.getPeerBandwidth()).thenReturn(0L);
Configuration testConf = HBaseConfiguration.create();
testConf.setInt("replication.source.maxretriesmultiplier", 1);
ReplicationSourceManager manager = Mockito.mock(ReplicationSourceManager.class);
Mockito.when(manager.getTotalBufferUsed()).thenReturn(new AtomicLong());
source.init(testConf, null, manager, null, mockPeers, null, "testPeer", null, replicationEndpoint, null);
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<?> future = executor.submit(new Runnable() {
@Override
public void run() {
source.terminate("testing source termination");
}
});
long sleepForRetries = testConf.getLong("replication.source.sleepforretries", 1000);
Waiter.waitFor(testConf, sleepForRetries * 2, new Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
return future.isDone();
}
});
}
use of org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager in project hbase by apache.
the class TestAddToSerialReplicationPeer method waitUntilReplicatedToTheCurrentWALFile.
private void waitUntilReplicatedToTheCurrentWALFile(HRegionServer rs, final String oldWalName) throws Exception {
Path path = ((AbstractFSWAL<?>) rs.getWAL(null)).getCurrentFileName();
String logPrefix = AbstractFSWALProvider.getWALPrefixFromWALName(path.getName());
UTIL.waitFor(30000, new ExplainingPredicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
ReplicationSourceManager manager = ((Replication) rs.getReplicationSourceService()).getReplicationManager();
// Make sure replication moves to the new file.
return (manager.getWALs().get(PEER_ID).get(logPrefix).size() == 1) && !oldWalName.equals(manager.getWALs().get(PEER_ID).get(logPrefix).first());
}
@Override
public String explainFailure() throws Exception {
return "Still not replicated to the current WAL file yet";
}
});
}
Aggregations