This method is called when an alarm expires for an "are you
flushed" or "flush request" query.

@param alarmContext the alarm context we passed into
the alarm scheduler.  Contains the stream ID we were querying.
502984
public void alarm(Object alarmContext)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(this, tc, "alarm", alarmContext);

    // Alarm context should be an sid, make it so.
    SIBUuid12 sid = (SIBUuid12) alarmContext;

    // synchronized here in case we're racing with an answer to our
    // query.
    synchronized (flushMap)
    {
      // See if the query record is still around
      FlushQueryRecord entry = flushMap.get(sid);

      if (entry != null)
      {
        // Query still active, see if we need to restart.
        entry.attempts--;
        if (entry.attempts > 0)
        {
          // Yup, resend the query and reset the alarm.  If
          // entry.cached is null, then this is a "request flush"
          // rather than an "are you flushed".
          try
          {
            if (entry.cache == null)
            {
              upControl.sendRequestFlushMessage(entry.source,
                                                entry.destId,
                                                entry.busId,
                                                entry.requestID,
                                                sid,
                                                false);  //TODO check indoubtDiscard
            }
            else
            {
              upControl.sendAreYouFlushedMessage(entry.source,
                                                 entry.destId,
                                                 entry.busId,
                                                 entry.requestID, sid);
            }
          }
          catch (SIResourceException e)
          {
            // No FFDC code needed

            // If we run out of resources, then give up on the query
            // and log an error.  This is probably only important for
            // "request flush" queries.
            flushMap.remove(sid);

            // TODO: actually, this should be an admin message.
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
              SibTr.event(tc, "Flush query failed for stream: " + sid);
          }

        }
        else
        {
          // Nope, didn't work.  Remove the query record, log the event,
          // and exit.
          flushMap.remove(sid);
          // TODO: actually, this should be an admin message.
          if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
            SibTr.event(tc, "Flush query expired for stream: " + sid);
        }
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "alarm");
  }
1122200
@Override
    public void contextDestroyed(ServletContextEvent event) {
        try {
            _gate.await();
            _logger.info("Stopping Argus web services.");
            _system.getServiceFactory().getMonitorService().stopRecordingCounters();
            _system.getServiceFactory().getSchedulingService().stopAlertScheduling();
            _system.getServiceFactory().getWardenService().disableWarden();
            _system.stop();
        } catch (InterruptedException ex) {
            _logger.info("Interrupted while waiting for startup to complete.");
        }
    }
863968
protected static void addAlarm(Object key, Object alarmObject)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "addAlarm", new Object[] { key, alarmObject });

        synchronized (pendingAlarms)
        {
            Set alarms = null;
            if (pendingAlarms.containsKey(key))
                alarms = (Set) pendingAlarms.get(key);
            else
            {
                alarms = new HashSet();
                pendingAlarms.put(key, alarms);
            }
            alarms.add(alarmObject);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "addAlarm");
    }
616223
public void alarm(Object thandle)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "alarm", new Object[] {this, mp.getMessagingEngineUuid()});

    synchronized (this)
    {
      if (!closed)
      {
        if ((executeSinceExpiry) || executing)
        { // has committed recently
          executeSinceExpiry = false;
        }
        else
        { // has not committed recently
          try
          {
            if (enqueuedUnits.size() > 0)
              startExecutingUpdates();
          }
          catch (ClosedException e)
          {
            // No FFDC code needed
            // do nothing as error already logged by startExecutingUpdates
          }
        }
      }
    } // end synchronized (this)

    if (maxCommitInterval > 0)
    {
      mp.getAlarmManager().create(maxCommitInterval, this);
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "alarm");
  }
573729
@Override
    public void run() {
        Date actualExecutionTime = new Date();
        super.run();
        Date completionTime = new Date();
        synchronized (this.triggerContextMonitor) {
            this.triggerContext.update(this.scheduledExecutionTime, actualExecutionTime, completionTime);
            if (!this.currentFuture.isCancelled()) {
                schedule();
            }
        }
    }
87351
public static synchronized void initEventHandlerInstance(int maxEntries,
                                                           int flushPeriodMs)
  {
    if (eventHandler.get() == null)
    {
      eventHandler.set(new EventHandler(maxEntries, flushPeriodMs));
    }
    //eventHandler.startFlusher();
  }
1367185
@Override
	protected final void onConsumerClose()
    {
    	super.onConsumerClose();

    	// Unlock waiting threads
    	prefetchSemaphore.release();
    	
    	try
    	{
        	CloseConsumerQuery query = new CloseConsumerQuery();
    		query.setSessionId(session.getId());
    		query.setConsumerId(id);
    		
    		// Append message IDs to rollback
    		synchronized (prefetchQueue)
            {
    		    while (!prefetchQueue.isEmpty())
    		    {
    		    	AbstractMessage msg = prefetchQueue.removeFirst();
    		        query.addUndeliveredMessageID(msg.getJMSMessageID());
    		    }
            }
    		
    		transportEndpoint.blockingRequest(query);
    	}
        catch (JMSException e)
        {
            ErrorTools.log(e, log);
        }
    }
1082047
private void handleAlarm()
  {
    AlarmListener listener = getListener();

    if (listener == null) {
      return;
    }

    Thread thread = Thread.currentThread();
    ClassLoader loader = getContextLoader();

    if (loader != null) {
      thread.setContextClassLoader(loader);
    }
    else {
      thread.setContextClassLoader(_systemLoader);
    }

    try {
      listener.handleAlarm(this);
    } finally {
      thread.setContextClassLoader(_systemLoader);
    }
  }
935499
private void createReaperAlarm() {
        final boolean isTracingEnabled = TraceComponent.isAnyTracingEnabled();

        if (pmQuiesced) {
            if (isTracingEnabled && tc.isDebugEnabled())
                Tr.debug(tc, " PM has been Quiesced, so cancel old reaper alarm.");
            if (am != null)
                am.cancel(false);
            return;
        }

        if (nonDeferredReaperAlarm) {
            if (isTracingEnabled && tc.isDebugEnabled())
                Tr.debug(this, tc, "Creating non-deferrable alarm for reaper");

            if (am != null) {
                // If an alarm thread already exists, cancel it and create a
                // new one with the latest reapTime
                am.cancel(false);
                if (am.isDone()) {
                    alarmThreadCounter.decrementAndGet();
                    if (isTracingEnabled && tc.isDebugEnabled())
                        Tr.debug(this, tc, "Previous alarm thread cancelled.");

                    alarmThreadCounter.incrementAndGet();
                    try {
                        am = connectorSvc.nonDeferrableSchedXSvcRef.getServiceWithException().schedule(this, reapTime, TimeUnit.SECONDS);
                    } catch (Exception e) {
                        alarmThreadCounter.decrementAndGet();
                        throw new RuntimeException(e);
                    }
                } // end am.isDone() == true
            } // end am != null
            else { // am == null
                if (isTracingEnabled && tc.isDebugEnabled())
                    Tr.debug(this, tc, "No previous alarm thread exists. Creating a new one.");

                alarmThreadCounter.incrementAndGet();
                try {
                    am = connectorSvc.nonDeferrableSchedXSvcRef.getServiceWithException().schedule(this, reapTime, TimeUnit.SECONDS);
                } catch (Exception e) {
                    alarmThreadCounter.decrementAndGet();
                    throw new RuntimeException(e);
                }
            } // am == null
        } // end nonDeferredReaperAlarm == true
        else { // nonDeferredReaperAlarm == false
            if (isTracingEnabled && tc.isDebugEnabled())
                Tr.debug(this, tc, "Creating deferrable alarm for reaper");

            if (am != null) {
                // If an alarm thread already exists, cancel it and create a
                // new one with the latest reapTime
                am.cancel(false);
                if (am.isDone()) {
                    alarmThreadCounter.decrementAndGet();
                    if (isTracingEnabled && tc.isDebugEnabled())
                        Tr.debug(this, tc, "Previous alarm thread cancelled.");

                    alarmThreadCounter.incrementAndGet();
                    try {
                        am = connectorSvc.deferrableSchedXSvcRef.getServiceWithException().schedule(this, reapTime, TimeUnit.SECONDS);
                    } catch (Exception e) {
                        alarmThreadCounter.decrementAndGet();
                        throw new RuntimeException(e);
                    }
                } // end am.isDone() == true
            } // end am != null
            else { // am == null
                if (isTracingEnabled && tc.isDebugEnabled())
                    Tr.debug(this, tc, "No previous alarm thread exists. Creating a new one.");

                alarmThreadCounter.incrementAndGet();
                try {
                    am = connectorSvc.deferrableSchedXSvcRef.getServiceWithException().schedule(this, reapTime, TimeUnit.SECONDS);
                } catch (Exception e) {
                    alarmThreadCounter.decrementAndGet();
                    throw new RuntimeException(e);
                }
            } // am == null
        } // end nonDeferredReaperAlarm == false
    }
1067391
protected void fireContextDestroyed(AgentContext context) {
		final ContextRepositoryListener[] ilisteners = this.listeners.getListeners(ContextRepositoryListener.class);
		this.logger.getKernelLogger().info(MessageFormat.format(Messages.StandardContextSpaceService_1, context.getID()));
		for (final ContextRepositoryListener listener : ilisteners) {
			listener.contextDestroyed(context);
		}
	}
873011
@Override
    public void alertISClose() {
        if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {
            logger.logp(Level.FINE, CLASS_NAME,"alertISClose()", "");
        }
        if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){
            checkRequestObjectInUse();
        }
        
        if (_srtRequestHelper != null)
            _srtRequestHelper._InputStreamClosed=true; 
    }
16426
public void setAlarmsEnabled(final boolean CHECK) {
        if (null == alarmsEnabled) {
            _alarmsEnabled = CHECK;
            fireUpdateEvent(VISIBILITY_EVENT);
        } else {
            alarmsEnabled.set(CHECK);
        }
    }
22759
public void setResourceAdaptorContext(ResourceAdaptorContext raContext) {
        this.resourceAdaptorContext = raContext;
        tracer = raContext.getTracer(HttpServletResourceAdaptor.class.getSimpleName());
        eventIdCache = new EventIDCache(raContext.getTracer(EventIDCache.class.getSimpleName()));
        eventIDFilter = new EventIDFilter();
        sleeEndpoint = raContext.getSleeEndpoint();
        eventLookup = raContext.getEventLookupFacility();
        requestLock = new RequestLock();
        httpRaSbbinterface = new HttpServletRaSbbInterfaceImpl(this);
    }
175074
boolean extendLeaseTime(String caller, long threadId, long leaseTime) {
        if (!isLockedBy(caller, threadId)) {
            return false;
        }
        this.blockReads = true;
        if (expirationTime < Long.MAX_VALUE) {
            setExpirationTime(expirationTime - Clock.currentTimeMillis() + leaseTime);
        }
        return true;
    }
1179343
static void scheduleWingsService(Context context, long delay) {
        Context appContext = context.getApplicationContext();

        // Create pending intent.
        Intent intent = new Intent(appContext, AlarmReceiver.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(appContext, 0, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        // Set alarm.
        AlarmManager alarmManager = (AlarmManager) appContext.getSystemService(Context.ALARM_SERVICE);
        alarmManager.set(AlarmManager.RTC_WAKEUP, delay, pendingIntent);
    }
242755
public void deactivate(ComponentContext context) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(this, tc, "Deactivating");
        }
        if (null != this.future) {
            synchronized (this.timerLock) {
                if (null != this.future) {
                    this.future.cancel(true);
                    this.future = null;
                }
            } // end-sync
        }
        // TODO purge the groupings/sessions maps, or dump to disk once
        // persistence is added
    }
1181928
void onSealExclusive(Batch batch, long elapsedTimeMillis)
  {
    batchFillingTimeCounter.add((int) Math.max(elapsedTimeMillis, 0));
    if (elapsedTimeMillis > 0) {
      // If elapsedTimeMillis is 0 or negative, it's likely because System.currentTimeMillis() is not monotonic, so not
      // accounting this time for determining batch sending timeout.
      lastFillTimeMillis = elapsedTimeMillis;
    }
    addBatchToEmitQueue(batch);
    wakeUpEmittingThread();
    if (!isTerminated()) {
      int nextBatchNumber = EmittedBatchCounter.nextBatchNumber(batch.batchNumber);
      if (!concurrentBatch.compareAndSet(batch, new Batch(this, acquireBuffer(), nextBatchNumber))) {
        // If compareAndSet failed, the service is closed concurrently.
        Preconditions.checkState(isTerminated());
      }
    }
  }