nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sally <salome.tkhilaishv...@gmail.com>
Subject Nifi: how to convert multiple log file in one file?
Date Wed, 03 Jan 2018 15:45:29 GMT
I have many internal log , which i write myself inside nifi environment, i
want to input all this data inside one log flowFile, but this code trows
Null pointer exception what should i cahnge?

import java.nio.charset.StandardCharsets;
import org.apache.commons.io.IOUtils;
import org.apache.nifi.processor.FlowFileFilter;
import groovy.json.JsonSlurper;
import groovy.json.JsonBuilder;

def flowFile = session.get();
def  n=0;

if(!flowFile)return
def size = flowFile.getAttribute('fileSize');
int value = size as Integer;
log.error("g");
if((value/338)>1){
def ffList = session.get(new FlowFileFilter(){
    public FlowFileFilterResult filter(FlowFile ff) {

        if( size == ff.getAttribute('fileSize') ){ n++; return
FlowFileFilterResult.ACCEPT_AND_CONTINUE;
        }
        else{
        return FlowFileFilterResult.REJECT_AND_CONTINUE
        }
    }

})

session.transfer(ffList[n-1],REL_SUCCESS);
session.remove( ffList[0..-2] )
session.remove(flowFile);

}
else{

session.transfer(flowFile,REL_SUCCESS);
}



--
Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/

Mime
View raw message