Search in sources :

Example 1 with ReplicationSourceManager

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();
        }
    });
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) ReplicationSourceManager(org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager) AtomicLong(java.util.concurrent.atomic.AtomicLong) HBaseInterClusterReplicationEndpoint(org.apache.hadoop.hbase.replication.regionserver.HBaseInterClusterReplicationEndpoint) HBaseInterClusterReplicationEndpoint(org.apache.hadoop.hbase.replication.regionserver.HBaseInterClusterReplicationEndpoint) ExecutorService(java.util.concurrent.ExecutorService) ReplicationSource(org.apache.hadoop.hbase.replication.regionserver.ReplicationSource) Test(org.junit.Test)

Example 2 with ReplicationSourceManager

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";
        }
    });
}
Also used : Path(org.apache.hadoop.fs.Path) AbstractFSWAL(org.apache.hadoop.hbase.regionserver.wal.AbstractFSWAL) ReplicationSourceManager(org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager) IOException(java.io.IOException) StreamLacksCapabilityException(org.apache.hadoop.hbase.util.CommonFSUtils.StreamLacksCapabilityException)

Aggregations

ReplicationSourceManager (org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager)2 IOException (java.io.IOException)1 ExecutorService (java.util.concurrent.ExecutorService)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)1 AbstractFSWAL (org.apache.hadoop.hbase.regionserver.wal.AbstractFSWAL)1 HBaseInterClusterReplicationEndpoint (org.apache.hadoop.hbase.replication.regionserver.HBaseInterClusterReplicationEndpoint)1 ReplicationSource (org.apache.hadoop.hbase.replication.regionserver.ReplicationSource)1 StreamLacksCapabilityException (org.apache.hadoop.hbase.util.CommonFSUtils.StreamLacksCapabilityException)1 Test (org.junit.Test)1