Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal CacheConfiguration(IBinaryRawReader reader)
        {
            AtomicityMode        = (CacheAtomicityMode)reader.ReadInt();
            AtomicWriteOrderMode = (CacheAtomicWriteOrderMode)reader.ReadInt();
            Backups           = reader.ReadInt();
            CacheMode         = (CacheMode)reader.ReadInt();
            CopyOnRead        = reader.ReadBoolean();
            EagerTtl          = reader.ReadBoolean();
            EnableSwap        = reader.ReadBoolean();
            EvictSynchronized = reader.ReadBoolean();
            EvictSynchronizedConcurrencyLevel = reader.ReadInt();
            EvictSynchronizedKeyBufferSize    = reader.ReadInt();
            EvictSynchronizedTimeout          = reader.ReadLongAsTimespan();
            Invalidate                   = reader.ReadBoolean();
            KeepBinaryInStore            = reader.ReadBoolean();
            LoadPreviousValue            = reader.ReadBoolean();
            LockTimeout                  = reader.ReadLongAsTimespan();
            LongQueryWarningTimeout      = reader.ReadLongAsTimespan();
            MaxConcurrentAsyncOperations = reader.ReadInt();
            MaxEvictionOverflowRatio     = reader.ReadFloat();
            MemoryMode                   = (CacheMemoryMode)reader.ReadInt();
            Name                        = reader.ReadString();
            OffHeapMaxMemory            = reader.ReadLong();
            ReadFromBackup              = reader.ReadBoolean();
            RebalanceBatchSize          = reader.ReadInt();
            RebalanceDelay              = reader.ReadLongAsTimespan();
            RebalanceMode               = (CacheRebalanceMode)reader.ReadInt();
            RebalanceThrottle           = reader.ReadLongAsTimespan();
            RebalanceTimeout            = reader.ReadLongAsTimespan();
            SqlEscapeAll                = reader.ReadBoolean();
            SqlOnheapRowCacheSize       = reader.ReadInt();
            StartSize                   = reader.ReadInt();
            WriteBehindBatchSize        = reader.ReadInt();
            WriteBehindEnabled          = reader.ReadBoolean();
            WriteBehindFlushFrequency   = reader.ReadLongAsTimespan();
            WriteBehindFlushSize        = reader.ReadInt();
            WriteBehindFlushThreadCount = reader.ReadInt();
            WriteSynchronizationMode    = (CacheWriteSynchronizationMode)reader.ReadInt();
            ReadThrough                 = reader.ReadBoolean();
            WriteThrough                = reader.ReadBoolean();
            EnableStatistics            = reader.ReadBoolean();
            CacheStoreFactory           = reader.ReadObject <IFactory <ICacheStore> >();

            var count = reader.ReadInt();

            QueryEntities = count == 0 ? null : Enumerable.Range(0, count).Select(x => new QueryEntity(reader)).ToList();

            NearConfiguration = reader.ReadBoolean() ? new NearCacheConfiguration(reader) : null;

            EvictionPolicy      = EvictionPolicyBase.Read(reader);
            AffinityFunction    = AffinityFunctionSerializer.Read(reader);
            ExpiryPolicyFactory = ExpiryPolicySerializer.ReadPolicyFactory(reader);

            count = reader.ReadInt();
            PluginConfigurations = count == 0
                ? null
                : Enumerable.Range(0, count).Select(x => reader.ReadObject <ICachePluginConfiguration>()).ToList();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal CacheConfiguration(IBinaryRawReader reader)
        {
            // Make sure system marshaller is used.
            Debug.Assert(((BinaryReader)reader).Marshaller == BinaryUtils.Marshaller);

            AtomicityMode     = (CacheAtomicityMode)reader.ReadInt();
            Backups           = reader.ReadInt();
            CacheMode         = (CacheMode)reader.ReadInt();
            CopyOnRead        = reader.ReadBoolean();
            EagerTtl          = reader.ReadBoolean();
            Invalidate        = reader.ReadBoolean();
            KeepBinaryInStore = reader.ReadBoolean();
            LoadPreviousValue = reader.ReadBoolean();
            LockTimeout       = reader.ReadLongAsTimespan();
#pragma warning disable 618
            LongQueryWarningTimeout = reader.ReadLongAsTimespan();
#pragma warning restore 618
            MaxConcurrentAsyncOperations = reader.ReadInt();
            Name                        = reader.ReadString();
            ReadFromBackup              = reader.ReadBoolean();
            RebalanceBatchSize          = reader.ReadInt();
            RebalanceDelay              = reader.ReadLongAsTimespan();
            RebalanceMode               = (CacheRebalanceMode)reader.ReadInt();
            RebalanceThrottle           = reader.ReadLongAsTimespan();
            RebalanceTimeout            = reader.ReadLongAsTimespan();
            SqlEscapeAll                = reader.ReadBoolean();
            WriteBehindBatchSize        = reader.ReadInt();
            WriteBehindEnabled          = reader.ReadBoolean();
            WriteBehindFlushFrequency   = reader.ReadLongAsTimespan();
            WriteBehindFlushSize        = reader.ReadInt();
            WriteBehindFlushThreadCount = reader.ReadInt();
            WriteBehindCoalescing       = reader.ReadBoolean();
            WriteSynchronizationMode    = (CacheWriteSynchronizationMode)reader.ReadInt();
            ReadThrough                 = reader.ReadBoolean();
            WriteThrough                = reader.ReadBoolean();
            EnableStatistics            = reader.ReadBoolean();
            MemoryPolicyName            = reader.ReadString();
            PartitionLossPolicy         = (PartitionLossPolicy)reader.ReadInt();
            GroupName                   = reader.ReadString();
            CacheStoreFactory           = reader.ReadObject <IFactory <ICacheStore> >();

            var count = reader.ReadInt();
            QueryEntities = count == 0 ? null : Enumerable.Range(0, count).Select(x => new QueryEntity(reader)).ToList();

            NearConfiguration = reader.ReadBoolean() ? new NearCacheConfiguration(reader) : null;

            EvictionPolicy      = EvictionPolicyBase.Read(reader);
            AffinityFunction    = AffinityFunctionSerializer.Read(reader);
            ExpiryPolicyFactory = ExpiryPolicySerializer.ReadPolicyFactory(reader);

            count = reader.ReadInt();
            PluginConfigurations = count == 0
                ? null
                : Enumerable.Range(0, count).Select(x => reader.ReadObject <ICachePluginConfiguration>()).ToList();
        }
        /// <summary>
        /// Reads the config.
        /// </summary>
        public static void Read(IBinaryStream stream, CacheClientConfiguration cfg, ClientFeatures features)
        {
            Debug.Assert(stream != null);

            // Configuration should be read with system marshaller.
            var reader = BinaryUtils.Marshaller.StartUnmarshal(stream);

            var len = reader.ReadInt();
            var pos = reader.Stream.Position;

            cfg.AtomicityMode                = (CacheAtomicityMode)reader.ReadInt();
            cfg.Backups                      = reader.ReadInt();
            cfg.CacheMode                    = (CacheMode)reader.ReadInt();
            cfg.CopyOnRead                   = reader.ReadBoolean();
            cfg.DataRegionName               = reader.ReadString();
            cfg.EagerTtl                     = reader.ReadBoolean();
            cfg.EnableStatistics             = reader.ReadBoolean();
            cfg.GroupName                    = reader.ReadString();
            cfg.LockTimeout                  = reader.ReadLongAsTimespan();
            cfg.MaxConcurrentAsyncOperations = reader.ReadInt();
            cfg.MaxQueryIteratorsCount       = reader.ReadInt();
            cfg.Name = reader.ReadString();
            cfg.OnheapCacheEnabled            = reader.ReadBoolean();
            cfg.PartitionLossPolicy           = (PartitionLossPolicy)reader.ReadInt();
            cfg.QueryDetailMetricsSize        = reader.ReadInt();
            cfg.QueryParallelism              = reader.ReadInt();
            cfg.ReadFromBackup                = reader.ReadBoolean();
            cfg.RebalanceBatchSize            = reader.ReadInt();
            cfg.RebalanceBatchesPrefetchCount = reader.ReadLong();
            cfg.RebalanceDelay                = reader.ReadLongAsTimespan();
            cfg.RebalanceMode            = (CacheRebalanceMode)reader.ReadInt();
            cfg.RebalanceOrder           = reader.ReadInt();
            cfg.RebalanceThrottle        = reader.ReadLongAsTimespan();
            cfg.RebalanceTimeout         = reader.ReadLongAsTimespan();
            cfg.SqlEscapeAll             = reader.ReadBoolean();
            cfg.SqlIndexMaxInlineSize    = reader.ReadInt();
            cfg.SqlSchema                = reader.ReadString();
            cfg.WriteSynchronizationMode = (CacheWriteSynchronizationMode)reader.ReadInt();
            cfg.KeyConfiguration         = reader.ReadCollectionRaw(r => new CacheKeyConfiguration(r));
            cfg.QueryEntities            = reader.ReadCollectionRaw(r => ReadQueryEntity(r, features));

            if (features.HasCacheConfigurationExpiryPolicyFactory())
            {
                cfg.ExpiryPolicyFactory = ExpiryPolicySerializer.ReadPolicyFactory(reader);
            }

            Debug.Assert(len == reader.Stream.Position - pos);
        }
        /// <summary>
        /// Reads data into this instance from the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        private void Read(BinaryReader reader)
        {
            // Make sure system marshaller is used.
            Debug.Assert(reader.Marshaller == BinaryUtils.Marshaller);

            AtomicityMode     = (CacheAtomicityMode)reader.ReadInt();
            Backups           = reader.ReadInt();
            CacheMode         = (CacheMode)reader.ReadInt();
            CopyOnRead        = reader.ReadBoolean();
            EagerTtl          = reader.ReadBoolean();
            Invalidate        = reader.ReadBoolean();
            KeepBinaryInStore = reader.ReadBoolean();
            LoadPreviousValue = reader.ReadBoolean();
            LockTimeout       = reader.ReadLongAsTimespan();
#pragma warning disable 618
            LongQueryWarningTimeout = reader.ReadLongAsTimespan();
#pragma warning restore 618
            MaxConcurrentAsyncOperations = reader.ReadInt();
            Name                            = reader.ReadString();
            ReadFromBackup                  = reader.ReadBoolean();
            RebalanceBatchSize              = reader.ReadInt();
            RebalanceDelay                  = reader.ReadLongAsTimespan();
            RebalanceMode                   = (CacheRebalanceMode)reader.ReadInt();
            RebalanceThrottle               = reader.ReadLongAsTimespan();
            RebalanceTimeout                = reader.ReadLongAsTimespan();
            SqlEscapeAll                    = reader.ReadBoolean();
            WriteBehindBatchSize            = reader.ReadInt();
            WriteBehindEnabled              = reader.ReadBoolean();
            WriteBehindFlushFrequency       = reader.ReadLongAsTimespan();
            WriteBehindFlushSize            = reader.ReadInt();
            WriteBehindFlushThreadCount     = reader.ReadInt();
            WriteBehindCoalescing           = reader.ReadBoolean();
            WriteSynchronizationMode        = (CacheWriteSynchronizationMode)reader.ReadInt();
            ReadThrough                     = reader.ReadBoolean();
            WriteThrough                    = reader.ReadBoolean();
            EnableStatistics                = reader.ReadBoolean();
            DataRegionName                  = reader.ReadString();
            PartitionLossPolicy             = (PartitionLossPolicy)reader.ReadInt();
            GroupName                       = reader.ReadString();
            CacheStoreFactory               = reader.ReadObject <IFactory <ICacheStore> >();
            SqlIndexMaxInlineSize           = reader.ReadInt();
            OnheapCacheEnabled              = reader.ReadBoolean();
            StoreConcurrentLoadAllThreshold = reader.ReadInt();
            RebalanceOrder                  = reader.ReadInt();
            RebalanceBatchesPrefetchCount   = reader.ReadLong();
            MaxQueryIteratorsCount          = reader.ReadInt();
            QueryDetailMetricsSize          = reader.ReadInt();
            QueryParallelism                = reader.ReadInt();
            SqlSchema                       = reader.ReadString();

            QueryEntities = reader.ReadCollectionRaw(r => new QueryEntity(r));

            NearConfiguration = reader.ReadBoolean() ? new NearCacheConfiguration(reader) : null;

            EvictionPolicy      = EvictionPolicyBase.Read(reader);
            AffinityFunction    = AffinityFunctionSerializer.Read(reader);
            ExpiryPolicyFactory = ExpiryPolicySerializer.ReadPolicyFactory(reader);

            KeyConfiguration = reader.ReadCollectionRaw(r => new CacheKeyConfiguration(r));

            var count = reader.ReadInt();

            if (count > 0)
            {
                PluginConfigurations = new List <ICachePluginConfiguration>(count);
                for (int i = 0; i < count; i++)
                {
                    if (reader.ReadBoolean())
                    {
                        // FactoryId-based plugin: skip.
                        reader.ReadInt();                             // Skip factory id.
                        var size = reader.ReadInt();
                        reader.Stream.Seek(size, SeekOrigin.Current); // Skip custom data.
                    }
                    else
                    {
                        // Pure .NET plugin.
                        PluginConfigurations.Add(reader.ReadObject <ICachePluginConfiguration>());
                    }
                }
            }
        }