Package org.apache.flume.channel.file.FileChannel

Examples of org.apache.flume.channel.file.FileChannel.FileBackedTransaction


    Map<String, String> overrides = Maps.newHashMap();
    overrides.put(FileChannelConfiguration.CHECKPOINT_INTERVAL,
            String.valueOf(Integer.MAX_VALUE));
    final FileChannel channel = createFileChannel(overrides);
    channel.start();
    FileBackedTransaction tx = (FileBackedTransaction) channel.getTransaction();

    InflightEventWrapper inflightPuts =
            field("inflightPuts").ofType(InflightEventWrapper.class).in(
            field("queue").ofType(FlumeEventQueue.class).in(tx).get()).get();

    tx.begin();

    for (int i = 0; i < 100; i++) {
      channel.put(EventBuilder.withBody("TestEvent".getBytes()));
    }

    Assert.assertFalse(inflightPuts.getFileIDs().isEmpty());
    Assert.assertFalse(inflightPuts.getInFlightPointers().isEmpty());

    tx.rollback();
    tx.close();

    Assert.assertTrue(inflightPuts.getFileIDs().isEmpty());
    Assert.assertTrue(inflightPuts.getInFlightPointers().isEmpty());
    Assert.assertTrue(channel.getDepth() == 0);

    Set<String> in = putEvents(channel, "testing-rollbacks", 100, 100);

    tx = (FileBackedTransaction) channel.getTransaction();

    InflightEventWrapper inflightTakes =
            field("inflightTakes").ofType(InflightEventWrapper.class).in(
            field("queue").ofType(FlumeEventQueue.class).in(tx).get()).get();

    tx.begin();

    for (int i = 0; i < 100; i++) {
      channel.take();
    }

    Assert.assertFalse(inflightTakes.getFileIDs().isEmpty());
    Assert.assertFalse(inflightTakes.getInFlightPointers().isEmpty());

    tx.rollback();
    tx.close();


    Assert.assertTrue(inflightTakes.getFileIDs().isEmpty());
    Assert.assertTrue(inflightTakes.getInFlightPointers().isEmpty());
    Assert.assertTrue(channel.getDepth() == in.size());
View Full Code Here


    Map<String, String> overrides = Maps.newHashMap();
    overrides.put(FileChannelConfiguration.CHECKPOINT_INTERVAL,
            String.valueOf(Integer.MAX_VALUE));
    final FileChannel channel = createFileChannel(overrides);
    channel.start();
    FileBackedTransaction tx = (FileBackedTransaction) channel.getTransaction();

    InflightEventWrapper inflightPuts =
            field("inflightPuts").ofType(InflightEventWrapper.class).in(
            field("queue").ofType(FlumeEventQueue.class).in(tx).get()).get();

    tx.begin();

    for (int i = 0; i < 100; i++) {
      channel.put(EventBuilder.withBody("TestEvent".getBytes()));
    }

    Assert.assertFalse(inflightPuts.getFileIDs().isEmpty());
    Assert.assertFalse(inflightPuts.getInFlightPointers().isEmpty());

    tx.rollback();
    tx.close();

    Assert.assertTrue(inflightPuts.getFileIDs().isEmpty());
    Assert.assertTrue(inflightPuts.getInFlightPointers().isEmpty());
    Assert.assertTrue(channel.getDepth() == 0);

    Set<String> in = putEvents(channel, "testing-rollbacks", 100, 100);

    tx = (FileBackedTransaction) channel.getTransaction();

    InflightEventWrapper inflightTakes =
            field("inflightTakes").ofType(InflightEventWrapper.class).in(
            field("queue").ofType(FlumeEventQueue.class).in(tx).get()).get();

    tx.begin();

    for (int i = 0; i < 100; i++) {
      channel.take();
    }

    Assert.assertFalse(inflightTakes.getFileIDs().isEmpty());
    Assert.assertFalse(inflightTakes.getInFlightPointers().isEmpty());

    tx.rollback();
    tx.close();


    Assert.assertTrue(inflightTakes.getFileIDs().isEmpty());
    Assert.assertTrue(inflightTakes.getInFlightPointers().isEmpty());
    Assert.assertTrue(channel.getDepth() == in.size());
View Full Code Here

    ExecutorService pool = Executors.newFixedThreadPool(2);

    Future<FileBackedTransaction> f1 = pool.submit(getTransRunnable);
    Future<FileBackedTransaction> f2 = pool.submit(getTransRunnable);

    FileBackedTransaction t1 = f1.get();
    FileBackedTransaction t2 = f2.get();

    Assert.assertNotSame("Transactions from different threads are different",
        t1, t2);
  }
View Full Code Here

    Map<String, String> overrides = Maps.newHashMap();
    overrides.put(FileChannelConfiguration.CHECKPOINT_INTERVAL,
            String.valueOf(Integer.MAX_VALUE));
    final FileChannel channel = createFileChannel(overrides);
    channel.start();
    FileBackedTransaction tx = (FileBackedTransaction) channel.getTransaction();

    InflightEventWrapper inflightPuts =
            field("inflightPuts").ofType(InflightEventWrapper.class).in(
            field("queue").ofType(FlumeEventQueue.class).in(tx).get()).get();

    tx.begin();

    for (int i = 0; i < 100; i++) {
      channel.put(EventBuilder.withBody("TestEvent".getBytes()));
    }

    Assert.assertFalse(inflightPuts.getFileIDs().isEmpty());
    Assert.assertFalse(inflightPuts.getInFlightPointers().isEmpty());

    tx.rollback();
    tx.close();

    Assert.assertTrue(inflightPuts.getFileIDs().isEmpty());
    Assert.assertTrue(inflightPuts.getInFlightPointers().isEmpty());
    Assert.assertTrue(channel.getDepth() == 0);

    Set<String> in = putEvents(channel, "testing-rollbacks", 100, 100);

    tx = (FileBackedTransaction) channel.getTransaction();

    InflightEventWrapper inflightTakes =
            field("inflightTakes").ofType(InflightEventWrapper.class).in(
            field("queue").ofType(FlumeEventQueue.class).in(tx).get()).get();

    tx.begin();

    for (int i = 0; i < 100; i++) {
      channel.take();
    }

    Assert.assertFalse(inflightTakes.getFileIDs().isEmpty());
    Assert.assertFalse(inflightTakes.getInFlightPointers().isEmpty());

    tx.rollback();
    tx.close();


    Assert.assertTrue(inflightTakes.getFileIDs().isEmpty());
    Assert.assertTrue(inflightTakes.getInFlightPointers().isEmpty());
    Assert.assertTrue(channel.getDepth() == in.size());
View Full Code Here

    Map<String, String> overrides = Maps.newHashMap();
    overrides.put(FileChannelConfiguration.CHECKPOINT_INTERVAL,
            String.valueOf(Integer.MAX_VALUE));
    final FileChannel channel = createFileChannel(overrides);
    channel.start();
    FileBackedTransaction tx = (FileBackedTransaction) channel.getTransaction();

    InflightEventWrapper inflightPuts =
            field("inflightPuts").ofType(InflightEventWrapper.class).in(
            field("queue").ofType(FlumeEventQueue.class).in(tx).get()).get();

    tx.begin();

    for (int i = 0; i < 100; i++) {
      channel.put(EventBuilder.withBody("TestEvent".getBytes()));
    }

    Assert.assertFalse(inflightPuts.getFileIDs().isEmpty());
    Assert.assertFalse(inflightPuts.getInFlightPointers().isEmpty());

    tx.rollback();
    tx.close();

    Assert.assertTrue(inflightPuts.getFileIDs().isEmpty());
    Assert.assertTrue(inflightPuts.getInFlightPointers().isEmpty());
    Assert.assertTrue(channel.getDepth() == 0);

    Set<String> in = putEvents(channel, "testing-rollbacks", 100, 100);

    tx = (FileBackedTransaction) channel.getTransaction();

    InflightEventWrapper inflightTakes =
            field("inflightTakes").ofType(InflightEventWrapper.class).in(
            field("queue").ofType(FlumeEventQueue.class).in(tx).get()).get();

    tx.begin();

    for (int i = 0; i < 100; i++) {
      channel.take();
    }

    Assert.assertFalse(inflightTakes.getFileIDs().isEmpty());
    Assert.assertFalse(inflightTakes.getInFlightPointers().isEmpty());

    tx.rollback();
    tx.close();


    Assert.assertTrue(inflightTakes.getFileIDs().isEmpty());
    Assert.assertTrue(inflightTakes.getInFlightPointers().isEmpty());
    Assert.assertTrue(channel.getDepth() == in.size());
View Full Code Here

TOP

Related Classes of org.apache.flume.channel.file.FileChannel.FileBackedTransaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.