Search in sources :

Example 1 with CacheNotInitializedException

use of com.thinkbiganalytics.nifi.v2.core.savepoint.CacheNotInitializedException in project kylo by Teradata.

the class SetSavepoint method getNextFlowFile.

/**
 * Return the next available flow file in the queue that is not in a waiting state.
 *
 * @param session       the process session
 * @param provider      the save point provider
 * @param pvSavepointId the savepoint id
 * @return the first flowfile not in a waiting savepoint state
 */
private Optional<FlowFile> getNextFlowFile(ProcessContext context, ProcessSession session, SavepointController controller, SavepointProvider provider, PropertyValue pvSavepointId) {
    long expirationDuration = context.getProperty(EXPIRATION_DURATION).asTimePeriod(TimeUnit.MILLISECONDS);
    FlowFileFilter flowFileFilter = null;
    try {
        Optional<String> nextFlowFile = controller.getNextFlowFile(getIdentifier());
        flowFileFilter = new FindFirstFlowFileFilter(nextFlowFile, expirationDuration, controller);
        return session.get(flowFileFilter).stream().findFirst();
    } catch (CacheNotInitializedException e) {
        CacheInitializingFilter filter = new CacheInitializingFilter(pvSavepointId, controller, provider, expirationDuration);
        return filter.initializeAndGetNextFlowfile(session);
    }
}
Also used : FlowFileFilter(org.apache.nifi.processor.FlowFileFilter) CacheNotInitializedException(com.thinkbiganalytics.nifi.v2.core.savepoint.CacheNotInitializedException)

Aggregations

CacheNotInitializedException (com.thinkbiganalytics.nifi.v2.core.savepoint.CacheNotInitializedException)1 FlowFileFilter (org.apache.nifi.processor.FlowFileFilter)1