use of jetbrains.exodus.io.FileDataReader in project xodus by JetBrains.
the class EnvironmentTest method createReaderWriter.
private Pair<DataReader, DataWriter> createReaderWriter(String subfolder) throws IOException {
final File parent = getEnvDirectory();
File child = subfolders.get(subfolder);
if (child == null) {
child = new File(parent, subfolder);
if (child.exists())
throw new IOException("SubDirectory already exists " + subfolder);
if (!child.mkdirs()) {
throw new IOException("Failed to create directory " + subfolder + " for tests.");
}
subfolders.put(subfolder, child);
}
FileDataReader reader = new FileDataReader(child);
return new Pair<>(reader, new FileDataWriter(reader));
}
use of jetbrains.exodus.io.FileDataReader in project xodus by JetBrains.
the class EnvironmentLockTest method openConcurrentEnvironment.
private void openConcurrentEnvironment() {
processor.start();
new Job(processor) {
@Override
protected void execute() {
final File dir = getEnvDirectory();
try {
FileDataReader reader = new FileDataReader(dir);
env = newEnvironmentInstance(LogConfig.create(reader, new FileDataWriter(reader, LOCK_ID)), new EnvironmentConfig().setLogLockTimeout(5000));
wasOpened[0] = true;
} catch (ExodusException e) {
Assert.assertTrue(e.getMessage().contains(LOCK_ID));
wasOpened[0] = false;
}
}
};
}
use of jetbrains.exodus.io.FileDataReader in project xodus by JetBrains.
the class EnvironmentLockTest method testAlreadyLockedEnvironment.
@Test
public void testAlreadyLockedEnvironment() {
boolean exOnCreate = false;
Environment first = null;
try {
final File dir = getEnvDirectory();
FileDataReader reader = new FileDataReader(dir);
first = Environments.newInstance(LogConfig.create(reader, new FileDataWriter(reader)), EnvironmentConfig.DEFAULT);
} catch (ExodusException ex) {
// Environment already created on startup!
exOnCreate = true;
}
if (first != null)
first.close();
Assert.assertTrue(exOnCreate);
}
Aggregations