public static int OptimizeAllBuffers(Db4oMessageBufferOptimizationTypes opts) { DateTime start = DateTime.UtcNow, stop; var dbPath = Platform.GetBuffersBasePath(); var dbFiles = Directory.GetFiles(dbPath, "*.db4o", SearchOption.AllDirectories); foreach (var dbFile in dbFiles) { #if LOG4NET Logger.Info(String.Format(_("Optimizing: {0}..."), dbFile)); #endif try { using (var buffer = new Db4oMessageBuffer(dbFile)) { buffer.AggressiveGC = false; if ((opts & Db4oMessageBufferOptimizationTypes.Defrag) != 0) { buffer.CloseDatabase(); buffer.DefragDatabase(); buffer.InitDatabase(); } if ((opts & Db4oMessageBufferOptimizationTypes.Index) != 0) { buffer.RebuildIndex(); } } } catch (Exception ex) { #if LOG4NET Logger.Debug("OptimizeAllBuffers(): Failed to optimize: " + dbFile + " Exception: ", ex); Logger.InfoFormat(_("Failed to optimize: {0}. Reason: {1}"), dbFile, ex.Message); #endif } } stop = DateTime.UtcNow; #if LOG4NET Logger.Debug( String.Format( "OptimizeAllBuffers(): optimizing buffers took: {0:0} second(s)", (stop - start).TotalSeconds ) ); #endif return(dbFiles.Length); }
public static int OptimizeAllBuffers(Db4oMessageBufferOptimizationTypes opts) { DateTime start = DateTime.UtcNow, stop; var dbPath = Platform.GetBuffersBasePath(); var dbFiles = Directory.GetFiles(dbPath, "*.db4o", SearchOption.AllDirectories); foreach (var dbFile in dbFiles) { #if LOG4NET Logger.Info(String.Format(_("Optimizing: {0}..."), dbFile)); #endif try { using (var buffer = new Db4oMessageBuffer(dbFile)) { buffer.AggressiveGC = false; if ((opts & Db4oMessageBufferOptimizationTypes.Defrag) != 0) { buffer.CloseDatabase(); buffer.DefragDatabase(); buffer.InitDatabase(); } if ((opts & Db4oMessageBufferOptimizationTypes.Index) != 0) { buffer.RebuildIndex(); } } } catch (Exception ex) { #if LOG4NET Logger.Debug("OptimizeAllBuffers(): Failed to optimize: " + dbFile + " Exception: ", ex); Logger.InfoFormat(_("Failed to optimize: {0}. Reason: {1}"), dbFile, ex.Message); #endif } } stop = DateTime.UtcNow; #if LOG4NET Logger.Debug( String.Format( "OptimizeAllBuffers(): optimizing buffers took: {0:0} second(s)", (stop - start).TotalSeconds ) ); #endif return dbFiles.Length; }
public static int OptimizeAllBuffers() { DateTime start = DateTime.UtcNow, stop; var dbPath = Platform.GetBuffersBasePath(); var dbFiles = Directory.GetFiles(dbPath, "*.db4o", SearchOption.AllDirectories); foreach (var dbFile in dbFiles) { #if LOG4NET Logger.Info(String.Format(_("Optimizing: {0}..."), dbFile)); #endif using (var buffer = new Db4oMessageBuffer(dbFile)) { buffer.AggressiveGC = false; buffer.CloseDatabase(); buffer.DefragDatabase(); buffer.InitDatabase(); buffer.RebuildIndex(); } } stop = DateTime.UtcNow; #if LOG4NET Logger.Debug( String.Format( "OptimizeAllBuffers(): optimizing buffers took: {0:0.0} ms", (stop - start).TotalMilliseconds ) ); #endif return dbFiles.Length; }