コード例 #1
0
        /// <summary>
        /// Writes this instance to a writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        private void WriteCore(BinaryWriter writer)
        {
            // Simple properties
            writer.WriteBoolean(ClientMode);
            writer.WriteIntArray(IncludedEventTypes == null ? null : IncludedEventTypes.ToArray());

            writer.WriteLong((long)MetricsExpireTime.TotalMilliseconds);
            writer.WriteInt(MetricsHistorySize);
            writer.WriteLong((long)MetricsLogFrequency.TotalMilliseconds);
            var metricsUpdateFreq = (long)MetricsUpdateFrequency.TotalMilliseconds;

            writer.WriteLong(metricsUpdateFreq >= 0 ? metricsUpdateFreq : -1);
            writer.WriteInt(NetworkSendRetryCount);
            writer.WriteLong((long)NetworkSendRetryDelay.TotalMilliseconds);
            writer.WriteLong((long)NetworkTimeout.TotalMilliseconds);
            writer.WriteString(WorkDirectory);
            writer.WriteString(Localhost);

            // Cache config
            var caches = CacheConfiguration;

            if (caches == null)
            {
                writer.WriteInt(0);
            }
            else
            {
                writer.WriteInt(caches.Count);

                foreach (var cache in caches)
                {
                    cache.Write(writer);
                }
            }

            // Discovery config
            var disco = DiscoverySpi;

            if (disco != null)
            {
                writer.WriteBoolean(true);

                var tcpDisco = disco as TcpDiscoverySpi;

                if (tcpDisco == null)
                {
                    throw new InvalidOperationException("Unsupported discovery SPI: " + disco.GetType());
                }

                tcpDisco.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// Writes this instance to a writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void Write(BinaryWriter writer)
        {
            Debug.Assert(writer != null);

            // Simple properties
            writer.WriteBooleanNullable(_clientMode);
            writer.WriteIntArray(IncludedEventTypes == null ? null : IncludedEventTypes.ToArray());

            writer.WriteTimeSpanAsLongNullable(_metricsExpireTime);
            writer.WriteIntNullable(_metricsHistorySize);
            writer.WriteTimeSpanAsLongNullable(_metricsLogFrequency);
            writer.WriteTimeSpanAsLongNullable(_metricsUpdateFrequency);
            writer.WriteIntNullable(_networkSendRetryCount);
            writer.WriteTimeSpanAsLongNullable(_networkSendRetryDelay);
            writer.WriteTimeSpanAsLongNullable(_networkTimeout);
            writer.WriteString(WorkDirectory);
            writer.WriteString(Localhost);
            writer.WriteBooleanNullable(_isDaemon);
            writer.WriteBooleanNullable(_isLateAffinityAssignment);
            writer.WriteTimeSpanAsLongNullable(_failureDetectionTimeout);

            // Cache config
            var caches = CacheConfiguration;

            if (caches == null)
                writer.WriteInt(0);
            else
            {
                writer.WriteInt(caches.Count);

                foreach (var cache in caches)
                    cache.Write(writer);
            }

            // Discovery config
            var disco = DiscoverySpi;

            if (disco != null)
            {
                writer.WriteBoolean(true);

                var tcpDisco = disco as TcpDiscoverySpi;

                if (tcpDisco == null)
                    throw new InvalidOperationException("Unsupported discovery SPI: " + disco.GetType());

                tcpDisco.Write(writer);
            }
            else
                writer.WriteBoolean(false);

            // Communication config
            var comm = CommunicationSpi;

            if (comm != null)
            {
                writer.WriteBoolean(true);

                var tcpComm = comm as TcpCommunicationSpi;

                if (tcpComm == null)
                    throw new InvalidOperationException("Unsupported communication SPI: " + comm.GetType());

                tcpComm.Write(writer);
            }
            else
                writer.WriteBoolean(false);

            // Binary config
            var isCompactFooterSet = BinaryConfiguration != null && BinaryConfiguration.CompactFooterInternal != null;

            writer.WriteBoolean(isCompactFooterSet);

            if (isCompactFooterSet)
                writer.WriteBoolean(BinaryConfiguration.CompactFooter);

            // User attributes
            var attrs = UserAttributes;

            if (attrs == null)
                writer.WriteInt(0);
            else
            {
                writer.WriteInt(attrs.Count);

                foreach (var pair in attrs)
                {
                    writer.WriteString(pair.Key);
                    writer.Write(pair.Value);
                }
            }

            // Atomic
            if (AtomicConfiguration != null)
            {
                writer.WriteBoolean(true);

                writer.WriteInt(AtomicConfiguration.AtomicSequenceReserveSize);
                writer.WriteInt(AtomicConfiguration.Backups);
                writer.WriteInt((int) AtomicConfiguration.CacheMode);
            }
            else
                writer.WriteBoolean(false);

            // Tx
            if (TransactionConfiguration != null)
            {
                writer.WriteBoolean(true);

                writer.WriteInt(TransactionConfiguration.PessimisticTransactionLogSize);
                writer.WriteInt((int) TransactionConfiguration.DefaultTransactionConcurrency);
                writer.WriteInt((int) TransactionConfiguration.DefaultTransactionIsolation);
                writer.WriteLong((long) TransactionConfiguration.DefaultTimeout.TotalMilliseconds);
                writer.WriteInt((int) TransactionConfiguration.PessimisticTransactionLogLinger.TotalMilliseconds);
            }
            else
                writer.WriteBoolean(false);

            // Swap space
            SwapSpaceSerializer.Write(writer, SwapSpaceSpi);
        }
コード例 #3
0
        /// <summary>
        /// Writes this instance to a writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void Write(BinaryWriter writer)
        {
            Debug.Assert(writer != null);

            // Simple properties
            writer.WriteBooleanNullable(_clientMode);
            writer.WriteIntArray(IncludedEventTypes == null ? null : IncludedEventTypes.ToArray());

            writer.WriteTimeSpanAsLongNullable(_metricsExpireTime);
            writer.WriteIntNullable(_metricsHistorySize);
            writer.WriteTimeSpanAsLongNullable(_metricsLogFrequency);
            writer.WriteTimeSpanAsLongNullable(_metricsUpdateFrequency);
            writer.WriteIntNullable(_networkSendRetryCount);
            writer.WriteTimeSpanAsLongNullable(_networkSendRetryDelay);
            writer.WriteTimeSpanAsLongNullable(_networkTimeout);
            writer.WriteString(WorkDirectory);
            writer.WriteString(Localhost);
            writer.WriteBooleanNullable(_isDaemon);
            writer.WriteBooleanNullable(_isLateAffinityAssignment);
            writer.WriteTimeSpanAsLongNullable(_failureDetectionTimeout);
            writer.WriteTimeSpanAsLongNullable(_clientFailureDetectionTimeout);
            writer.WriteTimeSpanAsLongNullable(_longQueryWarningTimeout);
            writer.WriteBooleanNullable(_isActiveOnStart);

            // Thread pools
            writer.WriteIntNullable(_publicThreadPoolSize);
            writer.WriteIntNullable(_stripedThreadPoolSize);
            writer.WriteIntNullable(_serviceThreadPoolSize);
            writer.WriteIntNullable(_systemThreadPoolSize);
            writer.WriteIntNullable(_asyncCallbackThreadPoolSize);
            writer.WriteIntNullable(_managementThreadPoolSize);
            writer.WriteIntNullable(_dataStreamerThreadPoolSize);
            writer.WriteIntNullable(_utilityCacheThreadPoolSize);
            writer.WriteIntNullable(_queryThreadPoolSize);

            // Cache config
            var caches = CacheConfiguration;

            if (caches == null)
            {
                writer.WriteInt(0);
            }
            else
            {
                writer.WriteInt(caches.Count);

                foreach (var cache in caches)
                {
                    cache.Write(writer);
                }
            }

            // Discovery config
            var disco = DiscoverySpi;

            if (disco != null)
            {
                writer.WriteBoolean(true);

                var tcpDisco = disco as TcpDiscoverySpi;

                if (tcpDisco == null)
                {
                    throw new InvalidOperationException("Unsupported discovery SPI: " + disco.GetType());
                }

                tcpDisco.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // Communication config
            var comm = CommunicationSpi;

            if (comm != null)
            {
                writer.WriteBoolean(true);

                var tcpComm = comm as TcpCommunicationSpi;

                if (tcpComm == null)
                {
                    throw new InvalidOperationException("Unsupported communication SPI: " + comm.GetType());
                }

                tcpComm.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // Binary config
            if (BinaryConfiguration != null)
            {
                writer.WriteBoolean(true);

                if (BinaryConfiguration.CompactFooterInternal != null)
                {
                    writer.WriteBoolean(true);
                    writer.WriteBoolean(BinaryConfiguration.CompactFooter);
                }
                else
                {
                    writer.WriteBoolean(false);
                }

                // Name mapper.
                var mapper = BinaryConfiguration.NameMapper as BinaryBasicNameMapper;
                writer.WriteBoolean(mapper != null && mapper.IsSimpleName);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // User attributes
            var attrs = UserAttributes;

            if (attrs == null)
            {
                writer.WriteInt(0);
            }
            else
            {
                writer.WriteInt(attrs.Count);

                foreach (var pair in attrs)
                {
                    writer.WriteString(pair.Key);
                    writer.Write(pair.Value);
                }
            }

            // Atomic
            if (AtomicConfiguration != null)
            {
                writer.WriteBoolean(true);

                writer.WriteInt(AtomicConfiguration.AtomicSequenceReserveSize);
                writer.WriteInt(AtomicConfiguration.Backups);
                writer.WriteInt((int)AtomicConfiguration.CacheMode);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // Tx
            if (TransactionConfiguration != null)
            {
                writer.WriteBoolean(true);

                writer.WriteInt(TransactionConfiguration.PessimisticTransactionLogSize);
                writer.WriteInt((int)TransactionConfiguration.DefaultTransactionConcurrency);
                writer.WriteInt((int)TransactionConfiguration.DefaultTransactionIsolation);
                writer.WriteLong((long)TransactionConfiguration.DefaultTimeout.TotalMilliseconds);
                writer.WriteInt((int)TransactionConfiguration.PessimisticTransactionLogLinger.TotalMilliseconds);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // Event storage
            if (EventStorageSpi == null)
            {
                writer.WriteByte(0);
            }
            else if (EventStorageSpi is NoopEventStorageSpi)
            {
                writer.WriteByte(1);
            }
            else
            {
                var memEventStorage = EventStorageSpi as MemoryEventStorageSpi;

                if (memEventStorage == null)
                {
                    throw new IgniteException(string.Format(
                                                  "Unsupported IgniteConfiguration.EventStorageSpi: '{0}'. " +
                                                  "Supported implementations: '{1}', '{2}'.",
                                                  EventStorageSpi.GetType(), typeof(NoopEventStorageSpi), typeof(MemoryEventStorageSpi)));
                }

                writer.WriteByte(2);

                memEventStorage.Write(writer);
            }

            if (MemoryConfiguration != null)
            {
                writer.WriteBoolean(true);
                MemoryConfiguration.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // SQL
            if (SqlConnectorConfiguration != null)
            {
                writer.WriteBoolean(true);
                SqlConnectorConfiguration.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // Persistence.
            if (PersistentStoreConfiguration != null)
            {
                writer.WriteBoolean(true);
                PersistentStoreConfiguration.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // Plugins (should be last)
            if (PluginConfigurations != null)
            {
                var pos = writer.Stream.Position;

                writer.WriteInt(0); // reserve count

                var cnt = 0;

                foreach (var cfg in PluginConfigurations)
                {
                    if (cfg.PluginConfigurationClosureFactoryId != null)
                    {
                        writer.WriteInt(cfg.PluginConfigurationClosureFactoryId.Value);

                        cfg.WriteBinary(writer);

                        cnt++;
                    }
                }

                writer.Stream.WriteInt(pos, cnt);
            }
            else
            {
                writer.WriteInt(0);
            }
        }
コード例 #4
0
        /// <summary>
        /// Writes this instance to a writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        private void WriteCore(BinaryWriter writer)
        {
            // Simple properties
            writer.WriteBoolean(ClientMode);
            writer.WriteIntArray(IncludedEventTypes == null ? null : IncludedEventTypes.ToArray());

            writer.WriteLong((long) MetricsExpireTime.TotalMilliseconds);
            writer.WriteInt(MetricsHistorySize);
            writer.WriteLong((long) MetricsLogFrequency.TotalMilliseconds);
            var metricsUpdateFreq = (long) MetricsUpdateFrequency.TotalMilliseconds;
            writer.WriteLong(metricsUpdateFreq >= 0 ? metricsUpdateFreq : -1);
            writer.WriteInt(NetworkSendRetryCount);
            writer.WriteLong((long) NetworkSendRetryDelay.TotalMilliseconds);
            writer.WriteLong((long) NetworkTimeout.TotalMilliseconds);
            writer.WriteString(WorkDirectory);
            writer.WriteString(Localhost);

            // Cache config
            var caches = CacheConfiguration;

            if (caches == null)
                writer.WriteInt(0);
            else
            {
                writer.WriteInt(caches.Count);

                foreach (var cache in caches)
                    cache.Write(writer);
            }

            // Discovery config
            var disco = DiscoverySpi;

            if (disco != null)
            {
                writer.WriteBoolean(true);

                var tcpDisco = disco as TcpDiscoverySpi;

                if (tcpDisco == null)
                    throw new InvalidOperationException("Unsupported discovery SPI: " + disco.GetType());

                tcpDisco.Write(writer);
            }
            else
                writer.WriteBoolean(false);
        }
コード例 #5
0
ファイル: IgniteConfiguration.cs プロジェクト: xestyle/ignite
        /// <summary>
        /// Writes this instance to a writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void Write(BinaryWriter writer)
        {
            Debug.Assert(writer != null);

            // Simple properties
            writer.WriteBooleanNullable(_clientMode);
            writer.WriteIntArray(IncludedEventTypes == null ? null : IncludedEventTypes.ToArray());

            writer.WriteTimeSpanAsLongNullable(_metricsExpireTime);
            writer.WriteIntNullable(_metricsHistorySize);
            writer.WriteTimeSpanAsLongNullable(_metricsLogFrequency);
            writer.WriteTimeSpanAsLongNullable(_metricsUpdateFrequency);
            writer.WriteIntNullable(_networkSendRetryCount);
            writer.WriteTimeSpanAsLongNullable(_networkSendRetryDelay);
            writer.WriteTimeSpanAsLongNullable(_networkTimeout);
            writer.WriteString(WorkDirectory);
            writer.WriteString(Localhost);
            writer.WriteBooleanNullable(_isDaemon);
            writer.WriteBooleanNullable(_isLateAffinityAssignment);
            writer.WriteTimeSpanAsLongNullable(_failureDetectionTimeout);

            // Cache config
            var caches = CacheConfiguration;

            if (caches == null)
            {
                writer.WriteInt(0);
            }
            else
            {
                writer.WriteInt(caches.Count);

                foreach (var cache in caches)
                {
                    cache.Write(writer);
                }
            }

            // Discovery config
            var disco = DiscoverySpi;

            if (disco != null)
            {
                writer.WriteBoolean(true);

                var tcpDisco = disco as TcpDiscoverySpi;

                if (tcpDisco == null)
                {
                    throw new InvalidOperationException("Unsupported discovery SPI: " + disco.GetType());
                }

                tcpDisco.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // Communication config
            var comm = CommunicationSpi;

            if (comm != null)
            {
                writer.WriteBoolean(true);

                var tcpComm = comm as TcpCommunicationSpi;

                if (tcpComm == null)
                {
                    throw new InvalidOperationException("Unsupported communication SPI: " + comm.GetType());
                }

                tcpComm.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // Binary config
            if (BinaryConfiguration != null)
            {
                writer.WriteBoolean(true);

                if (BinaryConfiguration.CompactFooterInternal != null)
                {
                    writer.WriteBoolean(true);
                    writer.WriteBoolean(BinaryConfiguration.CompactFooter);
                }
                else
                {
                    writer.WriteBoolean(false);
                }

                // Send only descriptors with non-null EqualityComparer to preserve old behavior where
                // remote nodes can have no BinaryConfiguration.
                var types = writer.Marshaller.GetUserTypeDescriptors().Where(x => x.EqualityComparer != null).ToList();

                writer.WriteInt(types.Count);

                foreach (var type in types)
                {
                    writer.WriteString(BinaryUtils.SimpleTypeName(type.TypeName));
                    writer.WriteBoolean(type.IsEnum);
                    BinaryEqualityComparerSerializer.Write(writer, type.EqualityComparer);
                }
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // User attributes
            var attrs = UserAttributes;

            if (attrs == null)
            {
                writer.WriteInt(0);
            }
            else
            {
                writer.WriteInt(attrs.Count);

                foreach (var pair in attrs)
                {
                    writer.WriteString(pair.Key);
                    writer.Write(pair.Value);
                }
            }

            // Atomic
            if (AtomicConfiguration != null)
            {
                writer.WriteBoolean(true);

                writer.WriteInt(AtomicConfiguration.AtomicSequenceReserveSize);
                writer.WriteInt(AtomicConfiguration.Backups);
                writer.WriteInt((int)AtomicConfiguration.CacheMode);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // Tx
            if (TransactionConfiguration != null)
            {
                writer.WriteBoolean(true);

                writer.WriteInt(TransactionConfiguration.PessimisticTransactionLogSize);
                writer.WriteInt((int)TransactionConfiguration.DefaultTransactionConcurrency);
                writer.WriteInt((int)TransactionConfiguration.DefaultTransactionIsolation);
                writer.WriteLong((long)TransactionConfiguration.DefaultTimeout.TotalMilliseconds);
                writer.WriteInt((int)TransactionConfiguration.PessimisticTransactionLogLinger.TotalMilliseconds);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // Swap space
            SwapSpaceSerializer.Write(writer, SwapSpaceSpi);

            // Plugins
            if (PluginConfigurations != null)
            {
                var pos = writer.Stream.Position;

                writer.WriteInt(0); // reserve count

                var cnt = 0;

                foreach (var cfg in PluginConfigurations)
                {
                    if (cfg.PluginConfigurationClosureFactoryId != null)
                    {
                        writer.WriteInt(cfg.PluginConfigurationClosureFactoryId.Value);

                        cfg.WriteBinary(writer);

                        cnt++;
                    }
                }

                writer.Stream.WriteInt(pos, cnt);
            }
            else
            {
                writer.WriteInt(0);
            }
        }
コード例 #6
0
        /// <summary>
        /// Writes this instance to a writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void Write(BinaryWriter writer)
        {
            Debug.Assert(writer != null);

            // Simple properties
            writer.WriteBooleanNullable(_clientMode);
            writer.WriteIntArray(IncludedEventTypes == null ? null : IncludedEventTypes.ToArray());

            writer.WriteTimeSpanAsLongNullable(_metricsExpireTime);
            writer.WriteIntNullable(_metricsHistorySize);
            writer.WriteTimeSpanAsLongNullable(_metricsLogFrequency);
            writer.WriteTimeSpanAsLongNullable(_metricsUpdateFrequency);
            writer.WriteIntNullable(_networkSendRetryCount);
            writer.WriteTimeSpanAsLongNullable(_networkSendRetryDelay);
            writer.WriteTimeSpanAsLongNullable(_networkTimeout);
            writer.WriteString(WorkDirectory);
            writer.WriteString(Localhost);
            writer.WriteBooleanNullable(_isDaemon);
            writer.WriteBooleanNullable(_isLateAffinityAssignment);

            // Cache config
            var caches = CacheConfiguration;

            if (caches == null)
            {
                writer.WriteInt(0);
            }
            else
            {
                writer.WriteInt(caches.Count);

                foreach (var cache in caches)
                {
                    cache.Write(writer);
                }
            }

            // Discovery config
            var disco = DiscoverySpi;

            if (disco != null)
            {
                writer.WriteBoolean(true);

                var tcpDisco = disco as TcpDiscoverySpi;

                if (tcpDisco == null)
                {
                    throw new InvalidOperationException("Unsupported discovery SPI: " + disco.GetType());
                }

                tcpDisco.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // Communication config
            var comm = CommunicationSpi;

            if (comm != null)
            {
                writer.WriteBoolean(true);

                var tcpComm = comm as TcpCommunicationSpi;

                if (tcpComm == null)
                {
                    throw new InvalidOperationException("Unsupported communication SPI: " + comm.GetType());
                }

                tcpComm.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // Binary config
            var isCompactFooterSet = BinaryConfiguration != null && BinaryConfiguration.CompactFooterInternal != null;

            writer.WriteBoolean(isCompactFooterSet);

            if (isCompactFooterSet)
            {
                writer.WriteBoolean(BinaryConfiguration.CompactFooter);
            }

            // User attributes
            var attrs = UserAttributes;

            if (attrs == null)
            {
                writer.WriteInt(0);
            }
            else
            {
                writer.WriteInt(attrs.Count);

                foreach (var pair in attrs)
                {
                    writer.WriteString(pair.Key);
                    writer.Write(pair.Value);
                }
            }

            // Atomic
            if (AtomicConfiguration != null)
            {
                writer.WriteBoolean(true);

                writer.WriteInt(AtomicConfiguration.AtomicSequenceReserveSize);
                writer.WriteInt(AtomicConfiguration.Backups);
                writer.WriteInt((int)AtomicConfiguration.CacheMode);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            // Tx
            if (TransactionConfiguration != null)
            {
                writer.WriteBoolean(true);

                writer.WriteInt(TransactionConfiguration.PessimisticTransactionLogSize);
                writer.WriteInt((int)TransactionConfiguration.DefaultTransactionConcurrency);
                writer.WriteInt((int)TransactionConfiguration.DefaultTransactionIsolation);
                writer.WriteLong((long)TransactionConfiguration.DefaultTimeout.TotalMilliseconds);
                writer.WriteLong((int)TransactionConfiguration.PessimisticTransactionLogLinger.TotalMilliseconds);
            }
            else
            {
                writer.WriteBoolean(false);
            }
        }
コード例 #7
0
        /// <summary>
        /// Writes this instance to a writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        private void WriteCore(BinaryWriter writer)
        {
            // Simple properties
            writer.WriteBoolean(ClientMode);
            writer.WriteIntArray(IncludedEventTypes == null ? null : IncludedEventTypes.ToArray());

            writer.WriteLong((long) MetricsExpireTime.TotalMilliseconds);
            writer.WriteInt(MetricsHistorySize);
            writer.WriteLong((long) MetricsLogFrequency.TotalMilliseconds);
            var metricsUpdateFreq = (long) MetricsUpdateFrequency.TotalMilliseconds;
            writer.WriteLong(metricsUpdateFreq >= 0 ? metricsUpdateFreq : -1);
            writer.WriteInt(NetworkSendRetryCount);
            writer.WriteLong((long) NetworkSendRetryDelay.TotalMilliseconds);
            writer.WriteLong((long) NetworkTimeout.TotalMilliseconds);
            writer.WriteString(WorkDirectory);
            writer.WriteString(Localhost);
            writer.WriteBoolean(IsDaemon);

            // Cache config
            var caches = CacheConfiguration;

            if (caches == null)
                writer.WriteInt(0);
            else
            {
                writer.WriteInt(caches.Count);

                foreach (var cache in caches)
                    cache.Write(writer);
            }

            // Discovery config
            var disco = DiscoverySpi;

            if (disco != null)
            {
                writer.WriteBoolean(true);

                var tcpDisco = disco as TcpDiscoverySpi;

                if (tcpDisco == null)
                    throw new InvalidOperationException("Unsupported discovery SPI: " + disco.GetType());

                tcpDisco.Write(writer);
            }
            else
                writer.WriteBoolean(false);

            // Binary config
            var isCompactFooterSet = BinaryConfiguration != null && BinaryConfiguration.CompactFooterInternal != null;

            writer.WriteBoolean(isCompactFooterSet);

            if (isCompactFooterSet)
                writer.WriteBoolean(BinaryConfiguration.CompactFooter);

            // User attributes
            var attrs = UserAttributes;

            if (attrs == null)
                writer.WriteInt(0);
            else
            {
                writer.WriteInt(attrs.Count);

                foreach (var pair in attrs)
                {
                    writer.WriteString(pair.Key);
                    writer.Write(pair.Value);
                }
            }

            // Atomic
            if (AtomicConfiguration != null)
            {
                writer.WriteBoolean(true);

                writer.WriteInt(AtomicConfiguration.AtomicSequenceReserveSize);
                writer.WriteInt(AtomicConfiguration.Backups);
                writer.WriteInt((int) AtomicConfiguration.CacheMode);
            }
            else
                writer.WriteBoolean(false);

            // Tx
            if (TransactionConfiguration != null)
            {
                writer.WriteBoolean(true);

                writer.WriteInt(TransactionConfiguration.PessimisticTransactionLogSize);
                writer.WriteInt((int) TransactionConfiguration.DefaultTransactionConcurrency);
                writer.WriteInt((int) TransactionConfiguration.DefaultTransactionIsolation);
                writer.WriteLong((long) TransactionConfiguration.DefaultTimeout.TotalMilliseconds);
                writer.WriteLong((int) TransactionConfiguration.PessimisticTransactionLogLinger.TotalMilliseconds);
            }
            else
                writer.WriteBoolean(false);
        }
コード例 #8
0
        /// <summary>
        /// Writes this instance to the specified writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void Write(BinaryWriter writer)
        {
            // Make sure system marshaller is used.
            Debug.Assert(writer.Marshaller == BinaryUtils.Marshaller);

            writer.WriteInt((int)AtomicityMode);
            writer.WriteInt(Backups);
            writer.WriteInt((int)CacheMode);
            writer.WriteBoolean(CopyOnRead);
            writer.WriteBoolean(EagerTtl);
            writer.WriteBoolean(Invalidate);
            writer.WriteBoolean(KeepBinaryInStore);
            writer.WriteBoolean(LoadPreviousValue);
            writer.WriteLong((long)LockTimeout.TotalMilliseconds);
#pragma warning disable 618
            writer.WriteLong((long)LongQueryWarningTimeout.TotalMilliseconds);
#pragma warning restore 618
            writer.WriteInt(MaxConcurrentAsyncOperations);
            writer.WriteString(Name);
            writer.WriteBoolean(ReadFromBackup);
            writer.WriteInt(RebalanceBatchSize);
            writer.WriteLong((long)RebalanceDelay.TotalMilliseconds);
            writer.WriteInt((int)RebalanceMode);
            writer.WriteLong((long)RebalanceThrottle.TotalMilliseconds);
            writer.WriteLong((long)RebalanceTimeout.TotalMilliseconds);
            writer.WriteBoolean(SqlEscapeAll);
            writer.WriteInt(WriteBehindBatchSize);
            writer.WriteBoolean(WriteBehindEnabled);
            writer.WriteLong((long)WriteBehindFlushFrequency.TotalMilliseconds);
            writer.WriteInt(WriteBehindFlushSize);
            writer.WriteInt(WriteBehindFlushThreadCount);
            writer.WriteBoolean(WriteBehindCoalescing);
            writer.WriteInt((int)WriteSynchronizationMode);
            writer.WriteBoolean(ReadThrough);
            writer.WriteBoolean(WriteThrough);
            writer.WriteBoolean(EnableStatistics);
            writer.WriteString(MemoryPolicyName);
            writer.WriteInt((int)PartitionLossPolicy);
            writer.WriteString(GroupName);
            writer.WriteObject(CacheStoreFactory);
            writer.WriteInt(SqlIndexMaxInlineSize);

            if (QueryEntities != null)
            {
                writer.WriteInt(QueryEntities.Count);

                foreach (var entity in QueryEntities)
                {
                    if (entity == null)
                    {
                        throw new InvalidOperationException("Invalid cache configuration: QueryEntity can't be null.");
                    }

                    entity.Write(writer);
                }
            }
            else
            {
                writer.WriteInt(0);
            }

            if (NearConfiguration != null)
            {
                writer.WriteBoolean(true);
                NearConfiguration.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            EvictionPolicyBase.Write(writer, EvictionPolicy);
            AffinityFunctionSerializer.Write(writer, AffinityFunction);
            ExpiryPolicySerializer.WritePolicyFactory(writer, ExpiryPolicyFactory);

            if (PluginConfigurations != null)
            {
                writer.WriteInt(PluginConfigurations.Count);

                foreach (var cachePlugin in PluginConfigurations)
                {
                    if (cachePlugin == null)
                    {
                        throw new InvalidOperationException("Invalid cache configuration: " +
                                                            "ICachePluginConfiguration can't be null.");
                    }

                    if (cachePlugin.CachePluginConfigurationClosureFactoryId != null)
                    {
                        writer.WriteBoolean(true);
                        writer.WriteInt(cachePlugin.CachePluginConfigurationClosureFactoryId.Value);

                        int pos = writer.Stream.Position;
                        writer.WriteInt(0);  // Reserve size.

                        cachePlugin.WriteBinary(writer);

                        writer.Stream.WriteInt(pos, writer.Stream.Position - pos - 4);  // Write size.
                    }
                    else
                    {
                        writer.WriteBoolean(false);
                        writer.WriteObject(cachePlugin);
                    }
                }
            }
            else
            {
                writer.WriteInt(0);
            }
        }
コード例 #9
0
 /// <summary>
 /// Writes the timespan.
 /// </summary>
 public static void WriteTimeSpanAsLong(this BinaryWriter writer, TimeSpan value)
 {
     writer.WriteLong((long)value.TotalMilliseconds);
 }