本文整理汇总了C#中Raven.Database.Config.RavenConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# RavenConfiguration类的具体用法?C# RavenConfiguration怎么用?C# RavenConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RavenConfiguration类属于Raven.Database.Config命名空间,在下文中一共展示了RavenConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNewServer
protected RavenDbServer GetNewServer()
{
var ravenConfiguration = new RavenConfiguration
{
Port = 8080,
RunInMemory = true,
DataDirectory = "Data",
AnonymousUserAccessMode = AnonymousUserAccessMode.All
};
ConfigureServer(ravenConfiguration);
if(ravenConfiguration.RunInMemory == false)
IOExtensions.DeleteDirectory(ravenConfiguration.DataDirectory);
var ravenDbServer = new RavenDbServer(ravenConfiguration);
using (var documentStore = new DocumentStore
{
Url = "http://localhost:8080"
}.Initialize())
{
new RavenDocumentsByEntityName().Execute(documentStore);
}
return ravenDbServer;
}
示例2: EsentExportOperation
public EsentExportOperation(string dataDirPath)
{
var dbFullPath = Path.Combine(dataDirPath, "Data");
try
{
Api.JetCreateInstance(out instance, "instance");
var ravenConfiguration = new RavenConfiguration();
ravenConfiguration.DataDirectory = dataDirPath;
ravenConfiguration.Storage.PreventSchemaUpdate = true;
ITransactionalStorage storage;
var success = StorageExporter.TryToCreateTransactionalStorage(ravenConfiguration, out storage);
if (!success) ConsoleUtils.PrintErrorAndFail("Failed to create transactional storage");
var configurator = new TransactionalStorageConfigurator(ravenConfiguration, (TransactionalStorage)storage);
configurator.ConfigureInstance(instance, dataDirPath);
storage.Dispose();
Api.JetInit(ref instance);
Api.JetBeginSession(instance, out sesid, null, null);
Api.JetAttachDatabase(sesid, dbFullPath, AttachDatabaseGrbit.None);
Api.JetOpenDatabase(sesid, dbFullPath, null, out dbid, OpenDatabaseGrbit.None);
}
catch (Exception e)
{
ConsoleUtils.PrintErrorAndFail(e.Message, e.StackTrace);
}
}
示例3: RespondToAdmin
public override void RespondToAdmin(IHttpContext context)
{
if (EnsureSystemDatabase(context) == false)
return;
var restoreRequest = context.ReadJsonObject<RestoreRequest>();
var ravenConfiguration = new RavenConfiguration();
if (File.Exists(Path.Combine(restoreRequest.RestoreLocation, "Raven.ravendb")))
{
ravenConfiguration.DefaultStorageTypeName = "Raven.Storage.Managed.TransactionalStorage, Raven.Storage.Managed";
}
else if (Directory.Exists(Path.Combine(restoreRequest.RestoreLocation, "new")))
{
ravenConfiguration.DefaultStorageTypeName = "Raven.Storage.Esent.TransactionalStorage, Raven.Storage.Esent";
}
var restoreDoc = new List<string>();
// Commented out unfinished code to get it to compile
// DocumentDatabase.Restore(ravenConfiguration, restoreRequest.RestoreLocation, restoreRequest.DatabaseLocation,
// msg =>
// {
//
// });
// SystemDatabase.
}
示例4: Restore
public static void Restore(RavenConfiguration configuration, DatabaseRestoreRequest restoreRequest, Action<string> output)
{
var databaseDocumentPath = FindDatabaseDocument(restoreRequest.BackupLocation);
if (File.Exists(databaseDocumentPath) == false)
{
throw new InvalidOperationException("Cannot restore when the Database.Document file is missing in the backup folder: " + restoreRequest.BackupLocation);
}
var databaseDocumentText = File.ReadAllText(databaseDocumentPath);
var databaseDocument = RavenJObject.Parse(databaseDocumentText).JsonDeserialization<DatabaseDocument>();
string storage;
if (databaseDocument.Settings.TryGetValue("Raven/StorageTypeName", out storage) == false)
{
storage = "esent";
}
if (!string.IsNullOrWhiteSpace(restoreRequest.DatabaseLocation))
{
configuration.DataDirectory = restoreRequest.DatabaseLocation;
}
using (var transactionalStorage = configuration.CreateTransactionalStorage(storage, () => { }))
{
transactionalStorage.Restore(restoreRequest, output);
}
}
示例5: StorageExporter
public StorageExporter(string databaseBaseDirectory, string databaseOutputFile,int batchSize)
{
baseDirectory = databaseBaseDirectory;
outputDirectory = databaseOutputFile;
var ravenConfiguration = new RavenConfiguration();
ravenConfiguration.DataDirectory = databaseBaseDirectory;
ravenConfiguration.Storage.PreventSchemaUpdate = true;
CreateTransactionalStorage(ravenConfiguration);
BatchSize = batchSize;
}
示例6: StorageExporter
public StorageExporter(string databaseBaseDirectory, string databaseOutputFile,int batchSize,Etag documentsStartEtag)
{
baseDirectory = databaseBaseDirectory;
outputDirectory = databaseOutputFile;
var ravenConfiguration = new RavenConfiguration();
ravenConfiguration.DataDirectory = databaseBaseDirectory;
ravenConfiguration.Storage.PreventSchemaUpdate = true;
ravenConfiguration.Storage.SkipConsistencyCheck = true;
CreateTransactionalStorage(ravenConfiguration);
BatchSize = batchSize;
DocumentsStartEtag = documentsStartEtag;
}
示例7: TestServerFixture
public TestServerFixture()
{
var configuration = new RavenConfiguration();
configuration.Port = Port;
configuration.ServerName = ServerName;
configuration.RunInMemory = configuration.DefaultStorageTypeName == InMemoryRavenConfiguration.VoronTypeName;
configuration.DataDirectory = Path.Combine(configuration.DataDirectory, "Tests");
IOExtensions.DeleteDirectory(configuration.DataDirectory);
Server = new RavenDbServer(configuration)
{
UseEmbeddedHttpServer = true
}.Initialize();
}
示例8: ConvertToRavenConfiguration
public RavenConfiguration ConvertToRavenConfiguration()
{
var configuration = new RavenConfiguration
{
Port = Port,
RunInMemory = RunInMemory,
DefaultStorageTypeName = "esent"
};
foreach (var key in Settings.Keys)
{
configuration.Settings.Add(key, Settings[key]);
}
return configuration;
}
示例9: RespondToAdmin
public override void RespondToAdmin(IHttpContext context)
{
if (EnsureSystemDatabase(context) == false)
return;
var restoreRequest = context.ReadJsonObject<RestoreRequest>();
var ravenConfiguration = new RavenConfiguration();
if (File.Exists(Path.Combine(restoreRequest.RestoreLocation, "Raven.ravendb")))
{
ravenConfiguration.DefaultStorageTypeName = "Raven.Storage.Managed.TransactionalStorage, Raven.Storage.Managed";
}
else if (Directory.Exists(Path.Combine(restoreRequest.RestoreLocation, "new")))
{
ravenConfiguration.DefaultStorageTypeName = "Raven.Storage.Esent.TransactionalStorage, Raven.Storage.Esent";
}
var restoreStatus = new List<string>();
DocumentDatabase.Restore(ravenConfiguration, restoreRequest.RestoreLocation, restoreRequest.DatabaseLocation,
msg =>
{
restoreStatus.Add(msg);
SystemDatabase.Put(RestoreStatus.RavenRestoreStatusDocumentKey, null,
RavenJObject.FromObject(new {restoreStatus}), new RavenJObject(), null);
});
if (File.Exists(Path.Combine(restoreRequest.RestoreLocation, "Database.Document")))
{
var databaseDocumentText = File.ReadAllText(Path.Combine(restoreRequest.RestoreLocation, "Database.Document"));
var databaseDocument = RavenJObject.Parse(databaseDocumentText).JsonDeserialization<DatabaseDocument>();
if (databaseDocument == null)
return;
if (!string.IsNullOrWhiteSpace(restoreRequest.DatabaseLocation))
databaseDocument.Settings[Constants.RavenDataDir] = restoreRequest.DatabaseLocation;
if (!string.IsNullOrWhiteSpace(restoreRequest.DatabaseName))
databaseDocument.Id = "Raven/Databases/" + restoreRequest.DatabaseName;
SystemDatabase.Put(databaseDocument.Id, null, RavenJObject.FromObject(databaseDocument), new RavenJObject(), null);
restoreStatus.Add("The new database was created");
SystemDatabase.Put(RestoreStatus.RavenRestoreStatusDocumentKey, null,
RavenJObject.FromObject(new { restoreStatus }), new RavenJObject(), null);
}
}
示例10: GetNewServer
protected RavenDbServer GetNewServer(int port)
{
var dataDirectory = Path.Combine(NewDataPath(), "System");
var configuration = new RavenConfiguration
{
Port = port,
DataDirectory = dataDirectory,
AnonymousUserAccessMode = AnonymousUserAccessMode.Admin
};
configuration.RunInMemory = configuration.DefaultStorageTypeName == InMemoryRavenConfiguration.VoronTypeName;
var ravenDbServer = new RavenDbServer(configuration)
{
UseEmbeddedHttpServer = true
};
ravenDbServer.Initialize();
return ravenDbServer;
}
示例11: TestServerFixture
public TestServerFixture()
{
var configuration = new RavenConfiguration();
configuration.Port = Port;
configuration.ServerName = ServerName;
configuration.RunInMemory = configuration.DefaultStorageTypeName == InMemoryRavenConfiguration.VoronTypeName;
configuration.DataDirectory = Path.Combine(configuration.DataDirectory, "Tests");
configuration.MaxSecondsForTaskToWaitForDatabaseToLoad = 10;
IOExtensions.DeleteDirectory(configuration.DataDirectory);
NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(Port);
Server = new RavenDbServer(configuration)
{
UseEmbeddedHttpServer = true,
RunInMemory = true
}.Initialize();
}
示例12: StorageExporter
public StorageExporter(string databaseBaseDirectory, string databaseOutputFile,
int batchSize, Etag documentsStartEtag, bool hasCompression, EncryptionConfiguration encryption)
{
HasCompression = hasCompression;
Encryption = encryption;
baseDirectory = databaseBaseDirectory;
outputDirectory = databaseOutputFile;
var ravenConfiguration = new RavenConfiguration
{
DataDirectory = databaseBaseDirectory,
CacheDocumentsInMemory = false,
Storage =
{
PreventSchemaUpdate = true,
SkipConsistencyCheck = true,
}
};
CreateTransactionalStorage(ravenConfiguration);
this.batchSize = batchSize;
DocumentsStartEtag = documentsStartEtag;
}
示例13: RavenDB_1594
public RavenDB_1594()
{
path = NewDataPath();
Raven.Database.Extensions.IOExtensions.DeleteDirectory(path);
var config = new Raven.Database.Config.RavenConfiguration
{
Port = 8079,
RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
DataDirectory = path,
Settings = { { "Raven/ActiveBundles", "PeriodicBackup" } },
};
config.PostInit();
ravenDbServer = new RavenDbServer(config)
{
UseEmbeddedHttpServer = true
};
ravenDbServer.Initialize();
documentStore = new DocumentStore
{
Url = "http://localhost:8079"
};
documentStore.Initialize();
}
示例14: ModifyConfiguration
protected virtual void ModifyConfiguration(RavenConfiguration configuration)
{
}
示例15: GetNewServer
protected RavenDbServer GetNewServer(int port = 8079, string dataDirectory = "Data")
{
var ravenConfiguration = new RavenConfiguration
{
Port = port,
DataDirectory = dataDirectory,
RunInMemory = true,
AnonymousUserAccessMode = AnonymousUserAccessMode.All
};
ModifyConfiguration(ravenConfiguration);
if (ravenConfiguration.RunInMemory == false)
IOExtensions.DeleteDirectory(ravenConfiguration.DataDirectory);
NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);
var ravenDbServer = new RavenDbServer(ravenConfiguration);
try
{
using (var documentStore = new DocumentStore
{
Conventions =
{
FailoverBehavior = FailoverBehavior.FailImmediately
},
Url = "http://localhost:" + port
}.Initialize())
{
CreateDefaultIndexes(documentStore);
}
}
catch
{
ravenDbServer.Dispose();
throw;
}
return ravenDbServer;
}