Search in sources :

Example 1 with DropFlowFileStatus

use of org.apache.nifi.controller.queue.DropFlowFileStatus in project nifi by apache.

the class StandardConnectionDAO method deleteFlowFileDropRequest.

@Override
public DropFlowFileStatus deleteFlowFileDropRequest(String connectionId, String dropRequestId) {
    final Connection connection = locateConnection(connectionId);
    final FlowFileQueue queue = connection.getFlowFileQueue();
    final DropFlowFileStatus dropFlowFileStatus = queue.cancelDropFlowFileRequest(dropRequestId);
    if (dropFlowFileStatus == null) {
        throw new ResourceNotFoundException(String.format("Unable to find drop request with id '%s'.", dropRequestId));
    }
    return dropFlowFileStatus;
}
Also used : Connection(org.apache.nifi.connectable.Connection) DropFlowFileStatus(org.apache.nifi.controller.queue.DropFlowFileStatus) FlowFileQueue(org.apache.nifi.controller.queue.FlowFileQueue) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 2 with DropFlowFileStatus

use of org.apache.nifi.controller.queue.DropFlowFileStatus in project nifi by apache.

the class StandardConnectionDAO method getFlowFileDropRequest.

@Override
public DropFlowFileStatus getFlowFileDropRequest(String connectionId, String dropRequestId) {
    final Connection connection = locateConnection(connectionId);
    final FlowFileQueue queue = connection.getFlowFileQueue();
    final DropFlowFileStatus dropRequest = queue.getDropFlowFileStatus(dropRequestId);
    if (dropRequest == null) {
        throw new ResourceNotFoundException(String.format("Unable to find drop request with id '%s'.", dropRequestId));
    }
    return dropRequest;
}
Also used : Connection(org.apache.nifi.connectable.Connection) DropFlowFileStatus(org.apache.nifi.controller.queue.DropFlowFileStatus) FlowFileQueue(org.apache.nifi.controller.queue.FlowFileQueue) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 3 with DropFlowFileStatus

use of org.apache.nifi.controller.queue.DropFlowFileStatus in project nifi by apache.

the class TestStandardFlowFileQueue method testBackPressureAfterDrop.

@Test(timeout = 10000)
public void testBackPressureAfterDrop() throws InterruptedException {
    queue.setBackPressureObjectThreshold(10);
    queue.setFlowFileExpiration("10 millis");
    for (int i = 0; i < 9; i++) {
        queue.put(new TestFlowFile());
        assertFalse(queue.isFull());
    }
    queue.put(new TestFlowFile());
    assertTrue(queue.isFull());
    Thread.sleep(100L);
    final String requestId = UUID.randomUUID().toString();
    final DropFlowFileStatus status = queue.dropFlowFiles(requestId, "Unit Test");
    while (status.getState() != DropFlowFileState.COMPLETE) {
        Thread.sleep(10L);
    }
    assertFalse(queue.isFull());
    assertTrue(queue.isEmpty());
    assertTrue(queue.isActiveQueueEmpty());
    assertEquals(10, provRecords.size());
    for (final ProvenanceEventRecord event : provRecords) {
        assertNotNull(event);
        assertEquals(ProvenanceEventType.DROP, event.getEventType());
    }
}
Also used : StandardProvenanceEventRecord(org.apache.nifi.provenance.StandardProvenanceEventRecord) ProvenanceEventRecord(org.apache.nifi.provenance.ProvenanceEventRecord) DropFlowFileStatus(org.apache.nifi.controller.queue.DropFlowFileStatus) Test(org.junit.Test)

Example 4 with DropFlowFileStatus

use of org.apache.nifi.controller.queue.DropFlowFileStatus in project nifi by apache.

the class TestStandardFlowFileQueue method testDropSwappedFlowFiles.

@Test(timeout = 120000)
public void testDropSwappedFlowFiles() {
    for (int i = 1; i <= 30000; i++) {
        queue.put(new TestFlowFile());
    }
    assertEquals(2, swapManager.swappedOut.size());
    final DropFlowFileStatus status = queue.dropFlowFiles("1", "Unit Test");
    while (status.getState() != DropFlowFileState.COMPLETE) {
        try {
            Thread.sleep(100L);
        } catch (final Exception e) {
        }
    }
    assertEquals(0, queue.size().getObjectCount());
    assertEquals(0, queue.size().getByteCount());
    assertEquals(0, swapManager.swappedOut.size());
    assertEquals(2, swapManager.swapInCalledCount);
}
Also used : DropFlowFileStatus(org.apache.nifi.controller.queue.DropFlowFileStatus) IncompleteSwapFileException(org.apache.nifi.controller.repository.IncompleteSwapFileException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

DropFlowFileStatus (org.apache.nifi.controller.queue.DropFlowFileStatus)4 Connection (org.apache.nifi.connectable.Connection)2 FlowFileQueue (org.apache.nifi.controller.queue.FlowFileQueue)2 ResourceNotFoundException (org.apache.nifi.web.ResourceNotFoundException)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 IncompleteSwapFileException (org.apache.nifi.controller.repository.IncompleteSwapFileException)1 ProvenanceEventRecord (org.apache.nifi.provenance.ProvenanceEventRecord)1 StandardProvenanceEventRecord (org.apache.nifi.provenance.StandardProvenanceEventRecord)1