public static extern int DB_ENV_rep_set_view(HandleRef jarg1, BDB_ReplicationViewDelegate jarg2);
        private void Config(DatabaseEnvironmentConfig cfg)
        {
            //Alpha by dbenv function call
            foreach (string dirname in cfg.DataDirs)
                dbenv.add_data_dir(dirname);
            if (cfg.BlobDir != null)
                dbenv.set_blob_dir(cfg.BlobDir);
            if (cfg.blobThresholdIsSet)
                dbenv.set_blob_threshold(cfg.BlobThreshold, 0);
            if (cfg.CreationDir != null)
                dbenv.set_create_dir(cfg.CreationDir);
            if (cfg.encryptionIsSet)
                dbenv.set_encrypt(
                    cfg.EncryptionPassword, (uint)cfg.EncryptAlgorithm);
            if (cfg.MetadataDir != null)
                dbenv.set_metadata_dir(cfg.MetadataDir);
            if (cfg.ErrorFeedback != null)
                ErrorFeedback = cfg.ErrorFeedback;
            ErrorPrefix = cfg.ErrorPrefix;
            if (cfg.EventNotify != null)
                EventNotify = cfg.EventNotify;
            if (cfg.Feedback != null)
                Feedback = cfg.Feedback;
            if (cfg.IntermediateDirMode != null)
                IntermediateDirMode = cfg.IntermediateDirMode;
            if (cfg.ThreadIsAlive != null)
                ThreadIsAlive = cfg.ThreadIsAlive;
            if (cfg.threadCntIsSet)
                ThreadCount = cfg.ThreadCount;
            if (cfg.SetThreadID != null)
                SetThreadID = cfg.SetThreadID;
            if (cfg.ThreadName != null)
                threadNameHandler = cfg.ThreadName;
            if (cfg.lckTimeoutIsSet)
                LockTimeout = cfg.LockTimeout;
            if (cfg.txnTimeoutIsSet)
                TxnTimeout = cfg.TxnTimeout;
            if (cfg.TempDir != null)
                TempDir = cfg.TempDir;
            if (cfg.maxTxnsIsSet)
                MaxTransactions = cfg.MaxTransactions;
            if (cfg.txnTimestampIsSet)
                TxnTimestamp = cfg.TxnTimestamp;
            if (cfg.Verbosity != null)
                Verbosity = cfg.Verbosity;
            if (cfg.flags != 0)
                dbenv.set_flags(cfg.flags, 1);
            if (cfg.initThreadCountIsSet)
                InitThreadCount = cfg.InitThreadCount;
            if (cfg.initTxnCountIsSet)
                InitTxnCount = cfg.InitTxnCount;

            if (cfg.LockSystemCfg != null) {
                if (cfg.LockSystemCfg.Conflicts != null)
                    LockConflictMatrix = cfg.LockSystemCfg.Conflicts;
                if (cfg.LockSystemCfg.DeadlockResolution != null)
                    DeadlockResolution = cfg.LockSystemCfg.DeadlockResolution;
                if (cfg.LockSystemCfg.initLockerCountIsSet)
                    InitLockerCount = cfg.LockSystemCfg.InitLockerCount;
                if (cfg.LockSystemCfg.initLockCountIsSet)
                    InitLockCount = cfg.LockSystemCfg.InitLockCount;
                if (cfg.LockSystemCfg.initLockObjectCountIsSet)
                    InitLockObjectCount = cfg.LockSystemCfg.InitLockObjectCount;
                if (cfg.LockSystemCfg.maxLockersIsSet)
                    MaxLockers = cfg.LockSystemCfg.MaxLockers;
                if (cfg.LockSystemCfg.maxLocksIsSet)
                    MaxLocks = cfg.LockSystemCfg.MaxLocks;
                if (cfg.LockSystemCfg.maxObjectsIsSet)
                    MaxObjects = cfg.LockSystemCfg.MaxObjects;
                if (cfg.LockSystemCfg.partitionsIsSet)
                    LockPartitions = cfg.LockSystemCfg.Partitions;
                if (cfg.LockSystemCfg.tablesizeIsSet)
                    LockTableSize = cfg.LockSystemCfg.TableSize;
            }

            if (cfg.LogSystemCfg != null) {
                if (cfg.LogSystemCfg.bsizeIsSet)
                    LogBufferSize = cfg.LogSystemCfg.BufferSize;
                if (cfg.LogSystemCfg.Dir != null)
                    LogDir = cfg.LogSystemCfg.Dir;
                if (cfg.LogSystemCfg.initLogIdCountIsSet)
                    InitLogIdCount = cfg.LogSystemCfg.InitLogIdCount;
                if (cfg.LogSystemCfg.modeIsSet)
                    LogFileMode = cfg.LogSystemCfg.FileMode;
                if (cfg.LogSystemCfg.maxSizeIsSet)
                    MaxLogFileSize = cfg.LogSystemCfg.MaxFileSize;
                if (cfg.LogSystemCfg.regionSizeIsSet)
                    LogRegionSize = cfg.LogSystemCfg.RegionSize;
                if (cfg.LogSystemCfg.ConfigFlags != 0)
                    dbenv.log_set_config(cfg.LogSystemCfg.ConfigFlags, 1);
            }

            if (cfg.MPoolSystemCfg != null) {
                if (cfg.MPoolSystemCfg.CacheSize != null)
                    CacheSize = cfg.MPoolSystemCfg.CacheSize;
                if (cfg.MPoolSystemCfg.MaxCacheSize != null)
                    MaxCacheSize = cfg.MPoolSystemCfg.MaxCacheSize;
                if (cfg.MPoolSystemCfg.maxOpenFDIsSet)
                    MaxOpenFiles = cfg.MPoolSystemCfg.MaxOpenFiles;
                if (cfg.MPoolSystemCfg.maxSeqWriteIsSet)
                    SetMaxSequentialWrites(
                        cfg.MPoolSystemCfg.MaxSequentialWrites,
                        cfg.MPoolSystemCfg.SequentialWritePause);
                if (cfg.MPoolSystemCfg.mmapSizeSet)
                    MMapSize = cfg.MPoolSystemCfg.MMapSize;
            }

            if (cfg.MutexSystemCfg != null) {
                if (cfg.MutexSystemCfg.alignmentIsSet)
                    MutexAlignment = cfg.MutexSystemCfg.Alignment;
                /*
                 * Setting max after increment ensures that the value of max
                 * will win if both max and increment are set.  This is the
                 * behavior we document in MutexConfig.
                 */
                if (cfg.MutexSystemCfg.incrementIsSet)
                    MutexIncrement = cfg.MutexSystemCfg.Increment;
                if (cfg.MutexSystemCfg.initMutexesIsSet)
                    InitMutexes = cfg.MutexSystemCfg.InitMutexes;
                if (cfg.MutexSystemCfg.maxMutexesIsSet)
                    MaxMutexes = cfg.MutexSystemCfg.MaxMutexes;
                if (cfg.MutexSystemCfg.numTASIsSet)
                    NumTestAndSetSpins = cfg.MutexSystemCfg.NumTestAndSetSpins;
            }

            if (cfg.RepSystemCfg != null) {
                if (cfg.RepSystemCfg.ackTimeoutIsSet)
                    RepAckTimeout = cfg.RepSystemCfg.AckTimeout;
                if (cfg.RepSystemCfg.BulkTransfer)
                    RepBulkTransfer = true;
                if (cfg.RepSystemCfg.checkpointDelayIsSet)
                    RepCheckpointDelay = cfg.RepSystemCfg.CheckpointDelay;
                if (cfg.RepSystemCfg.clockskewIsSet)
                    RepSetClockskew(cfg.RepSystemCfg.ClockskewFast,
                        cfg.RepSystemCfg.ClockskewSlow);
                if (cfg.RepSystemCfg.connectionRetryIsSet)
                    RepConnectionRetry = cfg.RepSystemCfg.ConnectionRetry;
                if (cfg.RepSystemCfg.DelayClientSync)
                    RepDelayClientSync = true;
                if (cfg.RepSystemCfg.electionRetryIsSet)
                    RepElectionRetry = cfg.RepSystemCfg.ElectionRetry;
                if (cfg.RepSystemCfg.electionTimeoutIsSet)
                    RepElectionTimeout = cfg.RepSystemCfg.ElectionTimeout;
                if (cfg.RepSystemCfg.fullElectionTimeoutIsSet)
                    RepFullElectionTimeout =
                        cfg.RepSystemCfg.FullElectionTimeout;
                if (cfg.RepSystemCfg.heartbeatMonitorIsSet)
                    RepHeartbeatMonitor = cfg.RepSystemCfg.HeartbeatMonitor;
                if (cfg.RepSystemCfg.heartbeatSendIsSet)
                    RepHeartbeatSend = cfg.RepSystemCfg.HeartbeatSend;
                if (cfg.RepSystemCfg.InMemory)
                    dbenv.rep_set_config(DbConstants.DB_REP_CONF_INMEM, 1);
                if (cfg.RepSystemCfg.leaseTimeoutIsSet)
                    RepLeaseTimeout = cfg.RepSystemCfg.LeaseTimeout;
                if (!cfg.RepSystemCfg.AutoInit)
                    RepAutoInit = false;
                if (cfg.RepSystemCfg.NoBlocking)
                    RepNoBlocking = true;
                if (cfg.RepSystemCfg.nsitesIsSet)
                    RepNSites = cfg.RepSystemCfg.NSites;
                for (int i = 0; i < cfg.RepSystemCfg.RepmgrSitesConfig.Count; i++)
                    RepMgrSiteConfig(cfg.RepSystemCfg.RepmgrSitesConfig[i]);
                if (cfg.RepSystemCfg.repViewIsSet) {
                    ReplicationView = cfg.RepSystemCfg.ReplicationView;
                    if (ReplicationView == null)
                        doRepViewRef = null;
                    else
                        doRepViewRef = new BDB_ReplicationViewDelegate(doRepView);
                    dbenv.rep_set_view(doRepViewRef);
                }
                if (cfg.RepSystemCfg.priorityIsSet)
                    RepPriority = cfg.RepSystemCfg.Priority;
                if (cfg.RepSystemCfg.RepMgrAckPolicy != null)
                    RepMgrAckPolicy = cfg.RepSystemCfg.RepMgrAckPolicy;
                if (cfg.RepSystemCfg.retransmissionRequestIsSet)
                    RepSetRetransmissionRequest(
                        cfg.RepSystemCfg.RetransmissionRequestMin,
                        cfg.RepSystemCfg.RetransmissionRequestMax);
                if (cfg.RepSystemCfg.Strict2Site)
                    RepStrict2Site = true;
                if (cfg.RepSystemCfg.transmitLimitIsSet)
                    RepSetTransmitLimit(
                        cfg.RepSystemCfg.TransmitLimitGBytes,
                        cfg.RepSystemCfg.TransmitLimitBytes);
                if (cfg.RepSystemCfg.repmgrIncomingQueueMaxIsSet)
                    RepmgrSetIncomingQueueMax(
                        cfg.RepSystemCfg.RepmgrIncomingQueueMaxGBytes,
                        cfg.RepSystemCfg.RepmgrIncomingQueueMaxBytes);
                if (cfg.RepSystemCfg.UseMasterLeases)
                    RepUseMasterLeases = true;
                if (!cfg.RepSystemCfg.Elections)
                    RepMgrRunElections = false;
                if (cfg.RepSystemCfg.PrefmasMaster)
                    RepPrefmasMaster = true;
                if (cfg.RepSystemCfg.PrefmasClient)
                    RepPrefmasClient = true;
            }
        }
Beispiel #3
0
 internal int rep_set_view(BDB_ReplicationViewDelegate f_repview)
 {
     int ret;
     ret = libdb_csharpPINVOKE.DB_ENV_rep_set_view(swigCPtr, f_repview);
     DatabaseException.ThrowException(ret);
     return ret;
 }