Support Questions

Find answers, ask questions, and share your expertise
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

Nifi:Automatizied Scheduler

I have attribute names like startDate:2017-09-07 and endDate:2017-09-16 i want to reitrive data with this parameters and after writing response into the base i want to change this parameter i mean (startDate:2017-09-07 and endDate:2017-09-16 with 2017-09-17 and 2017-09-24) i tried this ecmascript code:

<code> var OutputStreamCallback = Java.type("");
var StandardCharsets = Java.type("java.nio.charset.StandardCharsets");

Date.prototype.isValid = function () {
    return ( === "[object Date]")
        && !isNaN(this.getTime());
function addDays(date, days) {
    var result =new Date(date);
    result.setDate(result.getDate() + days);
    var dateFormated = result.toISOString().substr(0,10);
    return formatDate(dateFormated);
function formatDate(date) {
    var d = new Date(date),
        month = '' + (d.getMonth() + 1),
        day = '' + d.getDate(),
        year = d.getFullYear();

    if (month.length < 2) month = '0' + month;
    if (day.length < 2) day = '0' + day;

    return [year, month, day].join('-');
var startDate = startDate.getValue(),
    endDate = endDate.getValue(),
var flowFile = session.crete();

var  param=8;
    var endDate = addDays(end, param*count);
    var startDate = formatDate(newStart);
    flowFile = session.putAttribute(flowFile, 'startDate', startDate);
    flowFile = session.putAttribute(flowFile, 'endDate', endDate);

    session.transfer(flowFile, REL_SUCCESS)

but i don't know how can i make my code known when it should increase count in order to change endDate and startTdate manually and replace it with valid startDate and EndDate is there any service or processor i can use to simplify this task?


Expert Contributor

You can use a distributedcache to write startdate and enddate values. The retrieve those from the distributecache using fetchdistributedcache. I have a sample setting attached for fetchdistributemapcache. Once you are done incrementing the new value, you can push it back to the cache using putdistributemapcache.


@Karthik Narayanan can you link me any article or example of how can i use it?

I mean how can i use distributedCashService

Expert Contributor
Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.