Examples of IncomingMulticastAnnouncement


Examples of net.jini.discovery.IncomingMulticastAnnouncement

            throw new TestException(
                    "OutgoingMulticastAnnouncement.marshal returned non-1"
                    + " array");
        }

  IncomingMulticastAnnouncement ann =
      new IncomingMulticastAnnouncement(reqs[0]);

  if (ann.getGroups().length != 0) {
      throw new TestException("IncomingMulticastAnnouncement.getGroups "
          + "returned non-empty array");
  }

        /*
         * Try marshalling a normal-looking announcement, so we can
         * ensure that it contains everything it should.
         */
  reqs = OutgoingMulticastAnnouncement.marshal(sid, loc, grps);

        if (reqs == null) {
            throw new TestException(
                    "OutgoingMulticastAnnouncement.marshal returned null");
        }

        if (reqs.length == 0) {
            throw new TestException(
                    "OutgoingMulticastAnnouncement.marshal returned empty"
                    + " array");
        }
        logger.log(Level.INFO, "Marshaled " + reqs.length + " packets");
        Collection marshaledGroups = new HashSet();

        for (int i = 0; i < reqs.length; i++) {
            if (reqs[i].getData().length > 512) {
                throw new TestException(
                        "request data is too large, at "
                        + reqs[i].getData().length + " bytes");
            }
            IncomingMulticastAnnouncement req =
    new IncomingMulticastAnnouncement(reqs[i]);

            if (!req.getServiceID().equals(sid)) {
                throw new TestException(
                        "unmarshaled a bad service ID");
            }

            if (!QAConfig.getConstrainedLocator(req.getLocator()).equals(loc)) {
                throw new TestException(
                        "unmarshaled a bad locator");
            }
            String[] groupsU = req.getGroups();

            for (int j = 0; j < groupsU.length; j++) {
                if (!grpSet.contains(groupsU[j])) {
                    throw new TestException(
                            "unmarshaled a group we didn't marshal");
View Full Code Here

Examples of net.jini.discovery.IncomingMulticastAnnouncement

                announcementAddress = Constants.getAnnouncementAddress();
                multicastSocket = new MulticastSocket(Constants.discoveryPort);
                multicastSocket.joinGroup(announcementAddress);
                DatagramPacket annPacket;
                while (keepRunning.get()) {
                    IncomingMulticastAnnouncement ima;
                    annPacket = new DatagramPacket(packet, packet.length);
                    multicastSocket.receive(annPacket);
                    Date when;
                    try {
                        ima = new IncomingMulticastAnnouncement(annPacket);
                        when = new Date(System.currentTimeMillis());
                    } catch(IOException ioe) {
                        System.err.println("Unrecognized packet type in the AnnouncementListener");
                        continue;
                    }
                    StringBuilder groups = new StringBuilder();
                    for(String group : ima.getGroups()) {
                        if(groups.length()>0)
                            groups.append(", ");
                        groups.append(group);
                    }
                    Document document = area.getDocument();
                    document.insertString(document.getLength(),
                                          String.format("%s %s:%s [%s]\n",
                                                        format.format(when),
                                                        ima.getLocator().getHost(),
                                                        ima.getLocator().getPort(),
                                                        groups.toString()),
                                          null);
                }
            } catch(Exception e) {
                System.err.println("AnnouncementListener: "+ e.getClass().getName()+ ": "+e.getMessage()+", exiting");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.