Search code examples
javamicrostream

Use Microstream with Channel and specified directory


I want create a storage manager with many channels and in a specific directory, unfortunately is not very easy to implement this requirement. The example of the homepage microstream doesn't work, but one solution I could create one instance, but after the load the microstream directory I receive a new exceptions from microstream.

I try to implement following solution:

final var name = this.filePath[this.filePath.length - 1];
    this.getVertx().fileSystem().mkdirsBlocking(String.join(File.separator, this.filePath));
    this.storageManager = EmbeddedStorageConfigurationBuilder.New()
            .setChannelCount(this.numberOfThreads)
            .setStorageDirectory(String.join(File.separator, this.filePath))
            .setDataFileSuffix(".bin")
            .createEmbeddedStorageFoundation()
            .createEmbeddedStorageManager()
            .start();
    if (this.storageManager.root() == null) {
        final var root = this.tClass.getDeclaredConstructor().newInstance();
        this.storageManager.setRoot(root);
        this.storageManager.storeRoot();
    }
    this.executor = this.getVertx().createSharedWorkerExecutor(name, this.numberOfThreads);

Exceptions:

one.microstream.storage.exceptions.StorageException: Non-deleted non-empty data file not found: channel 2, file 1

I don't know what microstream mean with "a non deleted non empty data file" ?


Solution

  • The exception is thrown if the channels transaction log contains an entry for a data file that is not found on the file system but not yet logged as empty or deleted. Such errors may happen if you change the file name configuration of an existing storage, manually delete storage files or multiple instances try to access the same storage directory.