当前位置: 首页>>代码示例>>C#>>正文


C# BerkeleyDB.DatabaseEnvironmentConfig类代码示例

本文整理汇总了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();
        }
开发者ID:gildafnai82,项目名称:craq,代码行数:31,代码来源:RecnoCursorTest.cs

示例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);
        }
开发者ID:kanbang,项目名称:Colt,代码行数:34,代码来源:CursorTest.cs

示例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();
        }
开发者ID:jamiekeefer,项目名称:gldcoin,代码行数:32,代码来源:TransactionTest.cs

示例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")));
        }
开发者ID:simonzhangsm,项目名称:h-store,代码行数:38,代码来源:LogCursorTest.cs

示例5: EnvConfigCase1

 public void EnvConfigCase1(DatabaseEnvironmentConfig cfg)
 {
     cfg.Create = true;
     cfg.UseTxns = true;
     cfg.UseMPool = true;
     cfg.UseLogging = true;
 }
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:7,代码来源:HeapDatabaseTest.cs

示例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);
        }
开发者ID:mania25,项目名称:diy-project,代码行数:30,代码来源:LockTest.cs

示例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;
        }
开发者ID:simonzhangsm,项目名称:h-store,代码行数:34,代码来源:excs_env.cs

示例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();
        }
开发者ID:gildafnai82,项目名称:craq,代码行数:28,代码来源:RecnoCursorTest.cs

示例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;
 }
开发者ID:kanbang,项目名称:Colt,代码行数:9,代码来源:RepQuoteEnvironment.cs

示例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;
        }
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:52,代码来源:TransactionCommitTokenTest.cs

示例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();
        }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:51,代码来源:SecondaryDatabaseTest.cs

示例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;
        }
开发者ID:simonzhangsm,项目名称:h-store,代码行数:52,代码来源:excs_lock.cs

示例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();
        }
开发者ID:sukantoguha,项目名称:INET-Vagrant-Demos,代码行数:15,代码来源:MutexTest.cs

示例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();
        }
开发者ID:kanbang,项目名称:Colt,代码行数:16,代码来源:MutexTest.cs

示例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();
        }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:36,代码来源:SequenceTest.cs


注:本文中的BerkeleyDB.DatabaseEnvironmentConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。