@Override
  public final void storeCacheState(final OWriteCache writeCache) {
    """
	Stores state of queues of 2Q cache inside of {@link #CACHE_STATE_FILE} file if flag
	{@link OGlobalConfiguration#STORAGE_KEEP_DISK_CACHE_STATE} is set to <code>true</code>.
	Following format is used to store queue state:
	<ol>
	<li>Max cache size, single item (long)</li>
	<li>File id or -1 if end of queue is reached (int)</li>
	<li>Page index (long), is absent if end of the queue is reached</li>
	</ol>
	
	@param writeCache Write cache which manages files cache state of which is going to be stored.
    """
    if (!OGlobalConfiguration.STORAGE_KEEP_DISK_CACHE_STATE.getValueAsBoolean()) {
      return;
    }

    if (writeCache == null) {
      return;
    }

    cacheLock.acquireWriteLock();
    try {
      final Path rootDirectory = writeCache.getRootDirectory();
      final Path stateFile = rootDirectory.resolve(CACHE_STATE_FILE);

      if (Files.exists(stateFile)) {
        Files.delete(stateFile);
      }

      final Set<Long> filesToStore = new HashSet<>(writeCache.files().values());

      try (final FileChannel channel = FileChannel.open(stateFile, StandardOpenOption.WRITE, StandardOpenOption.CREATE)) {
        final OutputStream channelStream = Channels.newOutputStream(channel);
        final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(channelStream, 64 * 1024);

        try (final DataOutputStream dataOutputStream = new DataOutputStream(bufferedOutputStream)) {
          dataOutputStream.writeLong(memoryDataContainer.get().maxSize);

          storeQueueState(writeCache, filesToStore, dataOutputStream, am);
          dataOutputStream.writeInt(-1);

          storeQueueState(writeCache, filesToStore, dataOutputStream, a1in);
          dataOutputStream.writeInt(-1);

          storeQueueState(writeCache, filesToStore, dataOutputStream, a1out);
          dataOutputStream.writeInt(-1);
        }
      }
    } catch (final Exception e) {
      OLogManager.instance()
          .error(this, "Cannot store state of cache for storage placed under %s", e, writeCache.getRootDirectory());
    } finally {
      cacheLock.releaseWriteLock();
    }
  }
@Override
  public final void storeCacheState(final OWriteCache writeCache) {
    if (!OGlobalConfiguration.STORAGE_KEEP_DISK_CACHE_STATE.getValueAsBoolean()) {
      return;
    }

    if (writeCache == null) {
      return;
    }

    cacheLock.acquireWriteLock();
    try {
      final Path rootDirectory = writeCache.getRootDirectory();
      final Path stateFile = rootDirectory.resolve(CACHE_STATE_FILE);

      if (Files.exists(stateFile)) {
        Files.delete(stateFile);
      }

      final Set<Long> filesToStore = new HashSet<>(writeCache.files().values());

      try (final FileChannel channel = FileChannel.open(stateFile, StandardOpenOption.WRITE, StandardOpenOption.CREATE)) {
        final OutputStream channelStream = Channels.newOutputStream(channel);
        final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(channelStream, 64 * 1024);

        try (final DataOutputStream dataOutputStream = new DataOutputStream(bufferedOutputStream)) {
          dataOutputStream.writeLong(memoryDataContainer.get().maxSize);

          storeQueueState(writeCache, filesToStore, dataOutputStream, am);
          dataOutputStream.writeInt(-1);

          storeQueueState(writeCache, filesToStore, dataOutputStream, a1in);
          dataOutputStream.writeInt(-1);

          storeQueueState(writeCache, filesToStore, dataOutputStream, a1out);
          dataOutputStream.writeInt(-1);
        }
      }
    } catch (final Exception e) {
      OLogManager.instance()
          .error(this, "Cannot store state of cache for storage placed under %s", e, writeCache.getRootDirectory());
    } finally {
      cacheLock.releaseWriteLock();
    }
  }
@ Override public final void storeCacheState ( final OWriteCache writeCache ) { if ( ! OGlobalConfiguration . STORAGE_KEEP_DISK_CACHE_STATE . getValueAsBoolean ( ) ) { return ; } if ( writeCache == null ) { return ; } cacheLock . acquireWriteLock ( ) ; try { final Path rootDirectory = writeCache . getRootDirectory ( ) ; final Path stateFile = rootDirectory . resolve ( CACHE_STATE_FILE ) ; if ( Files . exists ( stateFile ) ) { Files . delete ( stateFile ) ; } final Set < Long > filesToStore = new HashSet <> ( writeCache . files ( ) . values ( ) ) ; try ( final FileChannel channel = FileChannel . open ( stateFile , StandardOpenOption . WRITE , StandardOpenOption . CREATE ) ) { final OutputStream channelStream = Channels . newOutputStream ( channel ) ; final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream ( channelStream , 64 * 1024 ) ; try ( final DataOutputStream dataOutputStream = new DataOutputStream ( bufferedOutputStream ) ) { dataOutputStream . writeLong ( memoryDataContainer . get ( ) . maxSize ) ; storeQueueState ( writeCache , filesToStore , dataOutputStream , am ) ; dataOutputStream . writeInt ( - 1 ) ; storeQueueState ( writeCache , filesToStore , dataOutputStream , a1in ) ; dataOutputStream . writeInt ( - 1 ) ; storeQueueState ( writeCache , filesToStore , dataOutputStream , a1out ) ; dataOutputStream . writeInt ( - 1 ) ; } } } catch ( final Exception e ) { OLogManager . instance ( ) . error ( this , "Cannot store state of cache for storage placed under %s" , e , writeCache . getRootDirectory ( ) ) ; } finally { cacheLock . releaseWriteLock ( ) ; } }
Stores state of queues of 2Q cache inside of {@link #CACHE_STATE_FILE} file if flag
{@link OGlobalConfiguration#STORAGE_KEEP_DISK_CACHE_STATE} is set to <code>true</code>.
Following format is used to store queue state:
<ol>
<li>Max cache size, single item (long)</li>
<li>File id or -1 if end of queue is reached (int)</li>
<li>Page index (long), is absent if end of the queue is reached</li>
</ol>

@param writeCache Write cache which manages files cache state of which is going to be stored.
Stores state of queues of 2Q cache inside of { @link #CACHE_STATE_FILE } file if flag { @link OGlobalConfiguration#STORAGE_KEEP_DISK_CACHE_STATE } is set to <code > true< / code > . Following format is used to store queue state : <ol > <li > Max cache size single item ( long ) < / li > <li > File id or - 1 if end of queue is reached ( int ) < / li > <li > Page index ( long ) is absent if end of the queue is reached< / li > < / ol >