예제 #1
0
        public void TestCustomPosition()
        {
            var stream = new BinaryHeapStream(16);

            stream.WriteLong(54);

            var marsh = new Marshaller(new BinaryConfiguration());

            var writer = new BinaryWriter(marsh, stream);

            writer.WriteChar('x');

            stream.Seek(0, SeekOrigin.Begin);

            Assert.AreEqual(54, stream.ReadLong());

            var reader = new BinaryReader(marsh, stream, BinaryMode.Deserialize, null);

            Assert.AreEqual('x', reader.ReadChar());
        }
예제 #2
0
        /// <summary>
        /// Reads data from specified reader into current instance.
        /// </summary>
        /// <param name="binaryReader">The binary reader.</param>
        private void Read(BinaryReader binaryReader)
        {
            var r = binaryReader;

            CopyLocalProperties(r.Marshaller.Ignite.Configuration);

            ReadCore(r);

            // Misc
            IgniteHome = r.ReadString();

            JvmInitialMemoryMb = (int) (r.ReadLong()/1024/2014);
            JvmMaxMemoryMb = (int) (r.ReadLong()/1024/2014);

            // Local data (not from reader)
            JvmDllPath = Process.GetCurrentProcess().Modules.OfType<ProcessModule>()
                .Single(x => string.Equals(x.ModuleName, IgniteUtils.FileJvmDll, StringComparison.OrdinalIgnoreCase))
                .FileName;
        }
예제 #3
0
        /// <summary>
        /// Reads data from specified reader into current instance.
        /// </summary>
        /// <param name="r">The binary reader.</param>
        private void ReadCore(BinaryReader r)
        {
            // Simple properties
            _clientMode = r.ReadBooleanNullable();
            IncludedEventTypes = r.ReadIntArray();
            _metricsExpireTime = r.ReadTimeSpanNullable();
            _metricsHistorySize = r.ReadIntNullable();
            _metricsLogFrequency = r.ReadTimeSpanNullable();
            _metricsUpdateFrequency = r.ReadTimeSpanNullable();
            _networkSendRetryCount = r.ReadIntNullable();
            _networkSendRetryDelay = r.ReadTimeSpanNullable();
            _networkTimeout = r.ReadTimeSpanNullable();
            WorkDirectory = r.ReadString();
            Localhost = r.ReadString();
            _isDaemon = r.ReadBooleanNullable();
            _isLateAffinityAssignment = r.ReadBooleanNullable();
            _failureDetectionTimeout = r.ReadTimeSpanNullable();

            // Cache config
            var cacheCfgCount = r.ReadInt();
            CacheConfiguration = new List<CacheConfiguration>(cacheCfgCount);
            for (int i = 0; i < cacheCfgCount; i++)
                CacheConfiguration.Add(new CacheConfiguration(r));

            // Discovery config
            DiscoverySpi = r.ReadBoolean() ? new TcpDiscoverySpi(r) : null;

            // Communication config
            CommunicationSpi = r.ReadBoolean() ? new TcpCommunicationSpi(r) : null;

            // Binary config
            if (r.ReadBoolean())
            {
                BinaryConfiguration = BinaryConfiguration ?? new BinaryConfiguration();
                BinaryConfiguration.CompactFooter = r.ReadBoolean();
            }

            // User attributes
            UserAttributes = Enumerable.Range(0, r.ReadInt())
                .ToDictionary(x => r.ReadString(), x => r.ReadObject<object>());

            // Atomic
            if (r.ReadBoolean())
            {
                AtomicConfiguration = new AtomicConfiguration
                {
                    AtomicSequenceReserveSize = r.ReadInt(),
                    Backups = r.ReadInt(),
                    CacheMode = (CacheMode) r.ReadInt()
                };
            }

            // Tx
            if (r.ReadBoolean())
            {
                TransactionConfiguration = new TransactionConfiguration
                {
                    PessimisticTransactionLogSize = r.ReadInt(),
                    DefaultTransactionConcurrency = (TransactionConcurrency) r.ReadInt(),
                    DefaultTransactionIsolation = (TransactionIsolation) r.ReadInt(),
                    DefaultTimeout = TimeSpan.FromMilliseconds(r.ReadLong()),
                    PessimisticTransactionLogLinger = TimeSpan.FromMilliseconds(r.ReadInt())
                };
            }

            // Swap
            SwapSpaceSpi = SwapSpaceSerializer.Read(r);
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IgniteConfiguration"/> class from a reader.
 /// </summary>
 /// <param name="binaryReader">The binary reader.</param>
 internal IgniteConfiguration(BinaryReader binaryReader)
 {
     Read(binaryReader);
 }
예제 #5
0
        /// <summary>
        /// Reads data from specified reader into current instance.
        /// </summary>
        /// <param name="r">The binary reader.</param>
        private void ReadCore(BinaryReader r)
        {
            // Simple properties
            ClientMode = r.ReadBoolean();
            IncludedEventTypes = r.ReadIntArray();

            MetricsExpireTime = r.ReadLongAsTimespan();
            MetricsHistorySize = r.ReadInt();
            MetricsLogFrequency = r.ReadLongAsTimespan();
            MetricsUpdateFrequency = r.ReadLongAsTimespan();
            NetworkSendRetryCount = r.ReadInt();
            NetworkSendRetryDelay = r.ReadLongAsTimespan();
            NetworkTimeout = r.ReadLongAsTimespan();
            WorkDirectory = r.ReadString();
            Localhost = r.ReadString();

            // Cache config
            var cacheCfgCount = r.ReadInt();
            CacheConfiguration = new List<CacheConfiguration>(cacheCfgCount);
            for (int i = 0; i < cacheCfgCount; i++)
                CacheConfiguration.Add(new CacheConfiguration(r));

            // Discovery config
            DiscoverySpi = r.ReadBoolean() ? new TcpDiscoverySpi(r) : null;
        }
예제 #6
0
파일: Ignition.cs 프로젝트: pires/ignite
        /// <summary>
        /// Prepare lifecycle beans.
        /// </summary>
        /// <param name="reader">Reader.</param>
        /// <param name="outStream">Output stream.</param>
        /// <param name="handleRegistry">Handle registry.</param>
        private static void PrepareLifecycleBeans(BinaryReader reader, PlatformMemoryStream outStream, 
            HandleRegistry handleRegistry)
        {
            IList<LifecycleBeanHolder> beans = new List<LifecycleBeanHolder>();

            // 1. Read beans defined in Java.
            int cnt = reader.ReadInt();

            for (int i = 0; i < cnt; i++)
                beans.Add(new LifecycleBeanHolder(CreateLifecycleBean(reader)));

            // 2. Append beans definied in local configuration.
            ICollection<ILifecycleBean> nativeBeans = _startup.Configuration.LifecycleBeans;

            if (nativeBeans != null)
            {
                foreach (ILifecycleBean nativeBean in nativeBeans)
                    beans.Add(new LifecycleBeanHolder(nativeBean));
            }

            // 3. Write bean pointers to Java stream.
            outStream.WriteInt(beans.Count);

            foreach (LifecycleBeanHolder bean in beans)
                outStream.WriteLong(handleRegistry.AllocateCritical(bean));

            outStream.SynchronizeOutput();

            // 4. Set beans to STARTUP object.
            _startup.LifecycleBeans = beans;
        }
예제 #7
0
파일: Ignition.cs 프로젝트: pires/ignite
        /// <summary>
        /// Preapare configuration.
        /// </summary>
        /// <param name="reader">Reader.</param>
        /// <param name="outStream">Response stream.</param>
        private static void PrepareConfiguration(BinaryReader reader, PlatformMemoryStream outStream)
        {
            // 1. Load assemblies.
            IgniteConfiguration cfg = _startup.Configuration;

            LoadAssemblies(cfg.Assemblies);

            ICollection<string> cfgAssembllies;
            BinaryConfiguration binaryCfg;

            BinaryUtils.ReadConfiguration(reader, out cfgAssembllies, out binaryCfg);

            LoadAssemblies(cfgAssembllies);

            // 2. Create marshaller only after assemblies are loaded.
            if (cfg.BinaryConfiguration == null)
                cfg.BinaryConfiguration = binaryCfg;

            _startup.Marshaller = new Marshaller(cfg.BinaryConfiguration);

            // 3. Send configuration details to Java
            cfg.Write(_startup.Marshaller.StartMarshal(outStream));
        }
예제 #8
0
파일: Ignition.cs 프로젝트: pires/ignite
        /// <summary>
        /// Create lifecycle bean.
        /// </summary>
        /// <param name="reader">Reader.</param>
        /// <returns>Lifecycle bean.</returns>
        private static ILifecycleBean CreateLifecycleBean(BinaryReader reader)
        {
            // 1. Instantiate.
            var bean = IgniteUtils.CreateInstance<ILifecycleBean>(reader.ReadString());

            // 2. Set properties.
            var props = reader.ReadDictionaryAsGeneric<string, object>();

            IgniteUtils.SetProperties(bean, props);

            return bean;
        }
예제 #9
0
파일: Ignition.cs 프로젝트: shjgiser/ignite
        /// <summary>
        /// Preapare configuration.
        /// </summary>
        /// <param name="reader">Reader.</param>
        private static void PrepareConfiguration(BinaryReader reader)
        {
            // 1. Load assemblies.
            IgniteConfiguration cfg = _startup.Configuration;

            LoadAssemblies(cfg.Assemblies);

            ICollection<string> cfgAssembllies;
            BinaryConfiguration binaryCfg;

            BinaryUtils.ReadConfiguration(reader, out cfgAssembllies, out binaryCfg);

            LoadAssemblies(cfgAssembllies);

            // 2. Create marshaller only after assemblies are loaded.
            if (cfg.BinaryConfiguration == null)
                cfg.BinaryConfiguration = binaryCfg;

            _startup.Marshaller = new Marshaller(cfg.BinaryConfiguration);
        }
예제 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal CacheConfiguration(BinaryReader reader)
 {
     Read(reader);
 }
예제 #11
0
        /// <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(((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();

            if (count > 0)
            {
                PluginConfigurations = new List <ICachePluginConfiguration>(count);
                for (int i = 0; i < count; i++)
                {
                    if (reader.ReadBoolean())
                    {
                        // FactoryId-based plugin: skip.
                        var size = reader.ReadInt();
                        reader.Stream.Seek(size, SeekOrigin.Current);
                    }
                    else
                    {
                        // Pure .NET plugin.
                        PluginConfigurations.Add(reader.ReadObject <ICachePluginConfiguration>());
                    }
                }
            }
        }
예제 #12
0
        /// <summary>
        /// Reads data from specified reader into current instance.
        /// </summary>
        /// <param name="r">The binary reader.</param>
        private void ReadCore(BinaryReader r)
        {
            // Simple properties
            _clientMode             = r.ReadBooleanNullable();
            IncludedEventTypes      = r.ReadIntArray();
            _metricsExpireTime      = r.ReadTimeSpanNullable();
            _metricsHistorySize     = r.ReadIntNullable();
            _metricsLogFrequency    = r.ReadTimeSpanNullable();
            _metricsUpdateFrequency = r.ReadTimeSpanNullable();
            _networkSendRetryCount  = r.ReadIntNullable();
            _networkSendRetryDelay  = r.ReadTimeSpanNullable();
            _networkTimeout         = r.ReadTimeSpanNullable();
            WorkDirectory           = r.ReadString();
            Localhost = r.ReadString();
            _isDaemon = r.ReadBooleanNullable();
            _isLateAffinityAssignment = r.ReadBooleanNullable();

            // Cache config
            var cacheCfgCount = r.ReadInt();

            CacheConfiguration = new List <CacheConfiguration>(cacheCfgCount);
            for (int i = 0; i < cacheCfgCount; i++)
            {
                CacheConfiguration.Add(new CacheConfiguration(r));
            }

            // Discovery config
            DiscoverySpi = r.ReadBoolean() ? new TcpDiscoverySpi(r) : null;

            // Communication config
            CommunicationSpi = r.ReadBoolean() ? new TcpCommunicationSpi(r) : null;

            // Binary config
            if (r.ReadBoolean())
            {
                BinaryConfiguration = BinaryConfiguration ?? new BinaryConfiguration();
                BinaryConfiguration.CompactFooter = r.ReadBoolean();
            }

            // User attributes
            UserAttributes = Enumerable.Range(0, r.ReadInt())
                             .ToDictionary(x => r.ReadString(), x => r.ReadObject <object>());

            // Atomic
            if (r.ReadBoolean())
            {
                AtomicConfiguration = new AtomicConfiguration
                {
                    AtomicSequenceReserveSize = r.ReadInt(),
                    Backups   = r.ReadInt(),
                    CacheMode = (CacheMode)r.ReadInt()
                };
            }

            // Tx
            if (r.ReadBoolean())
            {
                TransactionConfiguration = new TransactionConfiguration
                {
                    PessimisticTransactionLogSize = r.ReadInt(),
                    DefaultTransactionConcurrency = (TransactionConcurrency)r.ReadInt(),
                    DefaultTransactionIsolation   = (TransactionIsolation)r.ReadInt(),
                    DefaultTimeout = TimeSpan.FromMilliseconds(r.ReadLong()),
                    PessimisticTransactionLogLinger = TimeSpan.FromMilliseconds(r.ReadInt())
                };
            }
        }
예제 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IgniteConfiguration"/> class from a reader.
 /// </summary>
 /// <param name="binaryReader">The binary reader.</param>
 internal IgniteConfiguration(BinaryReader binaryReader)
 {
     Read(binaryReader);
 }
예제 #14
0
        /// <summary>
        /// Reads data into this instance from the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="srvVer">Server version.</param>
        private void Read(BinaryReader reader, ClientProtocolVersion srvVer)
        {
            // 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();
            EncryptionEnabled               = reader.ReadBoolean();

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

            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>());
                    }
                }
            }
        }
예제 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="srvVer">Server version.</param>
 internal CacheConfiguration(BinaryReader reader, ClientProtocolVersion srvVer)
 {
     Read(reader, srvVer);
 }
예제 #16
0
        /// <summary>
        /// Reads data from specified reader into current instance.
        /// </summary>
        /// <param name="r">The binary reader.</param>
        private void ReadCore(BinaryReader r)
        {
            // Simple properties
            _clientMode             = r.ReadBooleanNullable();
            IncludedEventTypes      = r.ReadIntArray();
            _metricsExpireTime      = r.ReadTimeSpanNullable();
            _metricsHistorySize     = r.ReadIntNullable();
            _metricsLogFrequency    = r.ReadTimeSpanNullable();
            _metricsUpdateFrequency = r.ReadTimeSpanNullable();
            _networkSendRetryCount  = r.ReadIntNullable();
            _networkSendRetryDelay  = r.ReadTimeSpanNullable();
            _networkTimeout         = r.ReadTimeSpanNullable();
            WorkDirectory           = r.ReadString();
            Localhost = r.ReadString();
            _isDaemon = r.ReadBooleanNullable();
            _failureDetectionTimeout       = r.ReadTimeSpanNullable();
            _clientFailureDetectionTimeout = r.ReadTimeSpanNullable();
            _longQueryWarningTimeout       = r.ReadTimeSpanNullable();
            _isActiveOnStart = r.ReadBooleanNullable();

            // Thread pools
            _publicThreadPoolSize        = r.ReadIntNullable();
            _stripedThreadPoolSize       = r.ReadIntNullable();
            _serviceThreadPoolSize       = r.ReadIntNullable();
            _systemThreadPoolSize        = r.ReadIntNullable();
            _asyncCallbackThreadPoolSize = r.ReadIntNullable();
            _managementThreadPoolSize    = r.ReadIntNullable();
            _dataStreamerThreadPoolSize  = r.ReadIntNullable();
            _utilityCacheThreadPoolSize  = r.ReadIntNullable();
            _queryThreadPoolSize         = r.ReadIntNullable();

            // Cache config
            var cacheCfgCount = r.ReadInt();

            CacheConfiguration = new List <CacheConfiguration>(cacheCfgCount);
            for (int i = 0; i < cacheCfgCount; i++)
            {
                CacheConfiguration.Add(new CacheConfiguration(r));
            }

            // Discovery config
            DiscoverySpi = r.ReadBoolean() ? new TcpDiscoverySpi(r) : null;

            // Communication config
            CommunicationSpi = r.ReadBoolean() ? new TcpCommunicationSpi(r) : null;

            // Binary config
            if (r.ReadBoolean())
            {
                BinaryConfiguration = BinaryConfiguration ?? new BinaryConfiguration();

                if (r.ReadBoolean())
                {
                    BinaryConfiguration.CompactFooter = r.ReadBoolean();
                }

                if (r.ReadBoolean())
                {
                    BinaryConfiguration.NameMapper = BinaryBasicNameMapper.SimpleNameInstance;
                }
            }

            // User attributes
            UserAttributes = Enumerable.Range(0, r.ReadInt())
                             .ToDictionary(x => r.ReadString(), x => r.ReadObject <object>());

            // Atomic
            if (r.ReadBoolean())
            {
                AtomicConfiguration = new AtomicConfiguration
                {
                    AtomicSequenceReserveSize = r.ReadInt(),
                    Backups   = r.ReadInt(),
                    CacheMode = (CacheMode)r.ReadInt()
                };
            }

            // Tx
            if (r.ReadBoolean())
            {
                TransactionConfiguration = new TransactionConfiguration
                {
                    PessimisticTransactionLogSize = r.ReadInt(),
                    DefaultTransactionConcurrency = (TransactionConcurrency)r.ReadInt(),
                    DefaultTransactionIsolation   = (TransactionIsolation)r.ReadInt(),
                    DefaultTimeout = TimeSpan.FromMilliseconds(r.ReadLong()),
                    PessimisticTransactionLogLinger = TimeSpan.FromMilliseconds(r.ReadInt())
                };
            }

            // Event storage
            switch (r.ReadByte())
            {
            case 1: EventStorageSpi = new NoopEventStorageSpi();
                break;

            case 2:
                EventStorageSpi = MemoryEventStorageSpi.Read(r);
                break;
            }

            if (r.ReadBoolean())
            {
                MemoryConfiguration = new MemoryConfiguration(r);
            }

            // SQL
            if (r.ReadBoolean())
            {
                SqlConnectorConfiguration = new SqlConnectorConfiguration(r);
            }

            // Persistence.
            if (r.ReadBoolean())
            {
                PersistentStoreConfiguration = new PersistentStoreConfiguration(r);
            }
        }