use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class StoreLockerTest method shouldNotObtainLockWhenUnableToOpenLockFile.
@Test
public void shouldNotObtainLockWhenUnableToOpenLockFile() throws Exception {
FileSystemAbstraction fileSystemAbstraction = new DelegatingFileSystemAbstraction(fileSystemRule.get()) {
@Override
public StoreChannel open(File fileName, String mode) throws IOException {
throw new IOException("cannot open lock file");
}
@Override
public boolean fileExists(File fileName) {
return false;
}
};
File storeDir = target.directory("unused");
try (StoreLocker storeLocker = new StoreLocker(fileSystemAbstraction)) {
storeLocker.checkLock(storeDir);
fail();
} catch (StoreLockException e) {
String msg = format("Unable to obtain lock on store lock file: %s. " + "Please ensure no other process is using this database, and that the " + "directory is writable (required even for read-only access)", new File(storeDir, STORE_LOCK_FILENAME));
assertThat(e.getMessage(), is(msg));
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class StoreLockerTest method shouldNotObtainLockWhenStoreDirCannotBeCreated.
@Test
public void shouldNotObtainLockWhenStoreDirCannotBeCreated() throws Exception {
FileSystemAbstraction fileSystemAbstraction = new DelegatingFileSystemAbstraction(fileSystemRule.get()) {
@Override
public void mkdirs(File fileName) throws IOException {
throw new IOException("store dir could not be created");
}
@Override
public boolean fileExists(File fileName) {
return false;
}
};
File storeDir = target.directory("unused");
try (StoreLocker storeLocker = new StoreLocker(fileSystemAbstraction)) {
storeLocker.checkLock(storeDir);
fail();
} catch (StoreLockException e) {
String msg = format("Unable to create path for store dir: %s. " + "Please ensure no other process is using this database, and that " + "the directory is writable (required even for read-only access)", storeDir);
assertThat(e.getMessage(), is(msg));
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class EditionModule method setupSecurityModule.
protected static void setupSecurityModule(PlatformModule platformModule, Log log, Procedures procedures, String key) {
for (SecurityModule candidate : Service.load(SecurityModule.class)) {
if (candidate.matches(key)) {
try {
candidate.setup(new SecurityModule.Dependencies() {
@Override
public LogService logService() {
return platformModule.logging;
}
@Override
public Config config() {
return platformModule.config;
}
@Override
public Procedures procedures() {
return procedures;
}
@Override
public JobScheduler scheduler() {
return platformModule.jobScheduler;
}
@Override
public FileSystemAbstraction fileSystem() {
return platformModule.fileSystem;
}
@Override
public LifeSupport lifeSupport() {
return platformModule.life;
}
@Override
public DependencySatisfier dependencySatisfier() {
return platformModule.dependencies;
}
});
return;
} catch (Exception e) {
String errorMessage = "Failed to load security module.";
log.error(errorMessage);
throw new RuntimeException(errorMessage, e);
}
}
}
String errorMessage = "Failed to load security module with key '" + key + "'.";
log.error(errorMessage);
throw new IllegalArgumentException(errorMessage);
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class RecoveryRequiredCheckerTest method shouldWantToRecoverBrokenStore.
@Test
public void shouldWantToRecoverBrokenStore() throws Exception {
try (FileSystemAbstraction fileSystemAbstraction = createSomeDataAndCrash(storeDir, fileSystem)) {
PageCache pageCache = pageCacheRule.getPageCache(fileSystemAbstraction);
RecoveryRequiredChecker recoverer = new RecoveryRequiredChecker(fileSystemAbstraction, pageCache);
assertThat(recoverer.isRecoveryRequiredAt(storeDir), is(true));
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class RecordStorageEngineTest method mustFlushStoresWithGivenIOLimiter.
@Test
public void mustFlushStoresWithGivenIOLimiter() throws Exception {
IOLimiter limiter = (stamp, completedIOs, swapper) -> 0;
FileSystemAbstraction fs = fsRule.get();
AtomicReference<IOLimiter> observedLimiter = new AtomicReference<>();
PageCache pageCache = new DelegatingPageCache(pageCacheRule.getPageCache(fs)) {
@Override
public void flushAndForce(IOLimiter limiter) throws IOException {
super.flushAndForce(limiter);
observedLimiter.set(limiter);
}
};
RecordStorageEngine engine = storageEngineRule.getWith(fs, pageCache).build();
engine.flushAndForce(limiter);
assertThat(observedLimiter.get(), sameInstance(limiter));
}
Aggregations