/**
  * Find a matching client SUBSCRIBE to the incoming notify. NOTIFY requests are matched to such
  * SUBSCRIBE requests if they contain the same "Call-ID", a "To" header "tag" parameter which
  * matches the "From" header "tag" parameter of the SUBSCRIBE, and the same "Event" header field.
  * Rules for comparisons of the "Event" headers are described in section 7.2.1. If a matching
  * NOTIFY request contains a "Subscription-State" of "active" or "pending", it creates a new
  * subscription and a new dialog (unless they have already been created by a matching response, as
  * described above).
  *
  * @param notifyMessage
  */
 public SIPClientTransaction findSubscribeTransaction(SIPRequest notifyMessage) {
   synchronized (clientTransactions) {
     Iterator<SIPClientTransaction> it = clientTransactions.iterator();
     String thisToTag = notifyMessage.getTo().getTag();
     if (thisToTag == null) return null;
     Event eventHdr = (Event) notifyMessage.getHeader(EventHeader.NAME);
     if (eventHdr == null) return null;
     while (it.hasNext()) {
       SIPClientTransaction ct = (SIPClientTransaction) it.next();
       // SIPRequest sipRequest = ct.getOriginalRequest();
       String fromTag = ct.from.getTag();
       Event hisEvent = ct.event;
       // Event header is mandatory but some slopply clients
       // dont include it.
       if (hisEvent == null) continue;
       if (ct.method.equals(Request.SUBSCRIBE)
           && fromTag.equalsIgnoreCase(thisToTag)
           && hisEvent != null
           && eventHdr.match(hisEvent)
           && notifyMessage.getCallId().getCallId().equalsIgnoreCase(ct.callId.getCallId()))
         return ct;
     }
   }
   return null;
 }
Exemple #2
0
  /**
   * handle the UP event.
   *
   * @param evt - the event being send from the stack
   */
  public void up(Event evt) {
    passUp(evt);

    switch (evt.getType()) {
      case Event.CONFIG:
        passUp(evt);
        if (Trace.trace) {
          Trace.info("UDP.up()", "received CONFIG event: " + evt.getArg());
        }
        handleConfigEvent((HashMap) evt.getArg());
        return;
    }

    passUp(evt);
  }
Exemple #3
0
    public Dialog getPreviousPoppedDialog(int time) {

      Dialog d = null;

      listIt = eventList.listIterator();
      while (listIt.hasNext()) {
        Event temp = listIt.next();
        if (temp.getTimeStamp() > time) {
          break;
        }
        if (temp.getType() == DIA_TIME) {
          d = (Dialog) temp;
        }
      }
      return d;
    }
Exemple #4
0
  void handleDownEvent(Event evt) {
    switch (evt.getType()) {
      case Event.TMP_VIEW:
      case Event.VIEW_CHANGE:
        synchronized (members) {
          members.removeAllElements();
          Vector tmpvec = ((View) evt.getArg()).getMembers();
          for (int i = 0; i < tmpvec.size(); i++) {
            members.addElement(tmpvec.elementAt(i));
          }
        }
        break;

      case Event.GET_LOCAL_ADDRESS: // return local address -> Event(SET_LOCAL_ADDRESS, local)
        passUp(new Event(Event.SET_LOCAL_ADDRESS, local_addr));
        break;

      case Event.CONNECT:
        group_addr = (String) evt.getArg();
        udp_hdr = new UdpHeader(group_addr);

        // removed March 18 2003 (bela), not needed (handled by GMS)
        // changed July 2 2003 (bela): we discard CONNECT_OK at the GMS level anyway, this might
        // be needed if we run without GMS though
        passUp(new Event(Event.CONNECT_OK));
        break;

      case Event.DISCONNECT:
        passUp(new Event(Event.DISCONNECT_OK));
        break;

      case Event.CONFIG:
        if (Trace.trace) {
          Trace.info("UDP.down()", "received CONFIG event: " + evt.getArg());
        }
        handleConfigEvent((HashMap) evt.getArg());
        break;
    }
  }
Exemple #5
0
    public void checkCuttingOnAction(SceneManager sm, Timeline tl) {
      LinkedList<Event> eList = sm.getEventList();
      ArrayList<Tick> tArr = tl.getTickArr();
      ListIterator<Event> listIt;

      for (int i = 0; i < tArr.size(); i++) {
        //      println("here");
        listIt = eList.listIterator();
        while (listIt.hasNext()) {
          Event tempEvent = listIt.next();
          // check for time colisions.
          //        println("event " + tempEvent.getTimeStamp() + " tick time " +
          // tArr.get(i).getTimeStamp() + " " + tempEvent.type);

          if ((tempEvent.getType() == DIA_TIME)
              && (tempEvent.getTimeStamp() == tArr.get(i).getTimeStamp())) {
            println("CUTTING ON ACTION ERROR!");
            tArr.get(i).setCutViolation(true);
          } else {
            tArr.get(i).setCutViolation(false);
          }
        }
      }
    }
Exemple #6
0
  /**
   * Caller by the layer above this layer. Usually we just put this Message into the send queue and
   * let one or more worker threads handle it. A worker thread then removes the Message from the
   * send queue, performs a conversion and adds the modified Message to the send queue of the layer
   * below it, by calling Down).
   */
  public void down(Event evt) {
    Message msg;
    Object dest_addr;

    if (evt.getType() != Event.MSG) { // unless it is a message handle it and respond
      handleDownEvent(evt);
      return;
    }

    // ****************** profiling ******************
    /*if(num_msgs == 0) {
    start=System.currentTimeMillis();
    num_msgs++;
         }
         else if(num_msgs >= 1000) {
    stop=System.currentTimeMillis();

    long total_time=stop-start;
    double msgs_per_msec=num_msgs / (double)total_time;

    if(Trace.trace)
        Trace.info("UDP.down.profile()",
                "total_time=" + total_time + ", msgs/ms=" + msgs_per_msec);
    num_msgs=0;
         }
         else {
    num_msgs++;
         }*/
    // ****************** profiling ******************

    msg = (Message) evt.getArg();

    if (udp_hdr != null && udp_hdr.group_addr != null) {
      // added patch by Roland Kurmann (March 20 2003)
      msg.putHeader(name, udp_hdr);
    }

    dest_addr = msg.getDest();

    // Because we don't call Protocol.passDown(), we notify the observer directly (e.g.
    // PerfObserver).
    // This way, we still have performance numbers for UDP
    if (observer != null) {
      observer.passDown(evt);
    }
    if (dest_addr == null) { // 'null' means send to all group members
      if (ip_mcast) {
        if (mcast_addr == null) {
          Trace.error(
              "UDP.down()",
              "dest address of message is null, and "
                  + "sending to default address fails as mcast_addr is null, too !"
                  + " Discarding message "
                  + Util.printEvent(evt));
          return;
        }
        // if we want to use IP multicast, then set the destination of the message
        msg.setDest(mcast_addr);
      } else {
        // sends a separate UDP message to each address
        sendMultipleUdpMessages(msg, members);
        return;
      }
    }

    try {
      sendUdpMessage(msg);
    } catch (Exception e) {
      Trace.error("UDP.down()", "exception=" + e + ", msg=" + msg + ", mcast_addr=" + mcast_addr);
    }
  }
  /**
   * Grabs local events and detects if events was lost since last poll.
   *
   * @param ignite Target grid.
   * @param evtOrderKey Unique key to take last order key from node local map.
   * @param evtThrottleCntrKey Unique key to take throttle count from node local map.
   * @param evtTypes Event types to collect.
   * @param evtMapper Closure to map grid events to Visor data transfer objects.
   * @return Collections of node events
   */
  public static Collection<VisorGridEvent> collectEvents(
      Ignite ignite,
      String evtOrderKey,
      String evtThrottleCntrKey,
      final int[] evtTypes,
      IgniteClosure<Event, VisorGridEvent> evtMapper) {
    assert ignite != null;
    assert evtTypes != null && evtTypes.length > 0;

    ConcurrentMap<String, Long> nl = ignite.cluster().nodeLocalMap();

    final long lastOrder = getOrElse(nl, evtOrderKey, -1L);
    final long throttle = getOrElse(nl, evtThrottleCntrKey, 0L);

    // When we first time arrive onto a node to get its local events,
    // we'll grab only last those events that not older than given period to make sure we are
    // not grabbing GBs of data accidentally.
    final long notOlderThan = System.currentTimeMillis() - EVENTS_COLLECT_TIME_WINDOW;

    // Flag for detecting gaps between events.
    final AtomicBoolean lastFound = new AtomicBoolean(lastOrder < 0);

    IgnitePredicate<Event> p =
        new IgnitePredicate<Event>() {
          /** */
          private static final long serialVersionUID = 0L;

          @Override
          public boolean apply(Event e) {
            // Detects that events were lost.
            if (!lastFound.get() && (lastOrder == e.localOrder())) lastFound.set(true);

            // Retains events by lastOrder, period and type.
            return e.localOrder() > lastOrder
                && e.timestamp() > notOlderThan
                && F.contains(evtTypes, e.type());
          }
        };

    Collection<Event> evts = ignite.events().localQuery(p);

    // Update latest order in node local, if not empty.
    if (!evts.isEmpty()) {
      Event maxEvt = Collections.max(evts, EVTS_ORDER_COMPARATOR);

      nl.put(evtOrderKey, maxEvt.localOrder());
    }

    // Update throttle counter.
    if (!lastFound.get())
      nl.put(evtThrottleCntrKey, throttle == 0 ? EVENTS_LOST_THROTTLE : throttle - 1);

    boolean lost = !lastFound.get() && throttle == 0;

    Collection<VisorGridEvent> res = new ArrayList<>(evts.size() + (lost ? 1 : 0));

    if (lost) res.add(new VisorGridEventsLost(ignite.cluster().localNode().id()));

    for (Event e : evts) {
      VisorGridEvent visorEvt = evtMapper.apply(e);

      if (visorEvt != null) res.add(visorEvt);
    }

    return res;
  }
 @Override
 public int compare(Event o1, Event o2) {
   return Long.compare(o1.localOrder(), o2.localOrder());
 }