segmentstore/server/src/main/java/io/pravega/segmentstore/server/CacheManager.java
@VisibleForTesting
    protected boolean applyCachePolicy() {
        if (this.closed.get()) {
            // We are done.
            return false;
        }

        try {
            synchronized (this.lock) {
                return applyCachePolicyInternal();
            }
        } catch (Throwable ex) {
            if (Exceptions.mustRethrow(ex)) {
                throw ex;
            }

            log.error("{}: Error while applying cache policy.", TRACE_OBJECT_ID, ex);
            return false;
        }
    }
/**
     * Same as {@link #applyCachePolicyInternal()}, but this is safe for concurrent invocation and handles all exceptions by
     * logging them.
     *
     * We must ensure that no two invocations of the {@link #applyCachePolicyInternal()) execute at the same time. It performs
     * a good amount of state checking and updating, and concurrent calls would corrupt the internal state of the {@link CacheManager).
     *
     * Under normal operating conditions, the only method invoking this is {@link #runOneIteration()} which is guaranteed
     * to execute only once at a time. Concurrent invocations come from {@link #cacheFullCallback()} which are triggered
     * by the {@link CacheStorage} becoming full while inserting into it, which can come (at the same time) from different
     * requesting threads.
     *
     * @return True if anything changed, false otherwise.
     */
Same as  #applyCachePolicyInternal(), but this is safe for concurrent invocation and handles all exceptions by
logging them.

We must ensure that no two invocations of the {@link #applyCachePolicyInternal()) execute at the same time. It performs
a good amount of state checking and updating, and concurrent calls would corrupt the internal state of the {@link CacheManager).

Under normal operating conditions, the only method invoking this is  #runOneIteration() which is guaranteed
to execute only once at a time. Concurrent invocations come from  #cacheFullCallback() which are triggered
by the  CacheStorage becoming full while inserting into it, which can come (at the same time) from different
requesting threads.

@return True if anything changed, false otherwise.
Same as #applyCachePolicyInternal () but this is safe for concurrent invocation and handles all exceptions by logging them . We must ensure that no two invocations of the { @link #applyCachePolicyInternal () ) execute at the same time . It performs a good amount of state checking and updating and concurrent calls would corrupt the internal state of the { @link CacheManager ) . Under normal operating conditions the only method invoking this is #runOneIteration () which is guaranteed to execute only once at a time . Concurrent invocations come from #cacheFullCallback () which are triggered by the CacheStorage becoming full while inserting into it which can come ( at the same time ) from different requesting threads . @return True if anything changed false otherwise .
@VisibleForTesting
    protected boolean applyCachePolicy() {
        if (this.closed.get()) {
            return false;
        }
        try {
            synchronized (this.lock) {
                return applyCachePolicyInternal();
            }
        } catch (Throwable ex) {
            if (Exceptions.mustRethrow(ex)) {
                throw ex;
            }
            log.error("{}: Error while applying cache policy.", TRACE_OBJECT_ID, ex);
            return false;
        }
    }
@ VisibleForTesting protected boolean applyCachePolicy ( ) { if ( this . closed . get ( ) ) { return false ; } try { synchronized ( this . lock ) { return applyCachePolicyInternal ( ) ; } } catch ( Throwable ex ) { if ( Exceptions . mustRethrow ( ex ) ) { throw ex ; } log . error ( "{}: Error while applying cache policy." , TRACE_OBJECT_ID , ex ) ; return false ; } }
Same as {@link #applyCachePolicyInternal()}, but this is safe for concurrent invocation and handles all exceptions by
 logging them.
Same as { @link #applyCachePolicyInternal () } but this is safe for concurrent invocation and handles all exceptions by logging them .
// We are done.