Search in sources :

Example 1 with FailureException

use of org.apache.nifi.processors.hadoop.exception.FailureException in project nifi by apache.

the class PutParquetTest method testFailureExceptionRenamingShouldRouteToFailure.

@Test
public void testFailureExceptionRenamingShouldRouteToFailure() throws InitializationException, IOException {
    final PutParquet proc = new PutParquet() {

        @Override
        protected void rename(FileSystem fileSystem, Path srcFile, Path destFile) throws IOException, InterruptedException, FailureException {
            throw new FailureException("FailureException renaming");
        }
    };
    configure(proc, 10);
    final String filename = "testFailureExceptionRenamingShouldRouteToFailure-" + System.currentTimeMillis();
    final Map<String, String> flowFileAttributes = new HashMap<>();
    flowFileAttributes.put(CoreAttributes.FILENAME.key(), filename);
    testRunner.enqueue("trigger", flowFileAttributes);
    testRunner.run();
    testRunner.assertAllFlowFilesTransferred(PutParquet.REL_FAILURE, 1);
    // verify we don't have the temp dot file after success
    final File tempAvroParquetFile = new File(DIRECTORY + "/." + filename);
    Assert.assertFalse(tempAvroParquetFile.exists());
}
Also used : Path(org.apache.hadoop.fs.Path) HashMap(java.util.HashMap) FileSystem(org.apache.hadoop.fs.FileSystem) FailureException(org.apache.nifi.processors.hadoop.exception.FailureException) FlowFile(org.apache.nifi.flowfile.FlowFile) File(java.io.File) MockFlowFile(org.apache.nifi.util.MockFlowFile) Test(org.junit.Test)

Aggregations

File (java.io.File)1 HashMap (java.util.HashMap)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 FlowFile (org.apache.nifi.flowfile.FlowFile)1 FailureException (org.apache.nifi.processors.hadoop.exception.FailureException)1 MockFlowFile (org.apache.nifi.util.MockFlowFile)1 Test (org.junit.Test)1