Search in sources :

Example 1 with OtterDownStreamHandler

use of com.alibaba.otter.node.etl.select.selector.canal.OtterDownStreamHandler in project otter by alibaba.

the class OtterDownStreamHandlerIntergration method testSimple.

@Test
public void testSimple() {
    final OtterDownStreamHandler handler = new OtterDownStreamHandler();
    handler.setPipelineId(388L);
    handler.setDetectingIntervalInSeconds(1);
    ((AutowireCapableBeanFactory) TestedObject.getSpringBeanFactory()).autowireBeanProperties(handler, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
    final CountDownLatch count = new CountDownLatch(1);
    ExecutorService executor = Executors.newFixedThreadPool(1);
    executor.submit(new Runnable() {

        public void run() {
            int times = 50;
            handler.before(Arrays.asList(buildEvent()));
            while (--times > 0) {
                try {
                    Thread.sleep(50000);
                } catch (InterruptedException e) {
                }
                handler.before(Arrays.asList(buildEvent()));
            }
            count.countDown();
        }
    });
    try {
        count.await();
    } catch (InterruptedException e) {
    }
}
Also used : OtterDownStreamHandler(com.alibaba.otter.node.etl.select.selector.canal.OtterDownStreamHandler) ExecutorService(java.util.concurrent.ExecutorService) AutowireCapableBeanFactory(org.springframework.beans.factory.config.AutowireCapableBeanFactory) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.testng.annotations.Test) BaseOtterTest(com.alibaba.otter.node.etl.BaseOtterTest)

Aggregations

BaseOtterTest (com.alibaba.otter.node.etl.BaseOtterTest)1 OtterDownStreamHandler (com.alibaba.otter.node.etl.select.selector.canal.OtterDownStreamHandler)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 AutowireCapableBeanFactory (org.springframework.beans.factory.config.AutowireCapableBeanFactory)1 Test (org.testng.annotations.Test)1