use of org.neo4j.kernel.impl.util.watcher.DefaultFileSystemWatcherService 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;
}
}
use of org.neo4j.kernel.impl.util.watcher.DefaultFileSystemWatcherService in project neo4j by neo4j.
the class GlobalModule method createFileSystemWatcherService.
private FileSystemWatcherService createFileSystemWatcherService(FileSystemAbstraction fileSystem, LogService logging, JobScheduler jobScheduler, Config config) {
if (!config.get(filewatcher_enabled)) {
Log log = logging.getInternalLog(getClass());
log.info("File watcher disabled by configuration.");
return FileSystemWatcherService.EMPTY_WATCHER;
}
try {
return new DefaultFileSystemWatcherService(jobScheduler, fileSystem.fileWatcher());
} 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;
}
}
use of org.neo4j.kernel.impl.util.watcher.DefaultFileSystemWatcherService in project neo4j by neo4j.
the class DefaultFileSystemWatcherServiceTest method stopMonitoringWhenLifecycleStops.
@Test
void stopMonitoringWhenLifecycleStops() throws Throwable {
DefaultFileSystemWatcherService service = new DefaultFileSystemWatcherService(jobScheduler, fileWatcher);
service.init();
service.start();
service.stop();
verify(fileWatcher).stopWatching();
}
use of org.neo4j.kernel.impl.util.watcher.DefaultFileSystemWatcherService in project neo4j by neo4j.
the class DefaultFileSystemWatcherServiceTest method startMonitoringWhenLifecycleStarting.
@Test
void startMonitoringWhenLifecycleStarting() throws Throwable {
CountDownLatch latch = new CountDownLatch(1);
FileWatcher watcher = new TestFileWatcher(latch);
DefaultFileSystemWatcherService service = new DefaultFileSystemWatcherService(jobScheduler, watcher);
service.init();
service.start();
latch.await();
}
use of org.neo4j.kernel.impl.util.watcher.DefaultFileSystemWatcherService in project neo4j by neo4j.
the class DefaultFileSystemWatcherServiceTest method closeFileWatcherOnShutdown.
@Test
void closeFileWatcherOnShutdown() throws Throwable {
DefaultFileSystemWatcherService service = new DefaultFileSystemWatcherService(jobScheduler, fileWatcher);
service.init();
service.start();
service.stop();
service.shutdown();
verify(fileWatcher).close();
}
Aggregations