Nevermind, I figured it out.

The API /status/selfDiscovered actually executes a process to check if a node 
has discovered itself or not  and logs the information as Node[%s] of role[%s] 
appeared.

Thank you

On 2021/08/26 10:07:10, Jeet Patel <jp707...@gmail.com> wrote: 
> Hi all,
> 
> I'm building a custom emitter where I get the DruidNode and set a @Self 
> annotation to it in my emitter module, shown below:
> 
>   @Provides
>   @ManageLifecycle
>   @Named(EMITTER_TYPE)
>   public Emitter getEmitter(MyEmitterConfig myEmitterConfig, ObjectMapper 
> mapper, @Self DruidNode druidNode)
>   {
>     return new HubbleEmitter(myEmitterConfig, mapper, druidNode);
>   }
> 
> 
> In the main MyEmitter class, I pass the DruidNode in the constructor so that 
> I can use the object as shown below:
> 
> public MyEmitter(
>       MyEmitterConfig myEmitterConfig,
>       ObjectMapper mapper,
>       DruidNode druidNode
>   )
>   {
>     this.mapper = mapper;
>     this.myEmitterConfig = myEmitterConfig;
>     this.druidNode = druidNode;
>     this.healthCheck = new DruidHealthCheck(this.myEmitterConfig, 
> this.druidNode.getServiceName(), this.druidNode.getUriToUse().toString(), 
> this.druidNode.getHost());
>     log.info("Constructed MyEmitter");
>   }
> 
> Now I've created a DruidHealthCheck class, in which I've a method 
> (checkDruidNodeHealth) which calls the /status/selfDiscovered endpoint. The 
> method returns 1 if status == 200 else 0.
> 
> Now in the start() method of MyEmitter class, I have following:
> 
> @Override
>   public void start()
>   {
>     exec.scheduleAtFixedRate(
>         healthCheck::checkDruidNodeHealth,
>         10000,
>         10000,
>         TimeUnit.MILLISECONDS
>     );
>   }
> 
> So every 10 seconds, the /status/selfDiscovered endpoint will be called which 
> will return either 1 or 0.
> 
> Now, wherever the executor calls the method `checkDruidNodeHealth` following 
> is printed in service logs after the lifecycle is started:
> 
> 2021-08-26T09:51:05,109 INFO [main] 
> org.apache.druid.java.util.common.lifecycle.Lifecycle - Successfully started 
> lifecycle [module]
> 2021-08-26T09:51:14,306 INFO [qtp589489519-126] 
> org.apache.druid.curator.discovery.CuratorDruidNodeDiscoveryProvider - 
> Node[http://localhost:8082] of role[broker] appeared.
> 2021-08-26T09:51:24,113 INFO [qtp589489519-125] 
> org.apache.druid.curator.discovery.CuratorDruidNodeDiscoveryProvider - 
> Node[http://localhost:8082] of role[broker] appeared.
> 
> Can someone please help me with this. Why this is happening? Every scheduled 
> fix rate `CuratorDruidNodeDiscoveryProvider` logs in the service.
> 
> Thank you :)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@druid.apache.org
> For additional commands, e-mail: dev-h...@druid.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@druid.apache.org
For additional commands, e-mail: dev-h...@druid.apache.org

Reply via email to