segmentstore/server/src/main/java/io/pravega/segmentstore/server/CacheManager.java
@GuardedBy("lock")
    private boolean applyCachePolicyInternal() {
        // Run through all the active clients and gather status.
        CacheStatus currentStatus = collectStatus();
        fetchCacheState();
        if (currentStatus == null || this.lastCacheState.getStoredBytes() == 0) {
            // We either have no clients or we have clients and they do not have any data stored.
            return false;
        }

        // Increment current generation (if needed).
        boolean currentChanged = adjustCurrentGeneration(currentStatus);

        // Increment oldest generation (if needed and if possible).
        boolean oldestChanged = adjustOldestGeneration(currentStatus);

        if (!currentChanged && !oldestChanged) {
            // Nothing changed, nothing to do.
            return false;
        }

        // Notify clients that something changed (if any of the above got changed). Run in a loop, until either we can't
        // adjust the oldest anymore or we are unable to trigger any changes to the clients.
        boolean reducedInIteration;
        boolean reducedOverall = false;
        do {
            reducedInIteration = updateClients();
            if (reducedInIteration) {
                fetchCacheState();
                logCurrentStatus(currentStatus);
                oldestChanged = adjustOldestGeneration(currentStatus);
                reducedOverall = true;
            }
        } while (reducedInIteration && oldestChanged);
        this.metrics.report(this.lastCacheState, currentStatus.getNewestGeneration() - currentStatus.getOldestGeneration());
        return reducedOverall;
    }
/**
     * Same as {@link #applyCachePolicy()}, but it is unsynchronized and does not handle any errors. This method should
     * only be invoked by {@link #applyCachePolicy()} as concurrent invocations from different threads may result
     * in state corruption.
     *
     * @return True if anything changed, false otherwise.
     */
Same as  #applyCachePolicy(), but it is unsynchronized and does not handle any errors. This method should
only be invoked by  #applyCachePolicy() as concurrent invocations from different threads may result
in state corruption.

@return True if anything changed, false otherwise.
Same as #applyCachePolicy () but it is unsynchronized and does not handle any errors . This method should only be invoked by #applyCachePolicy () as concurrent invocations from different threads may result in state corruption . @return True if anything changed false otherwise .
@GuardedBy("lock")
    private boolean applyCachePolicyInternal() {
        CacheStatus currentStatus = collectStatus();
        fetchCacheState();
        if (currentStatus == null || this.lastCacheState.getStoredBytes() == 0) {
            return false;
        }
        boolean currentChanged = adjustCurrentGeneration(currentStatus);
        boolean oldestChanged = adjustOldestGeneration(currentStatus);
        if (!currentChanged && !oldestChanged) {
            return false;
        }
        boolean reducedInIteration;
        boolean reducedOverall = false;
        do {
            reducedInIteration = updateClients();
            if (reducedInIteration) {
                fetchCacheState();
                logCurrentStatus(currentStatus);
                oldestChanged = adjustOldestGeneration(currentStatus);
                reducedOverall = true;
            }
        } while (reducedInIteration && oldestChanged);
        this.metrics.report(this.lastCacheState, currentStatus.getNewestGeneration() - currentStatus.getOldestGeneration());
        return reducedOverall;
    }
@ GuardedBy ( "lock" ) private boolean applyCachePolicyInternal ( ) { CacheStatus currentStatus = collectStatus ( ) ; fetchCacheState ( ) ; if ( currentStatus == null || this . lastCacheState . getStoredBytes ( ) == 0 ) { return false ; } boolean currentChanged = adjustCurrentGeneration ( currentStatus ) ; boolean oldestChanged = adjustOldestGeneration ( currentStatus ) ; if ( ! currentChanged && ! oldestChanged ) { return false ; } boolean reducedInIteration ; boolean reducedOverall = false ; do { reducedInIteration = updateClients ( ) ; if ( reducedInIteration ) { fetchCacheState ( ) ; logCurrentStatus ( currentStatus ) ; oldestChanged = adjustOldestGeneration ( currentStatus ) ; reducedOverall = true ; } } while ( reducedInIteration && oldestChanged ) ; this . metrics . report ( this . lastCacheState , currentStatus . getNewestGeneration ( ) - currentStatus . getOldestGeneration ( ) ) ; return reducedOverall ; }
Same as {@link #applyCachePolicy()}, but it is unsynchronized and does not handle any errors.
Same as { @link #applyCachePolicy () } but it is unsynchronized and does not handle any errors .
// Run through all the active clients and gather status. // We either have no clients or we have clients and they do not have any data stored. // Increment current generation (if needed). // Increment oldest generation (if needed and if possible). // Nothing changed, nothing to do. // Notify clients that something changed (if any of the above got changed). Run in a loop, until either we can't // adjust the oldest anymore or we are unable to trigger any changes to the clients.