Team,

I had a question regarding the code below - doTimeKeepingServices() is
called the very first time and
then it is waiting on mcast.receive - so it will advertize itself after
hearing from another broker, assuming keepAliveInterval
has elapsed.

Should we instead run doTimeKeepingServices on its own schedule, instead of
relying on distributed event driven advertisement ?  My concern is 1. that
since the first advertisement
is not retried, a new broker might miss others when its advertisement
(multicast packet) is lost on occasion (everybody is waiting on multicast
receive). 2. When large number of brokers are brought up, potential race
condition would result in some brokers not see each other.

I will create a Jira if somebody can confirm I haven't missed anything.

(Coming from a router background, usually there is a base timer that drives
all the calendar activity in the message router)

Thanks!
Regards
- Sridhar

public void run(){
       byte[] buf=new byte[BUFF_SIZE];
       DatagramPacket packet=new DatagramPacket(buf,0,buf.length);
       while(started.get()){
           doTimeKeepingServices();
           try{
               mcast.receive(packet);
               if(packet.getLength()>0){
                   String str=new String(packet.getData(),packet.getOffset
(),packet.getLength());
                   processData(str);
               }
           }catch(SocketTimeoutException se){
               // ignore
           }catch(IOException e){
               log.error("failed to process packet: "+e);
           }
       }
   }

Reply via email to