本文整理汇总了C#中Raven.Database.DocumentDatabase.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentDatabase.Dispose方法的具体用法?C# DocumentDatabase.Dispose怎么用?C# DocumentDatabase.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Database.DocumentDatabase
的用法示例。
在下文中一共展示了DocumentDatabase.Dispose方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public static void Init()
{
if (database != null)
return;
lock (locker)
{
if (database != null)
return;
try
{
var ravenConfiguration = new RavenConfiguration();
if (RoleEnvironment.IsAvailable)
{
ravenConfiguration.RunInMemory = true;
// Mount Cloud drive and set it as Data Directory
//var currentConfiguredRavenDataDir = ConfigurationManager.AppSettings["Raven/DataDir"] ?? string.Empty;
//string azureDrive = @"D:\"; // Environment.GetEnvironmentVariable(RavenDriveConfiguration.AzureDriveEnvironmentVariableName, EnvironmentVariableTarget.Machine);
//if (string.IsNullOrWhiteSpace(azureDrive))
//{
// throw new ArgumentException("RavenDb drive environment variable is not yet set by worker role. Please, retry in a couple of seconds");
//}
//string azurePath = Path.Combine(azureDrive,
// currentConfiguredRavenDataDir.StartsWith(@"~\")
// ? currentConfiguredRavenDataDir.Substring(2)
// : "Data");
//ravenConfiguration.DataDirectory = azurePath;
// Read port number specified for this Raven instance and set it in configuration
var endpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Raven"];
ravenConfiguration.Port = endpoint.IPEndpoint.Port;
// When mounting drives in emulator only Munin storage is supported, since drive is not actually present and low level access to it failes (Esent mode)
}
HttpEndpointRegistration.RegisterHttpEndpointTarget();
database = new DocumentDatabase(ravenConfiguration);
database.SpinBackgroundWorkers();
server = new HttpServer(ravenConfiguration, database);
server.Init();
}
catch
{
if (database != null)
{
database.Dispose();
database = null;
}
if (server != null)
{
server.Dispose();
server = null;
}
throw;
}
HostingEnvironment.RegisterObject(new ReleaseRavenDBWhenAppDomainIsTornDown());
}
}
示例2: Init
public static void Init()
{
if (database != null)
return;
lock (locker)
{
if (database != null)
return;
try
{
var ravenConfiguration = new RavenConfiguration();
HttpEndpointRegistration.RegisterHttpEndpointTarget();
database = new DocumentDatabase(ravenConfiguration);
database.SpinBackgroundWorkers();
server = new HttpServer(ravenConfiguration, database);
server.Init();
}
catch
{
if (database != null)
{
database.Dispose();
database = null;
}
if (server != null)
{
server.Dispose();
server = null;
}
throw;
}
}
}
示例3: RavenDbServer
public RavenDbServer(InMemoryRavenConfiguration settings)
{
database = new DocumentDatabase(settings);
try
{
database.SpinBackgroundWorkers();
server = new HttpServer(settings, database);
server.StartListening();
}
catch (Exception)
{
database.Dispose();
database = null;
throw;
}
}
示例4: RavenDbServer
public RavenDbServer(RavenConfiguration settings)
{
settings.LoadLoggingSettings();
database = new DocumentDatabase(settings);
try
{
database.SpinBackgroundWorkers();
server = new HttpServer(settings, database);
server.Start();
}
catch (Exception)
{
database.Dispose();
database = null;
throw;
}
}
示例5: Init
public static void Init()
{
if (database != null)
return;
lock (locker)
{
if (database != null)
return;
log.Info("Setting up RavenDB Http Integration to the ASP.Net Pipeline");
try
{
var ravenConfiguration = new RavenConfiguration();
HttpEndpointRegistration.RegisterHttpEndpointTarget();
database = new DocumentDatabase(ravenConfiguration);
database.SpinBackgroundWorkers();
server = new HttpServer(ravenConfiguration, database);
server.Init();
}
catch
{
if (database != null)
{
database.Dispose();
database = null;
}
if (server != null)
{
server.Dispose();
server = null;
}
throw;
}
shutdownDetector = new ShutdownDetector(log);
shutdownDetector.Initialize();
shutdownDetector.Token.Register(OnShutdown);
}
}
示例6: Init
public static void Init()
{
if (database != null)
return;
lock (locker)
{
if (database != null)
return;
log.Info("Setting up RavenDB Http Integration to the ASP.Net Pipeline");
try
{
var ravenConfiguration = new RavenConfiguration();
HttpEndpointRegistration.RegisterHttpEndpointTarget();
database = new DocumentDatabase(ravenConfiguration);
database.SpinBackgroundWorkers();
server = new HttpServer(ravenConfiguration, database);
server.Init();
}
catch
{
if (database != null)
{
database.Dispose();
database = null;
}
if (server != null)
{
server.Dispose();
server = null;
}
throw;
}
HostingEnvironment.RegisterObject(new ReleaseRavenDBWhenAppDomainIsTornDown());
}
}
示例7: AfterBackupRestore_IndexConsistentWithWritesDuringBackup
public void AfterBackupRestore_IndexConsistentWithWritesDuringBackup()
{
var count = 1;
var docId = string.Format("ayende{0}", count++.ToString("D4"));
db.Documents.Put(docId, null, RavenJObject.Parse("{'email':'[email protected]'}"), RavenJObject.Parse("{'Raven-Entity-Name':'Users'}"), null);
db.SpinBackgroundWorkers();
QueryResult queryResult;
do
{
queryResult = db.Queries.Query("Raven/DocumentsByEntityName", new IndexQuery
{
Query = "Tag:[[Users]]",
PageSize = 10
}, CancellationToken.None);
} while (queryResult.IsStale);
Assert.Equal(1, queryResult.Results.Count);
var runInserts = true;
Task.Run(() =>
{
while (runInserts)
{
docId = string.Format("ayende{0}", count++.ToString("D4"));
db.Documents.Put(docId, null, RavenJObject.Parse("{'email':'[email protected]'}"), RavenJObject.Parse("{'Raven-Entity-Name':'Users'}"), null);
db.IndexStorage.FlushMapIndexes();
}
});
db.Maintenance.StartBackup(BackupDir, false, new DatabaseDocument());
WaitForBackup(db, true);
runInserts = false;
db.Dispose();
IOExtensions.DeleteDirectory(DataDir);
MaintenanceActions.Restore(new RavenConfiguration(), new DatabaseRestoreRequest
{
BackupLocation = BackupDir,
DatabaseLocation = DataDir,
Defrag = true
}, s => { });
db = new DocumentDatabase(new RavenConfiguration { DataDirectory = DataDir });
docId = string.Format("ayende{0}", count++.ToString("D4"));
db.Documents.Put(docId, null, RavenJObject.Parse("{'email':'[email protected]'}"), RavenJObject.Parse("{'Raven-Entity-Name':'Users'}"), null);
db.SpinBackgroundWorkers();
int next = 0;
var storedDocs = new List<string>();
while (true)
{
var batch = db.Documents.GetDocumentsWithIdStartingWith("ayende", null, null, next, 1024, CancellationToken.None, ref next);
storedDocs.AddRange(batch.Select(doc => doc.Value<RavenJObject>("@metadata").Value<string>("@id")));
if (batch.Length < 1024) break;
}
List<string> indexedDocs;
bool stale;
do
{
indexedDocs = db.Queries.QueryDocumentIds("Raven/DocumentsByEntityName", new IndexQuery
{
Query = "Tag:[[Users]]",
PageSize = int.MaxValue,
WaitForNonStaleResultsAsOfNow = true
}, new CancellationTokenSource(), out stale).ToList();
} while (stale);
if (storedDocs.Count != indexedDocs.Count)
{
var storedHash = new HashSet<string>(storedDocs);
var indexedHash = new HashSet<string>(indexedDocs);
foreach (var id in storedDocs.Union(indexedDocs).OrderBy(x => x))
{
Debug.WriteLine("{0} Database:{1} Indexed:{2}", id, storedHash.Contains(id), indexedHash.Contains(id));
}
}
Assert.Equal(storedDocs.Count, indexedDocs.Count());
db.Dispose();
}
示例8: StartRaven
private void StartRaven(RavenConfiguration config)
{
try
{
_database = new DocumentDatabase(config);
_database.SpinBackgroundWorkers();
_server = new RavenDbHttpServer(config, _database);
try
{
_server.Start();
}
catch (Exception)
{
_server.Dispose();
_server = null;
throw;
}
}
catch (Exception)
{
_database.Dispose();
_database = null;
throw;
}
}
示例9: StartRaven
private void StartRaven()
{
try
{
Trace.TraceInformation("RavenDb: Starting...");
AnonymousUserAccessMode anonymousUserAccessMode;
if (!Enum.TryParse(RoleEnvironment.GetConfigurationSettingValue("AnonymousUserAccessMode"), true, out anonymousUserAccessMode))
anonymousUserAccessMode = AnonymousUserAccessMode.Get;
Trace.TraceInformation("Raven Configuration AnonymousUserAccessMode: {0}", anonymousUserAccessMode);
var httpCompression = Boolean.Parse(RoleEnvironment.GetConfigurationSettingValue("HttpCompression"));
Trace.TraceInformation("Raven Configuration HttpCompression: {0}", httpCompression);
var defaultStorageTypeName = RoleEnvironment.GetConfigurationSettingValue("DefaultStorageTypeName");
Trace.TraceInformation("Raven Configuration DefaultStorageTypeName: {0}", defaultStorageTypeName);
var port = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Raven"].IPEndpoint.Port;
Trace.TraceInformation("Raven Configuration Port: {0}", port);
Trace.TraceInformation("RavenDb: Ensure Can ListenTo When In Non Admin Context...");
NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port);
var config = new RavenConfiguration
{
DataDirectory = _dataDrive.LocalPath.EndsWith("\\")
? _dataDrive.LocalPath + "Data\\"
: _dataDrive.LocalPath + "\\Data\\",
AnonymousUserAccessMode = anonymousUserAccessMode,
HttpCompression = httpCompression,
DefaultStorageTypeName = defaultStorageTypeName,
Port = port,
PluginsDirectory = "Plugins"
};
_database = new DocumentDatabase(config);
Trace.TraceInformation("RavenDb: Spin Background Workers...");
_database.SpinBackgroundWorkers();
_server = new HttpServer(config, _database);
try
{
Trace.TraceInformation("Http Server: Initializing ...");
_server.Init();
Trace.TraceInformation("Http Server: Start Listening ...");
_server.StartListening();
}
catch (Exception)
{
_server.Dispose();
_server = null;
throw;
}
Trace.TraceInformation("RavenDb: Started.");
}
catch (Exception)
{
if (_database != null)
{
_database.Dispose();
_database = null;
}
throw;
}
}
示例10: NonIncrementalBackup_Restore_CanReadDocument
public void NonIncrementalBackup_Restore_CanReadDocument(string storageName)
{
InitializeDocumentDatabase(storageName);
IOExtensions.DeleteDirectory(BackupDir);
db.Documents.Put("Foo", null, RavenJObject.Parse("{'email':'[email protected]'}"), new RavenJObject(), null);
db.Maintenance.StartBackup(BackupDir, false, new DatabaseDocument());
WaitForBackup(db, true);
db.Dispose();
IOExtensions.DeleteDirectory(DataDir);
MaintenanceActions.Restore(new RavenConfiguration
{
DefaultStorageTypeName = storageName,
DataDirectory = DataDir,
RunInMemory = false,
RunInUnreliableYetFastModeThatIsNotSuitableForProduction = false,
Settings =
{
{"Raven/Esent/CircularLog", "false"},
{"Raven/Voron/AllowIncrementalBackups", "true"}
}
}, new DatabaseRestoreRequest
{
BackupLocation = BackupDir,
DatabaseLocation = DataDir,
Defrag = true
}, s => { });
db = new DocumentDatabase(new RavenConfiguration { DataDirectory = DataDir });
var fetchedData = db.Documents.Get("Foo", null);
Assert.NotNull(fetchedData);
var jObject = fetchedData.ToJson();
Assert.NotNull(jObject);
Assert.Equal("[email protected]", jObject.Value<string>("email"));
db.Dispose();
}