예제 #1
0
        /// <summary>
        /// Writes the configuration to writer.
        /// </summary>
        public static void Write(IBinaryRawWriter writer, ISwapSpaceSpi spi)
        {
            Debug.Assert(writer != null);

            var fileSwap = spi as FileSwapSpaceSpi;

            if (spi == null)
            {
                writer.WriteByte((byte) Type.None);
            }
            else if (fileSwap != null)
            {
                writer.WriteByte((byte) Type.File);

                writer.WriteString(fileSwap.BaseDirectory);
                writer.WriteFloat(fileSwap.MaximumSparsity);
                writer.WriteInt(fileSwap.MaximumWriteQueueSize);
                writer.WriteInt(fileSwap.ReadStripesNumber);
                writer.WriteInt(fileSwap.WriteBufferSize);

            }
            else
            {
                throw new InvalidOperationException("Unsupported swap space SPI: " + spi.GetType());
            }
        }
예제 #2
0
        /// <summary>
        /// Writes the policy.
        /// </summary>
        public static void WritePolicy(IBinaryRawWriter writer, IExpiryPolicy plc)
        {
            Debug.Assert(plc != null);
            Debug.Assert(writer != null);

            writer.WriteLong(ConvertDuration(plc.GetExpiryForCreate()));
            writer.WriteLong(ConvertDuration(plc.GetExpiryForUpdate()));
            writer.WriteLong(ConvertDuration(plc.GetExpiryForAccess()));
        }
        /// <summary>
        /// Writes this object to the given writer.
        /// </summary>
        public void WriteBinary(IBinaryRawWriter writer, bool changesOnly)
        {
            ((IgniteSessionStateItemCollection)Items).WriteBinary(writer, changesOnly);
            writer.WriteByteArray(SerializeStaticObjects());
            writer.WriteInt(Timeout);

            writer.WriteGuid(LockNodeId);
            writer.WriteLong(LockId);
            writer.WriteTimestamp(LockTime);
        }
        /** <inheritdoc /> */
        internal override void Write(IBinaryRawWriter writer)
        {
            base.Write(writer);

            var eps = Endpoints;

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

                foreach (var ep in eps)
                    writer.WriteString(ep);
            }
            else
                writer.WriteInt(0);
        }
예제 #5
0
        /// <summary>
        /// Writes the policy factory.
        /// </summary>
        public static void WritePolicyFactory(IBinaryRawWriter writer, IFactory<IExpiryPolicy> factory)
        {
            Debug.Assert(writer != null);

            if (factory != null)
            {
                writer.WriteBoolean(true);
                var expiryPolicy = factory.CreateInstance();

                if (expiryPolicy == null)
                    throw new IgniteException("ExpiryPolicyFactory should return non-null result.");

                WritePolicy(writer, expiryPolicy);
            }
            else
                writer.WriteBoolean(false);
        }
예제 #6
0
        /// <summary>
        /// Serializes content to the writer
        /// </summary>
        public override void InternalToBinary(IBinaryRawWriter writer)
        {
            base.InternalToBinary(writer);

            VersionSerializationHelper.EmitVersionByte(writer, VERSION_NUMBER);

            writer.WriteInt((int)ProfileTypeRequired);

            writer.WriteInt((int)ProfileStyle);

            writer.WriteBoolean(StartPoint != null);
            StartPoint?.ToBinary(writer);

            writer.WriteBoolean(EndPoint != null);
            EndPoint?.ToBinary(writer);

            writer.WriteBoolean(PositionsAreGrid);

            writer.WriteBoolean(ReturnAllPassesAndLayers);

            writer.WriteInt((int)VolumeType);
        }
예제 #7
0
        /// <summary>
        /// Serializes content to the writer
        /// </summary>
        public override void InternalToBinary(IBinaryRawWriter writer)
        {
            base.InternalToBinary(writer);

            VersionSerializationHelper.EmitVersionByte(writer, VERSION_NUMBER);

            writer.WriteString(FileName);
            writer.WriteInt((int)CoordType);
            writer.WriteInt((int)OutputType);
            UserPreferences.ToBinary(writer);
            var count = MappedMachines.Count;

            writer.WriteInt(count);
            foreach (var machine in MappedMachines)
            {
                writer.WriteGuid(machine.Uid);
                writer.WriteShort(machine.InternalSiteModelMachineIndex);
                writer.WriteString(machine.Name);
            }
            writer.WriteBoolean(RestrictOutputSize);
            writer.WriteBoolean(RawDataAsDBase);
        }
예제 #8
0
        /// <summary>
        /// Serialises content to the writer
        /// </summary>
        public override void InternalToBinary(IBinaryRawWriter writer)
        {
            base.InternalToBinary(writer);

            VersionSerializationHelper.EmitVersionByte(writer, VERSION_NUMBER);

            writer.WriteDouble(MinElevation);
            writer.WriteDouble(MaxElevation);
            writer.WriteDouble(ElevationPerBand);

            writer.WriteBoolean(ElevationPalette != null);

            if (ElevationPalette != null)
            {
                writer.WriteInt(ElevationPalette.Length);

                foreach (var color in ElevationPalette)
                {
                    writer.WriteInt(color.ToArgb());
                }
            }
        }
예제 #9
0
        public override void InternalToBinary(IBinaryRawWriter writer)
        {
            VersionSerializationHelper.EmitVersionByte(writer, VERSION_NUMBER);

            writer.WriteGuid(ProjectUID);
            writer.WriteByte((byte)Flags);
            writer.WriteInt((int)DeletionSelectivity);

            writer.WriteByte((byte)OriginS3TransferProxy);
            writer.WriteInt(NumberOfTAGFilesFromS3);
            writer.WriteInt(NumberOfTAGFileKeyCollections);
            writer.WriteInt(NumberOfTAGFilesSubmitted);
            writer.WriteInt(NumberOfTAGFilesProcessed);

            writer.WriteLong(LastUpdateUtcTicks);
            writer.WriteByte((byte)Phase);
            writer.WriteString(LastSubmittedTagFile);
            writer.WriteString(LastProcessedTagFile);

            writer.WriteByte((byte)DeletionResult);
            writer.WriteByte((byte)RebuildResult);
        }
예제 #10
0
        public override void InternalToBinary(IBinaryRawWriter writer)
        {
            base.InternalToBinary(writer);

            VersionSerializationHelper.EmitVersionByte(writer, VERSION_NUMBER);

            writer.WriteGuid(ProjectID);
            writer.WriteBoolean(DesignDescriptor != null);
            DesignDescriptor?.ToBinary(writer);

            writer.WriteLong(AsAtDate.Ticks);

            writer.WriteBoolean(Extents != null);
            Extents?.ToBinary(writer);

            writer.WriteBoolean(ExistenceMap != null);

            if (ExistenceMap != null)
            {
                writer.WriteByteArray(ExistenceMap.ToBytes());
            }
        }
예제 #11
0
        /// <summary>
        /// Serializes content to the writer
        /// </summary>
        public override void InternalToBinary(IBinaryRawWriter writer)
        {
            base.InternalToBinary(writer);

            VersionSerializationHelper.EmitVersionByte(writer, VERSION_NUMBER);

            writer.WriteGuid(ProjectID);
            writer.WriteInt((int)VolumeType);

            WriteFilter(writer, BaseFilter);
            WriteFilter(writer, TopFilter);

            writer.WriteBoolean(BaseDesign != null);
            BaseDesign?.ToBinary(writer);
            writer.WriteBoolean(TopDesign != null);
            TopDesign?.ToBinary(writer);

            WriteFilter(writer, AdditionalSpatialFilter);

            writer.WriteDouble(CutTolerance);
            writer.WriteDouble(FillTolerance);
        }
예제 #12
0
        /// <summary>
        /// Writes this instance to the specified writer.
        /// </summary>
        internal void Write(IBinaryRawWriter writer)
        {
            var ipFinder = IpFinder;

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

                var finder = ipFinder as TcpDiscoveryIpFinderBase;

                if (finder == null)
                {
                    throw new InvalidOperationException("Unsupported IP finder: " + ipFinder.GetType());
                }

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

            writer.WriteLong((long)SocketTimeout.TotalMilliseconds);
            writer.WriteLong((long)AckTimeout.TotalMilliseconds);
            writer.WriteLong((long)MaxAckTimeout.TotalMilliseconds);
            writer.WriteLong((long)NetworkTimeout.TotalMilliseconds);
            writer.WriteLong((long)JoinTimeout.TotalMilliseconds);

            writer.WriteBoolean(ForceServerMode);
            writer.WriteBoolean(ClientReconnectDisabled);
            writer.WriteString(LocalAddress);
            writer.WriteInt(ReconnectCount);
            writer.WriteInt(LocalPort);
            writer.WriteInt(LocalPortRange);
            writer.WriteLong((long)StatisticsPrintFrequency.TotalMilliseconds);
            writer.WriteLong((long)IpFinderCleanFrequency.TotalMilliseconds);
            writer.WriteInt(ThreadPriority);
            writer.WriteInt(TopologyHistorySize);
        }
예제 #13
0
        /// <summary>
        /// Writes the instance.
        /// </summary>
        internal static void Write(IBinaryRawWriter writer, IAffinityFunction fun, object userFuncOverride = null)
        {
            Debug.Assert(writer != null);

            if (fun == null)
            {
                writer.WriteByte(TypeCodeNull);
                return;
            }

            // 1) Type code
            // 2) Partitions
            // 3) ExcludeNeighbors
            // 4) Override flags
            // 5) User object

            var p = fun as AffinityFunctionBase;

            if (p != null)
            {
                writer.WriteByte(p is FairAffinityFunction ? TypeCodeFair : TypeCodeRendezvous);
                writer.WriteInt(p.Partitions);
                writer.WriteBoolean(p.ExcludeNeighbors);

                var overrideFlags = GetOverrideFlags(p.GetType());
                writer.WriteByte((byte)overrideFlags);

                // Do not write user func if there is nothing overridden
                WriteUserFunc(writer, overrideFlags != UserOverrides.None ? fun : null, userFuncOverride);
            }
            else
            {
                writer.WriteByte(TypeCodeUser);
                writer.WriteInt(fun.Partitions);
                writer.WriteBoolean(false); // Exclude neighbors
                writer.WriteByte((byte)UserOverrides.All);
                WriteUserFunc(writer, fun, userFuncOverride);
            }
        }
예제 #14
0
        /// <summary>
        /// Serializes content to the writer
        /// </summary>
        public override void InternalToBinary(IBinaryRawWriter writer)
        {
            base.InternalToBinary(writer);

            VersionSerializationHelper.EmitVersionByte(writer, VERSION_NUMBER);

            writer.WriteBoolean(Cut.HasValue);
            if (Cut.HasValue)
            {
                writer.WriteDouble(Cut.Value);
            }

            writer.WriteBoolean(Fill.HasValue);
            if (Fill.HasValue)
            {
                writer.WriteDouble(Fill.Value);
            }

            writer.WriteBoolean(TotalCoverageArea.HasValue);
            if (TotalCoverageArea.HasValue)
            {
                writer.WriteDouble(TotalCoverageArea.Value);
            }

            writer.WriteBoolean(CutArea.HasValue);
            if (CutArea.HasValue)
            {
                writer.WriteDouble(CutArea.Value);
            }

            writer.WriteBoolean(FillArea.HasValue);
            if (FillArea.HasValue)
            {
                writer.WriteDouble(FillArea.Value);
            }

            BoundingExtentGrid.ToBinary(writer);
            BoundingExtentLLH.ToBinary(writer);
        }
        /// <summary>
        /// Writes the instance.
        /// </summary>
        internal static void Write(IBinaryRawWriter writer, IAffinityFunction fun, object userFuncOverride = null)
        {
            Debug.Assert(writer != null);

            if (fun == null)
            {
                writer.WriteByte(TypeCodeNull);
                return;
            }

            // 1) Type code
            // 2) Partitions
            // 3) ExcludeNeighbors
            // 4) Override flags
            // 5) User object

            var p = fun as AffinityFunctionBase;

            if (p != null)
            {
                writer.WriteByte(p is FairAffinityFunction ? TypeCodeFair : TypeCodeRendezvous);
                writer.WriteInt(p.Partitions);
                writer.WriteBoolean(p.ExcludeNeighbors);

                var overrideFlags = GetOverrideFlags(p.GetType());
                writer.WriteByte((byte) overrideFlags);

                // Do not write user func if there is nothing overridden
                WriteUserFunc(writer, overrideFlags != UserOverrides.None ? fun : null, userFuncOverride);
            }
            else
            {
                writer.WriteByte(TypeCodeUser);
                writer.WriteInt(fun.Partitions);
                writer.WriteBoolean(false); // Exclude neighbors
                writer.WriteByte((byte) UserOverrides.All);
                WriteUserFunc(writer, fun, userFuncOverride);
            }
        }
예제 #16
0
        /// <summary>
        /// Writes this instance.
        /// </summary>
        internal void Write(IBinaryRawWriter writer)
        {
            writer.WriteString(Name);
            writer.WriteByte((byte)IndexType);
            writer.WriteInt(InlineSize);

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

                foreach (var field in Fields)
                {
                    writer.WriteString(field.Name);
                    writer.WriteBoolean(field.IsDescending);
                }
            }
            else
            {
                writer.WriteInt(0);
            }

            writer.WriteString(LuceneIndexOptions);
        }
예제 #17
0
        /// <summary>
        /// Writes the SSL context factory.
        /// </summary>
        internal static void Write(IBinaryRawWriter writer, ISslContextFactory factory)
        {
            Debug.Assert(writer != null);

            var contextFactory = factory as SslContextFactory;

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

                contextFactory.Write(writer);
            }
            else if (factory != null)
            {
                throw new NotSupportedException(
                          string.Format("Unsupported {0}: {1}. Only predefined implementations are supported: {2}",
                                        typeof(ISslContextFactory).Name, factory.GetType(), typeof(SslContextFactory).Name));
            }
            else
            {
                writer.WriteBoolean(false);
            }
        }
예제 #18
0
        public override void InternalToBinary(IBinaryRawWriter writer)
        {
            VersionSerializationHelper.EmitVersionByte(writer, VERSION_NUMBER);

            writer.WriteInt((int)ReturnCode);
            writer.WriteDouble(Northing);
            writer.WriteDouble(Easting);
            writer.WriteInt(CellPasses.Count);

            using (var ms = RecyclableMemoryStreamManagerHelper.Manager.GetStream())
            {
                using (var bw = new BinaryWriter(ms, Encoding.UTF8, true))
                {
                    CellPasses.ForEach(result =>
                    {
                        result.Write(bw);
                    });
                }

                var bytes = ms.ToArray();
                writer.WriteByteArray(bytes);
            }
        }
        /// <summary>
        /// Writes to the specified writer.
        /// </summary>
        internal void Write(ClientProtocolVersion ver, IBinaryRawWriter writer)
        {
            Debug.Assert(writer != null);

            writer.WriteString(Host);
            writer.WriteInt(Port);
            writer.WriteInt(PortRange);
            writer.WriteInt(SocketSendBufferSize);
            writer.WriteInt(SocketReceiveBufferSize);
            writer.WriteBoolean(TcpNoDelay);
            writer.WriteInt(MaxOpenCursorsPerConnection);
            writer.WriteInt(ThreadPoolSize);
            writer.WriteTimeSpanAsLong(IdleTimeout);

            writer.WriteBoolean(ThinClientEnabled);
            writer.WriteBoolean(OdbcEnabled);
            writer.WriteBoolean(JdbcEnabled);

            if (ver.CompareTo(ClientSocket.Ver130) >= 0)
            {
                writer.WriteTimeSpanAsLong(HandshakeTimeout);
            }
        }
예제 #20
0
        /// <summary>
        /// Serializes the Service configuration using IBinaryRawWriter
        /// </summary>
        /// <param name="w">IBinaryRawWriter</param>
        internal void Write(IBinaryRawWriter w)
        {
            Debug.Assert(w != null);

            w.WriteString(Name);
            w.WriteObject(Service);
            w.WriteInt(TotalCount);
            w.WriteInt(MaxPerNodeCount);
            w.WriteString(CacheName);
            w.WriteObject(AffinityKey);

            if (NodeFilter != null)
            {
                w.WriteObject(NodeFilter);
            }
            else
            {
                w.WriteObject <object>(null);
            }

            w.WriteBoolean(StatisticsEnabled);

            WriteExtraDescription(w);
        }
        /// <summary>
        /// Writes this instance to the specified writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void Write(IBinaryRawWriter writer)
        {
            Debug.Assert(writer != null);

            writer.WriteString(PersistentStorePath);
            writer.WriteTimeSpanAsLong(CheckpointingFrequency);
            writer.WriteLong(CheckpointingPageBufferSize);
            writer.WriteInt(CheckpointingThreads);
            writer.WriteTimeSpanAsLong(LockWaitTime);
            writer.WriteInt(WalHistorySize);
            writer.WriteInt(WalSegments);
            writer.WriteInt(WalSegmentSize);
            writer.WriteString(WalStorePath);
            writer.WriteString(WalArchivePath);
            writer.WriteInt((int)WalMode);
            writer.WriteInt(TlbSize);
            writer.WriteTimeSpanAsLong(WalFlushFrequency);
            writer.WriteLong(WalFsyncDelayNanos);
            writer.WriteInt(WalRecordIteratorBufferSize);
            writer.WriteBoolean(AlwaysWriteFullPages);
            writer.WriteBoolean(MetricsEnabled);
            writer.WriteInt(SubIntervals);
            writer.WriteTimeSpanAsLong(RateTimeInterval);
        }
        /// <summary>
        /// Writes to the specified writer.
        /// </summary>
        internal static void Write(IBinaryRawWriter writer, IEvictionPolicy policy)
        {
            if (policy == null)
            {
                writer.WriteByte(0);
                return;
            }

            var p = policy as EvictionPolicyBase;

            if (p == null)
            {
                throw new NotSupportedException(
                          string.Format("Unsupported Eviction Policy: {0}. Only predefined eviction policy types " +
                                        "are supported: {1}, {2}", policy.GetType(), typeof(LruEvictionPolicy),
                                        typeof(FifoEvictionPolicy)));
            }

            writer.WriteByte(p is FifoEvictionPolicy ? (byte)1 : (byte)2);

            writer.WriteInt(p.BatchSize);
            writer.WriteInt(p.MaxSize);
            writer.WriteLong(p.MaxMemorySize);
        }
예제 #23
0
        /// <summary>
        /// Writes the key.
        /// </summary>
        private static void WriteKey(DbCacheKey key, IBinaryRawWriter writer, bool includeNames)
        {
            writer.WriteString(key.Key);

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

                // Versions should be in the same order, so we can't iterate over the dictionary.
                foreach (var entitySet in key.EntitySets)
                {
                    writer.WriteLong(key.EntitySetVersions[entitySet.Name]);

                    if (includeNames)
                    {
                        writer.WriteString(entitySet.Name);
                    }
                }
            }
            else
            {
                writer.WriteInt(-1);
            }
        }
예제 #24
0
        /// <summary>
        /// Writes the SQL fields query.
        /// </summary>
        private static void WriteSqlFieldsQuery(IBinaryRawWriter writer, SqlFieldsQuery qry,
                                                bool includeColumns = true)
        {
            Debug.Assert(qry != null);

            writer.WriteString(qry.Schema);
            writer.WriteInt(qry.PageSize);
            writer.WriteInt(-1);  // maxRows: unlimited
            writer.WriteString(qry.Sql);
            QueryBase.WriteQueryArgs(writer, qry.Arguments);

            // .NET client does not discern between different statements for now.
            // We cound have ExecuteNonQuery method, which uses StatementType.Update, for example.
            writer.WriteByte((byte)StatementType.Any);

            writer.WriteBoolean(qry.EnableDistributedJoins);
            writer.WriteBoolean(qry.Local);
            writer.WriteBoolean(qry.ReplicatedOnly);
            writer.WriteBoolean(qry.EnforceJoinOrder);
            writer.WriteBoolean(qry.Colocated);
            writer.WriteBoolean(qry.Lazy);
            writer.WriteTimeSpanAsLong(qry.Timeout);
            writer.WriteBoolean(includeColumns);
        }
예제 #25
0
        public override void InternalToBinary(IBinaryRawWriter writer)
        {
            VersionSerializationHelper.EmitVersionByte(writer, VERSION_NUMBER);

            writer.WriteByteArray(Bytes);
        }
예제 #26
0
 public void WriteBinary(IBinaryRawWriter writer)
 {
     throw new NotSupportedException();
 }
        /// <summary>
        /// Writes the user function.
        /// </summary>
        private static void WriteUserFunc(IBinaryRawWriter writer, IAffinityFunction func, object funcOverride)
        {
            if (funcOverride != null)
            {
                writer.WriteObject(funcOverride);
                return;
            }

            if (func != null && !func.GetType().IsSerializable)
                throw new IgniteException("AffinityFunction should be serializable.");

            writer.WriteObject(func);
        }
 /// <summary>
 /// Writes to the specified writer.
 /// </summary>
 internal void Write(IBinaryRawWriter writer)
 {
     writer.WriteInt(NearStartSize);
     EvictionPolicyBase.Write(writer, EvictionPolicy);
 }
예제 #29
0
 /** <inheritdoc /> */
 public void WriteBinary(IBinaryRawWriter writer)
 {
     writer.WriteString(PluginProperty);
 }
예제 #30
0
        /// <summary>
        /// The service has no serialization requirements
        /// </summary>
        public override void InternalToBinary(IBinaryRawWriter writer)
        {
            VersionSerializationHelper.EmitVersionByte(writer, VERSION_NUMBER);

            writer.WriteLong(retirementAge.Ticks);
        }
예제 #31
0
        /// <summary>
        /// Writes this instane to the specified writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void Write(IBinaryRawWriter writer)
        {
            writer.WriteInt((int) AtomicityMode);
            writer.WriteInt((int) AtomicWriteOrderMode);
            writer.WriteInt(Backups);
            writer.WriteInt((int) CacheMode);
            writer.WriteBoolean(CopyOnRead);
            writer.WriteBoolean(EagerTtl);
            writer.WriteBoolean(EnableSwap);
            writer.WriteBoolean(EvictSynchronized);
            writer.WriteInt(EvictSynchronizedConcurrencyLevel);
            writer.WriteInt(EvictSynchronizedKeyBufferSize);
            writer.WriteLong((long) EvictSynchronizedTimeout.TotalMilliseconds);
            writer.WriteBoolean(Invalidate);
            writer.WriteBoolean(KeepBinaryInStore);
            writer.WriteBoolean(LoadPreviousValue);
            writer.WriteLong((long) LockTimeout.TotalMilliseconds);
            writer.WriteLong((long) LongQueryWarningTimeout.TotalMilliseconds);
            writer.WriteInt(MaxConcurrentAsyncOperations);
            writer.WriteFloat(MaxEvictionOverflowRatio);
            writer.WriteInt((int) MemoryMode);
            writer.WriteString(Name);
            writer.WriteLong(OffHeapMaxMemory);
            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(SqlOnheapRowCacheSize);
            writer.WriteInt(StartSize);
            writer.WriteInt(WriteBehindBatchSize);
            writer.WriteBoolean(WriteBehindEnabled);
            writer.WriteLong((long) WriteBehindFlushFrequency.TotalMilliseconds);
            writer.WriteInt(WriteBehindFlushSize);
            writer.WriteInt(WriteBehindFlushThreadCount);
            writer.WriteInt((int) WriteSynchronizationMode);
            writer.WriteObject(CacheStoreFactory);

            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);
        }
예제 #32
0
        /// <summary>
        /// Writes this instance.
        /// </summary>
        internal void Write(IBinaryRawWriter writer)
        {
            writer.WriteString(Name);
            writer.WriteByte((byte) IndexType);

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

                foreach (var field in Fields)
                {
                    writer.WriteString(field.Name);
                    writer.WriteBoolean(field.IsDescending);
                }
            }
            else
                writer.WriteInt(0);
        }
예제 #33
0
        /// <summary>
        /// Writes this instance.
        /// </summary>
        internal void Write(IBinaryRawWriter writer)
        {
            writer.WriteString(KeyTypeName);
            writer.WriteString(ValueTypeName);

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

                foreach (var field in Fields)
                {
                    writer.WriteString(field.Name);
                    writer.WriteString(field.FieldTypeName);
                }
            }
            else
                writer.WriteInt(0);

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

                foreach (var queryAlias in Aliases)
                {
                    writer.WriteString(queryAlias.FullName);
                    writer.WriteString(queryAlias.Alias);
                }
            }
            else
                writer.WriteInt(0);

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

                foreach (var index in Indexes)
                {
                    if (index == null)
                        throw new InvalidOperationException("Invalid cache configuration: QueryIndex can't be null.");

                    index.Write(writer);
                }
            }
            else
                writer.WriteInt(0);
        }
예제 #34
0
 /// <summary>
 /// Writes this instance to the specified writer.
 /// </summary>
 internal void Write(IBinaryRawWriter writer)
 {
     writer.WriteInt(AckSendThreshold);
     writer.WriteLong((long) ConnectTimeout.TotalMilliseconds);
     writer.WriteBoolean(DirectBuffer);
     writer.WriteBoolean(DirectSendBuffer);
     writer.WriteLong((long) IdleConnectionTimeout.TotalMilliseconds);
     writer.WriteString(LocalAddress);
     writer.WriteInt(LocalPort);
     writer.WriteInt(LocalPortRange);
     writer.WriteLong((long) MaxConnectTimeout.TotalMilliseconds);
     writer.WriteInt(MessageQueueLimit);
     writer.WriteInt(ReconnectCount);
     writer.WriteInt(SelectorsCount);
     writer.WriteInt(SlowClientQueueLimit);
     writer.WriteInt(SocketReceiveBufferSize);
     writer.WriteInt(SocketSendBufferSize);
     writer.WriteBoolean(TcpNoDelay);
     writer.WriteInt(UnacknowledgedMessagesBufferSize);
 }
예제 #35
0
        /// <summary>
        /// Writes this instance to the specified writer.
        /// </summary>
        internal void Write(IBinaryRawWriter writer)
        {
            var ipFinder = IpFinder;

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

                var finder = ipFinder as TcpDiscoveryIpFinderBase;

                if (finder == null)
                    throw new InvalidOperationException("Unsupported IP finder: " + ipFinder.GetType());

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

            writer.WriteLong((long) SocketTimeout.TotalMilliseconds);
            writer.WriteLong((long) AckTimeout.TotalMilliseconds);
            writer.WriteLong((long) MaxAckTimeout.TotalMilliseconds);
            writer.WriteLong((long) NetworkTimeout.TotalMilliseconds);
            writer.WriteLong((long) JoinTimeout.TotalMilliseconds);
        }
예제 #36
0
        /// <summary>
        /// Writes to the specified writer.
        /// </summary>
        internal static void Write(IBinaryRawWriter writer, IEvictionPolicy policy)
        {
            if (policy == null)
            {
                writer.WriteByte(0);
                return;
            }

            var p = policy as EvictionPolicyBase;

            if (p == null)
            {
                throw new NotSupportedException(
                    string.Format("Unsupported Eviction Policy: {0}. Only predefined eviction policy types " +
                                  "are supported: {1}, {2}", policy.GetType(), typeof (LruEvictionPolicy),
                        typeof (FifoEvictionPolicy)));
            }

            writer.WriteByte(p is FifoEvictionPolicy ? (byte) 1 : (byte) 2);

            writer.WriteInt(p.BatchSize);
            writer.WriteInt(p.MaxSize);
            writer.WriteLong(p.MaxMemorySize);
        }
        /// <summary>
        /// Writes this object to the given writer.
        /// </summary>
        public void WriteBinary(IBinaryRawWriter writer, bool changesOnly)
        {
            IgniteArgumentCheck.NotNull(writer, "writer");

            if (_isNew || _dirtyAll || !changesOnly || (_removedKeys == null && _list.All(x => x.IsDirty)))
            {
                // Write in full mode.
                writer.WriteInt(_list.Count);

                foreach (var entry in _list)
                {
                    writer.WriteString(entry.Key);

                    // Write as byte array to enable partial deserialization.
                    writer.WriteByteArray(entry.GetBytes());
                }
            }
            else
            {
                // Write in diff mode.
                var removed = GetRemovedKeys();

                var count = _list.Count(x => x.IsDirty) + (removed == null ? 0 : removed.Count);

                writer.WriteInt(count);  // reserve count

                // Write removed keys as [key + null].
                if (removed != null)
                {
                    foreach (var removedKey in removed)
                    {
                        writer.WriteString(removedKey);
                        writer.WriteByteArray(null);
                    }
                }

                // Write dirty items.
                foreach (var entry in _list)
                {
                    if (!entry.IsDirty)
                        continue;

                    writer.WriteString(entry.Key);

                    // Write as byte array to enable partial deserialization.
                    writer.WriteByteArray(entry.GetBytes());
                }
            }
        }
예제 #38
0
 public void WriteBinary(IBinaryRawWriter writer)
 {
     // No-op
 }
 /// <summary>
 /// Writes this instance to the specified writer.
 /// </summary>
 /// <param name="writer">The writer.</param>
 internal virtual void Write(IBinaryRawWriter writer)
 {
     writer.WriteByte(TypeCode);
 }
예제 #40
0
        /// <summary>
        /// Writes this instance to the specified writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void Write(IBinaryRawWriter writer)
        {
            writer.WriteInt((int)AtomicityMode);
            writer.WriteInt((int)AtomicWriteOrderMode);
            writer.WriteInt(Backups);
            writer.WriteInt((int)CacheMode);
            writer.WriteBoolean(CopyOnRead);
            writer.WriteBoolean(EagerTtl);
            writer.WriteBoolean(EnableSwap);
            writer.WriteBoolean(EvictSynchronized);
            writer.WriteInt(EvictSynchronizedConcurrencyLevel);
            writer.WriteInt(EvictSynchronizedKeyBufferSize);
            writer.WriteLong((long)EvictSynchronizedTimeout.TotalMilliseconds);
            writer.WriteBoolean(Invalidate);
            writer.WriteBoolean(KeepBinaryInStore);
            writer.WriteBoolean(LoadPreviousValue);
            writer.WriteLong((long)LockTimeout.TotalMilliseconds);
            writer.WriteLong((long)LongQueryWarningTimeout.TotalMilliseconds);
            writer.WriteInt(MaxConcurrentAsyncOperations);
            writer.WriteFloat(MaxEvictionOverflowRatio);
            writer.WriteInt((int)MemoryMode);
            writer.WriteString(Name);
            writer.WriteLong(OffHeapMaxMemory);
            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(SqlOnheapRowCacheSize);
            writer.WriteInt(StartSize);
            writer.WriteInt(WriteBehindBatchSize);
            writer.WriteBoolean(WriteBehindEnabled);
            writer.WriteLong((long)WriteBehindFlushFrequency.TotalMilliseconds);
            writer.WriteInt(WriteBehindFlushSize);
            writer.WriteInt(WriteBehindFlushThreadCount);
            writer.WriteInt((int)WriteSynchronizationMode);
            writer.WriteBoolean(ReadThrough);
            writer.WriteBoolean(WriteThrough);
            writer.WriteBoolean(EnableStatistics);
            writer.WriteObject(CacheStoreFactory);

            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);
                        cachePlugin.WriteBinary(writer);
                    }
                    else
                    {
                        if (!cachePlugin.GetType().IsSerializable)
                        {
                            throw new InvalidOperationException("Invalid cache configuration: " +
                                                                "ICachePluginConfiguration should be Serializable.");
                        }

                        writer.WriteBoolean(false);
                        writer.WriteObject(cachePlugin);
                    }
                }
            }
            else
            {
                writer.WriteInt(0);
            }
        }
예제 #41
0
 /// <summary>
 /// Serializes content to the writer
 /// </summary>
 public void ToBinary(IBinaryRawWriter writer)
 {
     writer.WriteDouble(Lat);
     writer.WriteDouble(Lon);
     writer.WriteDouble(Height);
 }
 void ICachePluginConfiguration.WriteBinary(IBinaryRawWriter writer)
 {
     throw new NotImplementedException();
 }
예제 #43
0
        /// <summary>
        /// Writes this instance to the specified writer.
        /// </summary>
        internal void Write(IBinaryRawWriter writer)
        {
            var ipFinder = IpFinder;

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

                var finder = ipFinder as TcpDiscoveryIpFinderBase;

                if (finder == null)
                    throw new InvalidOperationException("Unsupported IP finder: " + ipFinder.GetType());

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

            writer.WriteLong((long) SocketTimeout.TotalMilliseconds);
            writer.WriteLong((long) AckTimeout.TotalMilliseconds);
            writer.WriteLong((long) MaxAckTimeout.TotalMilliseconds);
            writer.WriteLong((long) NetworkTimeout.TotalMilliseconds);
            writer.WriteLong((long) JoinTimeout.TotalMilliseconds);

            writer.WriteBoolean(ForceServerMode);
            writer.WriteBoolean(ClientReconnectDisabled);
            writer.WriteString(LocalAddress);
            writer.WriteInt(ReconnectCount);
            writer.WriteInt(LocalPort);
            writer.WriteInt(LocalPortRange);
            writer.WriteInt(MaxMissedHeartbeats);
            writer.WriteInt(MaxMissedClientHeartbeats);
            writer.WriteLong((long) StatisticsPrintFrequency.TotalMilliseconds);
            writer.WriteLong((long) IpFinderCleanFrequency.TotalMilliseconds);
            writer.WriteInt(ThreadPriority);
            writer.WriteLong((long) HeartbeatFrequency.TotalMilliseconds);
            writer.WriteInt(TopologyHistorySize);
        }
예제 #44
0
파일: DbCache.cs 프로젝트: vladisav/ignite
        /// <summary>
        /// Writes the key.
        /// </summary>
        private static void WriteKey(DbCacheKey key, IBinaryRawWriter writer, bool includeNames)
        {
            writer.WriteString(key.Key);

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

                // Versions should be in the same order, so we can't iterate over the dictionary.
                foreach (var entitySet in key.EntitySets)
                {
                    writer.WriteLong(key.EntitySetVersions[entitySet.Name]);

                    if (includeNames)
                        writer.WriteString(entitySet.Name);
                }
            }
            else
            {
                writer.WriteInt(-1);
            }
        }
 /// <summary>
 /// Writes the timespan.
 /// </summary>
 public static void WriteTimeSpanAsLong(this IBinaryRawWriter writer, TimeSpan value)
 {
     writer.WriteLong((long)value.TotalMilliseconds);
 }
예제 #46
0
        /// <summary>
        /// Writes the instance.
        /// </summary>
        internal static void Write(IBinaryRawWriter writer, IAffinityFunction fun)
        {
            if (fun == null)
            {
                writer.WriteByte(TypeCodeNull);
                return;
            }

            var p = fun as AffinityFunctionBase;

            if (p != null)
            {
                ValidateAffinityFunctionType(p.GetType());
                writer.WriteByte(p is FairAffinityFunction ? TypeCodeFair : TypeCodeRendezvous);
                writer.WriteInt(p.Partitions);
                writer.WriteBoolean(p.ExcludeNeighbors);
            }
            else
            {
                writer.WriteByte(TypeCodeUser);

                if (!fun.GetType().IsSerializable)
                    throw new IgniteException("AffinityFunction should be serializable.");

                writer.WriteObject(fun);
                writer.WriteInt(fun.Partitions);  // partition count is written once and can not be changed.
            }
        }
예제 #47
0
 /// <summary>
 /// Serialises content of the cell to the writer
 /// </summary>
 /// <param name="writer"></param>
 public void ToBinary(IBinaryRawWriter writer)
 {
     writer.WriteDouble(Min);
     writer.WriteDouble(Max);
 }
예제 #48
0
 public abstract void InternalToBinary(IBinaryRawWriter writer);
예제 #49
0
 public void WriteBinary(IBinaryRawWriter writer)
 {
     throw new NotImplementedException();
 }
예제 #50
0
        /** <inheritdoc /> */
        internal override void Write(IBinaryRawWriter writer)
        {
            base.Write(writer);

            writer.WriteString(LocalAddress);
            writer.WriteString(MulticastGroup);
            writer.WriteInt(MulticastPort);
            writer.WriteInt(AddressRequestAttempts);
            writer.WriteInt((int) ResponseTimeout.TotalMilliseconds);

            writer.WriteBoolean(TimeToLive.HasValue);

            if (TimeToLive.HasValue)
                writer.WriteInt(TimeToLive.Value);
        }