Search in sources :

Example 1 with DefaultFileDeletionEventListener

use of org.neo4j.kernel.impl.util.watcher.DefaultFileDeletionEventListener in project neo4j by neo4j.

the class EditionModule method createFileSystemWatcherService.

protected FileSystemWatcherService createFileSystemWatcherService(FileSystemAbstraction fileSystem, File storeDir, LogService logging, JobScheduler jobScheduler, Predicate<String> fileNameFilter) {
    try {
        RestartableFileSystemWatcher watcher = new RestartableFileSystemWatcher(fileSystem.fileWatcher());
        watcher.addFileWatchEventListener(new DefaultFileDeletionEventListener(logging, fileNameFilter));
        watcher.watch(storeDir);
        // register to watch store dir parent folder to see when store dir removed
        watcher.watch(storeDir.getParentFile());
        return new DefaultFileSystemWatcherService(jobScheduler, watcher);
    } catch (Exception e) {
        Log log = logging.getInternalLog(getClass());
        log.warn("Can not create file watcher for current file system. File monitoring capabilities for store " + "files will be disabled.", e);
        return FileSystemWatcherService.EMPTY_WATCHER;
    }
}
Also used : DefaultFileDeletionEventListener(org.neo4j.kernel.impl.util.watcher.DefaultFileDeletionEventListener) Log(org.neo4j.logging.Log) DefaultFileSystemWatcherService(org.neo4j.kernel.impl.util.watcher.DefaultFileSystemWatcherService) RestartableFileSystemWatcher(org.neo4j.io.fs.watcher.RestartableFileSystemWatcher) KernelException(org.neo4j.kernel.api.exceptions.KernelException)

Aggregations

RestartableFileSystemWatcher (org.neo4j.io.fs.watcher.RestartableFileSystemWatcher)1 KernelException (org.neo4j.kernel.api.exceptions.KernelException)1 DefaultFileDeletionEventListener (org.neo4j.kernel.impl.util.watcher.DefaultFileDeletionEventListener)1 DefaultFileSystemWatcherService (org.neo4j.kernel.impl.util.watcher.DefaultFileSystemWatcherService)1 Log (org.neo4j.logging.Log)1