Schedules a log compaction.

@param lastApplied the last applied index at the start of snapshotting. This represents the highest index
before which segments can be safely removed from disk
332170
private void scheduleCompaction(long lastApplied) {
    // Schedule compaction after a randomized delay to discourage snapshots on multiple nodes at the same time.
    logger.trace("Scheduling compaction in {}", COMPACT_DELAY);
    stateContext.schedule(COMPACT_DELAY, () -> compactLogs(lastApplied));
  }
1264313
public void applyLogEntries() {
        // Reject logs we've applied already
        long commitIndex = state.commitIndex();
        long lastApplied = state.lastApplied();

        if (commitIndex == lastApplied) {
            return;
        }

        // If commitIndex > lastApplied: increment lastApplied, apply log[lastApplied] to state machine (§5.3)
        assert commitIndex > lastApplied
                : "commit index: " + commitIndex + " cannot be smaller than last applied: " + lastApplied;

        // Apply all the preceding logs
        RaftLog raftLog = state.log();
        for (long idx = state.lastApplied() + 1; idx <= commitIndex; idx++) {
            LogEntry entry = raftLog.getLogEntry(idx);
            if (entry == null) {
                String msg = "Failed to get log entry at index: " + idx;
                logger.severe(msg);
                throw new AssertionError(msg);
            }

            applyLogEntry(entry);

            // Update the lastApplied index
            state.lastApplied(idx);
        }

        assert status != TERMINATED || commitIndex == raftLog.lastLogOrSnapshotIndex()
                : "commit index: " + commitIndex + " must be equal to " + raftLog.lastLogOrSnapshotIndex() + " on termination.";

        if (state.role() == LEADER || state.role() == FOLLOWER) {
            takeSnapshotIfCommitIndexAdvanced();
        }
    }
921621
public JobAddHeaders withLastModified(DateTime lastModified) {
        if (lastModified == null) {
            this.lastModified = null;
        } else {
            this.lastModified = new DateTimeRfc1123(lastModified);
        }
        return this;
    }
1265651
public void setRestoreLastValid (boolean restoreLastValid) {
		if (hasSelection)
			throw new IllegalStateException("Last valid text restore can't be changed while filed has selection");

		this.restoreLastValid = restoreLastValid;

		if (restoreLastValid) {
			if (restoreFocusListener == null) restoreFocusListener = new LastValidFocusListener();
			addListener(restoreFocusListener);
		} else {
			removeListener(restoreFocusListener);
		}
	}
1075137
private void removeLast(HeapEntry<E> entry) {
    indexToEntry.remove(entry.index);
    objectToEntry.remove(entry.object);
  }
531372
@Override
    public void onApplicationEvent(final ContextRefreshedEvent event) {
        if (!hasStarted) {
            hasStarted = true;
            log.info(Markers.AUDIT, message);
        }
    }
1028253
public long getLastCompleted() {
    // If there are any queued events, return the index prior to the first event in the queue.
    EventHolder event = events.peek();
    if (event != null && event.eventIndex > completeIndex) {
      return event.eventIndex - 1;
    }
    // If no events are queued, return the highest index applied to the session.
    return lastApplied;
  }
452408
@Override
	final protected long getLastModified(HttpServletRequest req) {
		lastModifiedCount.incrementAndGet();
		try {
			return reportingGetLastModified(req);
		} catch (ThreadDeath err) {
			throw err;
		} catch (RuntimeException err) {
			getLogger().log(Level.SEVERE, null, err);
			throw err;
		} catch (IOException | SQLException err) {
			getLogger().log(Level.SEVERE, null, err);
			throw new RuntimeException(err);
		}
	}
356465
public void setLastApplied(long index) {
    // Query callbacks for this session are added to the indexQueries map to be executed once the required index
    // for the query is reached. For each increment of the index, trigger query callbacks that are dependent
    // on the specific index.
    for (long i = lastApplied + 1; i <= index; i++) {
      lastApplied = i;
      List<Runnable> queries = this.indexQueries.remove(lastApplied);
      if (queries != null) {
        for (Runnable query : queries) {
          query.run();
        }
      }
    }
  }
923696
@Override
    public void deleteApplication(ApplicationDefinition appDef) {
        checkServiceState();
        deleteApplicationCFs(appDef);
        m_shardCache.clear(appDef);
    }
946752
private void consumeCompaction(CompactionUpdateBatch updateBatch) throws Exception {
        int ignoreCount = 0;
        int updateCount = updateBatch.size();
        int totalIgnoreBytes = 0;
        int totalUpdateBytes = updateBatch.getDataSizeTotal();
        
        /* Using lwMark is to guarantee that redo logs from compaction will not increase
         * the hwMark of the underlying array file. If hwMark is being used, the current
         * redo entry is discarded upon crash. Upon restart, the hwMark from the underlying
         * array file may prevent updates in the lost redo entry from being resent.   
         */
        long updateScn = _addressArray.getLWMark();
        Segment segTarget = updateBatch.getTargetSegment();
        
        for(int i = 0; i < updateCount; i++) {
            int index = updateBatch.getUpdateIndex(i);
            long origAddr = updateBatch.getOriginDataAddr(i);
            long currAddr = getAddress(index);
            
            if(currAddr == 0 ||      /* data at the given index is deleted by writer */ 
               currAddr != origAddr  /* data at the given index is updated by writer */) {
                /*
                 * The address generated by the compactor is obsolete.
                 */
                int updateBytes = updateBatch.getUpdateDataSize(i);
                totalIgnoreBytes += updateBytes;
                ignoreCount++;
            } else {
                /*
                 * The address generated by the compactor has not been touched by the writer.
                 * Update the address array directly.
                 */ 
                setCompactionAddress(index, updateBatch.getUpdateDataAddr(i), updateScn);
            }
        }
        
        int consumeCount = updateCount - ignoreCount;
        int totalConsumeBytes = totalUpdateBytes - totalIgnoreBytes;
        
        if(_log.isTraceEnabled()) {
            _log.trace("consumed compaction batch " +
                       updateBatch.getDescriptiveId() +
                       " updates " + consumeCount + "/" + updateCount +
                       " bytes " + totalConsumeBytes + "/" + totalUpdateBytes);
        }
        
        // Update segment load size
        segTarget.decrLoadSize(totalIgnoreBytes);
    }
1144856
private void compactEntries(Segment segment, Segment compactSegment) {
    for (long i = segment.firstIndex(); i <= segment.lastIndex(); i++) {
      checkEntry(i, segment, compactSegment);
    }
  }
866154
@Pure
	public int lastIndexOf(RoadSegment segment) {
		int count = 0;
		int index;
		int lastIndex = -1;
		for (final RoadPath p : this.paths) {
			index = p.lastIndexOf(segment);
			if (index >= 0) {
				lastIndex = count + index;
			}
			count += p.size();
		}
		return lastIndex;
	}
1317010
synchronized void register(LogWithPatternAndLevel log, Duration period) {

        // if we haven't seen this period before, we'll need to add a schedule to the ScheduledExecutorService
        // to perform a counter reset with that periodicity, otherwise we can count on the existing schedule
        // taking care of it.
        boolean needToScheduleReset = false;

        ConcurrentHashMap<LogWithPatternAndLevel, Boolean> logLinesForPeriod = registry.get(period);
        if (logLinesForPeriod == null) {
            needToScheduleReset = true;
            logLinesForPeriod = new ConcurrentHashMap<>();
            registry.put(period, logLinesForPeriod);

        } else {
            if (logLinesForPeriod.get(log) != null) {
                return;     // this has already been registered
            }
        }
        logLinesForPeriod.put(log, Boolean.TRUE);

        if (needToScheduleReset) {
            final ConcurrentHashMap<LogWithPatternAndLevel, Boolean> finalLogLinesForPeriod = logLinesForPeriod;
            resetScheduler.scheduleWithFixedDelay(() -> {
                try {
                    resetAllCounters(finalLogLinesForPeriod);
                } catch (Exception e) {
                    logger.warn("failed to reset counters: " + e, e);
                    // but carry on in the next iteration
                }
            }, period.toMillis(), period.toMillis(), TimeUnit.MILLISECONDS);
        }
    }
123362
@com.fasterxml.jackson.annotation.JsonProperty("lastValidByteReceived")
    public void setLastValidByteReceived(Long lastValidByteReceived) {
        this.lastValidByteReceived = lastValidByteReceived;
    }
598849
private void processLastCell(LastCellOfRowDummyRecord lastCell) {
		// 每行结束时， 调用handle() 方法
		this.rowHandler.handle(curSheetIndex, lastCell.getRow(), this.rowCellList);
		// 清空行Cache
		this.rowCellList.clear();
	}
1079346
@Override
    public Row lastRow(Session session, PersistentStore store) {

        readLock.lock();

        try {
            NodeAVL x = getAccessor(store);
            NodeAVL l = x;

            while (l != null) {
                x = l;
                l = x.getRight(store);
            }

            while (session != null && x != null) {
                Row row = x.getRow(store);

                if (session.database.txManager.canRead(session, row)) {
                    break;
                }

                x = last(store, x);
            }

            return x == null ? null
                             : x.getRow(store);
        } finally {
            readLock.unlock();
        }
    }