예제 #1
0
 internal MPoolStats(Internal.MempStatStruct stats) {
     st = stats.st;
     ci = new CacheInfo(st.st_gbytes, st.st_bytes, (int)st.st_max_ncache);
     mempfiles = new List<MPoolFileStats>();
     foreach (Internal.MPoolFileStatStruct file in stats.files)
         mempfiles.Add(new MPoolFileStats(file));
 }
        /*
         * Confirm the fields/properties in the environment.
         * Those set by setting functions are not checked here.
         */
        public static void Confirm(XmlElement xmlElement,
		    DatabaseEnvironment env, bool compulsory,
		    bool logging, bool locking, bool mutex, bool mpool,
		    bool replication)
        {
            XmlElement childElem;
            CacheInfo cacheInfo = new CacheInfo(0, 0, 0);

            // Confirm environment configuration.
            Configuration.ConfirmBool(xmlElement, "AutoCommit",
                env.AutoCommit, compulsory);
            Configuration.ConfirmBool(xmlElement, "CDB_ALLDB",
                env.CDB_ALLDB, compulsory);
            Configuration.ConfirmBool(xmlElement, "Create",
                env.Create, compulsory);
            Configuration.ConfirmStringList(xmlElement, "DataDirs",
                env.DataDirs, compulsory);
            Configuration.ConfirmString(xmlElement, "ErrorPrefix",
                env.ErrorPrefix, compulsory);
            Configuration.ConfirmBool(xmlElement, "ForceFlush",
                env.ForceFlush, compulsory);
            Configuration.ConfirmBool(xmlElement, "FreeThreaded",
                env.FreeThreaded, compulsory);
            Configuration.ConfirmBool(xmlElement, "InitRegions",
                env.InitRegions, compulsory);
            Configuration.ConfirmString(xmlElement, "IntermediateDirMode",
                env.IntermediateDirMode, compulsory);
            Configuration.ConfirmBool(xmlElement, "Lockdown",
                env.Lockdown, compulsory);
            Configuration.ConfirmUint(xmlElement, "LockTimeout",
                env.LockTimeout, compulsory);
            Configuration.ConfirmUint(xmlElement, "MaxTransactions",
                env.MaxTransactions, compulsory);
            Configuration.ConfirmBool(xmlElement, "NoBuffer",
                env.NoBuffer, compulsory);
            Configuration.ConfirmBool(xmlElement, "NoLocking",
                env.NoLocking, compulsory);
            Configuration.ConfirmBool(xmlElement, "NoMMap",
                env.NoMMap, compulsory);
            Configuration.ConfirmBool(xmlElement, "NoPanic",
                env.NoPanic, compulsory);
            Configuration.ConfirmBool(xmlElement, "Overwrite",
                env.Overwrite, compulsory);
            Configuration.ConfirmBool(xmlElement, "Private",
                env.Private, compulsory);
            Configuration.ConfirmBool(xmlElement, "Register",
                env.Register, compulsory);
            Configuration.ConfirmBool(xmlElement, "RunFatalRecovery",
                env.RunFatalRecovery, compulsory);
            Configuration.ConfirmBool(xmlElement, "RunRecovery",
                env.RunRecovery, compulsory);
            Configuration.ConfirmBool(xmlElement, "SystemMemory",
                env.SystemMemory, compulsory);
            Configuration.ConfirmString(xmlElement, "TempDir",
                env.TempDir, compulsory);
            Configuration.ConfirmBool(xmlElement, "TimeNotGranted",
                env.TimeNotGranted, compulsory);
            Configuration.ConfirmBool(xmlElement, "TxnNoSync",
                env.TxnNoSync, compulsory);
            Configuration.ConfirmBool(xmlElement, "TxnNoWait",
                env.TxnNoWait, compulsory);
            Configuration.ConfirmBool(xmlElement, "TxnSnapshot",
                env.TxnSnapshot, compulsory);
            Configuration.ConfirmDateTime(xmlElement, "TxnTimestamp",
                env.TxnTimestamp, compulsory);
            Configuration.ConfirmBool(xmlElement, "TxnWriteNoSync",
                env.TxnWriteNoSync, compulsory);
            Configuration.ConfirmBool(xmlElement, "UseMVCC",
                env.UseMVCC, compulsory);
            Configuration.ConfirmBool(xmlElement, "UseCDB",
                env.UsingCDB, compulsory);
            Configuration.ConfirmBool(xmlElement, "UseLocking",
                env.UsingLocking, compulsory);
            Configuration.ConfirmBool(xmlElement, "UseLogging",
                env.UsingLogging, compulsory);
            Configuration.ConfirmBool(xmlElement, "UseMPool",
                env.UsingMPool, compulsory);
            Configuration.ConfirmBool(xmlElement, "UseReplication",
                env.UsingReplication, compulsory);
            Configuration.ConfirmBool(xmlElement, "UseTxns",
                env.UsingTxns, compulsory);
            env.Verbosity = new VerboseMessages();
            Configuration.ConfirmVerboseMessages(xmlElement,
                "Verbosity", env.Verbosity, compulsory);
            Configuration.ConfirmBool(xmlElement, "YieldCPU",
                env.YieldCPU, compulsory);

            /*
             * If the locking subsystem is set, check the
             * field/properties set in LockingConfig.
             */
            if (locking == true)
            {
                childElem = (XmlElement)XMLReader.GetNode(
                    xmlElement, "LockingConfig");
                Configuration.ConfirmByteMatrix(childElem,
                    "Conflicts", env.LockConflictMatrix,
                    compulsory);
                Configuration.ConfirmDeadlockPolicy(
                    childElem, "DeadlockResolution",
                    env.DeadlockResolution, compulsory);
                Configuration.ConfirmUint(childElem,
                    "Partitions", env.LockPartitions,
                    compulsory);
                Configuration.ConfirmUint(childElem,
                    "MaxLockers", env.MaxLockers, compulsory);
                Configuration.ConfirmUint(childElem,
                    "MaxLocks", env.MaxLocks, compulsory);
                Configuration.ConfirmUint(childElem,
                    "MaxObjects", env.MaxObjects, compulsory);
            }

            /*
             * If the locking subsystem is set, check the
             * field/properties set in LogConfig.
             */
            if (logging == true)
            {
                childElem = (XmlElement)XMLReader.GetNode(
                    xmlElement, "LogConfig");
                Configuration.ConfirmBool(childElem,
                    "AutoRemove", env.LogAutoRemove,
                    compulsory);
                Configuration.ConfirmUint(childElem,
                    "BufferSize", env.LogBufferSize,
                    compulsory);
                Configuration.ConfirmString(childElem,
                    "Dir", env.LogDir, compulsory);
                Configuration.ConfirmInt(childElem,
                    "FileMode", env.LogFileMode, compulsory);
                Configuration.ConfirmBool(childElem,
                    "ForceSync", env.LogForceSync, compulsory);
                Configuration.ConfirmBool(childElem,
                    "InMemory", env.LogInMemory, compulsory);
                Configuration.ConfirmBool(childElem,
                    "NoBuffer", env.LogNoBuffer, compulsory);
                Configuration.ConfirmUint(childElem,
                    "RegionSize", env.LogRegionSize,
                    compulsory);
                Configuration.ConfirmBool(childElem,
                    "ZeroOnCreate", env.LogZeroOnCreate,
                    compulsory);
                Configuration.ConfirmUint(childElem,
                    "MaxFileSize", env.MaxLogFileSize,
                    compulsory);
            }

            /*
             * If the locking subsystem is set, check the
             * field/properties set in MutexConfig.
             */
            if (mutex == true)
            {
                childElem = (XmlElement)XMLReader.GetNode(
                    xmlElement, "MutexConfig");
                Configuration.ConfirmUint(childElem,
                    "Alignment", env.MutexAlignment,
                    compulsory);
                Configuration.ConfirmUint(childElem,
                    "MaxMutexes", env.MaxMutexes, compulsory);
                try
                {
                    Configuration.ConfirmUint(childElem,
                        "Increment", env.MutexIncrement,
                        compulsory);
                }
                catch (AssertionException)
                {
                    Assert.AreEqual(0, env.MutexIncrement);
                }

                Configuration.ConfirmUint(childElem,
                    "NumTestAndSetSpins",
                    env.NumTestAndSetSpins, compulsory);
            }

            if (mpool == true)
            {
                childElem = (XmlElement)XMLReader.GetNode(
                    xmlElement, "MPoolConfig");
                Configuration.ConfirmCacheSize(childElem,
                    "CacheSize", env.CacheSize, compulsory);
                if (env.UsingMPool == false)
                    Configuration.ConfirmCacheSize(childElem,
                        "MaxCacheSize", env.MaxCacheSize, compulsory);
                Configuration.ConfirmInt(childElem,
                    "MaxOpenFiles", env.MaxOpenFiles, compulsory);
                Configuration.ConfirmMaxSequentialWrites(childElem,
                    "MaxSequentialWrites", env.SequentialWritePause,
                    env.MaxSequentialWrites, compulsory);
                Configuration.ConfirmUint(childElem,
                    "MMapSize", env.MMapSize, compulsory);
            }

            if (replication == true)
            {
                childElem = (XmlElement)XMLReader.GetNode(
                    xmlElement, "ReplicationConfig");
                Configuration.ConfirmUint(childElem,
                    "AckTimeout", env.RepAckTimeout, compulsory);
                Configuration.ConfirmBool(childElem,
                    "BulkTransfer", env.RepBulkTransfer, compulsory);
                Configuration.ConfirmUint(childElem,
                    "CheckpointDelay", env.RepCheckpointDelay, compulsory);
                Configuration.ConfirmUint(childElem,
                    "ConnectionRetry", env.RepConnectionRetry, compulsory);
                Configuration.ConfirmBool(childElem,
                    "DelayClientSync", env.RepDelayClientSync, compulsory);
                Configuration.ConfirmUint(childElem,
                    "ElectionRetry", env.RepElectionRetry, compulsory);
                Configuration.ConfirmUint(childElem,
                    "ElectionTimeout", env.RepElectionTimeout, compulsory);
                Configuration.ConfirmUint(childElem,
                    "FullElectionTimeout", env.RepFullElectionTimeout,compulsory);
                Configuration.ConfirmUint(childElem,
                    "HeartbeatMonitor", env.RepHeartbeatMonitor, compulsory);
                Configuration.ConfirmUint(childElem,
                    "HeartbeatSend", env.RepHeartbeatSend, compulsory);
                Configuration.ConfirmUint(childElem,
                    "LeaseTimeout", env.RepLeaseTimeout, compulsory);
                Configuration.ConfirmBool(childElem,
                    "AutoInit", env.RepAutoInit, compulsory);
                Configuration.ConfirmBool(childElem,
                    "NoBlocking", env.RepNoBlocking, compulsory);
                Configuration.ConfirmUint(childElem,
                    "NSites", env.RepNSites, compulsory);
                Configuration.ConfirmUint(childElem,
                    "Priority", env.RepPriority, compulsory);
                Configuration.ConfirmAckPolicy(childElem,
                    "RepMgrAckPolicy", env.RepMgrAckPolicy, compulsory);
                Configuration.ConfirmBool(childElem,
                    "Strict2Site", env.RepStrict2Site, compulsory);
                Configuration.ConfirmBool(childElem,
                    "UseMasterLeases", env.RepUseMasterLeases, compulsory);
            }
        }
예제 #3
0
        /*
         * If bytes in CacheSize is assigned, the bytes in cachesize
         * couldn't be the default one.
         */
        public static void ConfirmCacheSize(XmlElement xmlElem,
		    string name, CacheInfo cache, uint defaultCache,
		    bool compulsory)
        {
            uint bytes;
            uint gigabytes;
            int nCaches;
            XmlNode xmlNode;
            XmlNode xmlChildNode;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == true)
                throw new ConfigNotFoundException(name);
            else if (xmlNode != null)
            {
                if ((xmlChildNode = XMLReader.GetNode(
                    (XmlElement)xmlNode, "Bytes")) != null)
                {
                    bytes = defaultCache;
                    if ((xmlChildNode = XMLReader.GetNode(
                        (XmlElement)xmlNode, "Gigabytes")) != null)
                    {
                        gigabytes = uint.Parse(xmlChildNode.InnerText);
                        if ((xmlChildNode = XMLReader.GetNode(
                            (XmlElement)xmlNode, "NCaches")) != null)
                        {
                            nCaches = int.Parse(xmlChildNode.InnerText);
                            Assert.AreNotEqual(bytes, cache.Bytes);
                            Assert.AreEqual(gigabytes, cache.Gigabytes);
                            Assert.AreEqual(nCaches, cache.NCaches);
                        }
                    }
                }
            }
        }
예제 #4
0
        public static bool ConfigCacheInfo(XmlElement xmlElem,
		    string name, ref CacheInfo cacheSize, bool compulsory)
        {
            XmlNode xmlNode;
            XmlNode xmlChildNode;
            uint bytes;
            uint gigabytes;
            int nCaches;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == true)
                throw new ConfigNotFoundException(name);
            else if (xmlNode != null)
            {
                if ((xmlChildNode = XMLReader.GetNode(
                    (XmlElement)xmlNode, "Bytes")) != null)
                {
                    bytes = uint.Parse(xmlChildNode.InnerText);
                    if ((xmlChildNode = XMLReader.GetNode(
                         (XmlElement)xmlNode, "Gigabytes")) != null)
                    {
                        gigabytes = uint.Parse(xmlChildNode.InnerText);
                        if ((xmlChildNode = XMLReader.GetNode(
                            (XmlElement)xmlNode, "NCaches")) != null)
                        {
                            nCaches = int.Parse(xmlChildNode.InnerText);
                            cacheSize = new CacheInfo(gigabytes,bytes,nCaches);
                            return true;
                        }
                    }
                }
            }

            return false;
        }