Hi Kumiko,

I would recommend that in your OnEnabled method that you just create a 
ScheduledExecutorService and
schedule the task to occur every 24 hours or however you'd like. Then, in your 
OnDisabled method call
shutdown on that ScheduledExecutorService.

A word to the wise, though - NiFi tends to have quite a few threads running, so 
for debugging purposes
it is easier to see what's going on if you provide a ThreadFactory to your 
executor so that you can name
your threads appropriately. Something like:

Executors.newScheduledThreadPool(3, new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
                final Thread t = Executors.defaultThreadFactory().newThread(r);
                t.setDaemon(true);
                t.setName("Refresh Azure DataLake Token");
                return t;
            }
});

I hope this helps!

Thanks
-Mark


> On Jun 17, 2016, at 3:00 PM, Kumiko Yada <kumiko.y...@ds-iq.com> wrote:
> 
> Hello,
>  
> I wrote the Custom Controller Service to authenticate the Azure Datalake 
> Store, and I’d like to refresh a token every 24 hours.  What is the best way 
> to authenticate every 24 hours?  Should I loop the authenticate code every 24 
> hours in OnEnabled?
>  
> Thanks
> Kumiko

Reply via email to