microstream-one / microstream

High-Performance Java-Native-Persistence. Store and load any Java Object Graph or Subgraphs partially, Relieved of Heavy-weight JPA. Microsecond Response Time. Ultra-High Throughput. Minimum of Latencies. Create Ultra-Fast In-Memory Database Applications & Microservices.
https://microstream.one/
Eclipse Public License 2.0
558 stars 44 forks source link

Use provided PersistenceTypeDictionary-Name for the FullBackup #481

Open JohannesRabauer opened 1 year ago

JohannesRabauer commented 1 year ago

I'm initialising my MicroStream-Datastore with the following code:

    public static final EmbeddedStorageFoundation<?> createStorageFoundation(
        final File                        directory      
    )
    {
        final EmbeddedStorageFoundation<?> foundation = EmbeddedStorage.Foundation();
        foundation.onConnectionFoundation(
            f ->
            {
                f
                .setTypeDictionaryIoHandler( dictionaryStorage(, directory))
            }
        );
        return foundation;
    }

    static final PersistenceTypeDictionaryFileHandler dictionaryStorage(final File directory)
    {
        final File dictFile = new File(directory, "MyTypeDict.ptd");
        final NioFileSystem fileSystem = NioFileSystem.New();

        return dispatch(PersistenceTypeDictionaryFileHandler.New(fileSystem.ensureFile(dictFile.toPath())));
    }

Perfect! It works. Then i create a Backup like this:

public void createBackup(EmbeddedStorageManager       storageManager)
{
  storageManager.issueFullBackup(backupFileSystem.ensureDirectoryPath("."));
}

Now the backup works as well, with one exception: The created PersistenceTypeDictionary is named 'PersistenceTypeDictionary.ptd' instead of the configured 'MyTypeDict.ptd'. That means if i want to use the backup, i have to rename the file.

The MicroStream support already offered me a solution:

final ADirectory targetDirectory = fileSystem.ensureDirectoryPath("c:/temp/MPS15/bkup");
storage.issueFullBackup(
    StorageLiveFileProvider.New(targetDirectory),
    PersistenceTypeDictionaryExporter.New(
        PersistenceTypeDictionaryFileHandler.New(targetDirectory.ensureFile("MyTypeDict.ptd"))
    )
);

My feature request is simple enough: Make it work without the offered solution.

rdebusscher commented 1 year ago

Hi Johannes,

Thank you for the description of the issue. We will have a look how this custom type dictionary name can be used for the backup by default.