public void BeforeTests() { //TestUtils.JVM_DEBUG = true; TestUtils.KillProcesses(); TestUtils.JvmDebug = true; IgniteConfigurationEx cfg = new IgniteConfigurationEx(); cfg.GridName = GridName; cfg.JvmClasspath = TestUtils.CreateTestClasspath(); cfg.JvmOptions = TestUtils.TestJavaOptions(); cfg.SpringConfigUrl = "config\\native-client-test-cache-store.xml"; BinaryConfiguration portCfg = new BinaryConfiguration(); portCfg.Types = new List <string> { typeof(Key).FullName, typeof(Value).FullName }; cfg.BinaryConfiguration = portCfg; Ignition.Start(cfg); }
/// <summary> /// Initializes a new instance of the <see cref="IgniteClientConfiguration"/> class. /// </summary> /// <param name="cfg">The configuration to copy.</param> public IgniteClientConfiguration(IgniteClientConfiguration cfg) : this() { if (cfg == null) { return; } Host = cfg.Host; Port = cfg.Port; SocketSendBufferSize = cfg.SocketSendBufferSize; SocketReceiveBufferSize = cfg.SocketReceiveBufferSize; TcpNoDelay = cfg.TcpNoDelay; SocketTimeout = cfg.SocketTimeout; if (cfg.BinaryConfiguration != null) { BinaryConfiguration = new BinaryConfiguration(cfg.BinaryConfiguration); } BinaryProcessor = cfg.BinaryProcessor; SslStreamFactory = cfg.SslStreamFactory; UserName = cfg.UserName; Password = cfg.Password; }
/// <summary> /// Configuration for node. /// </summary> /// <param name="path">Path to Java XML configuration.</param> /// <returns>Node configuration.</returns> protected IgniteConfiguration Configuration(string path) { IgniteConfiguration cfg = new IgniteConfiguration(); if (!_fork) { BinaryConfiguration portCfg = new BinaryConfiguration(); ICollection <BinaryTypeConfiguration> portTypeCfgs = new List <BinaryTypeConfiguration>(); GetBinaryTypeConfigurations(portTypeCfgs); portCfg.TypeConfigurations = portTypeCfgs; cfg.BinaryConfiguration = portCfg; } cfg.JvmClasspath = TestUtils.CreateTestClasspath(); cfg.JvmOptions = TestUtils.TestJavaOptions(); cfg.SpringConfigUrl = path; return(cfg); }
/// <summary> /// Gets the serializer. /// </summary> private static IBinarySerializerInternal GetSerializer(BinaryConfiguration cfg, BinaryTypeConfiguration typeCfg, Type type, int typeId, IBinaryNameMapper nameMapper, IBinaryIdMapper idMapper, ILogger log) { var serializer = (typeCfg != null ? typeCfg.Serializer : null) ?? (cfg != null ? cfg.Serializer : null); if (serializer == null) { if (type.GetInterfaces().Contains(typeof(IBinarizable))) { return(BinarizableSerializer.Instance); } if (type.GetInterfaces().Contains(typeof(ISerializable))) { LogSerializableWarning(type, log); return(new SerializableSerializer(type)); } serializer = new BinaryReflectiveSerializer { ForceTimestamp = cfg != null && cfg.ForceTimestamp }; } var refSerializer = serializer as BinaryReflectiveSerializer; return(refSerializer != null ? refSerializer.Register(type, typeId, nameMapper, idMapper) : new UserSerializerProxy(serializer)); }
public void SetUp() { GC.Collect(); TestUtils.JvmDebug = true; IgniteConfiguration cfg = new IgniteConfiguration(); BinaryConfiguration portCfg = new BinaryConfiguration(); ICollection <BinaryTypeConfiguration> portTypeCfgs = new List <BinaryTypeConfiguration>(); portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableEntry))); portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableFilter))); portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(KeepBinaryFilter))); portCfg.TypeConfigurations = portTypeCfgs; cfg.BinaryConfiguration = portCfg; cfg.JvmClasspath = TestUtils.CreateTestClasspath(); cfg.JvmOptions = TestUtils.TestJavaOptions(); cfg.SpringConfigUrl = "config\\cache-query-continuous.xml"; cfg.GridName = "grid-1"; grid1 = Ignition.Start(cfg); cache1 = grid1.GetCache <int, BinarizableEntry>(cacheName); cfg.GridName = "grid-2"; grid2 = Ignition.Start(cfg); cache2 = grid2.GetCache <int, BinarizableEntry>(cacheName); }
/// <summary> /// Tests the failed registration, when we write type name after the header. /// </summary> private static void TestFailedRegistration <T>(bool rawStr, bool rawInt) where T : ITest, new() { // Disable compact footers for local mode var cfg = new BinaryConfiguration { CompactFooter = false }; // Test in local mode so that MarshallerContext can't propagate type registration. var bytes = new Marshaller(cfg).Marshal(new T { Int = 1, Str = "2" }); var res = new Marshaller(cfg).Unmarshal <T>(bytes); Assert.AreEqual(1, res.Int); Assert.AreEqual("2", res.Str); // Check binary mode var bin = new Marshaller(cfg).Unmarshal <IBinaryObject>(bytes, BinaryMode.ForceBinary); if (!rawStr) { Assert.AreEqual("2", bin.GetField <string>("Str")); } if (!rawInt) { Assert.AreEqual(1, bin.GetField <int>("Int")); } res = bin.Deserialize <T>(); Assert.AreEqual(1, res.Int); Assert.AreEqual("2", res.Str); }
/// <summary> /// Serializes and deserializes back an object. /// </summary> public static T SerializeDeserialize <T>(T obj, bool raw = false) { var cfg = new BinaryConfiguration { Serializer = raw ? new BinaryReflectiveSerializer { RawMode = true } : null }; #if NETCOREAPP2_0 var marshType = typeof(IIgnite).Assembly.GetType("Apache.Ignite.Core.Impl.Binary.Marshaller"); var marsh = Activator.CreateInstance(marshType, new object[] { cfg, null }); marshType.GetProperty("CompactFooter").SetValue(marsh, false); var bytes = marshType.GetMethod("Marshal").MakeGenericMethod(typeof(object)) .Invoke(marsh, new object[] { obj }); var res = marshType.GetMethods().Single(mi => mi.Name == "Unmarshal" && mi.GetParameters().First().ParameterType == typeof(byte[])) .MakeGenericMethod(typeof(object)).Invoke(marsh, new[] { bytes, 0 }); return((T)res); #else var marsh = new Marshaller(cfg) { CompactFooter = false }; return(marsh.Unmarshal <T>(marsh.Marshal(obj))); #endif }
/// <summary> /// Initializes a new instance of the <see cref="IgniteClientConfiguration"/> class. /// </summary> /// <param name="cfg">The configuration to copy.</param> public IgniteClientConfiguration(IgniteClientConfiguration cfg) : this() { if (cfg == null) { return; } #pragma warning disable 618 Host = cfg.Host; Port = cfg.Port; #pragma warning restore 618 SocketSendBufferSize = cfg.SocketSendBufferSize; SocketReceiveBufferSize = cfg.SocketReceiveBufferSize; TcpNoDelay = cfg.TcpNoDelay; SocketTimeout = cfg.SocketTimeout; if (cfg.BinaryConfiguration != null) { BinaryConfiguration = new BinaryConfiguration(cfg.BinaryConfiguration); } BinaryProcessor = cfg.BinaryProcessor; SslStreamFactory = cfg.SslStreamFactory; UserName = cfg.UserName; Password = cfg.Password; Endpoints = cfg.Endpoints == null ? null : cfg.Endpoints.ToList(); ReconnectDisabled = cfg.ReconnectDisabled; EnablePartitionAwareness = cfg.EnablePartitionAwareness; Logger = cfg.Logger; ProtocolVersion = cfg.ProtocolVersion; }
/// <summary> /// Constructor. /// </summary> /// <param name="cfg">Configuration.</param> /// <param name="name">Type name.</param> public BinarySurrogateTypeDescriptor(BinaryConfiguration cfg, string name) { _cfg = cfg; _name = name; _id = BinaryUtils.TypeId(name, cfg.DefaultNameMapper, cfg.DefaultIdMapper); }
/// <summary> /// Constructor. /// </summary> /// <param name="cfg">Configuration.</param> /// <param name="id">Type ID.</param> /// <param name="typeName">Name of the type.</param> public BinarySurrogateTypeDescriptor(BinaryConfiguration cfg, int id, string typeName) { Debug.Assert(cfg != null); _cfg = cfg; _id = id; _name = typeName; }
/// <summary> /// Constructor. /// </summary> /// <param name="cfg">Configurtaion.</param> public Marshaller(BinaryConfiguration cfg) { // Validation. if (cfg == null) { cfg = new BinaryConfiguration(); } CompactFooter = cfg.CompactFooter; if (cfg.TypeConfigurations == null) { cfg.TypeConfigurations = new List <BinaryTypeConfiguration>(); } foreach (BinaryTypeConfiguration typeCfg in cfg.TypeConfigurations) { if (string.IsNullOrEmpty(typeCfg.TypeName)) { throw new BinaryObjectException("Type name cannot be null or empty: " + typeCfg); } } // Define system types. They use internal reflective stuff, so configuration doesn't affect them. AddSystemTypes(); // 2. Define user types. var dfltSerializer = cfg.DefaultSerializer == null ? new BinaryReflectiveSerializer() : null; var typeResolver = new TypeResolver(); ICollection <BinaryTypeConfiguration> typeCfgs = cfg.TypeConfigurations; if (typeCfgs != null) { foreach (BinaryTypeConfiguration typeCfg in typeCfgs) { AddUserType(cfg, typeCfg, typeResolver, dfltSerializer); } } var typeNames = cfg.Types; if (typeNames != null) { foreach (string typeName in typeNames) { AddUserType(cfg, new BinaryTypeConfiguration(typeName), typeResolver, dfltSerializer); } } if (cfg.DefaultSerializer == null) { cfg.DefaultSerializer = dfltSerializer; } _cfg = cfg; }
/// <summary> /// Add user type. /// </summary> /// <param name="cfg">Configuration.</param> /// <param name="typeCfg">Type configuration.</param> /// <param name="typeResolver">The type resolver.</param> /// <param name="dfltSerializer">The default serializer.</param> private void AddUserType(BinaryConfiguration cfg, BinaryTypeConfiguration typeCfg, TypeResolver typeResolver, IBinarySerializer dfltSerializer) { // Get converter/mapper/serializer. IBinaryNameMapper nameMapper = typeCfg.NameMapper ?? cfg.DefaultNameMapper; IBinaryIdMapper idMapper = typeCfg.IdMapper ?? cfg.DefaultIdMapper; bool keepDeserialized = typeCfg.KeepDeserialized ?? cfg.DefaultKeepDeserialized; // Try resolving type. Type type = typeResolver.ResolveType(typeCfg.TypeName); if (type != null) { // Type is found. var typeName = BinaryUtils.GetTypeName(type); int typeId = BinaryUtils.TypeId(typeName, nameMapper, idMapper); var serializer = typeCfg.Serializer ?? cfg.DefaultSerializer ?? GetBinarizableSerializer(type) ?? dfltSerializer; var refSerializer = serializer as BinaryReflectiveSerializer; if (refSerializer != null) { refSerializer.Register(type, typeId, nameMapper, idMapper); } if (typeCfg.IsEnum != type.IsEnum) { throw new BinaryObjectException( string.Format( "Invalid IsEnum flag in binary type configuration. " + "Configuration value: IsEnum={0}, actual type: IsEnum={1}", typeCfg.IsEnum, type.IsEnum)); } var affKeyFld = typeCfg.AffinityKeyFieldName ?? GetAffinityKeyFieldNameFromAttribute(type); AddType(type, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, serializer, affKeyFld, type.IsEnum); } else { // Type is not found. string typeName = BinaryUtils.SimpleTypeName(typeCfg.TypeName); int typeId = BinaryUtils.TypeId(typeName, nameMapper, idMapper); AddType(null, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, null, typeCfg.AffinityKeyFieldName, typeCfg.IsEnum); } }
public void TestCodeConfiguration() { var cfg = new BinaryConfiguration { TypeConfigurations = TestTypes.Select(x => new BinaryTypeConfiguration(x)).ToList() }; StartGrid(new BinaryConfiguration(cfg)); CheckBinarizableTypes(TestTypes); }
/// <summary> /// Starts the grid with provided config. /// </summary> /// <param name="binaryConfiguration">The binary configuration.</param> private void StartGrid(BinaryConfiguration binaryConfiguration) { Ignition.StopAll(true); var grid = Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration()) { SpringConfigUrl = "config\\cache-binarizables.xml", BinaryConfiguration = binaryConfiguration }); _cache = grid.GetCache <int, TestGenericBinarizableBase>("default"); }
/// <summary> /// Constructor. /// </summary> /// <param name="cfg">Configuration.</param> /// <param name="log"></param> public Marshaller(BinaryConfiguration cfg, ILogger log = null) { _cfg = cfg ?? new BinaryConfiguration(); _log = log; CompactFooter = _cfg.CompactFooter; if (_cfg.TypeConfigurations == null) { _cfg.TypeConfigurations = new List <BinaryTypeConfiguration>(); } foreach (BinaryTypeConfiguration typeCfg in _cfg.TypeConfigurations) { if (string.IsNullOrEmpty(typeCfg.TypeName)) { throw new BinaryObjectException("Type name cannot be null or empty: " + typeCfg); } } // Define system types. They use internal reflective stuff, so configuration doesn't affect them. AddSystemTypes(); // 2. Define user types. var typeResolver = new TypeResolver(); ICollection <BinaryTypeConfiguration> typeCfgs = _cfg.TypeConfigurations; if (typeCfgs != null) { foreach (BinaryTypeConfiguration typeCfg in typeCfgs) { AddUserType(typeCfg, typeResolver); } } var typeNames = _cfg.Types; if (typeNames != null) { foreach (string typeName in typeNames) { AddUserType(new BinaryTypeConfiguration(typeName), typeResolver); } } _registerSameJavaType = _cfg.NameMapper == null || _cfg.NameMapper is BinaryBasicNameMapper && !((BinaryBasicNameMapper)_cfg.NameMapper).IsSimpleName && _cfg.IdMapper == null; }
/// <summary> /// Starts the grid with provided config. /// </summary> /// <param name="binaryConfiguration">The binary configuration.</param> private void StartGrid(BinaryConfiguration binaryConfiguration) { Ignition.StopAll(true); var grid = Ignition.Start(new IgniteConfiguration { SpringConfigUrl = "config\\cache-binarizables.xml", JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions(), BinaryConfiguration = binaryConfiguration }); _cache = grid.GetCache <int, TestGenericBinarizableBase>(null); }
public void TestStructure() { for (int i = 1; i <= RepeatCnt; i++) { Console.WriteLine(">>> Iteration started: " + i); // 1. Generate and shuffle objects. IList <BranchedType> objs = new List <BranchedType>(); for (int j = 0; j < 6 * ObjectsPerMode; j++) { objs.Add(new BranchedType((j % 6) + 1)); } objs = IgniteUtils.Shuffle(objs); // 2. Create new marshaller. BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(BranchedType)); BinaryConfiguration cfg = new BinaryConfiguration { TypeConfigurations = new List <BinaryTypeConfiguration> { typeCfg } }; Marshaller marsh = new Marshaller(cfg); // 3. Marshal all data and ensure deserialized object is fine. foreach (BranchedType obj in objs) { Console.WriteLine(">>> Write object [mode=" + obj.mode + ']'); byte[] data = marsh.Marshal(obj); BranchedType other = marsh.Unmarshal <BranchedType>(data); Assert.IsTrue(obj.Equals(other)); } Console.WriteLine(); // 4. Ensure that all fields are recorded. var desc = marsh.GetDescriptor(typeof(BranchedType)); CollectionAssert.AreEquivalent(new[] { "mode", "f2", "f3", "f4", "f5", "f6", "f7", "f8" }, desc.WriterTypeStructure.FieldTypes.Keys); } }
/// <summary> /// Serializes and deserializes back an object. /// </summary> public static T SerializeDeserialize <T>(T obj, bool raw = false) { var cfg = new BinaryConfiguration { Serializer = raw ? new BinaryReflectiveSerializer { RawMode = true } : null }; var marsh = new Marshaller(cfg) { CompactFooter = false }; return(marsh.Unmarshal <T>(marsh.Marshal(obj))); }
/// <summary> /// Add user type. /// </summary> /// <param name="cfg">The binary configuration.</param> /// <param name="typeCfg">Type configuration.</param> /// <param name="typeResolver">The type resolver.</param> /// <exception cref="BinaryObjectException"></exception> private void AddUserType(BinaryConfiguration cfg, BinaryTypeConfiguration typeCfg, TypeResolver typeResolver) { // Get converter/mapper/serializer. IBinaryNameMapper nameMapper = typeCfg.NameMapper ?? _cfg.NameMapper ?? GetDefaultNameMapper(); IBinaryIdMapper idMapper = typeCfg.IdMapper ?? _cfg.IdMapper; bool keepDeserialized = typeCfg.KeepDeserialized ?? _cfg.KeepDeserialized; // Try resolving type. Type type = typeResolver.ResolveType(typeCfg.TypeName); if (type != null) { ValidateUserType(type); if (typeCfg.IsEnum != type.IsEnum) { throw new BinaryObjectException( string.Format( "Invalid IsEnum flag in binary type configuration. " + "Configuration value: IsEnum={0}, actual type: IsEnum={1}", typeCfg.IsEnum, type.IsEnum)); } // Type is found. var typeName = GetTypeName(type, nameMapper); int typeId = GetTypeId(typeName, idMapper); var affKeyFld = typeCfg.AffinityKeyFieldName ?? GetAffinityKeyFieldNameFromAttribute(type); var serializer = GetSerializer(cfg, typeCfg, type, typeId, nameMapper, idMapper, _log); AddType(type, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, serializer, affKeyFld, type.IsEnum); } else { // Type is not found. string typeName = GetTypeName(typeCfg.TypeName, nameMapper); int typeId = GetTypeId(typeName, idMapper); AddType(null, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, null, typeCfg.AffinityKeyFieldName, typeCfg.IsEnum); } }
/// <summary> /// Add user type. /// </summary> /// <param name="cfg">Configuration.</param> /// <param name="typeCfg">Type configuration.</param> /// <param name="typeResolver">The type resolver.</param> /// <param name="dfltSerializer">The default serializer.</param> private void AddUserType(BinaryConfiguration cfg, BinaryTypeConfiguration typeCfg, TypeResolver typeResolver, IBinarySerializer dfltSerializer) { // Get converter/mapper/serializer. IBinaryNameMapper nameMapper = typeCfg.NameMapper ?? cfg.DefaultNameMapper; IBinaryIdMapper idMapper = typeCfg.IdMapper ?? cfg.DefaultIdMapper; bool keepDeserialized = typeCfg.KeepDeserialized ?? cfg.DefaultKeepDeserialized; // Try resolving type. Type type = typeResolver.ResolveType(typeCfg.TypeName); if (type != null) { // Type is found. var typeName = GetTypeName(type); int typeId = BinaryUtils.TypeId(typeName, nameMapper, idMapper); var serializer = typeCfg.Serializer ?? cfg.DefaultSerializer ?? GetBinarizableSerializer(type) ?? dfltSerializer; var refSerializer = serializer as BinaryReflectiveSerializer; if (refSerializer != null) { refSerializer.Register(type, typeId, nameMapper, idMapper); } AddType(type, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, serializer, typeCfg.AffinityKeyFieldName); } else { // Type is not found. string typeName = BinaryUtils.SimpleTypeName(typeCfg.TypeName); int typeId = BinaryUtils.TypeId(typeName, nameMapper, idMapper); AddType(null, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, null, typeCfg.AffinityKeyFieldName); } }
/// <summary> /// Create configuration. /// </summary> /// <param name="name">Grid name.</param> /// <param name="springCfg">Spring configuration.</param> /// <returns>Configuration.</returns> private static IgniteConfiguration CreateConfiguration(string name, string springCfg) { var cfg = new IgniteConfiguration(); BinaryConfiguration portCfg = new BinaryConfiguration(); ICollection <BinaryTypeConfiguration> portTypeCfgs = new List <BinaryTypeConfiguration>(); portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(DynamicTestKey))); portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(DynamicTestValue))); portCfg.TypeConfigurations = portTypeCfgs; cfg.IgniteInstanceName = name; cfg.BinaryConfiguration = portCfg; cfg.JvmClasspath = TestUtils.CreateTestClasspath(); cfg.JvmOptions = TestUtils.TestJavaOptions(); cfg.SpringConfigUrl = springCfg; return(cfg); }
/// <summary> /// Gets the serializer. /// </summary> private static IBinarySerializerInternal GetSerializer(BinaryConfiguration cfg, BinaryTypeConfiguration typeCfg, Type type, int typeId, IBinaryNameMapper nameMapper, IBinaryIdMapper idMapper) { var serializer = typeCfg.Serializer ?? cfg.DefaultSerializer; if (serializer == null) { if (type.GetInterfaces().Contains(typeof(IBinarizable))) { return(BinarizableSerializer.Instance); } serializer = new BinaryReflectiveSerializer(); } var refSerializer = serializer as BinaryReflectiveSerializer; return(refSerializer != null ? refSerializer.Register(type, typeId, nameMapper, idMapper) : new UserSerializerProxy(serializer)); }
/// <summary> /// Copies the local properties (properties that are not written in Write method). /// </summary> private void CopyLocalProperties(IgniteConfiguration cfg) { GridName = cfg.GridName; if (BinaryConfiguration != null && cfg.BinaryConfiguration != null) { BinaryConfiguration.MergeTypes(cfg.BinaryConfiguration); } else if (cfg.BinaryConfiguration != null) { BinaryConfiguration = new BinaryConfiguration(cfg.BinaryConfiguration); } JvmClasspath = cfg.JvmClasspath; JvmOptions = cfg.JvmOptions; Assemblies = cfg.Assemblies; SuppressWarnings = cfg.SuppressWarnings; LifecycleBeans = cfg.LifecycleBeans; Logger = cfg.Logger; JvmInitialMemoryMb = cfg.JvmInitialMemoryMb; JvmMaxMemoryMb = cfg.JvmMaxMemoryMb; }
/// <summary> /// Configuration for node. /// </summary> /// <param name="path">Path to Java XML configuration.</param> /// <returns>Node configuration.</returns> private static IgniteConfiguration Configuration(string path) { var cfg = new IgniteConfiguration(); var portCfg = new BinaryConfiguration(); ICollection <BinaryTypeConfiguration> portTypeCfgs = new List <BinaryTypeConfiguration>(); portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(RemoteConfiguration))); portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(RemoteConfigurationClosure))); portCfg.TypeConfigurations = portTypeCfgs; cfg.BinaryConfiguration = portCfg; cfg.JvmClasspath = TestUtils.CreateTestClasspath(); cfg.JvmOptions = new List <string> { "-ea", "-Xcheck:jni", "-Xms4g", "-Xmx4g", "-DIGNITE_QUIET=false", "-Xnoagent", "-Djava.compiler=NONE", "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005", "-XX:+HeapDumpOnOutOfMemoryError" }; cfg.SpringConfigUrl = path; return(cfg); }
/// <summary> /// Copies the local properties (properties that are not written in Write method). /// </summary> private void CopyLocalProperties(IgniteConfiguration cfg) { IgniteInstanceName = cfg.IgniteInstanceName; if (BinaryConfiguration != null && cfg.BinaryConfiguration != null) { BinaryConfiguration.MergeTypes(cfg.BinaryConfiguration); } else if (cfg.BinaryConfiguration != null) { BinaryConfiguration = new BinaryConfiguration(cfg.BinaryConfiguration); } JvmClasspath = cfg.JvmClasspath; JvmOptions = cfg.JvmOptions; Assemblies = cfg.Assemblies; SuppressWarnings = cfg.SuppressWarnings; LifecycleHandlers = cfg.LifecycleHandlers; Logger = cfg.Logger; JvmInitialMemoryMb = cfg.JvmInitialMemoryMb; JvmMaxMemoryMb = cfg.JvmMaxMemoryMb; PluginConfigurations = cfg.PluginConfigurations; AutoGenerateIgniteInstanceName = cfg.AutoGenerateIgniteInstanceName; }
public void TestStructure() { for (int i = 1; i <= RepeatCnt; i++) { Console.WriteLine(">>> Iteration started: " + i); // 1. Generate and shuffle objects. IList <BranchedType> objs = new List <BranchedType>(); for (int j = 0; j < 6 * ObjectsPerMode; j++) { objs.Add(new BranchedType((j % 6) + 1)); } objs = IgniteUtils.Shuffle(objs); // 2. Create new marshaller. BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(BranchedType)); BinaryConfiguration cfg = new BinaryConfiguration { TypeConfigurations = new List <BinaryTypeConfiguration> { typeCfg } }; Marshaller marsh = new Marshaller(cfg); // 3. Marshal all data and ensure deserialized object is fine. // Use single stream to test object offsets using (var stream = new BinaryHeapStream(128)) { var writer = marsh.StartMarshal(stream); foreach (var obj in objs) { Console.WriteLine(">>> Write object [mode=" + obj.mode + ']'); writer.WriteObject(obj); } stream.Seek(0, SeekOrigin.Begin); var reader = marsh.StartUnmarshal(stream); foreach (var obj in objs) { var other = reader.ReadObject <BranchedType>(); Assert.IsTrue(obj.Equals(other)); } } Console.WriteLine(); // 4. Ensure that all fields are recorded. var desc = marsh.GetDescriptor(typeof(BranchedType)); CollectionAssert.AreEquivalent(new[] { "mode", "f2", "f3", "f4", "f5", "f6", "f7", "f8" }, desc.WriterTypeStructure.FieldTypes.Keys); } }
/// <summary> /// Constructor. /// </summary> /// <param name="cfg">Configuration.</param> /// <param name="id">Type ID.</param> public BinarySurrogateTypeDescriptor(BinaryConfiguration cfg, int id) { _cfg = cfg; _id = id; }