private boolean announce(String[] groups){
  if (dataPackets == null || !lastLocator.equals(myLocator) || !Arrays.equals(lastGroups,groups)) {
    List<DatagramPacket> packets=new ArrayList<DatagramPacket>();
    Discovery disco;
    try {
      disco=getDiscovery(multicastAnnouncementConstraints.chooseProtocolVersion());
    }
 catch (    DiscoveryProtocolException e) {
      throw new AssertionError(e);
    }
    EncodeIterator ei=disco.encodeMulticastAnnouncement(new MulticastAnnouncement(announcementSeqNo++,myLocator.getHost(),myLocator.getPort(),groups,myServiceID),multicastAnnouncementConstraints.getMulticastMaxPacketSize(DEFAULT_MAX_PACKET_SIZE),multicastAnnouncementConstraints.getUnfulfilledConstraints());
    while (ei.hasNext()) {
      try {
        packets.addAll(Arrays.asList(ei.next()));
      }
 catch (      Exception e) {
        logger.log((e instanceof UnsupportedConstraintException) ? Levels.HANDLED : Level.INFO,"exception encoding multicast" + " announcement",e);
      }
    }
    lastLocator=myLocator;
    lastGroups=groups;
    dataPackets=packets.toArray(new DatagramPacket[packets.size()]);
  }
  try {
    send(dataPackets);
  }
 catch (  InterruptedIOException e) {
    return false;
  }
  return true;
}

private boolean announce ( String [ ] groups ) { if ( dataPackets == null || ! lastLocator . equals ( myLocator ) || ! Arrays . equals ( lastGroups , groups ) ) { List < DatagramPacket > packets = new ArrayList < DatagramPacket > ( ) ; Discovery disco ; try { disco = getDiscovery ( multicastAnnouncementConstraints . chooseProtocolVersion ( ) ) ; } catch ( DiscoveryProtocolException e ) { throw new AssertionError ( e ) ; } EncodeIterator ei = disco . encodeMulticastAnnouncement ( new MulticastAnnouncement ( announcementSeqNo ++ , myLocator . getHost ( ) , myLocator . getPort ( ) , groups , myServiceID ) , multicastAnnouncementConstraints . getMulticastMaxPacketSize ( DEFAULT_MAX_PACKET_SIZE ) , multicastAnnouncementConstraints . getUnfulfilledConstraints ( ) ) ; while ( ei . hasNext ( ) ) { try { packets . addAll ( Arrays . asList ( ei . next ( ) ) ) ; } catch ( Exception e ) { logger . log ( ( e instanceof UnsupportedConstraintException ) ? Levels . HANDLED : Level . INFO , "exception encoding multicast" + " announcement" , e ) ; } } lastLocator = myLocator ; lastGroups = groups ; dataPackets = packets . toArray ( new DatagramPacket [ packets . size ( ) ] ) ; } try { send ( dataPackets ) ; } catch ( InterruptedIOException e ) { return false ; } return true ; }
announce membership in the specified groups , and return false if interrupted , otherwise return true . this method is run from synchronized run method in thread .
