Skip to content

Commit

Permalink
Allow multiple JET instances
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelGrafnetter committed Sep 16, 2023
1 parent 7587c5f commit 0ed595b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Src/DSInternals.DataStore/DirectoryContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class DirectoryContext : IDisposable
{
private const string JetInstanceName = "DSInternals";
private const string JetInstanceNameFormat = "DSInternals-{0:D}";

private IsamInstance instance;
private IsamSession session;
Expand Down Expand Up @@ -47,8 +47,12 @@ public DirectoryContext(string dbFilePath, bool readOnly, string logDirectoryPat
this.DatabaseLogFilesPath = this.DSAWorkingDirectory;
}

// Achieve instance name uniquness by appending a GUID to "DSInternals-"
string jetInstanceName = String.Format(JetInstanceNameFormat, Guid.NewGuid());

// Note: IsamInstance constructor throws AccessDenied Exception when the path does not end with a backslash.
this.instance = new IsamInstance(AddPathSeparator(checkpointDirectoryPath), AddPathSeparator(this.DatabaseLogFilesPath), tempDatabasePath, ADConstants.EseBaseName, JetInstanceName, readOnly, ADConstants.PageSize);
this.instance = new IsamInstance(AddPathSeparator(checkpointDirectoryPath), AddPathSeparator(this.DatabaseLogFilesPath), tempDatabasePath, ADConstants.EseBaseName, jetInstanceName, readOnly, ADConstants.PageSize);

try
{
var isamParameters = this.instance.IsamSystemParameters;
Expand Down

0 comments on commit 0ed595b

Please sign in to comment.