Question: Is there a way to add a specific behavior that should only be executed on (and **follow**) the Ignite Coordinator ServerNode?

Is there a add-on hook to add some customer specific behavior?

Thanks in advance.

Greg

Answer: 
AFAIK, there is not any built-in hook to achieve this.
However, it can be achieved through **Node Singleton Ignite Service** and using an api on `TcpDiscoverySpi.isLocalNodeCoordinator()`.

If different discovery mechanism other than TcpDiscovery, is used, above mentioned way by @Alexandr can be used to get a co-ordinator node.

1. Define an Ignite Service as follows. It will schedule a task that will periodically execute on every node of the cluster and execute certain logic, if it's a coordinator node.

public class IgniteServiceImpl implements Service {

```
 @IgniteInstanceResource
 Ignite ignite;

 @Override
 public void cancel(ServiceContext ctx) {
 }

 @Override
 public void init(ServiceContext ctx) throws Exception {
     System.out.println("Starting a service");
 }

 @Override
 public void execute(ServiceContext ctx) throws Exception {

     Timer timer = new Timer();
     timer.schedule(new TimerTask() {
         @Override
         public void run() {
             System.out.println("Inside a service");
             if (ignite != null) {
                 DiscoverySpi discoverySpi = ignite.configuration().getDiscoverySpi();
                 if (discoverySpi instanceof TcpDiscoverySpi) {
                     TcpDiscoverySpi tcpDiscoverySpi = (TcpDiscoverySpi) discoverySpi;
                     if(tcpDiscoverySpi.isLocalNodeCoordinator())
                         doSomething();
                 } else {
                     ClusterNode coordinatorNode = ((IgniteEx) ignite).context().discovery().discoCache().oldestAliveServerNode();
                     UUID localNodeId = ((IgniteEx) ignite).context().localNodeId();
                     if(localNodeId.equals(coordinatorNode.id()))
                         doSomething();
                 }
             } else {
                 System.out.println("Ignite is null");
             }
         }
     }, 5, (30 * 1000L));
 }

 private void doSomething(){
     System.out.println("Hi I am Co-ordinator Node");
 }

```

}
2. Start above service as node singleton using `Ignite.services()` as follows

```
 IgniteConfiguration igniteConfiguration = new IgniteConfiguration();
 igniteConfiguration.setIgniteInstanceName("ignite-node");
 Ignite ignite = Ignition.start(igniteConfiguration);

 IgniteServices services = ignite.services();
 services.deployNodeSingleton("test-service",new IgniteServiceImpl());

```
In case of a low-level logic, you can extend Ignite with [custom plugins](https://ignite.apache.org/docs/latest/plugins).
I'm not sure if there is an easy way to check if a node is indeed the coordinator, but you might check for the oldest one:

```
private boolean isCoordinator() {
        ClusterNode node = ((IgniteEx)ignite()).context().discovery().discoCache().oldestAliveServerNode();

        return node != null && node.isLocal();
    }

```

Otherwise, just run a custom initialization logic/compute task, once a node is started.