Search in sources :

Example 6 with WeightController

use of com.alibaba.otter.node.etl.load.loader.weight.WeightController in project otter by alibaba.

the class WeightWorkerTest method test_simple.

@Test
public void test_simple() {
    int thread = 10;
    int count = 10;
    WeightController controller = new WeightController(thread);
    CountDownLatch latch = new CountDownLatch(thread);
    WeightWorkerTest[] workers = new WeightWorkerTest[thread];
    for (int i = 0; i < thread; i++) {
        int[] weights = new int[count];
        for (int j = 0; j < count; j++) {
            weights[j] = RandomUtils.nextInt(count);
        }
        workers[i] = new WeightWorkerTest(i, weights, controller, latch);
    }
    for (int i = 0; i < thread; i++) {
        workers[i].start();
    }
    try {
        latch.await();
    } catch (InterruptedException e) {
        want.fail();
    }
}
Also used : WeightController(com.alibaba.otter.node.etl.load.loader.weight.WeightController) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.testng.annotations.Test) BaseOtterTest(com.alibaba.otter.node.etl.BaseOtterTest)

Aggregations

WeightController (com.alibaba.otter.node.etl.load.loader.weight.WeightController)6 Test (org.testng.annotations.Test)5 BaseDbTest (com.alibaba.otter.node.etl.BaseDbTest)4 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)4 Identity (com.alibaba.otter.shared.etl.model.Identity)4 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)3 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)3 FileBatch (com.alibaba.otter.shared.etl.model.FileBatch)3 RowBatch (com.alibaba.otter.shared.etl.model.RowBatch)3 FileLoadContext (com.alibaba.otter.node.etl.load.loader.db.context.FileLoadContext)2 ChannelParameter (com.alibaba.otter.shared.common.model.config.channel.ChannelParameter)2 Node (com.alibaba.otter.shared.common.model.config.node.Node)2 SystemParameter (com.alibaba.otter.shared.common.model.config.parameter.SystemParameter)2 EventData (com.alibaba.otter.shared.etl.model.EventData)2 BaseOtterTest (com.alibaba.otter.node.etl.BaseOtterTest)1 LoadException (com.alibaba.otter.node.etl.load.exception.LoadException)1 LoadContext (com.alibaba.otter.node.etl.load.loader.LoadContext)1 DbLoadContext (com.alibaba.otter.node.etl.load.loader.db.context.DbLoadContext)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1