/// <summary> /// Writes the user function. /// </summary> private static void WriteUserFunc(IBinaryRawWriter writer, IAffinityFunction func, object funcOverride) { if (funcOverride != null) { writer.WriteObject(funcOverride); return; } writer.WriteObject(func); }
/// <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 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) { 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. } }
/// <summary> /// Write query arguments. /// </summary> /// <param name="writer">Writer.</param> /// <param name="args">Arguments.</param> internal static void WriteQueryArgs(IBinaryRawWriter writer, object[] args) { if (args == null) { writer.WriteInt(0); } else { writer.WriteInt(args.Length); foreach (var arg in args) { // Write DateTime as TimeStamp always, otherwise it does not make sense // Wrapped DateTime comparison does not work in SQL var dt = arg as DateTime?; // Works with DateTime also if (dt != null) { writer.WriteTimestamp(dt); } else { writer.WriteObject(arg); } } } }
/// <summary> /// Writes the load cache data to the writer. /// </summary> private void WriteLoadCacheData(IBinaryRawWriter writer, ICacheEntryFilter <TK, TV> p, object[] args) { if (p != null) { var p0 = new CacheEntryFilterHolder(p, (k, v) => p.Invoke(new CacheEntry <TK, TV>((TK)k, (TV)v)), Marshaller, IsKeepBinary); writer.WriteObject(p0); } else { writer.WriteObject <CacheEntryFilterHolder>(null); } writer.WriteArray(args); }
/// <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); } }
/// <summary> /// Write task to the writer. /// </summary> /// <param name="writer">Writer.</param> /// <param name="taskName">Task name.</param> /// <param name="taskArg">Task arg.</param> /// <param name="nodes">Nodes.</param> private void WriteTask(IBinaryRawWriter writer, string taskName, object taskArg, ICollection <IClusterNode> nodes) { writer.WriteString(taskName); writer.WriteBoolean(_keepBinary.Value); writer.WriteObject(taskArg); WriteNodeIds(writer, nodes); }
/// <summary> /// Writes the remote query. /// </summary> /// <param name="filter">The filter.</param> /// <param name="timeout">The timeout.</param> /// <param name="types">The types.</param> /// <param name="writer">The writer.</param> private static void WriteRemoteQuery <T>(IEventFilter <T> filter, TimeSpan?timeout, int[] types, IBinaryRawWriter writer) where T : IEvent { writer.WriteObject(filter); writer.WriteLong((long)(timeout == null ? 0 : timeout.Value.TotalMilliseconds)); WriteEventTypes(types, writer); }
/// <summary> /// Writes this instance to the specified writer. /// </summary> internal void Write(IBinaryRawWriter writer) { Debug.Assert(writer != null); writer.WriteString(Name); writer.WriteString(FieldTypeName); writer.WriteBoolean(IsKeyField); writer.WriteBoolean(NotNull); writer.WriteObject(DefaultValue); }
/// <summary> /// Writes the instance to a writer. /// </summary> /// <param name="writer">Writer.</param> internal void Write(IBinaryRawWriter writer) { writer.WriteInt(Attributes.Count); // Does not preserve ordering, it's fine. foreach (KeyValuePair <string, object> attr in Attributes) { writer.WriteString(attr.Key); writer.WriteObject(attr.Value); } }
/// <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); } }
/// <summary> /// Writes the service configuration. /// </summary> private static void WriteServiceConfiguration(ServiceConfiguration configuration, IBinaryRawWriter w) { Debug.Assert(configuration != null); Debug.Assert(w != null); w.WriteString(configuration.Name); w.WriteObject(configuration.Service); w.WriteInt(configuration.TotalCount); w.WriteInt(configuration.MaxPerNodeCount); w.WriteString(configuration.CacheName); w.WriteObject(configuration.AffinityKey); if (configuration.NodeFilter != null) { w.WriteObject(configuration.NodeFilter); } else { w.WriteObject <object>(null); } }
/// <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> internal void Write(IBinaryRawWriter writer, ClientProtocolVersion srvVer) { Debug.Assert(writer != null); writer.WriteString(Name); writer.WriteString(FieldTypeName); writer.WriteBoolean(IsKeyField); writer.WriteBoolean(NotNull); writer.WriteObject(DefaultValue); if (srvVer.CompareTo(ClientSocket.Ver120) >= 0) { writer.WriteInt(Precision); writer.WriteInt(Scale); } }
/// <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); } }
/// <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); }
/// <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 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. } }
/// <summary> /// Writes this instance to the specified writer. /// </summary> /// <param name="writer">The writer.</param> internal void Write(IBinaryRawWriter writer) { // Make sure system marshaller is used. Debug.Assert(((BinaryWriter)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); writer.WriteLong((long)LongQueryWarningTimeout.TotalMilliseconds); 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(StartSize); 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.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 { writer.WriteBoolean(false); writer.WriteObject(cachePlugin); } } } else { writer.WriteInt(0); } }