All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.java.truevfs.ext.pacemaker.PaceController Maven / Gradle / Ivy

Go to download

Constrains the number of concurrently mounted archive file systems in order to save some heap space. This module provides a JMX interface for monitoring and management. Add the JAR artifact of this module to the run time class path to make its services available for service location in the client API modules.

The newest version!
/*
 * Copyright © 2005 - 2021 Schlichtherle IT Services.
 * All rights reserved. Use is subject to license terms.
 */
package net.java.truevfs.ext.pacemaker;

import net.java.truevfs.kernel.spec.FsController;
import net.java.truevfs.kernel.spec.FsSyncException;

import java.io.IOException;

/**
 * Calls back the given pace manager after each file system operation in order to register itself as the most recently
 * accessed file system and unmount the least recently accessed file systems which exceed the maximum number of mounted
 * file systems.
 *
 * @author Christian Schlichtherle
 */
class PaceController extends AspectController {

    private final PaceManager manager;

    PaceController(PaceManager manager, FsController controller) {
        super(controller);
        this.manager = manager;
    }

    @Override
     T apply(final Op op) throws IOException {
        IOException t1 = null;
        try {
            return op.call();
        } catch (final IOException t2) {
            t1 = t2;
            throw t2;
        } finally {
            try {
                manager.recordAccess(getMountPoint());
            } catch (final FsSyncException t2) {
                if (null == t1) {
                    throw t2;
                }
                t1.addSuppressed(t2);
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy