TMasterLocationRefreshMessage handler
506107
private void handleTMasterLocationRefreshMessage(
      Metrics.MetricPublisher request,
      Metrics.TMasterLocationRefreshMessage tMasterLocationRefreshMessage) {
    TopologyMaster.TMasterLocation oldLocation =
        (TopologyMaster.TMasterLocation)
            SingletonRegistry.INSTANCE.getSingleton(TMASTER_LOCATION_BEAN_NAME);

    TopologyMaster.TMasterLocation newLocation = tMasterLocationRefreshMessage.getTmaster();

    if (oldLocation == null) {
      // The first time to get TMasterLocation

      // Register to the SingletonRegistry
      LOG.info("We received a new TMasterLocation. Register it into SingletonRegistry");
      SingletonRegistry.INSTANCE.registerSingleton(TMASTER_LOCATION_BEAN_NAME, newLocation);

      // Update Metrics
      serverMetricsCounters.scope(SERVER_NEW_TMASTER_LOCATION).incr();

    } else if (oldLocation.equals(newLocation)) {
      // The new one is the same as old one.

      // Just Log. Do nothing
      LOG.info("We received a new TMasterLocation the same as the old one. Do nothing.");
    } else {
      // Have received TMasterLocation earlier, but it changed.

      // We need update the SingletonRegistry
      LOG.info("We received a new TMasterLocation. Replace the old one.");
      LOG.info("Old TMasterLocation: " + oldLocation);
      SingletonRegistry.INSTANCE.updateSingleton(TMASTER_LOCATION_BEAN_NAME, newLocation);

      // Update Metrics
      serverMetricsCounters.scope(SERVER_NEW_TMASTER_LOCATION).incr();
    }

    LOG.info("Current TMaster location: " + newLocation);

    // Update Metrics
    serverMetricsCounters.scope(SERVER_TMASTER_LOCATION_RECEIVED).incr();
  }
390172
public void destinationLocationChange (SIBUuid12 destId, Set additions, Set deletions, Capability capability)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "destinationLocationChange",
        new Object[]{destId, additions, deletions, capability});

    BaseDestinationHandler destinationHandler =
      (BaseDestinationHandler) _destinationManager.getDestinationInternal(destId, false);

    if (destinationHandler != null)
    {

      // Check if the localisation should be deleted
      Set localitySet = getDestinationLocalitySet(destinationHandler, capability);
      
      synchronized(destinationHandler)
      {
        // d526250 - If a remote destination is deleted then its ME stopped we might
        // get a trm notification in. Meanwhile, admin has told us to delete the dest
        // already. If we dont do the following we end up performing cleanup on a 
        // dest that no longer exists and we get nullpointers.
        if (!destinationHandler.isToBeDeleted())
        {
          // Process deletions from the WLM set for the destination
          // (No requirement to react to additions)
          Iterator i = deletions.iterator();
  
          while(i.hasNext())
          {
            SIBUuid8 meUuid = (SIBUuid8) i.next();
  
            //No point reacting to our own ME uuid
            if (!(meUuid.equals(_messageProcessor.getMessagingEngineUuid())))
            {
              PtoPMessageItemStream ptoPMessageItemStream;
  
                ptoPMessageItemStream = destinationHandler.getXmitQueuePoint(meUuid);
  
              // Dont touch a localisation that doesnt exist
              if (ptoPMessageItemStream != null)
              {
                if ((localitySet == null) || !localitySet.contains(meUuid.toString()))
                {
                  // The localisation is not known in WCCM or WLM, so mark it for deletion
                  cleanupDestination(ptoPMessageItemStream, 
                      destinationHandler,
                      meUuid,
                      capability);
                }
              }
            }
          }

          if (capability != Capability.GET)
          {
            // Reallocate the transmitQs to evenly spread messages
            destinationHandler.requestReallocation();
          }
        }
      }
    }
    
    // Iterate over the registered MP listeners and alert them to the location change
    for (int i = 0; i < _destinationChangeListeners.size(); i++)
    {
      MPDestinationChangeListener listener = _destinationChangeListeners.get(i);
      if (listener != null)
        listener.destinationLocationChange(destId, additions, deletions, capability);
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "destinationLocationChange");

    return;
  }
1030044
function _wrapMessageHandler(onmessage) {
            return function(message) {
                var msgObject;

                if (!message.origin || "*" === message.origin ||  this.targetOrigin === message.origin) {
                    if (_isHandshake.call(this, message) && !this.disposed && !this.hosted && !this.ready) {
                        _onReady.call(this);
                    }
                    else {
                        try {
                            msgObject = this.deserialize(message.data);

                            if (_validateToken.call(this, msgObject)) {
                                return onmessage && onmessage(msgObject);
                            }
                        }
                        catch (ex) {
                            msgObject = message.data || message;
                            PostMessageUtilities.log("Error while trying to handle the message", "ERROR", "PostMessageChannel");
                        }

                        return msgObject || message;
                    }
                }
            };
        }
947051
def stop_message_live_location(self, *args, **kwargs):
        """"""
        return stop_message_live_location(*args, **self._merge_overrides(**kwargs)).run()
295577
def _refresh(self):
        """"""

        while not self._stopevent.isSet():
            line = self._serial.readline()
            #this is for python2/python3 compatibility. Is there a better way?
            try:
                line = line.encode().decode('utf-8')
            except AttributeError:
                line = line.decode('utf-8')

            if LaCrosseSensor.re_reading.match(line):
                sensor = LaCrosseSensor(line)
                self.sensors[sensor.sensorid] = sensor

                if self._callback:
                    self._callback(sensor, self._callback_data)

                if sensor.sensorid in self._registry:
                    for cbs in self._registry[sensor.sensorid]:
                        cbs[0](sensor, cbs[1])
293463
void validateStopCloseForMessageListener(String functionCall) throws IllegalStateException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "validateStopForMessageListener");

        //Before triggering onMessage .. SIB pushes "owning session object" to Thread Local, 
        //Now obtain the Session object from Thread Local and validate with 'this'. 
        if ((JmsSessionImpl.asyncReceiverThreadLocal.get() != null) && (JmsSessionImpl.asyncReceiverThreadLocal.get() == this)) {

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(tc, "Message Listener onMessage called stop on its own Context/connection.");

            if (functionCall.equalsIgnoreCase("stop")) {
                //stop is called.

                //the stop call is driven from this JmsSessionImpl object only.. throw JMSException
                throw (IllegalStateException) JmsErrorUtils.newThrowable(IllegalStateException.class,
                                                                         "INVALID_METHOD_CWSIA0517",
                                                                         new Object[] { this },
                                                                         tc
                                );
            } else {
                //close is called
                //the stop call is driven from this JmsSessionImpl object only.. throw JMSException
                throw (IllegalStateException) JmsErrorUtils.newThrowable(IllegalStateException.class,
                                                                         "INVALID_METHOD_CWSIA0518",
                                                                         new Object[] { this },
                                                                         tc
                                );

            }

        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "validateStopForMessageListener");

    }
1336887
@EventListener
    public void handleRefreshEvent(final RefreshRemoteApplicationEvent event) {
        LOGGER.trace("Received event [{}]", event);
        configurationPropertiesEnvironmentManager.rebindCasConfigurationProperties(this.applicationContext);
    }
221647
function() {
      delete self._requestState[transactionId];
      self._localMap.add(nbname, group, address, ttl, self._type);
      self._sendRefresh(nbname, function(error) {
        if (typeof callback === 'function') {
          callback(error, !error);
        }
      });
    }
846498
async def editMessageLiveLocation(self, msg_identifier, latitude, longitude,
                                      reply_markup=None):
        
        p = _strip(locals(), more=['msg_identifier'])
        p.update(_dismantle_message_identifier(msg_identifier))
        return await self._api_request('editMessageLiveLocation', _rectify(p))
245198
public void handleNotFlushedMessage(ControlNotFlushed cMsg)

  throws SIIncorrectCallException, SIErrorException, SIResourceException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(this, tc, "handleNotFlushedMessage", new Object[] { cMsg });

    SIBUuid12 streamID = cMsg.getGuaranteedStreamUUID();
    //Synchronize to resolve racing messages.
    synchronized (flushMap)
    {
      FlushQueryRecord entry = flushMap.get(streamID);
      // make sure the request ID matches.
      long reqId = cMsg.getRequestID();
      //if there is no entry or the entry's request ID does not match then
      //it must have been a stale request and we ignore it.
      if ((entry != null) && (entry.requestID == reqId))
      {
        // ASSERT.isTrue(entry.cache != null)

        // The assertion basically means that we should only receive
        // NOTFLUSHED if the original query was AREYOUFLUSHED.  The
        // only legal reply to REQUESTFLUSH is, eventually, FLUSHED.

        // Our original query was for "are you flushed" and we now
        // have the reply, so:
        // 1) remove the entry from the flush map and disable the alarm
        // 2) handle the new prefixes and replay any cached data messages.
        flushMap.remove(streamID);
        entry.resend.cancel();

        StreamSet streamSet = getStreamSetForMessage(cMsg);

        if(streamSet == null)
        {
          //check that we don't already have a streamSet for this source, because there
          // should only be the one at any one time (except for links, see below...)
          SIBUuid8 sourceMEUuid = cMsg.getGuaranteedSourceMessagingEngineUUID();
          if(sourceMap.containsValue(sourceMEUuid))
          {
            //if we do, try to remove it
            Iterator<SIBUuid12> itr = sourceMap.keySet().iterator();
            while(itr.hasNext())
            {
              SIBUuid12 sid = itr.next();
              SIBUuid8 uuid = sourceMap.get(sid);
              if(sourceMEUuid.equals(uuid))
              {
                // 538529
                // If this is a link it is possible to have multiple streams of messages
                // coming in from the source ME concurrently. We have one for all point-to-point
                // messages and one per topicspace that is sending messages to us.
                // Ideally we need to check with the source before we flush any of our existing
                // streams, as they may still be valid. We would do this by asking the sender if
                // they are flushed (commented out code below). Unfortunately we can't do that because
                // the sender (the other end of the link) may not be the source of the messages
                // so it's not guaranteed to actually know about this stream even if it still
                // exists (for example the ME's just been restarted and lost the non-persistent
                // state for this stream). So, instead we simply keep all streams.
                // TODO This isn't ideal so maybe we can fix it in the future 
                if(destination.isLink())
                {
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(tc, "WARNING: Existing Link stream, " + sid + ", not flushed");
                  
//                  StreamSet existingStreamSet = (StreamSet)streamSets.get(sid);
//
//                  // Create and store the new request record
//                  long reqID = messageProcessor.nextTick();
//                  FlushQueryRecord newEntry = new FlushQueryRecord(sourceMEUuid,
//                                               existingStreamSet.getDestUuid(),
//                                               existingStreamSet.getBusUuid(),
//                                               null,
//                                               reqID);
//                  flushMap.put(sid, newEntry);
//
//                  // Create and send the query
//                  upControl.sendAreYouFlushedMessage(sourceMEUuid,
//                                                     existingStreamSet.getDestUuid(),
//                                                     existingStreamSet.getBusUuid(),
//                                                     reqID,
//                                                     sid);
//
//                  // Start the alarm.  The context for the alarm is the stream id, which
//                  // we can use to look up the FlushQueryRecord if the alarm expires.
//                  newEntry.resend = am.create(GDConfig.FLUSH_QUERY_INTERVAL, this, sid);
                }
                // If we're not a link we only ever expect a single streamSet to be in use
                // by the source at any one time, so flush any that we already have.
                else
                {
                  flush(sid);
                  //there should only ever be at most one other streamSet found
                  //so stop looking if we found one.
                  break;
                }
              }
            }
          }
          
          // If this is a link, get the actual target destination 
          String linkTarget = SIMPConstants.PTOP_TARGET_STREAM;
          JsDestinationAddress routingDest = cMsg.getRoutingDestination();
          if (destination.isLink() &&  routingDest!= null)
          {
            // get the destination and check if it is a topicspace
            DestinationHandler dest = 
              destination.getDestinationManager().
                getDestinationInternal(routingDest.getDestinationName(),
                                       routingDest.getBusName(), true);
            if (dest!=null && dest.isPubSub())
              linkTarget = routingDest.getDestinationName();
          }           
          
          //create a new streamSet
          SIBUuid8 busId = cMsg.getGuaranteedCrossBusSourceBusUUID();
          if( busId == null)
          {
            busId = messageProcessor.getMessagingEngineBusUuid();
          }
          streamSet = addNewStreamSet(streamID,
                                      sourceMEUuid,
                                      cMsg.getGuaranteedTargetDestinationDefinitionUUID(),
                                      busId,
                                      linkTarget);
          //set all the completed prefixes
          long[] completedPrefixes = cMsg.getCompletedPrefixTicks();
          int[] priority  = cMsg.getCompletedPrefixPriority();
          int[] reliability = cMsg.getCompletedPrefixQOS();
          for(int i=0;i<completedPrefixes.length;i++)
          {
            streamSet.setPersistentData(priority[i],
                                                Reliability.getReliability(reliability[i]),
                                                completedPrefixes[i]);
          }
        }
        // Now replay any cached messages
        for(int i=0; i<entry.cacheIndex; i++)
        {
          handleMessage(entry.cache[i]);
        }
      }
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "handleNotFlushedMessage");
  }
409672
public void error(Object message, Throwable t) {
        differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, t);
    }
1065798
function toEvent(message) {
            if (message) {
                if (message.error) {
                    PostMessageUtilities.log("Error on message: " + message.error, "ERROR", "PostMessageMapper");
                    return function() {
                        return message;
                    };
                }
                else {
                    return _getMappedMethod.call(this, message);
                }
            }
        }
1207413
public static void handleWarning(final Node node, final String msg)
    {
        final ErrorHandler handler = (ErrorHandler)node.getOwnerDocument().getUserData(ERROR_HANDLER_KEY);

        if (handler == null)
        {
            throw new IllegalStateException("WARNING: " + formatLocationInfo(node) + msg);
        }
        else
        {
            handler.warning(formatLocationInfo(node) + msg);
        }
    }
251152
Observable<ChatResult> handleMessageStatusToUpdate(String conversationId, List<MessageStatusUpdate> msgStatusList, ComapiResult<Void> result) {
        if (result.isSuccessful() && msgStatusList != null && !msgStatusList.isEmpty()) {
            return persistenceController.upsertMessageStatuses(conversationId, getProfileId(), msgStatusList).map(success -> adapter.adaptResult(result, success));
        } else {
            return Observable.fromCallable(() -> adapter.adaptResult(result));
        }
    }
1108397
function getRoutedMessageHandler(params, onMessage, onError, isRetryPatchMode) {
  var expectedBatchMessageCount = 0;
  var numBatchesDetermined = false;
  var messageBatchBuffer = [];
  var lastSeenDataTime = 0;
  var lastSeenDataBatchTime = 0;

  function composeDataBatches(dataArray) {
    if (dataArray.length === 0) {
      if (messageBatchBuffer.length > 0) {
        console.error('Composed an empty data batch despite having data in the buffer!');
      }
      return null;
    }

    var errorOccurred = false;
    var basisData = dataArray[0];
    var expectedTimeStamp = basisData.logicalTimestampMs;
    lastSeenDataBatchTime = expectedTimeStamp;
    dataArray.slice(1).forEach(function (batch) {
      if (batch.logicalTimestampMs !== expectedTimeStamp) {
        errorOccurred = true;
      } else {
        basisData.data = basisData.data.concat(batch.data);
      }
    });

    if (errorOccurred) {
      console.error('Bad timestamp pairs when flushing data batches!  Inconsistent data!');
      return null;
    }
    return basisData;
  }

  function flushBuffer() {
    if (numBatchesDetermined && messageBatchBuffer.length === expectedBatchMessageCount && messageBatchBuffer.length > 0) {
      onMessage(composeDataBatches(messageBatchBuffer));
      messageBatchBuffer = [];
    }
  }

  return {
    getLatestBatchTimeStamp: function () {
      return lastSeenDataBatchTime;
    },
    onMessage: function messageReceived(msg) {
      if (!msg.type && msg.hasOwnProperty('error')) {
        onMessage(msg);
        return;
      }
      switch (msg.type) {
        case 'data':
          if (lastSeenDataTime && lastSeenDataTime !== msg.logicalTimestampMs) {
            // if zero time series are encountered, then no metadata arrives, but data batches arrive with differing
            // timestamp as the only evidence of a stream block
            numBatchesDetermined = true;
          }
          lastSeenDataTime = msg.logicalTimestampMs;
          messageBatchBuffer.push(msg);
          if (!numBatchesDetermined) {
            expectedBatchMessageCount++;
          } else if (messageBatchBuffer.length === expectedBatchMessageCount) {
            flushBuffer();
          }
          break;
        case 'message':
          if (msg.message && msg.message.messageCode === 'JOB_RUNNING_RESOLUTION') {
            numBatchesDetermined = true;
            flushBuffer();
          }
          onMessage(msg);
          break;
        case 'metadata':
        case 'event':
          onMessage(msg);
          break;
        case 'control-message':
          if (isRetryPatchMode && !numBatchesDetermined) {
            break;
          }
          onMessage(msg);
          break;
        case 'error':
          if (onError) {
            onError(msg);
          }
          break;
        default:
          console.log('Unrecognized message type.');
          break;
      }
      flushBuffer();
    }
  };
}
515385
private synchronized void refresh() {

        try {
            long now = System.currentTimeMillis();
            if ((now - m_lastUpdate) > UPDATE_INTERVAL) {
                setup();
            }
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
    }
1145513
public void updateMessageDetail(MessageProcessInfo recMessageProcessInfo, Map<String,Object> map)
    {
        MessageDetail recMessageDetail = (MessageDetail)this.getRecord(MessageDetail.MESSAGE_DETAIL_FILE);
        MessageTransport recMessageTransport = (MessageTransport)this.getRecord(MessageTransport.MESSAGE_TRANSPORT_FILE);
        
        try {
            recMessageDetail.addNew();
            
            recMessageDetail.getField(MessageDetail.MESSAGE_PROCESS_INFO_ID).moveFieldToThis((BaseField)recMessageProcessInfo.getCounterField());
            recMessageDetail.getField(MessageDetail.MESSAGE_TRANSPORT_ID).moveFieldToThis((BaseField)recMessageTransport.getCounterField());
            if (recMessageDetail.seek(null))
                recMessageDetail.edit();
            else
                recMessageDetail.addNew();
            
            recMessageDetail.getField(MessageDetail.MESSAGE_PROCESS_INFO_ID).moveFieldToThis((BaseField)recMessageProcessInfo.getCounterField());
            recMessageDetail.getField(MessageDetail.MESSAGE_TRANSPORT_ID).moveFieldToThis((BaseField)recMessageTransport.getCounterField());
            String site = (map == null) ? null : (String)map.get(TrxMessageHeader.DESTINATION_PARAM);
            ((PropertiesField)recMessageDetail.getField(MessageDetail.PROPERTIES)).setProperty(TrxMessageHeader.DESTINATION_PARAM, site);
            String wspath = (map == null) ? null : (String)map.get(TrxMessageHeader.DESTINATION_MESSAGE_PARAM);
            ((PropertiesField)recMessageDetail.getField(MessageDetail.PROPERTIES)).setProperty(TrxMessageHeader.DESTINATION_MESSAGE_PARAM, wspath);
            
            if (recMessageDetail.getEditMode() == DBConstants.EDIT_ADD)
                recMessageDetail.add();
            else
                recMessageDetail.set();
        } catch (DBException e) {
            e.printStackTrace();
        }
    }