本文整理汇总了C#中BerkeleyDB.DatabaseEnvironmentConfig类的典型用法代码示例。如果您正苦于以下问题:C# DatabaseEnvironmentConfig类的具体用法?C# DatabaseEnvironmentConfig怎么用?C# DatabaseEnvironmentConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseEnvironmentConfig类属于BerkeleyDB命名空间,在下文中一共展示了DatabaseEnvironmentConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCursorWithExplicitTxn
public void GetCursorWithExplicitTxn(string home,
string dbFile, bool ifConfig)
{
DatabaseEnvironmentConfig envConfig =
new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.UseTxns = true;
envConfig.UseMPool = true;
DatabaseEnvironment env = DatabaseEnvironment.Open(
home, envConfig);
Transaction openTxn = env.BeginTransaction();
RecnoDatabaseConfig dbConfig =
new RecnoDatabaseConfig();
dbConfig.Creation = CreatePolicy.IF_NEEDED;
dbConfig.Env = env;
RecnoDatabase db = RecnoDatabase.Open(dbFile,
dbConfig, openTxn);
openTxn.Commit();
Transaction cursorTxn = env.BeginTransaction();
RecnoCursor cursor;
if (ifConfig == false)
cursor = db.Cursor(cursorTxn);
else
cursor = db.Cursor(new CursorConfig(), cursorTxn);
cursor.Close();
cursorTxn.Commit();
db.Close();
env.Close();
}
示例2: GetCursorInBtreeDBInCDS
// Get a cursor in CDS.
public static void GetCursorInBtreeDBInCDS(
string home, string name,
CursorConfig cursorConfig,
out DatabaseEnvironment env, out BTreeDatabase db,
out BTreeCursor cursor)
{
string dbFileName = name + ".db";
// Open an environment.
DatabaseEnvironmentConfig envConfig =
new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.UseCDB = true;
envConfig.UseMPool = true;
env = DatabaseEnvironment.Open(home, envConfig);
/*
* Open an btree database. The underlying database
* should be opened with ReadUncommitted if the
* cursor's isolation degree will be set to be 1.
*/
BTreeDatabaseConfig dbConfig = new BTreeDatabaseConfig();
dbConfig.Creation = CreatePolicy.IF_NEEDED;
dbConfig.Env = env;
if (cursorConfig.IsolationDegree == Isolation.DEGREE_ONE)
dbConfig.ReadUncommitted = true;
db = BTreeDatabase.Open(dbFileName, dbConfig);
// Get a cursor in the transaction.
cursor = db.Cursor(cursorConfig);
}
示例3: SetUpEnvWithTxnAndLocking
public static void SetUpEnvWithTxnAndLocking(string envHome,
out DatabaseEnvironment env, out Transaction txn,
uint maxLock, uint maxLocker, uint maxObject, uint partition)
{
// Configure env and locking subsystem.
LockingConfig lkConfig = new LockingConfig();
/*
* If the maximum number of locks/lockers/objects
* is given, then the LockingConfig is set. Unless,
* it is not set to any value.
*/
if (maxLock != 0)
lkConfig.MaxLocks = maxLock;
if (maxLocker != 0)
lkConfig.MaxLockers = maxLocker;
if (maxObject != 0)
lkConfig.MaxObjects = maxObject;
if (partition != 0)
lkConfig.Partitions = partition;
DatabaseEnvironmentConfig envConfig =
new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.UseTxns = true;
envConfig.UseMPool = true;
envConfig.LockSystemCfg = lkConfig;
envConfig.UseLocking = true;
envConfig.NoLocking = false;
env = DatabaseEnvironment.Open(envHome, envConfig);
txn = env.BeginTransaction();
}
示例4: Logging
/*
* Open environment, database and write data into database.
* Generated log files are put under testHome.
*/
public void Logging(string home, string dbName,
out DatabaseEnvironment env, out RecnoDatabase recnoDB)
{
string dbFileName = dbName + ".db";
Configuration.ClearDir(home);
// Open environment with logging subsystem.
DatabaseEnvironmentConfig envConfig =
new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.UseLogging = true;
envConfig.LogSystemCfg = new LogConfig();
envConfig.LogSystemCfg.FileMode = 755;
envConfig.LogSystemCfg.ZeroOnCreate = true;
envConfig.UseMPool = true;
env = DatabaseEnvironment.Open(home, envConfig);
/*
* Open recno database, write 100000 records into
* the database and close it.
*/
RecnoDatabaseConfig recnoConfig =
new RecnoDatabaseConfig();
recnoConfig.Creation = CreatePolicy.IF_NEEDED;
recnoConfig.Env = env;
// The db needs mpool to open.
recnoConfig.NoMMap = false;
recnoDB = RecnoDatabase.Open(dbFileName,
recnoConfig);
for (int i = 0; i < 1000; i++)
recnoDB.Append(new DatabaseEntry(
ASCIIEncoding.ASCII.GetBytes("key")));
}
示例5: EnvConfigCase1
public void EnvConfigCase1(DatabaseEnvironmentConfig cfg)
{
cfg.Create = true;
cfg.UseTxns = true;
cfg.UseMPool = true;
cfg.UseLogging = true;
}
示例6: LockingEnvSetUp
public static void LockingEnvSetUp(string testHome,
string testName, out DatabaseEnvironment env,
uint maxLock, uint maxLocker, uint maxObject,
uint partition)
{
// Configure env and locking subsystem.
LockingConfig lkConfig = new LockingConfig();
/*
* If the maximum number of locks/lockers/objects
* is given, then the LockingConfig is set. Unless,
* it is not set to any value.
*/
if (maxLock != 0)
lkConfig.MaxLocks = maxLock;
if (maxLocker != 0)
lkConfig.MaxLockers = maxLocker;
if (maxObject != 0)
lkConfig.MaxObjects = maxObject;
if (partition != 0)
lkConfig.Partitions = partition;
DatabaseEnvironmentConfig envConfig =
new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.LockSystemCfg = lkConfig;
envConfig.UseLocking = true;
envConfig.ErrorPrefix = testName;
env = DatabaseEnvironment.Open(testHome, envConfig);
}
示例7: SetUpEnv
/*
* Set up environment.
*/
public static int SetUpEnv(string home, string data_dir)
{
DatabaseEnvironment env;
DatabaseEnvironmentConfig envConfig;
/* Configure an environment. */
envConfig = new DatabaseEnvironmentConfig();
envConfig.MPoolSystemCfg = new MPoolConfig();
envConfig.MPoolSystemCfg.CacheSize = new CacheInfo(
0, 64 * 1024, 1);
envConfig.Create = true;
envConfig.DataDirs.Add(data_dir);
envConfig.CreationDir = data_dir;
envConfig.ErrorPrefix = progName;
envConfig.UseLogging = true;
envConfig.UseLocking = true;
envConfig.UseMPool = true;
envConfig.UseTxns = true;
/* Create and open the environment. */
try {
env = DatabaseEnvironment.Open(home, envConfig);
} catch (Exception e) {
Console.WriteLine("{0}", e.Message);
return EXIT_FAILURE;
}
Console.ReadLine();
env.Close();
return EXIT_SUCCESS;
}
示例8: GetCursorWithImplicitTxn
public void GetCursorWithImplicitTxn(string home,
string dbFile, bool ifConfig)
{
DatabaseEnvironmentConfig envConfig =
new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.UseCDB = true;
envConfig.UseMPool = true;
DatabaseEnvironment env = DatabaseEnvironment.Open(
home, envConfig);
RecnoDatabaseConfig dbConfig =
new RecnoDatabaseConfig();
dbConfig.Creation = CreatePolicy.IF_NEEDED;
dbConfig.Env = env;
RecnoDatabase db = RecnoDatabase.Open(dbFile,
dbConfig);
RecnoCursor cursor;
if (ifConfig == false)
cursor = db.Cursor();
else
cursor = db.Cursor(new CursorConfig());
cursor.Close();
db.Close();
env.Close();
}
示例9: Open
public static RepQuoteEnvironment Open(string home, DatabaseEnvironmentConfig cfg)
{
RepQuoteEnvironment dbEnv = new RepQuoteEnvironment();
dbEnv.env = DatabaseEnvironment.Open(home, cfg);
dbEnv._appFinished = false;
dbEnv._inClientSync = false;
dbEnv._isMaster = false;
return dbEnv;
}
示例10: SetUpEnv
public DatabaseEnvironment SetUpEnv(String home, uint priority, uint port, bool isMaster)
{
try {
Configuration.ClearDir(home);
} catch (Exception e) {
Console.WriteLine(e.Message);
throw new TestException("Please clean the directory");
}
/* Configure and open environment with replication
* application.
*/
DatabaseEnvironmentConfig cfg =
new DatabaseEnvironmentConfig();
cfg.UseReplication = true;
cfg.MPoolSystemCfg = new MPoolConfig();
cfg.MPoolSystemCfg.CacheSize =
new CacheInfo(0, 20485760, 1);
cfg.UseLocking = true;
cfg.UseTxns = true;
cfg.UseMPool = true;
cfg.Create = true;
cfg.UseLogging = true;
cfg.RunRecovery = true;
cfg.TxnNoSync = true;
cfg.FreeThreaded = true;
cfg.RepSystemCfg = new ReplicationConfig();
DbSiteConfig dbSiteConfig = new DbSiteConfig();
dbSiteConfig.Host = ip;
dbSiteConfig.Port = port;
dbSiteConfig.LocalSite = true;
cfg.RepSystemCfg.RepmgrSitesConfig.Add(dbSiteConfig);
cfg.RepSystemCfg.Priority = priority;
if (!isMaster) {
DbSiteConfig dbSiteConfig1 = new DbSiteConfig();
dbSiteConfig1.Host = ip;
dbSiteConfig1.Port = masterPort;
dbSiteConfig1.Helper = true;
cfg.RepSystemCfg.RepmgrSitesConfig.Add(dbSiteConfig1);
}
cfg.RepSystemCfg.BulkTransfer = false;
cfg.RepSystemCfg.AckTimeout = 5000;
cfg.RepSystemCfg.RepMgrAckPolicy =
AckPolicy.ALL_PEERS;
DatabaseEnvironment env = DatabaseEnvironment.Open(
home, cfg);
return env;
}
示例11: GetSecondaryCursurWithTxn
public void GetSecondaryCursurWithTxn(string home,
string name, bool ifCfg)
{
string dbFileName = name + ".db";
SecondaryCursor cursor;
// Open env.
DatabaseEnvironmentConfig envConfig =
new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.UseTxns = true;
envConfig.UseMPool = true;
DatabaseEnvironment env = DatabaseEnvironment.Open(home,
envConfig);
// Open primary/secondary database.
Transaction txn = env.BeginTransaction();
BTreeDatabaseConfig dbConfig = new BTreeDatabaseConfig();
dbConfig.Creation = CreatePolicy.IF_NEEDED;
dbConfig.Env = env;
BTreeDatabase db = BTreeDatabase.Open(dbFileName,
dbConfig, txn);
SecondaryBTreeDatabaseConfig secDBConfig = new
SecondaryBTreeDatabaseConfig(db,
new SecondaryKeyGenDelegate(SecondaryKeyGen));
secDBConfig.Env = env;
SecondaryBTreeDatabase secDB =
SecondaryBTreeDatabase.Open(dbFileName,
secDBConfig, txn);
for (int i = 0; i < 10; i++)
db.Put(new DatabaseEntry(BitConverter.GetBytes(i)),
new DatabaseEntry(BitConverter.GetBytes((int)i)), txn);
// Create secondary cursor.
if (ifCfg == false)
secDB.SecondaryCursor(txn);
else if (ifCfg == true)
{
CursorConfig cursorConfig = new CursorConfig();
cursorConfig.WriteCursor = false;
cursor = secDB.SecondaryCursor(cursorConfig, txn);
cursor.Close();
}
secDB.Close();
db.Close();
txn.Commit();
env.Close();
}
示例12: DBInit
/*
* Create and open environment and database.
*/
public static int DBInit(out DatabaseEnvironment env,
string home, string progName, uint maxLock,
uint doUnLink)
{
DatabaseEnvironmentConfig envConfig;
LockingConfig lkConfig;
/* Configure locking subsystem. */
lkConfig = new LockingConfig();
lkConfig.MaxLocks = maxLock;
/* Configure environment. */
envConfig = new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.ErrorPrefix = progName;
envConfig.LockSystemCfg = lkConfig;
envConfig.UseLocking = true;
/*
* Optionally remove the environment region and
* open the environment.
*/
try {
if (doUnLink == 1)
DatabaseEnvironment.Remove(home, true);
env = DatabaseEnvironment.Open(home, envConfig);
} catch (Exception e) {
Console.WriteLine("{0}:{1}\n{2}",
e.Source, e.Message, e.StackTrace);
env = null;
return EXIT_FAILURE;
}
/*
try
{
env = DatabaseEnvironment.Open(home, envConfig);
}
catch(Exception e)
{
Console.WriteLine("{0}:{1}\n{2}",
e.Source, e.Message, e.StackTrace);
env = null;
return ExConstants.EXIT_FAILURE;
}
*/
return EXIT_SUCCESS;
}
示例13: TestGetAndFreeMutex
public void TestGetAndFreeMutex()
{
testName = "TestGetAndFreeMutex";
SetUpTest(true);
DatabaseEnvironmentConfig envConfig =
new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.UseMPool = true;
DatabaseEnvironment env = DatabaseEnvironment.Open(
testHome, envConfig);
BerkeleyDB.Mutex mutex = env.GetMutex(true, true);
mutex.Dispose();
env.Close();
}
示例14: TestGetAndFreeMutex
public void TestGetAndFreeMutex()
{
testName = "TestGetAndFreeMutex";
testHome = testFixtureHome + "/" + testName;
Configuration.ClearDir(testHome);
DatabaseEnvironmentConfig envConfig =
new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.UseMPool = true;
DatabaseEnvironment env = DatabaseEnvironment.Open(
testHome, envConfig);
BerkeleyDB.Mutex mutex = env.GetMutex(true, true);
mutex.Dispose();
env.Close();
}
示例15: OpenNewSequenceInEnv
public void OpenNewSequenceInEnv(string home, string dbname,
out DatabaseEnvironment env, out BTreeDatabase db,
out Sequence seq)
{
DatabaseEnvironmentConfig envConfig =
new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.UseTxns = true;
envConfig.UseMPool = true;
envConfig.UseLogging = true;
env = DatabaseEnvironment.Open(home, envConfig);
Transaction openTxn = env.BeginTransaction();
BTreeDatabaseConfig dbConfig =
new BTreeDatabaseConfig();
dbConfig.Creation = CreatePolicy.IF_NEEDED;
dbConfig.Env = env;
db = BTreeDatabase.Open(dbname + ".db", dbConfig,
openTxn);
openTxn.Commit();
Transaction seqTxn = env.BeginTransaction();
SequenceConfig seqConfig = new SequenceConfig();
seqConfig.BackingDatabase = db;
seqConfig.Creation = CreatePolicy.ALWAYS;
seqConfig.Decrement = false;
seqConfig.FreeThreaded = true;
seqConfig.Increment = true;
seqConfig.InitialValue = 0;
seqConfig.key = new DatabaseEntry(
ASCIIEncoding.ASCII.GetBytes("key"));
seqConfig.SetRange(Int64.MinValue, Int64.MaxValue);
seqConfig.Wrap = true;
seq = new Sequence(seqConfig);
seqTxn.Commit();
}