public RemoteEsentStorage(RemoteEsentStorageState state) { instance = state.Instance; database = state.Database; tableColumnsCache = new TableColumnsCache(); tableColumnsCache.InitColumDictionaries(instance, database); }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.table = "table"; this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); Api.JetCreateDatabase(this.sesid, this.database, String.Empty, out this.dbid, CreateDatabaseGrbit.None); Api.JetBeginTransaction(this.sesid); Api.JetCreateTable(this.sesid, this.dbid, this.table, 0, 100, out this.tableid); JET_COLUMNID ignored; var columndef = new JET_COLUMNDEF { coltyp = JET_coltyp.Text, cp = JET_CP.Unicode }; Api.JetAddColumn(this.sesid, this.tableid, "C1", columndef, null, 0, out ignored); Api.JetAddColumn(this.sesid, this.tableid, "C2", columndef, null, 0, out ignored); Api.JetAddColumn(this.sesid, this.tableid, "C3", columndef, null, 0, out ignored); Api.JetCreateIndex(this.sesid, this.tableid, "Primary", CreateIndexGrbit.IndexPrimary, "+C1\0\0", 5, 100); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); JET_INDEXCREATE[] indexcreates = new[] { new JET_INDEXCREATE { szIndexName = "Index2", cbKey = 5, szKey = "+C2\0\0" }, new JET_INDEXCREATE { szIndexName = "Index3", cbKey = 5, szKey = "+C3\0\0", cbVarSegMac = 100 }, }; Api.JetCreateIndex2(this.sesid, this.tableid, indexcreates, indexcreates.Length); Api.JetCloseTable(this.sesid, this.tableid); Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.None, out this.tableid); }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.table = "table"; this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); Api.JetCreateDatabase(this.sesid, this.database, String.Empty, out this.dbid, CreateDatabaseGrbit.None); Api.JetBeginTransaction(this.sesid); Api.JetCreateTable(this.sesid, this.dbid, this.table, 0, 100, out this.tableid); var columndef = new JET_COLUMNDEF() { cp = JET_CP.Unicode, coltyp = JET_coltyp.LongText, }; Api.JetAddColumn(this.sesid, this.tableid, "TestColumn", columndef, null, 0, out this.testColumnid); Api.JetCloseTable(this.sesid, this.tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.None, out this.tableid); }
public BackupOperation(DocumentDatabase database, string backupSourceDirectory, string backupDestinationDirectory, bool incrementalBackup, DatabaseDocument databaseDocument) : base(database, backupSourceDirectory, backupDestinationDirectory, incrementalBackup, databaseDocument) { instance = ((TransactionalStorage) database.TransactionalStorage).Instance; backupConfigPath = Path.Combine(backupDestinationDirectory, "RavenDB.Backup"); }
public BackupOperation(DocumentDatabase database, string src, string to) { instance = database.TransactionalStorage.Instance; this.database = database; this.to = to; this.src = src; }
public InstanceParameters ConfigureInstance(JET_INSTANCE jetInstance, string path) { path = Path.GetFullPath(path); var logsPath = path; if (string.IsNullOrEmpty(configuration.Settings["Raven/Esent/LogsPath"]) == false) { logsPath = configuration.Settings["Raven/Esent/LogsPath"].ToFullPath(); } var circularLog = GetValueFromConfiguration("Raven/Esent/CircularLog", true); var logFileSizeInMb = GetValueFromConfiguration("Raven/Esent/LogFileSize", 64); logFileSizeInMb = Math.Max(1, logFileSizeInMb / 4); var instanceParameters = new InstanceParameters(jetInstance) { CircularLog = circularLog, Recovery = true, NoInformationEvent = false, CreatePathIfNotExist = true, EnableIndexChecking = true, TempDirectory = Path.Combine(logsPath, "temp"), SystemDirectory = Path.Combine(logsPath, "system"), LogFileDirectory = Path.Combine(logsPath, "logs"), MaxVerPages = TranslateToSizeInVersionPages(GetValueFromConfiguration("Raven/Esent/MaxVerPages", 512), 1024 * 1024), PreferredVerPages = TranslateToSizeInVersionPages(GetValueFromConfiguration("Raven/Esent/PreferredVerPages", 472), 1024 * 1024), BaseName = "RVN", EventSource = "Raven", LogBuffers = TranslateToSizeInDatabasePages(GetValueFromConfiguration("Raven/Esent/LogBuffers", 8192), 1024), LogFileSize = (logFileSizeInMb * 1024), MaxSessions = MaxSessions, MaxCursors = GetValueFromConfiguration("Raven/Esent/MaxCursors", 2048), DbExtensionSize = TranslateToSizeInDatabasePages(GetValueFromConfiguration("Raven/Esent/DbExtensionSize", 8), 1024 * 1024), AlternateDatabaseRecoveryDirectory = path }; return instanceParameters; }
public DocumentStorageActions( JET_INSTANCE instance, string database, TableColumnsCache tableColumnsCache, OrderedPartCollection<AbstractDocumentCodec> documentCodecs, IUuidGenerator uuidGenerator, IDocumentCacher cacher, TransactionalStorage transactionalStorage) { this.tableColumnsCache = tableColumnsCache; this.documentCodecs = documentCodecs; this.uuidGenerator = uuidGenerator; this.cacher = cacher; this.transactionalStorage = transactionalStorage; try { session = new Session(instance); transaction = new Transaction(session); Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None); } catch (Exception) { Dispose(); throw; } }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref this.instance); }
public BackupOperation(RavenFileSystem filesystem, string backupSourceDirectory, string backupDestinationDirectory, bool incrementalBackup, FileSystemDocument filesystemDocument) : base(filesystem, backupSourceDirectory, backupDestinationDirectory, incrementalBackup, filesystemDocument) { instance = ((TransactionalStorage)filesystem.Storage).Instance; backupConfigPath = Path.Combine(backupDestinationDirectory, "RavenDB.Backup"); }
protected AbstractActions(JET_INSTANCE instance, ColumnsInformation columnsInformation, string database, Guid instanceId) { logger = LogManager.GetLogger(GetType()); try { this.instanceId = instanceId; ColumnsInformation = columnsInformation; session = new Session(instance); transaction = new Transaction(session); Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None); queues = new EsentTable(session, new Table(session, dbid, "queues", OpenTableGrbit.None)); subqueues = new EsentTable(session, new Table(session, dbid, "subqueues", OpenTableGrbit.None)); txs = new EsentTable(session, new Table(session, dbid, "transactions", OpenTableGrbit.None)); recovery = new EsentTable(session, new Table(session, dbid, "recovery", OpenTableGrbit.None)); outgoing = new EsentTable(session, new Table(session, dbid, "outgoing", OpenTableGrbit.None)); outgoingHistory = new EsentTable(session, new Table(session, dbid, "outgoing_history", OpenTableGrbit.None)); recveivedMsgs = new EsentTable(session, new Table(session, dbid, "recveived_msgs", OpenTableGrbit.None)); } catch (Exception) { Dispose(); throw; } }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); var columns = new[] { new JET_COLUMNDEF { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.TTKey } }; var columnids = new JET_COLUMNID[columns.Length]; // BUG: use TempTableGrbit.Indexed once in-memory TT bugs are fixed Api.JetOpenTempTable(this.sesid, columns, columns.Length, TempTableGrbit.ForceMaterialization, out this.tableid, columnids); this.columnid = columnids[0]; for (int i = 10; i <= 30; i += 10) { Api.JetPrepareUpdate(this.sesid, this.tableid, JET_prep.Insert); Api.JetSetColumn(this.sesid, this.tableid, this.columnid, BitConverter.GetBytes(i), 4, SetColumnGrbit.None, null); int ignored; Api.JetUpdate(this.sesid, this.tableid, null, 0, out ignored); } }
public void InitColumDictionaries(JET_INSTANCE instance, string database) { using (var session = new Session(instance)) { var dbid = JET_DBID.Nil; try { Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None); using (var usage = new Table(session, dbid, "usage", OpenTableGrbit.None)) UsageColumns = Api.GetColumnDictionary(session, usage); using (var details = new Table(session, dbid, "details", OpenTableGrbit.None)) DetailsColumns = Api.GetColumnDictionary(session, details); using (var pages = new Table(session, dbid, "pages", OpenTableGrbit.None)) PagesColumns = Api.GetColumnDictionary(session, pages); using (var files = new Table(session, dbid, "files", OpenTableGrbit.None)) FilesColumns = Api.GetColumnDictionary(session, files); using (var signatures = new Table(session, dbid, "signatures", OpenTableGrbit.None)) SignaturesColumns = Api.GetColumnDictionary(session, signatures); using (var config = new Table(session, dbid, "config", OpenTableGrbit.None)) ConfigColumns = Api.GetColumnDictionary(session, config); } finally { if (Equals(dbid, JET_DBID.Nil) == false) Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None); } } }
public BackupOperation(DocumentDatabase database, string src, string to) { instance = ((TransactionalStorage)database.TransactionalStorage).Instance; this.database = database; this.to = to.ToFullPath(); this.src = src.ToFullPath(); }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.table = "table"; this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); Api.JetCreateDatabase(this.sesid, this.database, String.Empty, out this.dbid, CreateDatabaseGrbit.None); Api.JetBeginTransaction(this.sesid); Api.JetCreateTable(this.sesid, this.dbid, this.table, 0, 100, out this.tableid); var columndef = new JET_COLUMNDEF() { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.ColumnEscrowUpdate, }; Api.JetAddColumn(this.sesid, this.tableid, "EscrowColumn", columndef, BitConverter.GetBytes(0), 4, out this.columnid); Api.JetCloseTable(this.sesid, this.tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.None, out this.tableid); Api.JetBeginTransaction(this.sesid); Api.JetPrepareUpdate(this.sesid, this.tableid, JET_prep.Insert); Api.JetUpdate(this.sesid, this.tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); Api.JetMove(this.sesid, this.tableid, JET_Move.First, MoveGrbit.None); }
public void ConfigureInstance(JET_INSTANCE jetInstance, string path) { path = Path.GetFullPath(path); var logsPath = path; if (string.IsNullOrEmpty(configuration.Settings["Raven/Esent/LogsPath"]) == false) { logsPath = configuration.Settings["Raven/Esent/LogsPath"].ToFullPath(); } new InstanceParameters(jetInstance) { CircularLog = true, Recovery = true, NoInformationEvent = false, CreatePathIfNotExist = true, TempDirectory = Path.Combine(logsPath, "temp"), SystemDirectory = Path.Combine(logsPath, "system"), LogFileDirectory = Path.Combine(logsPath, "logs"), MaxVerPages = TranslateToSizeInDatabasePages(GetValueFromConfiguration("Raven/Esent/MaxVerPages", 128)), BaseName = "RVN", EventSource = "Raven", LogBuffers = TranslateToSizeInDatabasePages(GetValueFromConfiguration("Raven/Esent/LogBuffers", 16)) / 2, LogFileSize = GetValueFromConfiguration("Raven/Esent/LogFileSize", 16) * 1024, MaxSessions = MaxSessions, MaxCursors = GetValueFromConfiguration("Raven/Esent/MaxCursors", 2048), DbExtensionSize = TranslateToSizeInDatabasePages(GetValueFromConfiguration("Raven/Esent/DbExtensionSize", 16)), AlternateDatabaseRecoveryDirectory = path }; }
public StorageActionsAccessor(TableColumnsCache tableColumnsCache, JET_INSTANCE instance, string databaseName, UuidGenerator uuidGenerator, OrderedPartCollection<AbstractFileCodec> fileCodecs) { this.tableColumnsCache = tableColumnsCache; this.uuidGenerator = uuidGenerator; this.fileCodecs = fileCodecs; try { session = new Session(instance); transaction = new Transaction(session); Api.JetOpenDatabase(session, databaseName, null, out database, OpenDatabaseGrbit.None); } catch (Exception original) { log.WarnException("Could not create accessor", original); try { Dispose(); } catch (Exception e) { log.WarnException("Could not properly dispose accessor after exception in ctor.", e); } throw; } }
public void InstanceCanConvertToJetInstance() { using (var instance = new Instance("theinstance")) { JET_INSTANCE jetinstance = instance; Assert.AreEqual(jetinstance, instance.JetInstance); } }
public HiLoVersionGenerator(JET_INSTANCE instance, int capacity, string database) { this.instance = instance; this.capacity = capacity; this.database = database; currentHi = GenerateNextHi(); currentLo = 0; }
/// <summary> /// Calls JetGetSystemParamter to return a JET_param value. /// </summary> /// <param name="instance">The instance to use.</param> /// <param name="param">The param to get.</param> /// <returns>The parameter value as an integer.</returns> private string GetStringParam(JET_INSTANCE instance, JET_param param) { int dummy = 0; string value; Api.JetGetSystemParameter(instance, JET_SESID.Nil, param, ref dummy, out value, 260); return(value); }
/// <summary> /// Calls JetGetSystemParamter to return a JET_param value. /// </summary> /// <param name="instance">The instance to use.</param> /// <param name="param">The param to get.</param> /// <returns>The parameter value as an integer.</returns> private int GetIntParam(JET_INSTANCE instance, JET_param param) { int value = 0; string dummy; Api.JetGetSystemParameter(instance, JET_SESID.Nil, param, ref value, out dummy, 0); return(value); }
public void Setup() { // we just need a session so don't do any logging or create a database this.instance = SetupHelper.CreateNewInstance("."); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref this.instance); }
public BackupOperation(DocumentDatabase database, string src, string to, bool incrementalBackup) { instance = ((TransactionalStorage)database.TransactionalStorage).Instance; this.src = src; this.to = to; this.incrementalBackup = incrementalBackup; this.database = database; }
public void JetInstanceToStringFormat() { var value = new JET_INSTANCE { Value = (IntPtr)0x123ABC }; Assert.AreEqual("123ABC", string.Format("{0:X}", value)); }
public void JetInstanceToStringGeneralFormat() { var value = new JET_INSTANCE { Value = (IntPtr)0x123ABC }; VerifyIFormattableGeneralEqualsToString(value); }
public void JetInstanceToString() { var value = new JET_INSTANCE { Value = (IntPtr)0x123ABC }; Assert.AreEqual("JET_INSTANCE(0x123abc)", value.ToString()); }
/// <summary>Close the DB.</summary> public void Dispose() { if (JET_INSTANCE.Nil != idInstance) { Api.JetTerm(idInstance); m_idInstance = JET_INSTANCE.Nil; } }
public DocumentStorageActions( JET_INSTANCE instance, string database, TableColumnsCache tableColumnsCache, OrderedPartCollection <AbstractDocumentCodec> documentCodecs, IUuidGenerator uuidGenerator, IDocumentCacher cacher, EsentTransactionContext transactionContext, TransactionalStorage transactionalStorage) { this.tableColumnsCache = tableColumnsCache; this.documentCodecs = documentCodecs; this.uuidGenerator = uuidGenerator; this.cacher = cacher; this.transactionalStorage = transactionalStorage; this.transactionContext = transactionContext; try { if (transactionContext == null) { session = new Session(instance); transaction = new Transaction(session); sessionAndTransactionDisposer = () => { if (transaction != null) { transaction.Dispose(); } if (session != null) { session.Dispose(); } }; } else { session = transactionContext.Session; transaction = transactionContext.Transaction; var disposable = transactionContext.EnterSessionContext(); sessionAndTransactionDisposer = disposable.Dispose; } Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None); } catch (Exception ex) { logger.WarnException("Error when trying to open a new DocumentStorageActions", ex); try { Dispose(); } catch (Exception e) { logger.WarnException("Error on dispose when the ctor threw an exception, resources may have leaked", e); } throw; } }
public void InitAndTermOneInstanceAbruptly() { JET_INSTANCE instance = SetupHelper.CreateNewInstance("instance"); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref instance); Api.JetTerm2(instance, TermGrbit.Abrupt); }
public void JetInstanceThrowsExceptionWhenInstanceIsClosed() { var instance = new Instance("closed"); SetupHelper.SetLightweightConfiguration(instance); instance.Init(); instance.Term(); JET_INSTANCE x = instance.JetInstance; }
/// <summary> /// Test callback method /// </summary> /// <param name="instance">Current instance.</param> /// <param name="commitId">Commit id seen.</param> /// <param name="grbit">Grbit - reserved.</param> /// <returns>Success or error.</returns> private JET_err TestCallback( JET_INSTANCE instance, JET_COMMIT_ID commitId, DurableCommitCallbackGrbit grbit) { this.lastCommitIdFlushed = commitId; this.lastCallbackTime = DateTime.Now; return(JET_err.Success); }
public InstanceParameters ConfigureInstance(JET_INSTANCE jetInstance, string path) { path = Path.GetFullPath(path); var logsPath = path; var configuredLogsPath = Configuration.Storage.Esent.JournalsStoragePath; if (string.IsNullOrEmpty(configuredLogsPath) == false) { logsPath = configuredLogsPath.ToFullPath(); } var circularLog = GetValueFromConfiguration(Constants.Esent.CircularLog, true); var logFileSizeInMb = GetValueFromConfiguration(Constants.Esent.LogFileSize, 64); logFileSizeInMb = Math.Max(1, logFileSizeInMb / 4); var maxVerPages = GetValueFromConfiguration(Constants.Esent.MaxVerPages, 512); var maxVerPagesResult = TranslateToSizeInVersionPages(maxVerPages, 1024 * 1024); ConfigureInstanceInternal(maxVerPages); var instanceParameters = new InstanceParameters(jetInstance) { CircularLog = circularLog, Recovery = true, NoInformationEvent = false, CreatePathIfNotExist = true, EnableIndexChecking = true, TempDirectory = Path.Combine(logsPath, "temp"), SystemDirectory = Path.Combine(logsPath, "system"), LogFileDirectory = Path.Combine(logsPath, "logs"), MaxVerPages = maxVerPagesResult, PreferredVerPages = TranslateToSizeInVersionPages(GetValueFromConfiguration(Constants.Esent.PreferredVerPages, (int)(maxVerPagesResult * 0.85)), 1024 * 1024), BaseName = BaseName, EventSource = EventSource, LogBuffers = TranslateToSizeInDatabasePages(GetValueFromConfiguration(Constants.Esent.LogBuffers, 8192), 1024), LogFileSize = (logFileSizeInMb * 1024), MaxSessions = MaxSessions, MaxCursors = GetValueFromConfiguration(Constants.Esent.MaxCursors, 2048), DbExtensionSize = TranslateToSizeInDatabasePages(GetValueFromConfiguration(Constants.Esent.DbExtensionSize, 8), 1024 * 1024), AlternateDatabaseRecoveryDirectory = path }; if (Environment.OSVersion.Version >= new Version(5, 2)) { // JET_paramEnableIndexCleanup is not supported on WindowsXP const int JET_paramEnableIndexCleanup = 54; Api.JetSetSystemParameter(jetInstance, JET_SESID.Nil, (JET_param)JET_paramEnableIndexCleanup, 1, null); } Log.Info(@"Esent Settings: MaxVerPages = {0} CacheSizeMax = {1} DatabasePageSize = {2}", instanceParameters.MaxVerPages, SystemParameters.CacheSizeMax, SystemParameters.DatabasePageSize); return(instanceParameters); }
public void InitColumDictionaries(JET_INSTANCE instance, string database) { using (var session = new Session(instance)) { var dbid = JET_DBID.Nil; try { Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None); using (var documents = new Table(session, dbid, "documents", OpenTableGrbit.None)) DocumentsColumns = Api.GetColumnDictionary(session, documents); using (var lists = new Table(session, dbid, "lists", OpenTableGrbit.None)) ListsColumns = Api.GetColumnDictionary(session, lists); using (var tasks = new Table(session, dbid, "tasks", OpenTableGrbit.None)) TasksColumns = Api.GetColumnDictionary(session, tasks); using (var files = new Table(session, dbid, "files", OpenTableGrbit.None)) FilesColumns = Api.GetColumnDictionary(session, files); using (var scheduledReductions = new Table(session, dbid, "scheduled_reductions", OpenTableGrbit.None)) ScheduledReductionColumns = Api.GetColumnDictionary(session, scheduledReductions); using (var indexStats = new Table(session, dbid, "indexes_stats", OpenTableGrbit.None)) IndexesStatsColumns = Api.GetColumnDictionary(session, indexStats); using (var indexStatsReduce = new Table(session, dbid, "indexes_stats_reduce", OpenTableGrbit.None)) IndexesStatsReduceColumns = Api.GetColumnDictionary(session, indexStatsReduce); using (var indexEtags = new Table(session, dbid, "indexes_etag", OpenTableGrbit.None)) IndexesEtagsColumns = Api.GetColumnDictionary(session, indexEtags); using (var mappedResults = new Table(session, dbid, "mapped_results", OpenTableGrbit.None)) MappedResultsColumns = Api.GetColumnDictionary(session, mappedResults); using (var reduceResults = new Table(session, dbid, "reduce_results", OpenTableGrbit.None)) ReduceResultsColumns = Api.GetColumnDictionary(session, reduceResults); using (var indexed_documents_references = new Table(session, dbid, "indexed_documents_references", OpenTableGrbit.None)) IndexedDocumentsReferencesColumns = Api.GetColumnDictionary(session, tableid: indexed_documents_references); using ( var documentsModifiedByTransactions = new Table(session, dbid, "documents_modified_by_transaction", OpenTableGrbit.None)) DocumentsModifiedByTransactionsColumns = Api.GetColumnDictionary(session, documentsModifiedByTransactions); using (var transactions = new Table(session, dbid, "transactions", OpenTableGrbit.None)) TransactionsColumns = Api.GetColumnDictionary(session, transactions); using (var identity = new Table(session, dbid, "identity_table", OpenTableGrbit.None)) IdentityColumns = Api.GetColumnDictionary(session, identity); using (var details = new Table(session, dbid, "details", OpenTableGrbit.None)) DetailsColumns = Api.GetColumnDictionary(session, details); using (var queue = new Table(session, dbid, "queue", OpenTableGrbit.None)) QueueColumns = Api.GetColumnDictionary(session, queue); using (var reduceKeys = new Table(session, dbid, "reduce_keys_counts", OpenTableGrbit.None)) ReduceKeysCountsColumns = Api.GetColumnDictionary(session, reduceKeys); using (var reduceKeys = new Table(session, dbid, "reduce_keys_status", OpenTableGrbit.None)) ReduceKeysStatusColumns = Api.GetColumnDictionary(session, reduceKeys); } finally { if (Equals(dbid, JET_DBID.Nil) == false) { Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None); } } } }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref this.instance); }
public void Setup() { this.instance = SetupHelper.CreateNewInstance("."); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); }
/// <summary> /// Terminates the Database. The exact behaviour of the termination process depends on the <see cref="TermGrbit"/> passed to the function. /// </summary> public void Term() { if (this.ownsInstance && this.instance != JET_INSTANCE.Nil) { // The TermGrbit.None should be equivalent to TermGrbit.Complete, but to stay consistent // with JetInit[2]() mapping to JetInit2() mapping in jetapi, we just translate it. Api.JetTerm2(this.instance, this.config.DatabaseStopFlags == TermGrbit.None ? TermGrbit.Complete : this.config.DatabaseStopFlags); this.instance = JET_INSTANCE.Nil; } }
public void InitColumDictionaries(JET_INSTANCE instance, string database) { using (var session = new Session(instance)) { var dbid = JET_DBID.Nil; try { Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None); using (var documents = new Table(session, dbid, "documents", OpenTableGrbit.None)) DocumentsColumns = Api.GetColumnDictionary(session, documents); using (var lists = new Table(session, dbid, "lists", OpenTableGrbit.None)) ListsColumns = Api.GetColumnDictionary(session, lists); using (var tasks = new Table(session, dbid, "tasks", OpenTableGrbit.None)) TasksColumns = Api.GetColumnDictionary(session, tasks); using (var files = new Table(session, dbid, "files", OpenTableGrbit.None)) FilesColumns = Api.GetColumnDictionary(session, files); using (var scheduledReductions = new Table(session, dbid, "scheduled_reductions", OpenTableGrbit.None)) ScheduledReductionColumns = Api.GetColumnDictionary(session, scheduledReductions); using (var indexStats = new Table(session, dbid, "indexes_stats", OpenTableGrbit.None)) IndexesStatsColumns = Api.GetColumnDictionary(session, indexStats); using (var indexStatsReduce = new Table(session, dbid, "indexes_stats_reduce", OpenTableGrbit.None)) IndexesStatsReduceColumns = Api.GetColumnDictionary(session, indexStatsReduce); using (var indexEtags = new Table(session, dbid, "indexes_etag", OpenTableGrbit.None)) IndexesEtagsColumns = Api.GetColumnDictionary(session, indexEtags); using (var mappedResults = new Table(session, dbid, "mapped_results", OpenTableGrbit.None)) MappedResultsColumns = Api.GetColumnDictionary(session, mappedResults); using (var reduceResults = new Table(session, dbid, "reduce_results", OpenTableGrbit.None)) ReduceResultsColumns = Api.GetColumnDictionary(session, reduceResults); using (var indexed_documents_references = new Table(session, dbid, "indexed_documents_references", OpenTableGrbit.None)) IndexedDocumentsReferencesColumns = Api.GetColumnDictionary(session, tableid: indexed_documents_references); using ( var documentsModifiedByTransactions = new Table(session, dbid, "documents_modified_by_transaction", OpenTableGrbit.None)) DocumentsModifiedByTransactionsColumns = Api.GetColumnDictionary(session, documentsModifiedByTransactions); using (var transactions = new Table(session, dbid, "transactions", OpenTableGrbit.None)) TransactionsColumns = Api.GetColumnDictionary(session, transactions); using (var identity = new Table(session, dbid, "identity_table", OpenTableGrbit.None)) IdentityColumns = Api.GetColumnDictionary(session, identity); using (var details = new Table(session, dbid, "details", OpenTableGrbit.None)) DetailsColumns = Api.GetColumnDictionary(session, details); using (var queue = new Table(session, dbid, "queue", OpenTableGrbit.None)) QueueColumns = Api.GetColumnDictionary(session, queue); using (var reduceKeys = new Table(session, dbid, "reduce_keys_counts", OpenTableGrbit.None)) ReduceKeysCountsColumns = Api.GetColumnDictionary(session, reduceKeys); using (var reduceKeys = new Table(session, dbid, "reduce_keys_status", OpenTableGrbit.None)) ReduceKeysStatusColumns = Api.GetColumnDictionary(session, reduceKeys); } finally { if (Equals(dbid, JET_DBID.Nil) == false) Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None); } } }
public InstanceParameters ConfigureInstance(JET_INSTANCE jetInstance, string path) { path = Path.GetFullPath(path); var logsPath = path; var configuredLogsPath = Configuration.Settings["Raven/Esent/LogsPath"] ?? Configuration.Settings[Constants.RavenTxJournalPath] ?? Configuration.JournalsStoragePath; if (string.IsNullOrEmpty(configuredLogsPath) == false) { logsPath = configuredLogsPath.ToFullPath(); } var circularLog = GetValueFromConfiguration("Raven/Esent/CircularLog", true); var logFileSizeInMb = GetValueFromConfiguration("Raven/Esent/LogFileSize", 64); logFileSizeInMb = Math.Max(1, logFileSizeInMb / 4); var maxVerPages = GetValueFromConfiguration("Raven/Esent/MaxVerPages", 512); var maxVerPagesResult = TranslateToSizeInVersionPages(maxVerPages, 1024 * 1024); ConfigureInstanceInternal(maxVerPages); var instanceParameters = new InstanceParameters(jetInstance) { CircularLog = circularLog, Recovery = true, NoInformationEvent = false, CreatePathIfNotExist = true, EnableIndexChecking = true, TempDirectory = Path.Combine(logsPath, "temp"), SystemDirectory = Path.Combine(logsPath, "system"), LogFileDirectory = Path.Combine(logsPath, "logs"), MaxVerPages = maxVerPagesResult, PreferredVerPages = TranslateToSizeInVersionPages(GetValueFromConfiguration("Raven/Esent/PreferredVerPages", (int)(maxVerPagesResult * 0.85)), 1024 * 1024), BaseName = BaseName, EventSource = EventSource, LogBuffers = TranslateToSizeInDatabasePages(GetValueFromConfiguration("Raven/Esent/LogBuffers", 8192), 1024), LogFileSize = (logFileSizeInMb * 1024), MaxSessions = MaxSessions, MaxCursors = GetValueFromConfiguration("Raven/Esent/MaxCursors", 2048), DbExtensionSize = TranslateToSizeInDatabasePages(GetValueFromConfiguration("Raven/Esent/DbExtensionSize", 8), 1024 * 1024), AlternateDatabaseRecoveryDirectory = path }; if (Environment.OSVersion.Version >= new Version(5, 2)) { // JET_paramEnableIndexCleanup is not supported on WindowsXP const int JET_paramEnableIndexCleanup = 54; Api.JetSetSystemParameter(jetInstance, JET_SESID.Nil, (JET_param)JET_paramEnableIndexCleanup, 1, null); } Log.Info(@"Esent Settings: MaxVerPages = {0} CacheSizeMax = {1} DatabasePageSize = {2}", instanceParameters.MaxVerPages, SystemParameters.CacheSizeMax, SystemParameters.DatabasePageSize); return instanceParameters; }
public void JetInstanceThrowsExceptionWhenInstanceIsClosed() { var instance = new Instance("theinstance"); instance.Parameters.NoInformationEvent = true; instance.Parameters.Recovery = false; instance.Parameters.MaxTemporaryTables = 0; instance.Init(); instance.Term(); JET_INSTANCE x = instance.JetInstance; }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); this.tableid = JET_TABLEID.Nil; }
public DocumentStorageActions( JET_INSTANCE instance, string database, TableColumnsCache tableColumnsCache, OrderedPartCollection<AbstractDocumentCodec> documentCodecs, IUuidGenerator uuidGenerator, IDocumentCacher cacher, EsentTransactionContext transactionContext, TransactionalStorage transactionalStorage) { this.tableColumnsCache = tableColumnsCache; this.documentCodecs = documentCodecs; this.uuidGenerator = uuidGenerator; this.cacher = cacher; this.transactionalStorage = transactionalStorage; this.transactionContext = transactionContext; try { if (transactionContext == null) { session = new Session(instance); transaction = new Transaction(session); sessionAndTransactionDisposer = () => { if(transaction != null) transaction.Dispose(); if(session != null) session.Dispose(); }; } else { session = transactionContext.Session; transaction = transactionContext.Transaction; var disposable = transactionContext.EnterSessionContext(); sessionAndTransactionDisposer = disposable.Dispose; } Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None); } catch (Exception ex) { logger.WarnException("Error when trying to open a new DocumentStorageActions", ex); try { Dispose(); } catch (Exception e) { logger.WarnException("Error on dispose when the ctor threw an exception, resources may have leaked", e); } throw; } }
public void VerifyJetInstanceInequality() { var x = JET_INSTANCE.Nil; var y = new JET_INSTANCE { Value = (IntPtr)0x7 }; TestUnequalObjects(x, y); Assert.IsTrue(x != y); Assert.IsFalse(x == y); }
/// <summary> /// Test setting and retrieving a system parameter that uses a string. /// </summary> /// <param name="instance">The ESE instance.</param> /// <param name="param">The parameter to set.</param> /// <param name="expected">The string to expect when reading the parameter.</param> private static void StringParameterTest(JET_INSTANCE instance, JET_param param, string expected) { Api.JetSetSystemParameter(instance, JET_SESID.Nil, param, 0, expected); int ignored = 0; string actual; Api.JetGetSystemParameter(instance, JET_SESID.Nil, param, ref ignored, out actual, 256); Assert.AreEqual(expected, actual); }
/// <summary> /// Test setting and retrieving an integer system parameter. /// </summary> /// <param name="instance">The ESE instance.</param> /// <param name="param">The parameter to set.</param> /// <param name="expected">The string to set it to.</param> private static void IntegerParameterTest(JET_INSTANCE instance, JET_param param, int expected) { Api.JetSetSystemParameter(instance, JET_SESID.Nil, param, expected, null); int actual = 0; string ignored; Api.JetGetSystemParameter(instance, JET_SESID.Nil, param, ref actual, out ignored, 0); Assert.AreEqual(expected, actual); }
public static void DisableIndexChecking(JET_INSTANCE jetInstance) { Api.JetSetSystemParameter(jetInstance, JET_SESID.Nil, JET_param.EnableIndexChecking, 0, null); if (Environment.OSVersion.Version >= new Version(5, 2)) { // JET_paramEnableIndexCleanup is not supported on WindowsXP const int JET_paramEnableIndexCleanup = 54; Api.JetSetSystemParameter(jetInstance, JET_SESID.Nil, (JET_param)JET_paramEnableIndexCleanup, 0, null); } }
private Session OpenSession(JET_INSTANCE instance, out Table table, out JET_COLUMNID primaryColumnId, out JET_COLUMNID secondaryColumnId) { var session = new Session(instance); Api.JetAttachDatabase2(session, _database, 0, AttachDatabaseGrbit.None); JET_DBID dbid; Api.JetOpenDatabase(session, _database, null, out dbid, OpenDatabaseGrbit.None); table = OpenSchema(session, dbid, out primaryColumnId, out secondaryColumnId); return session; }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); Api.JetCreateDatabase(this.sesid, this.database, String.Empty, out this.dbid, CreateDatabaseGrbit.None); }
public void Close() { if (!Opened || !Valid) { return; } Sessions.Reverse(); Sessions.ForEach(s => s?.Dispose()); Opened = false; Api.JetTerm(JetId); JetId = JET_INSTANCE.Nil; }
public InstanceParameters ConfigureInstance(JET_INSTANCE jetInstance, string path) { path = Path.GetFullPath(path); var logsPath = path; var configuredLogsPath = configuration.Settings["Raven/Esent/LogsPath"] ?? configuration.Settings[Constants.RavenTxJournalPath] ?? configuration.JournalsStoragePath; if (string.IsNullOrEmpty(configuredLogsPath) == false) { logsPath = configuredLogsPath.ToFullPath(); } var circularLog = GetValueFromConfiguration("Raven/Esent/CircularLog", true); var logFileSizeInMb = GetValueFromConfiguration("Raven/Esent/LogFileSize", 64); logFileSizeInMb = Math.Max(1, logFileSizeInMb / 4); var maxVerPages = GetValueFromConfiguration("Raven/Esent/MaxVerPages", 512); if (transactionalStorage != null) { transactionalStorage.MaxVerPagesValueInBytes = maxVerPages * 1024 * 1024; } var maxVerPagesResult = TranslateToSizeInVersionPages(maxVerPages, 1024 * 1024); var instanceParameters = new InstanceParameters(jetInstance) { CircularLog = circularLog, Recovery = true, NoInformationEvent = false, CreatePathIfNotExist = true, EnableIndexChecking = true, TempDirectory = Path.Combine(logsPath, "temp"), SystemDirectory = Path.Combine(logsPath, "system"), LogFileDirectory = Path.Combine(logsPath, "logs"), MaxVerPages = maxVerPagesResult, PreferredVerPages = TranslateToSizeInVersionPages(GetValueFromConfiguration("Raven/Esent/PreferredVerPages", (int)(maxVerPagesResult * 0.85)), 1024 * 1024), BaseName = "RVN", EventSource = "Raven", LogBuffers = TranslateToSizeInDatabasePages(GetValueFromConfiguration("Raven/Esent/LogBuffers", 8192), 1024), LogFileSize = (logFileSizeInMb * 1024), MaxSessions = MaxSessions, MaxCursors = GetValueFromConfiguration("Raven/Esent/MaxCursors", 2048), DbExtensionSize = TranslateToSizeInDatabasePages(GetValueFromConfiguration("Raven/Esent/DbExtensionSize", 8), 1024 * 1024), AlternateDatabaseRecoveryDirectory = path }; if (Environment.OSVersion.Version >= new Version(5, 2)) { // JET_paramEnableIndexCleanup is not supported on WindowsXP const int JET_paramEnableIndexCleanup = 54; Api.JetSetSystemParameter(jetInstance, JET_SESID.Nil, (JET_param)JET_paramEnableIndexCleanup, 1, null); } return(instanceParameters); }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.PageTempDBMin, SystemParameters.PageTempDBSmallest, null); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, string.Empty, string.Empty); this.columnidDict = SetupHelper.CreateTempTableWithAllColumns(this.sesid, TempTableGrbit.None, out this.tableid); }
/// <summary> /// Resets the cache for the database. /// </summary> private void ResetCache() { Api.JetCloseTable(this.sesid, this.tableid); Api.JetEndSession(this.sesid, EndSessionGrbit.None); Api.JetTerm(this.instance); this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, string.Empty, string.Empty); Api.JetAttachDatabase(this.sesid, this.database, AttachDatabaseGrbit.None); Api.JetOpenDatabase(this.sesid, this.database, null, out this.dbid, OpenDatabaseGrbit.None); Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.None, out this.tableid); }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.PageTempDBMin, SystemParameters.PageTempDBSmallest, null); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); this.columnidDict = SetupHelper.CreateTempTableWithAllColumns(this.sesid, TempTableGrbit.None, out this.tableid); }
public StorageActionsAccessor(TableColumnsCache tableColumnsCache, JET_INSTANCE instance, string databaseName) { this.tableColumnsCache = tableColumnsCache; try { session = new Session(instance); transaction = new Transaction(session); Api.JetOpenDatabase(session, databaseName, null, out database, OpenDatabaseGrbit.None); } catch (Exception) { Dispose(); throw; } }
public StorageActionsAccessor(TableColumnsCache tableColumnsCache, JET_INSTANCE instance, string databaseName) { this.lastEtag = new Guid("ffffffff-ffff-ffff-ffff-ffffffffffff").TransformToValueForEsentSorting(); this.tableColumnsCache = tableColumnsCache; try { session = new Session(instance); transaction = new Transaction(session); Api.JetOpenDatabase(session, databaseName, null, out database, OpenDatabaseGrbit.None); } catch (Exception) { Dispose(); throw; } }
public DocumentStorageActions(JET_INSTANCE instance, string database, TableColumnsCache tableColumnsCache, IEnumerable<AbstractDocumentCodec> documentCodecs) { this.tableColumnsCache = tableColumnsCache; this.documentCodecs = documentCodecs; try { session = new Session(instance); transaction = new Transaction(session); Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None); } catch (Exception) { Dispose(); throw; } }