Пример #1
0
 void handleConfigEvent(HashMap map) {
   if (map == null) {
     return;
   }
   if (map.containsKey("additional_data")) {
     additional_data = (byte[]) map.get("additional_data");
   }
   if (map.containsKey("send_buf_size")) {
     mcast_send_buf_size = ((Integer) map.get("send_buf_size")).intValue();
     ucast_send_buf_size = mcast_send_buf_size;
   }
   if (map.containsKey("recv_buf_size")) {
     mcast_recv_buf_size = ((Integer) map.get("recv_buf_size")).intValue();
     ucast_recv_buf_size = mcast_recv_buf_size;
   }
   setBufferSizes();
 }
Пример #2
0
    protected void handleMessage(Message msg) throws Exception {
      Address dest = msg.getDest();
      long len;
      List tmp;

      len = msg.size(); // todo: use msg.getLength() instead of msg.getSize()
      if (len > max_bundle_size) {
        throw new Exception(
            "UDP.BundlingOutgoingPacketHandler.handleMessage(): "
                + "message size ("
                + len
                + ") is greater than UDP fragmentation size. "
                + "Set the fragmentation/bundle size in FRAG and UDP correctly");
      }

      if (total_bytes + len >= max_bundle_size) {
        if (Trace.trace) {
          Trace.info(
              "UDP.BundlingOutgoingPacketHandler.handleMessage()",
              "sending " + total_bytes + " bytes");
        }
        bundleAndSend(); // send all pending message and clear table
        total_bytes = 0;
      }

      synchronized (msgs) {
        tmp = (List) msgs.get(dest);
        if (tmp == null) {
          tmp = new List();
          msgs.put(dest, tmp);
        }
        tmp.add(msg);
        total_bytes += len;
      }

      if (!timer_running) { // first message to be bundled
        startTimer();
      }
    }