Last active
April 17, 2021 16:52
-
-
Save natansil/1c6b100de3f5e323062a914809e0cf19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.wix.cronulla.example; | |
import com.wix.cronulla.example.GetTasks; | |
import org.apache.curator.framework.CuratorFramework; | |
import org.apache.curator.framework.recipes.leader.LeaderSelectorListenerAdapter; | |
import java.util.concurrent.ExecutorService; | |
public class LeaderNodeCronScheduler extends LeaderSelectorListenerAdapter { | |
public LeaderNodeCronScheduler(GetTasks getTasks, ExecutorService executorService) { } | |
@Override | |
public void takeLeadership(CuratorFramework curatorFramework) throws Exception { | |
try { | |
while (true) { | |
if (Thread.currentThread().isInterrupted()) { | |
throw new InterruptedException(); | |
} | |
// process currently available scheduled tasks (getTasks) to run on a separate thread pool (executorService) | |
// delay next iteration | |
} | |
} catch (InterruptedException ex) { | |
} finally { | |
// Stop processing scheduling tasks | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment