I'm having a bit of trouble with Xodus VFS, and the application is throwing this error:
jetbrains.exodus.ExodusException: write not in progress
at jetbrains.exodus.log.Log.ensureWriter(Log.kt:700)
at jetbrains.exodus.log.Log.writeContinuously(Log.kt:827)
at jetbrains.exodus.log.Log.write(Log.kt:519)
at jetbrains.exodus.tree.patricia.MutableNode.save(MutableNode.java:324)
at jetbrains.exodus.tree.patricia.PatriciaTreeMutable.save(PatriciaTreeMutable.java:258)
at jetbrains.exodus.env.MetaTreeImpl.saveTree(MetaTreeImpl.java:167)
at jetbrains.exodus.env.ReadWriteTransaction.doCommit(ReadWriteTransaction.java:248)
at jetbrains.exodus.env.EnvironmentImpl.flushTransaction(EnvironmentImpl.java:662)
at jetbrains.exodus.env.ReadWriteTransaction.flush(ReadWriteTransaction.java:109)
at jetbrains.exodus.env.EnvironmentImpl.executeInTransaction(EnvironmentImpl.java:1039)
at jetbrains.exodus.env.EnvironmentImpl.executeInTransaction(EnvironmentImpl.java:261)
at com.backend.repository.jee.JeeXodusVFSRepository.put(JeeXodusVFSRepository.java:97)
Here's the complete code:
public com.backend.model.File put(
String appId, String namespace, String name, InputStream is) {
final com.backend.model.File[] createdFile = {null};
final Environment env = manager.getEnvironment(xodusRoot, appId);
final VirtualFileSystem vfs = manager.getVirtualFileSystem(env);
env.executeInTransaction(
new TransactionalExecutable() {
@Override
public void execute(@NotNull final Transaction txn) {
final File file = vfs.openFile(txn, name, true);
DataOutputStream output = new DataOutputStream(vfs.writeFile(txn, file));
try {
output.write(ByteStreams.toByteArray(is));
} catch (IOException e) {
e.printStackTrace();
}
createdFile[0] = new com.backend.model.File();
createdFile[0].setDescriptor(file.getDescriptor());
createdFile[0].setName(name);
createdFile[0].setCreated(file.getCreated());
createdFile[0].setModified(file.getLastModified());
}
});
// vfs.shutdown();
// env.close();
return createdFile[0];
}
What could be wrong in the code?
UPDATE
@Override
public Environment getEnvironment(String xodusRoot, String instance) {
Environment environment = environmentMap.get(xodusRoot + instance);
if (environment == null) {
EnvironmentConfig config = new EnvironmentConfig();
//config.setLogDataReaderWriterProvider("jetbrains.exodus.log.replication.S3DataReaderWriterProvider");
//config.setLogCacheShared(false);
Environment env = Environments.newInstance(xodusRoot + instance, config);
environmentMap.put(xodusRoot + instance, env);
}
Environment e = environmentMap.get(xodusRoot + instance);
return e;
}