예제 #1
0
파일: UDP.java 프로젝트: NZDIS/jgroups
 String dumpMessages(HashMap map) {
   StringBuffer sb = new StringBuffer();
   Map.Entry entry;
   List l;
   if (map != null) {
     synchronized (map) {
       for (Iterator it = map.entrySet().iterator(); it.hasNext(); ) {
         entry = (Map.Entry) it.next();
         l = (List) entry.getValue();
         sb.append(entry.getKey()).append(": ");
         sb.append(l.size()).append(" msgs\n");
       }
     }
   }
   return sb.toString();
 }
예제 #2
0
파일: UDP.java 프로젝트: NZDIS/jgroups
    void bundleAndSend() {
      Map.Entry entry;
      IpAddress dest;
      ObjectOutputStream out;
      InetAddress addr;
      int port;
      byte[] data;
      List l;

      if (Trace.trace) {
        Trace.info(
            "UDP.BundlingOutgoingPacketHandler.bundleAndSend()",
            "\nsending msgs:\n" + dumpMessages(msgs));
      }
      synchronized (msgs) {
        stopTimer();

        if (msgs.size() == 0) {
          return;
        }

        for (Iterator it = msgs.entrySet().iterator(); it.hasNext(); ) {
          entry = (Map.Entry) it.next();
          dest = (IpAddress) entry.getKey();
          addr = dest.getIpAddress();
          port = dest.getPort();
          l = (List) entry.getValue();
          try {
            out_stream.reset();
            // BufferedOutputStream bos=new BufferedOutputStream(out_stream);
            out_stream.write(Version.version_id, 0, Version.version_id.length); // write the version
            // bos.write(Version.version_id, 0, Version.version_id.length); // write the version
            out = new ObjectOutputStream(out_stream);
            // out=new ObjectOutputStream(bos);
            l.writeExternal(out);
            out.close(); // needed if out buffers its output to out_stream
            data = out_stream.toByteArray();
            doSend(data, addr, port);
          } catch (IOException e) {
            Trace.error(
                "UDP.BundlingOutgoingPacketHandle.bundleAndSend()",
                "exception sending msg (to dest=" + dest + "): " + e);
          }
        }
        msgs.clear();
      }
    }
    public void draw() {
      if (_pointLists.size() <= 0) return;

      pushStyle();
      noFill();

      PVector vec;
      PVector firstVec;
      PVector screenPos = new PVector();
      int colorIndex = 0;

      // draw the hand lists
      Iterator<Map.Entry> itrList = _pointLists.entrySet().iterator();
      while (itrList.hasNext()) {
        strokeWeight(2);
        stroke(_colorList[colorIndex % (_colorList.length - 1)]);

        ArrayList curList = (ArrayList) itrList.next().getValue();

        // draw line
        firstVec = null;
        Iterator<PVector> itr = curList.iterator();
        beginShape();
        while (itr.hasNext()) {
          vec = itr.next();
          if (firstVec == null) firstVec = vec;
          // calc the screen pos
          context.convertRealWorldToProjective(vec, screenPos);
          vertex(screenPos.x, screenPos.y);
        }
        endShape();

        // draw current pos of the hand
        if (firstVec != null) {
          strokeWeight(8);
          context.convertRealWorldToProjective(firstVec, screenPos);
          point(screenPos.x, screenPos.y);
        }
        colorIndex++;
      }

      popStyle();
    }
예제 #4
0
  public FunctionalTest() throws IOException {
    Vector v = new Vector();
    for (Enumeration e = v.elements(); e.hasMoreElements(); ) {}
    IOException e = new IOException();

    // this is to test excluding literals
    String buz = "text/plain";

    // this is to test array handling
    ArrayList[] foo = new ArrayList[0];
    ArrayList bar = new ArrayList();
    bar.add(HashSet.class);
    bar.add(Integer.class);
    File[] files = (File[]) bar.toArray(new File[0]);

    // this is to test imports of inner classes
    HashMap biv = new HashMap();
    Set set = biv.entrySet();
    Iterator iter = set.iterator();
    bar.add((Entry) iter.next());

    // this is to test inclusion of classes from java.lang.reflect
    Modifier m = new Modifier();

    // This next one can't be picked up by importscrubber because the compiler inlines it
    // System.out.println("A JOptionPane thingy " + JOptionPane.CANCEL_OPTION);
    // bummer!

    // this is to test importing a class and only calling a static method on it
    // Buz.doSomething();

    // this is to test NOT importing classes which are fully qualified in the class body
    // java.sql.Date sqlDate = new java.sql.Date(20);
    // Date javaDate = new Date();

    throw new IllegalArgumentException();
  }