Ejemplo n.º 1
0
  private void testSingleFileFailedWriteHelper(
      SingleHDFSExactlyOnceWriter writer, ProcessingMode mode) {
    File meta = new File(testMeta.getDir());
    writer.setFilePath(meta.getAbsolutePath());
    writer.setup(new DummyContext(0, mode));

    writer.beginWindow(0);
    writer.input.put(0);
    writer.input.put(1);
    writer.endWindow();

    CheckPointWriter checkPointWriter = checkpoint(writer);

    writer.beginWindow(1);
    writer.input.put(2);

    writer.teardown();

    restoreCheckPoint(checkPointWriter, writer);
    writer.setup(new DummyContext(0, mode));

    writer.beginWindow(1);
    writer.input.put(4);
    writer.input.put(5);
    writer.endWindow();

    writer.beginWindow(2);
    writer.input.put(6);
    writer.input.put(7);
    writer.endWindow();

    writer.teardown();
  }
Ejemplo n.º 2
0
  private void testSingleRollingFileFailedWriteOverwriteHelper(
      SingleHDFSExactlyOnceWriter writer, ProcessingMode mode) {
    writer.setMaxLength(4);
    writer.setFilePath(testMeta.getDir());
    writer.setup(new DummyContext(0, mode));

    writer.beginWindow(0);
    writer.input.put(0);
    writer.input.put(1);
    writer.input.put(2);
    writer.endWindow();

    writer.beginWindow(1);
    writer.input.put(3);
    writer.input.put(4);

    CheckPointWriter checkPointWriter = checkpoint(writer);

    writer.teardown();

    restoreCheckPoint(checkPointWriter, writer);
    writer.setup(new DummyContext(0, mode));

    writer.beginWindow(1);
    writer.input.put(3);
    writer.endWindow();

    writer.beginWindow(2);
    writer.input.put(6);
    writer.input.put(7);
    writer.input.put(8);
    writer.endWindow();

    writer.teardown();
  }
Ejemplo n.º 3
0
  private void testSingleFileCompletedWriteHelper(
      SingleHDFSExactlyOnceWriter writer, ProcessingMode mode) {
    writer.setFilePath(testMeta.getDir());
    writer.setup(new DummyContext(0, mode));

    writer.beginWindow(0);
    writer.input.put(0);
    writer.input.put(1);
    writer.endWindow();

    writer.beginWindow(1);
    writer.input.put(2);
    writer.input.put(3);
    writer.endWindow();

    writer.teardown();
  }
Ejemplo n.º 4
0
  // @Ignore
  @Test
  public void singleFileMultiRollingFailureOverwrite() {
    prepareTest();
    SingleHDFSExactlyOnceWriter writer = new SingleHDFSExactlyOnceWriter();
    File meta = new File(testMeta.getDir());
    writer.setFilePath(meta.getAbsolutePath());
    writer.setAppend(false);
    writer.setMaxLength(4);

    singleFileMultiRollingFailureHelper(writer, ProcessingMode.EXACTLY_ONCE);

    String singleFilePath = testMeta.getDir() + File.separator + SINGLE_FILE;

    // Rolling file 0

    String correctContents = "0\n" + "1\n" + "2\n";
    checkOutput(0, singleFilePath, correctContents);

    // Rolling file 1

    correctContents = "3\n" + "4\n" + "0\n";

    checkOutput(1, singleFilePath, correctContents);

    // Rolling file 2

    correctContents = "1\n" + "2\n" + "3\n";

    checkOutput(2, singleFilePath, correctContents);

    // Rolling file 2

    correctContents = "4\n" + "5\n";

    checkOutput(3, singleFilePath, correctContents);
  }
Ejemplo n.º 5
0
  // @Ignore
  @Test
  public void testSingleRollingFileFailedWrite1() {
    prepareTest();
    SingleHDFSExactlyOnceWriter writer = new SingleHDFSExactlyOnceWriter();
    writer.setAppend(true);
    writer.setFilePath(testMeta.getDir());
    writer.setMaxLength(4);

    writer.setup(new DummyContext(0, ProcessingMode.EXACTLY_ONCE));

    writer.beginWindow(0);
    writer.input.put(0);
    writer.input.put(1);
    writer.input.put(2);
    writer.endWindow();

    writer.beginWindow(1);
    writer.input.put(3);
    writer.input.put(4);
    writer.endWindow();

    CheckPointWriter checkPointWriter = checkpoint(writer);
    CheckPointWriter checkPointWriter1 = checkpoint(writer);

    LOG.debug("Checkpoint endOffsets={}", checkPointWriter.endOffsets);

    writer.beginWindow(2);
    writer.input.put(5);
    writer.teardown();

    restoreCheckPoint(checkPointWriter, writer);
    LOG.debug("Checkpoint endOffsets={}", checkPointWriter.endOffsets);
    writer.setup(new DummyContext(0, ProcessingMode.EXACTLY_ONCE));

    writer.beginWindow(2);
    writer.input.put(5);
    writer.endWindow();

    writer.beginWindow(3);
    writer.input.put(6);
    writer.input.put(7);
    writer.input.put(8);
    writer.endWindow();

    writer.teardown();

    restoreCheckPoint(checkPointWriter1, writer);
    writer.setup(new DummyContext(0, ProcessingMode.EXACTLY_ONCE));

    String singleFilePath = testMeta.getDir() + File.separator + SINGLE_FILE;

    // Rolling file 0

    String correctContents = "0\n" + "1\n" + "2\n";
    checkOutput(0, singleFilePath, correctContents);

    // Rolling file 1

    correctContents = "3\n" + "4\n";

    checkOutput(1, singleFilePath, correctContents);
  }