Search in sources :

Example 1 with MissingFlowFileException

use of org.apache.nifi.processor.exception.MissingFlowFileException in project nifi by apache.

the class TestStandardProcessSession method testContentNotFoundExceptionThrownWhenUnableToReadDataOffsetTooLarge.

@Test
public void testContentNotFoundExceptionThrownWhenUnableToReadDataOffsetTooLarge() {
    final FlowFileRecord flowFileRecord = new StandardFlowFileRecord.Builder().addAttribute("uuid", "12345678-1234-1234-1234-123456789012").entryDate(System.currentTimeMillis()).contentClaim(new StandardContentClaim(resourceClaimManager.newResourceClaim("x", "x", "0", true, false), 0L)).build();
    flowFileQueue.put(flowFileRecord);
    FlowFile ff1 = session.get();
    ff1 = session.write(ff1, new OutputStreamCallback() {

        @Override
        public void process(OutputStream out) throws IOException {
        }
    });
    session.transfer(ff1);
    session.commit();
    final FlowFileRecord flowFileRecord2 = new StandardFlowFileRecord.Builder().addAttribute("uuid", "12345678-1234-1234-1234-123456789012").entryDate(System.currentTimeMillis()).contentClaim(new StandardContentClaim(resourceClaimManager.newResourceClaim("x", "x", "0", true, false), 0L)).contentClaimOffset(1000L).size(1L).build();
    flowFileQueue.put(flowFileRecord2);
    // attempt to read the data.
    try {
        session.get();
        final FlowFile ff2 = session.get();
        session.read(ff2, new InputStreamCallback() {

            @Override
            public void process(InputStream in) throws IOException {
            }
        });
        Assert.fail("Expected MissingFlowFileException");
    } catch (final MissingFlowFileException mffe) {
    }
}
Also used : FlowFile(org.apache.nifi.flowfile.FlowFile) MockFlowFile(org.apache.nifi.util.MockFlowFile) StandardContentClaim(org.apache.nifi.controller.repository.claim.StandardContentClaim) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FilterOutputStream(java.io.FilterOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) InputStreamCallback(org.apache.nifi.processor.io.InputStreamCallback) OutputStreamCallback(org.apache.nifi.processor.io.OutputStreamCallback) IOException(java.io.IOException) MissingFlowFileException(org.apache.nifi.processor.exception.MissingFlowFileException) Test(org.junit.Test)

Example 2 with MissingFlowFileException

use of org.apache.nifi.processor.exception.MissingFlowFileException in project nifi by apache.

the class StandardProcessSession method handleContentNotFound.

private void handleContentNotFound(final ContentNotFoundException nfe, final StandardRepositoryRecord suspectRecord) {
    final ContentClaim registeredClaim = suspectRecord.getOriginalClaim();
    final ContentClaim transientClaim = suspectRecord.getWorkingClaim();
    final ContentClaim missingClaim = nfe.getMissingClaim();
    final ProvenanceEventRecord dropEvent = provenanceReporter.drop(suspectRecord.getCurrent(), nfe.getMessage() == null ? "Content Not Found" : nfe.getMessage());
    if (dropEvent != null) {
        context.getProvenanceRepository().registerEvent(dropEvent);
    }
    if (missingClaim == registeredClaim) {
        suspectRecord.markForAbort();
        rollback();
        throw new MissingFlowFileException("Unable to find content for FlowFile", nfe);
    }
    if (missingClaim == transientClaim) {
        rollback();
        throw new MissingFlowFileException("Unable to find content for FlowFile", nfe);
    }
}
Also used : ContentClaim(org.apache.nifi.controller.repository.claim.ContentClaim) StandardProvenanceEventRecord(org.apache.nifi.provenance.StandardProvenanceEventRecord) ProvenanceEventRecord(org.apache.nifi.provenance.ProvenanceEventRecord) MissingFlowFileException(org.apache.nifi.processor.exception.MissingFlowFileException)

Example 3 with MissingFlowFileException

use of org.apache.nifi.processor.exception.MissingFlowFileException in project nifi by apache.

the class TestStandardProcessSession method testMissingFlowFileExceptionThrownWhenUnableToReadData.

@Test
public void testMissingFlowFileExceptionThrownWhenUnableToReadData() {
    final FlowFileRecord flowFileRecord = new StandardFlowFileRecord.Builder().addAttribute("uuid", "12345678-1234-1234-1234-123456789012").entryDate(System.currentTimeMillis()).contentClaim(new StandardContentClaim(resourceClaimManager.newResourceClaim("x", "x", "0", true, false), 0L)).size(1L).build();
    flowFileQueue.put(flowFileRecord);
    // attempt to read the data.
    try {
        final FlowFile ff1 = session.get();
        session.read(ff1, new InputStreamCallback() {

            @Override
            public void process(InputStream in) throws IOException {
            }
        });
        Assert.fail("Expected MissingFlowFileException");
    } catch (final MissingFlowFileException mffe) {
    }
}
Also used : FlowFile(org.apache.nifi.flowfile.FlowFile) MockFlowFile(org.apache.nifi.util.MockFlowFile) StandardContentClaim(org.apache.nifi.controller.repository.claim.StandardContentClaim) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) InputStreamCallback(org.apache.nifi.processor.io.InputStreamCallback) IOException(java.io.IOException) MissingFlowFileException(org.apache.nifi.processor.exception.MissingFlowFileException) Test(org.junit.Test)

Example 4 with MissingFlowFileException

use of org.apache.nifi.processor.exception.MissingFlowFileException in project nifi by apache.

the class TestStandardProcessSession method testMissingFlowFileExceptionThrownWhenUnableToReadDataStreamCallback.

@Test
public void testMissingFlowFileExceptionThrownWhenUnableToReadDataStreamCallback() {
    final FlowFileRecord flowFileRecord = new StandardFlowFileRecord.Builder().addAttribute("uuid", "12345678-1234-1234-1234-123456789012").entryDate(System.currentTimeMillis()).contentClaim(new StandardContentClaim(resourceClaimManager.newResourceClaim("x", "x", "0", true, false), 0L)).size(1L).build();
    flowFileQueue.put(flowFileRecord);
    // attempt to read the data.
    try {
        final FlowFile ff1 = session.get();
        session.write(ff1, new StreamCallback() {

            @Override
            public void process(InputStream in, OutputStream out) throws IOException {
            }
        });
        Assert.fail("Expected MissingFlowFileException");
    } catch (final MissingFlowFileException mffe) {
    }
}
Also used : FlowFile(org.apache.nifi.flowfile.FlowFile) MockFlowFile(org.apache.nifi.util.MockFlowFile) StandardContentClaim(org.apache.nifi.controller.repository.claim.StandardContentClaim) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FilterOutputStream(java.io.FilterOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) OutputStreamCallback(org.apache.nifi.processor.io.OutputStreamCallback) InputStreamCallback(org.apache.nifi.processor.io.InputStreamCallback) StreamCallback(org.apache.nifi.processor.io.StreamCallback) MissingFlowFileException(org.apache.nifi.processor.exception.MissingFlowFileException) Test(org.junit.Test)

Example 5 with MissingFlowFileException

use of org.apache.nifi.processor.exception.MissingFlowFileException in project nifi by apache.

the class TestStandardProcessSession method testContentNotFoundExceptionThrownWhenUnableToReadDataStreamCallbackOffsetTooLarge.

@Test
public void testContentNotFoundExceptionThrownWhenUnableToReadDataStreamCallbackOffsetTooLarge() {
    final FlowFileRecord flowFileRecord = new StandardFlowFileRecord.Builder().addAttribute("uuid", "12345678-1234-1234-1234-123456789012").entryDate(System.currentTimeMillis()).contentClaim(new StandardContentClaim(resourceClaimManager.newResourceClaim("x", "x", "0", true, false), 0L)).build();
    flowFileQueue.put(flowFileRecord);
    FlowFile ff1 = session.get();
    ff1 = session.write(ff1, new OutputStreamCallback() {

        @Override
        public void process(OutputStream out) throws IOException {
        }
    });
    session.transfer(ff1);
    session.commit();
    final FlowFileRecord flowFileRecord2 = new StandardFlowFileRecord.Builder().addAttribute("uuid", "12345678-1234-1234-1234-123456789012").entryDate(System.currentTimeMillis()).contentClaim(new StandardContentClaim(resourceClaimManager.newResourceClaim("x", "x", "0", true, false), 0L)).contentClaimOffset(1000L).size(1000L).build();
    flowFileQueue.put(flowFileRecord2);
    // attempt to read the data.
    try {
        session.get();
        final FlowFile ff2 = session.get();
        session.write(ff2, new StreamCallback() {

            @Override
            public void process(InputStream in, OutputStream out) throws IOException {
            }
        });
        Assert.fail("Expected ContentNotFoundException");
    } catch (final MissingFlowFileException mffe) {
    }
}
Also used : FlowFile(org.apache.nifi.flowfile.FlowFile) MockFlowFile(org.apache.nifi.util.MockFlowFile) StandardContentClaim(org.apache.nifi.controller.repository.claim.StandardContentClaim) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FilterOutputStream(java.io.FilterOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) OutputStreamCallback(org.apache.nifi.processor.io.OutputStreamCallback) IOException(java.io.IOException) OutputStreamCallback(org.apache.nifi.processor.io.OutputStreamCallback) InputStreamCallback(org.apache.nifi.processor.io.InputStreamCallback) StreamCallback(org.apache.nifi.processor.io.StreamCallback) MissingFlowFileException(org.apache.nifi.processor.exception.MissingFlowFileException) Test(org.junit.Test)

Aggregations

MissingFlowFileException (org.apache.nifi.processor.exception.MissingFlowFileException)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 FileInputStream (java.io.FileInputStream)4 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 StandardContentClaim (org.apache.nifi.controller.repository.claim.StandardContentClaim)4 FlowFile (org.apache.nifi.flowfile.FlowFile)4 InputStreamCallback (org.apache.nifi.processor.io.InputStreamCallback)4 MockFlowFile (org.apache.nifi.util.MockFlowFile)4 Test (org.junit.Test)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 FileOutputStream (java.io.FileOutputStream)3 FilterOutputStream (java.io.FilterOutputStream)3 OutputStream (java.io.OutputStream)3 OutputStreamCallback (org.apache.nifi.processor.io.OutputStreamCallback)3 StreamCallback (org.apache.nifi.processor.io.StreamCallback)2 ContentClaim (org.apache.nifi.controller.repository.claim.ContentClaim)1 ProvenanceEventRecord (org.apache.nifi.provenance.ProvenanceEventRecord)1 StandardProvenanceEventRecord (org.apache.nifi.provenance.StandardProvenanceEventRecord)1