/// <summary>
 /// Starts and stops database defragmentation tasks that improves data
 /// organization within a database.
 /// </summary>
 /// <param name="sesid">The session to use for the call.</param>
 /// <param name="dbid">The database to be defragmented.</param>
 /// <param name="tableName">
 /// Under some options defragmentation is performed for the entire database described by the given
 /// database ID, and other options (such as <see cref="Windows7.Windows7Grbits.DefragmentBTree"/>) require
 /// the name of the table to defragment.
 /// </param>
 /// <param name="grbit">Defragmentation options.</param>
 /// <returns>A warning code.</returns>
 /// <seealso cref="Api.JetDefragment"/>
 public static JET_wrn Defragment(
     JET_SESID sesid,
     JET_DBID dbid,
     string tableName,
     DefragGrbit grbit)
 {
     return(Api.Check(Impl.Defragment(sesid, dbid, tableName, grbit)));
 }
 public void TestStartOld2WithDefragmentBTreeBatchReadOnlyDbMustFail()
 {
     this.ReattachDatabase(AttachDatabaseGrbit.ReadOnly);
     try
     {
         DefragGrbit defragGrbit = UnpublishedGrbits.DefragmentBTreeBatch | DefragGrbit.BatchStart;
         Api.Defragment(this.sesid, this.dbid, null, defragGrbit);
         Assert.Fail("Starting OLD2 with {0} should have failed with EsentDatabaseFileReadOnlyException, but succeeded.", defragGrbit);
     }
     catch (EsentDatabaseFileReadOnlyException)
     {
         // Expected.
     }
     finally
     {
         this.ReattachDatabase(AttachDatabaseGrbit.None);
     }
 }
示例#3
0
文件: Api.cs 项目: 925coder/ravendb
 /// <summary>
 /// Starts and stops database defragmentation tasks that improves data
 /// organization within a database.
 /// </summary>
 /// <remarks>
 /// The callback passed to JetDefragment2 can be executed asynchronously.
 /// The GC doesn't know that the unmanaged code has a reference to the callback
 /// so it is important to make sure the callback isn't collected.
 /// </remarks>
 /// <param name="sesid">The session to use for the call.</param>
 /// <param name="dbid">The database to be defragmented.</param>
 /// <param name="tableName">
 /// Unused parameter. Defragmentation is performed for the entire database described by the given database ID.
 /// </param>
 /// <param name="passes">
 /// When starting an online defragmentation task, this parameter sets the maximum number of defragmentation
 /// passes. When stopping an online defragmentation task, this parameter is set to the number of passes
 /// performed.
 /// </param>
 /// <param name="seconds">
 /// When starting an online defragmentation task, this parameter sets
 /// the maximum time for defragmentation. When stopping an online
 /// defragmentation task, this output buffer is set to the length of
 /// time used for defragmentation.
 /// </param>
 /// <param name="callback">Callback function that defrag uses to report progress.</param>
 /// <param name="grbit">Defragmentation options.</param>
 /// <returns>A warning code.</returns>
 public static JET_wrn JetDefragment2(
     JET_SESID sesid, 
     JET_DBID dbid, 
     string tableName, 
     ref int passes, 
     ref int seconds, 
     JET_CALLBACK callback, 
     DefragGrbit grbit)
 {
     return Api.Check(Impl.JetDefragment2(sesid, dbid, tableName, ref passes, ref seconds, callback, grbit));
 }