Exemplo n.º 1
0
        /// <summary>
        /// Put binary types to Grid.
        /// </summary>
        /// <param name="types">Binary types.</param>
        internal void PutBinaryTypes(ICollection <BinaryType> types)
        {
            DoOutOp(OpMeta, stream =>
            {
                BinaryWriter metaWriter = _marsh.StartMarshal(stream);

                metaWriter.WriteInt(types.Count);

                foreach (var meta in types)
                {
                    BinaryType meta0 = meta;

                    metaWriter.WriteInt(meta0.TypeId);
                    metaWriter.WriteString(meta0.TypeName);
                    metaWriter.WriteString(meta0.AffinityKeyFieldName);

                    IDictionary <string, int> fields = meta0.GetFieldsMap();

                    metaWriter.WriteInt(fields.Count);

                    foreach (var field in fields)
                    {
                        metaWriter.WriteString(field.Key);
                        metaWriter.WriteInt(field.Value);
                    }

                    metaWriter.WriteBoolean(meta.IsEnum);
                }

                _marsh.FinishMarshal(metaWriter);
            });

            _marsh.OnBinaryTypesSent(types);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Put binary types to Grid.
        /// </summary>
        /// <param name="types">Binary types.</param>
        internal void PutBinaryTypes(ICollection <BinaryType> types)
        {
            DoOutOp(OpMeta, stream =>
            {
                BinaryWriter w = _marsh.StartMarshal(stream);

                w.WriteInt(types.Count);

                foreach (var meta in types)
                {
                    w.WriteInt(meta.TypeId);
                    w.WriteString(meta.TypeName);
                    w.WriteString(meta.AffinityKeyFieldName);

                    IDictionary <string, int> fields = meta.GetFieldsMap();

                    w.WriteInt(fields.Count);

                    foreach (var field in fields)
                    {
                        w.WriteString(field.Key);
                        w.WriteInt(field.Value);
                    }

                    w.WriteBoolean(meta.IsEnum);

                    // Send schemas
                    var desc = meta.Descriptor;
                    Debug.Assert(desc != null);

                    var count    = 0;
                    var countPos = stream.Position;
                    w.WriteInt(0);  // Reserve for count

                    foreach (var schema in desc.Schema.GetAll())
                    {
                        w.WriteInt(schema.Key);

                        var ids = schema.Value;
                        w.WriteInt(ids.Length);

                        foreach (var id in ids)
                        {
                            w.WriteInt(id);
                        }

                        count++;
                    }

                    stream.WriteInt(countPos, count);
                }

                _marsh.FinishMarshal(w);
            });

            _marsh.OnBinaryTypesSent(types);
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Write dictionary.
        /// </summary>
        /// <param name="writer">Writer.</param>
        /// <param name="vals">Values.</param>
        /// <returns>The same writer.</returns>
        protected static BinaryWriter WriteDictionary <T1, T2>(BinaryWriter writer,
                                                               IDictionary <T1, T2> vals)
        {
            writer.WriteInt(vals.Count);

            foreach (KeyValuePair <T1, T2> pair in vals)
            {
                writer.Write(pair.Key);
                writer.Write(pair.Value);
            }

            return(writer);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Write a nullable item.
        /// </summary>
        /// <param name="writer">Writer.</param>
        /// <param name="item">Item.</param>
        /// <param name="writeItem">Write action to perform on item when it is not null.</param>
        /// <returns>The same writer for chaining.</returns>
        private static BinaryWriter WriteNullable <T>(BinaryWriter writer, T item,
                                                      Func <BinaryWriter, T, BinaryWriter> writeItem) where T : class
        {
            if (item == null)
            {
                writer.WriteBoolean(false);

                return(writer);
            }

            writer.WriteBoolean(true);

            return(writeItem(writer, item));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Write a nullable item.
        /// </summary>
        /// <param name="writer">Writer.</param>
        /// <param name="item">Item.</param>
        /// <param name="writeItem">Write action to perform on item when it is not null.</param>
        /// <returns>The same writer for chaining.</returns>
        protected static BinaryWriter WriteNullable <T>(BinaryWriter writer, T item,
                                                        Func <BinaryWriter, T, BinaryWriter> writeItem)
        {
            if (item == null)
            {
                writer.WriteBoolean(false);

                return(writer);
            }

            writer.WriteBoolean(true);

            return(writeItem(writer, item));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Writes buffer data to the specified writer.
        /// </summary>
        private void WriteBuffer(DataStreamerClientBuffer <TK, TV> buffer, BinaryWriter w)
        {
            w.WriteInt(_cacheId);
            w.WriteByte((byte)_flags);
            w.WriteInt(ServerBufferSizeAuto); // Server per-node buffer size.
            w.WriteInt(ServerBufferSizeAuto); // Server per-thread buffer size.

            if (_options.Receiver != null)
            {
                var rcvHolder = new StreamReceiverHolder(_options.Receiver,
                                                         (rec, grid, cache, stream, keepBinary) =>
                                                         StreamReceiverHolder.InvokeReceiver((IStreamReceiver <TK, TV>)rec, grid, cache, stream,
                                                                                             keepBinary));

                w.WriteObjectDetached(rcvHolder);
                w.WriteByte(ClientPlatformId.Dotnet);
            }
            else
            {
                w.WriteObject <object>(null);
            }

            var count = buffer.Count;

            w.WriteInt(count);

            var entries = buffer.Entries;

            for (var i = 0; i < count; i++)
            {
                var entry = entries[i];

                if (entry.IsEmpty)
                {
                    continue;
                }

                w.WriteObjectDetached(entry.Key);

                if (entry.Remove)
                {
                    w.WriteObject <object>(null);
                }
                else
                {
                    w.WriteObjectDetached(entry.Val);
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Writes this instance to a writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void Write(BinaryWriter writer)
        {
            Debug.Assert(writer != null);

            if (!string.IsNullOrEmpty(SpringConfigUrl))
            {
                // Do not write details when there is Spring config.
                writer.WriteBoolean(false);
                return;
            }

            writer.WriteBoolean(true);  // details are present

            WriteCore(writer);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Write dictionary.
        /// </summary>
        /// <param name="writer">Writer.</param>
        /// <param name="vals">Values.</param>
        protected static void WriteDictionary <T1, T2>(BinaryWriter writer, IEnumerable <KeyValuePair <T1, T2> > vals)
        {
            var pos = writer.Stream.Position;

            writer.WriteInt(0);  // Reserve count.

            int cnt = 0;

            foreach (var pair in vals)
            {
                writer.Write(pair.Key);
                writer.Write(pair.Value);

                cnt++;
            }

            writer.Stream.WriteInt(pos, cnt);
        }
Exemplo n.º 10
0
        private void Marshal(BinaryWriter writer)
        {
            var pos = writer.Stream.Position;

            try
            {
                if (Error == null)
                {
                    writer.WriteByte((byte)Entry.State);

                    if (Entry.State == MutableCacheEntryState.ValueSet)
                    {
                        writer.Write(Entry.Value);
                    }

                    writer.Write(ProcessResult);
                }
                else
                {
                    writer.WriteByte((byte)MutableCacheEntryState.ErrBinary);
                    writer.Write(Error);
                }
            }
            catch (Exception marshErr)
            {
                writer.Stream.Seek(pos, SeekOrigin.Begin);

                writer.WriteByte((byte)MutableCacheEntryState.ErrString);

                if (Error == null)
                {
                    writer.WriteString(string.Format(CultureInfo.InvariantCulture,
                                                     "CacheEntryProcessor completed with error, but result serialization failed [errType={0}, " +
                                                     "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
                }
                else
                {
                    writer.WriteString(string.Format(CultureInfo.InvariantCulture,
                                                     "CacheEntryProcessor completed with error, and error serialization failed [errType={0}, " +
                                                     "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Perform out-in operation.
        /// </summary>
        /// <param name="type">Operation type.</param>
        /// <param name="outAction">Out action.</param>
        /// <param name="inAction">In action.</param>
        protected void DoOutInOp(int type, Action <BinaryWriter> outAction, Action <IBinaryStream> inAction)
        {
            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().GetStream())
            {
                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().GetStream())
                {
                    BinaryWriter writer = _marsh.StartMarshal(outStream);

                    outAction(writer);

                    FinishMarshal(writer);

                    UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);

                    inStream.SynchronizeInput();

                    inAction(inStream);
                }
            }
        }
Exemplo n.º 12
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());
        }
Exemplo n.º 13
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());
        }
Exemplo n.º 14
0
        /// <summary>
        /// Perform out-in operation.
        /// </summary>
        /// <param name="type">Operation type.</param>
        /// <param name="outAction">Out action.</param>
        /// <param name="inAction">In action.</param>
        /// <param name="arg">Argument.</param>
        /// <returns>Result.</returns>
        protected unsafe TR DoOutInOp <TR>(int type, Action <BinaryWriter> outAction, Func <IBinaryStream, TR> inAction, void *arg)
        {
            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().GetStream())
            {
                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().GetStream())
                {
                    BinaryWriter writer = _marsh.StartMarshal(outStream);

                    outAction(writer);

                    FinishMarshal(writer);

                    UU.TargetInObjectStreamOutStream(_target, type, arg, outStream.SynchronizeOutput(), inStream.MemoryPointer);

                    inStream.SynchronizeInput();

                    return(inAction(inStream));
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Perform simple out-in operation accepting single argument.
        /// </summary>
        /// <param name="type">Operation type.</param>
        /// <param name="val">Value.</param>
        /// <returns>Result.</returns>
        protected TR DoOutInOp <T1, TR>(int type, T1 val)
        {
            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().GetStream())
            {
                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().GetStream())
                {
                    BinaryWriter writer = _marsh.StartMarshal(outStream);

                    writer.WriteObject(val);

                    FinishMarshal(writer);

                    UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);

                    inStream.SynchronizeInput();

                    return(Unmarshal <TR>(inStream));
                }
            }
        }
        private void Marshal(BinaryWriter writer)
        {
            var pos = writer.Stream.Position;

            try
            {
                if (Error == null)
                {
                    writer.WriteByte((byte) Entry.State);

                    if (Entry.State == MutableCacheEntryState.ValueSet)
                        writer.Write(Entry.Value);

                    writer.Write(ProcessResult);
                }
                else
                {
                    writer.WriteByte((byte) MutableCacheEntryState.ErrBinary);
                    writer.Write(Error);
                }
            }
            catch (Exception marshErr)
            {
                writer.Stream.Seek(pos, SeekOrigin.Begin);

                writer.WriteByte((byte) MutableCacheEntryState.ErrString);

                if (Error == null)
                {
                    writer.WriteString(string.Format(CultureInfo.InvariantCulture,
                    "CacheEntryProcessor completed with error, but result serialization failed [errType={0}, " +
                    "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
                }
                else
                {
                    writer.WriteString(string.Format(CultureInfo.InvariantCulture,
                    "CacheEntryProcessor completed with error, and error serialization failed [errType={0}, " +
                    "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Write enumerable.
        /// </summary>
        /// <param name="writer">Writer.</param>
        /// <param name="vals">Values.</param>
        /// <param name="selector">A transform function to apply to each element.</param>
        /// <returns>The same writer for chaining.</returns>
        protected static BinaryWriter WriteEnumerable <T1, T2>(BinaryWriter writer,
                                                               IEnumerable <T1> vals, Func <T1, T2> selector)
        {
            var col = vals as ICollection <T1>;

            if (col != null)
            {
                return(WriteCollection(writer, col, selector));
            }

            var stream = writer.Stream;

            var pos = stream.Position;

            stream.Seek(4, SeekOrigin.Current);

            var size = 0;

            if (selector == null)
            {
                foreach (var val in vals)
                {
                    writer.Write(val);

                    size++;
                }
            }
            else
            {
                foreach (var val in vals)
                {
                    writer.Write(selector(val));

                    size++;
                }
            }

            stream.WriteInt(pos, size);

            return(writer);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Write collection.
        /// </summary>
        /// <param name="writer">Writer.</param>
        /// <param name="vals">Values.</param>
        /// <param name="selector">A transform function to apply to each element.</param>
        /// <returns>The same writer for chaining.</returns>
        protected static BinaryWriter WriteCollection <T1, T2>(BinaryWriter writer,
                                                               ICollection <T1> vals, Func <T1, T2> selector)
        {
            writer.WriteInt(vals.Count);

            if (selector == null)
            {
                foreach (var val in vals)
                {
                    writer.Write(val);
                }
            }
            else
            {
                foreach (var val in vals)
                {
                    writer.Write(selector(val));
                }
            }

            return(writer);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Writes the scan query.
        /// </summary>
        private void WriteScanQuery(BinaryWriter writer, ScanQuery <TK, TV> qry)
        {
            Debug.Assert(qry != null);

            if (qry.Filter == null)
            {
                writer.WriteByte(BinaryUtils.HdrNull);
            }
            else
            {
                var holder = new CacheEntryFilterHolder(qry.Filter, (key, val) => qry.Filter.Invoke(
                                                            new CacheEntry <TK, TV>((TK)key, (TV)val)), writer.Marshaller, _keepBinary);

                writer.WriteObject(holder);

                writer.WriteByte(FilterPlatformDotnet);
            }

            writer.WriteInt(qry.PageSize);

            writer.WriteInt(qry.Partition ?? -1);

            writer.WriteBoolean(qry.Local);
        }
Exemplo n.º 20
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);
            }
        }
Exemplo n.º 21
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);
            }
        }
Exemplo n.º 22
0
 /// <summary>
 /// Writes key and value.
 /// </summary>
 private static void WriteKeyVal(BinaryWriter w, TK key, TV val)
 {
     w.WriteObjectDetached(key);
     w.WriteObjectDetached(val);
 }
Exemplo n.º 23
0
        /// <summary>
        /// Writes this instance to a writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void Write(BinaryWriter writer)
        {
            Debug.Assert(writer != null);

            if (!string.IsNullOrEmpty(SpringConfigUrl))
            {
                // Do not write details when there is Spring config.
                writer.WriteBoolean(false);
                return;
            }

            writer.WriteBoolean(true);  // details are present

            WriteCore(writer);
        }
Exemplo n.º 24
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);
        }
Exemplo n.º 25
0
 /// <summary>
 /// Finish marshaling.
 /// </summary>
 /// <param name="writer">Writer.</param>
 internal void FinishMarshal(BinaryWriter writer)
 {
     _marsh.FinishMarshal(writer);
 }
Exemplo n.º 26
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);
        }
Exemplo n.º 27
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);
            }
        }
Exemplo n.º 28
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
            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);
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// Finish marshaling.
 /// </summary>
 /// <param name="writer">Writer.</param>
 private void FinishMarshal(BinaryWriter writer)
 {
     _marsh.FinishMarshal(writer);
 }
Exemplo n.º 30
0
 /// <summary>
 /// Write collection.
 /// </summary>
 /// <param name="writer">Writer.</param>
 /// <param name="vals">Values.</param>
 /// <returns>The same writer for chaining.</returns>
 protected static BinaryWriter WriteCollection <T>(BinaryWriter writer, ICollection <T> vals)
 {
     return(WriteCollection <T, T>(writer, vals, null));
 }
Exemplo n.º 31
0
 /// <summary>
 /// Write nullable collection.
 /// </summary>
 /// <param name="writer">Writer.</param>
 /// <param name="vals">Values.</param>
 /// <returns>The same writer for chaining.</returns>
 protected static BinaryWriter WriteNullableCollection <T>(BinaryWriter writer, ICollection <T> vals)
 {
     return(WriteNullable(writer, vals, WriteCollection));
 }
Exemplo n.º 32
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);
        }
Exemplo n.º 33
0
 /// <summary>
 /// Write enumerable.
 /// </summary>
 /// <param name="writer">Writer.</param>
 /// <param name="vals">Values.</param>
 /// <returns>The same writer for chaining.</returns>
 protected static BinaryWriter WriteEnumerable <T>(BinaryWriter writer, IEnumerable <T> vals)
 {
     return(WriteEnumerable <T, T>(writer, vals, null));
 }