Search in sources :

Example 1 with RowDataMemoryPipe

use of com.alibaba.otter.node.etl.common.pipe.impl.memory.RowDataMemoryPipe in project otter by alibaba.

the class MemoryPipeTest method test_timeout.

@Test
public void test_timeout() {
    RowDataMemoryPipe pipe = new RowDataMemoryPipe();
    // 1s后超时
    pipe.setTimeout(1 * 1000L);
    pipe.setDownloadDir(tmp);
    try {
        pipe.afterPropertiesSet();
    } catch (Exception e) {
        want.fail();
    }
    DbBatch source = new DbBatch();
    RowBatch rowBatch = new RowBatch();
    Identity identity = new Identity();
    identity.setChannelId(100L);
    identity.setPipelineId(100L);
    identity.setProcessId(100L);
    rowBatch.setIdentity(identity);
    source.setRowBatch(rowBatch);
    MemoryPipeKey key = pipe.put(source);
    try {
        Thread.sleep(1500L);
    } catch (InterruptedException e) {
        want.fail();
    }
    DbBatch target = pipe.get(key);
    // 返回结果为空
    want.bool(target == null).is(true);
}
Also used : RowBatch(com.alibaba.otter.shared.etl.model.RowBatch) MemoryPipeKey(com.alibaba.otter.node.etl.common.pipe.impl.memory.MemoryPipeKey) Identity(com.alibaba.otter.shared.etl.model.Identity) RowDataMemoryPipe(com.alibaba.otter.node.etl.common.pipe.impl.memory.RowDataMemoryPipe) DbBatch(com.alibaba.otter.shared.etl.model.DbBatch) Test(org.testng.annotations.Test) BaseOtterTest(com.alibaba.otter.node.etl.BaseOtterTest)

Example 2 with RowDataMemoryPipe

use of com.alibaba.otter.node.etl.common.pipe.impl.memory.RowDataMemoryPipe in project otter by alibaba.

the class MemoryPipeTest method test_ok.

@Test
public void test_ok() {
    RowDataMemoryPipe pipe = new RowDataMemoryPipe();
    pipe.setDownloadDir(tmp);
    try {
        pipe.afterPropertiesSet();
    } catch (Exception e) {
        want.fail();
    }
    DbBatch source = new DbBatch();
    RowBatch rowBatch = new RowBatch();
    Identity identity = new Identity();
    identity.setChannelId(100L);
    identity.setPipelineId(100L);
    identity.setProcessId(100L);
    rowBatch.setIdentity(identity);
    source.setRowBatch(rowBatch);
    MemoryPipeKey key = pipe.put(source);
    DbBatch target = pipe.get(key);
    // 引用为同一个
    want.bool(source == target).is(true);
}
Also used : RowBatch(com.alibaba.otter.shared.etl.model.RowBatch) MemoryPipeKey(com.alibaba.otter.node.etl.common.pipe.impl.memory.MemoryPipeKey) Identity(com.alibaba.otter.shared.etl.model.Identity) RowDataMemoryPipe(com.alibaba.otter.node.etl.common.pipe.impl.memory.RowDataMemoryPipe) DbBatch(com.alibaba.otter.shared.etl.model.DbBatch) Test(org.testng.annotations.Test) BaseOtterTest(com.alibaba.otter.node.etl.BaseOtterTest)

Aggregations

BaseOtterTest (com.alibaba.otter.node.etl.BaseOtterTest)2 MemoryPipeKey (com.alibaba.otter.node.etl.common.pipe.impl.memory.MemoryPipeKey)2 RowDataMemoryPipe (com.alibaba.otter.node.etl.common.pipe.impl.memory.RowDataMemoryPipe)2 DbBatch (com.alibaba.otter.shared.etl.model.DbBatch)2 Identity (com.alibaba.otter.shared.etl.model.Identity)2 RowBatch (com.alibaba.otter.shared.etl.model.RowBatch)2 Test (org.testng.annotations.Test)2