/// <summary> /// Constrcutor. /// </summary> /// <param name="cfg">Portable configuration.</param> /// <param name="name">Type name.</param> public PortableSurrogateTypeDescriptor(PortableConfiguration cfg, string name) { _cfg = cfg; _name = name; _id = PortableUtils.TypeId(name, cfg.DefaultNameMapper, cfg.DefaultIdMapper); }
/// <summary> /// Creates PortableConfiguration. /// </summary> /// <returns>PortableConfiguration</returns> public PortableConfiguration ToPortableConfiguration() { PortableConfiguration res = new PortableConfiguration(); if (TypeConfigurations != null) { List <PortableTypeConfiguration> typeCfgs = new List <PortableTypeConfiguration>(); foreach (InteropDotNetPortableTypeConfiguration dotNetTypeCfg in TypeConfigurations) { typeCfgs.Add(dotNetTypeCfg.ToPortableTypeConfiguration()); } res.TypeConfigurations = typeCfgs; } res.Types = Types; res.DefaultNameMapper = (IPortableNameMapper)InteropDotNetPortableTypeConfiguration.CreateInstance(DefaultNameMapper); res.DefaultIdMapper = (IPortableIdMapper)InteropDotNetPortableTypeConfiguration.CreateInstance(DefaultIdMapper); res.DefaultSerializer = (IPortableSerializer)InteropDotNetPortableTypeConfiguration.CreateInstance(DefaultSerializer); res.DefaultMetadataEnabled = DefaultMetadataEnabled; res.DefaultKeepDeserialized = DefaultKeepDeserialized; return(res); }
public void SetUp() { GC.Collect(); TestUtils.JvmDebug = true; IgniteConfigurationEx cfg = new IgniteConfigurationEx(); PortableConfiguration portCfg = new PortableConfiguration(); ICollection <PortableTypeConfiguration> portTypeCfgs = new List <PortableTypeConfiguration>(); portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableEntry))); portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableFilter))); portTypeCfgs.Add(new PortableTypeConfiguration(typeof(KeepPortableFilter))); portCfg.TypeConfigurations = portTypeCfgs; cfg.PortableConfiguration = 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.Cache <int, PortableEntry>(cacheName); cfg.GridName = "grid-2"; grid2 = Ignition.Start(cfg); cache2 = grid2.Cache <int, PortableEntry>(cacheName); }
/// <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) { PortableConfiguration portCfg = new PortableConfiguration(); ICollection <PortableTypeConfiguration> portTypeCfgs = new List <PortableTypeConfiguration>(); PortableTypeConfigurations(portTypeCfgs); portCfg.TypeConfigurations = portTypeCfgs; cfg.PortableConfiguration = portCfg; } cfg.JvmClasspath = TestUtils.CreateTestClasspath(); cfg.JvmOptions = TestUtils.TestJavaOptions(); cfg.SpringConfigUrl = path; return(cfg); }
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"; PortableConfiguration portCfg = new PortableConfiguration(); portCfg.Types = new List <string> { typeof(Key).FullName, typeof(Value).FullName }; cfg.PortableConfiguration = portCfg; Ignition.Start(cfg); }
/// <summary> /// Starts the grid with provided config. /// </summary> /// <param name="portableConfiguration">The portable configuration.</param> private void StartGrid(PortableConfiguration portableConfiguration) { Ignition.StopAll(true); var grid = Ignition.Start(new IgniteConfiguration { SpringConfigUrl = "config\\cache-portables.xml", JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions(), PortableConfiguration = portableConfiguration }); _cache = grid.Cache <int, TestGenericPortableBase>(null); }
/// <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(PortableConfiguration cfg, PortableTypeConfiguration typeCfg, TypeResolver typeResolver, IPortableSerializer dfltSerializer) { // Get converter/mapper/serializer. IPortableNameMapper nameMapper = typeCfg.NameMapper ?? cfg.DefaultNameMapper; IPortableIdMapper idMapper = typeCfg.IdMapper ?? cfg.DefaultIdMapper; bool metaEnabled = typeCfg.MetadataEnabled ?? cfg.DefaultMetadataEnabled; bool keepDeserialized = typeCfg.KeepDeserialized ?? cfg.DefaultKeepDeserialized; // Try resolving type. Type type = typeResolver.ResolveType(typeCfg.TypeName, typeCfg.AssemblyName); if (type != null) { // Type is found. var typeName = GetTypeName(type); int typeId = PortableUtils.TypeId(typeName, nameMapper, idMapper); var serializer = typeCfg.Serializer ?? cfg.DefaultSerializer ?? GetPortableMarshalAwareSerializer(type) ?? dfltSerializer; var refSerializer = serializer as PortableReflectiveSerializer; if (refSerializer != null) { refSerializer.Register(type, typeId, nameMapper, idMapper); } AddType(type, typeId, typeName, true, metaEnabled, keepDeserialized, nameMapper, idMapper, serializer, typeCfg.AffinityKeyFieldName, null, null); } else { // Type is not found. string typeName = PortableUtils.SimpleTypeName(typeCfg.TypeName); int typeId = PortableUtils.TypeId(typeName, nameMapper, idMapper); AddType(null, typeId, typeName, true, metaEnabled, keepDeserialized, nameMapper, idMapper, null, typeCfg.AffinityKeyFieldName, null, null); } }
/// <summary> /// Create configuration. /// </summary> /// <param name="name">Grid name.</param> /// <param name="springCfg">Spring configuration.</param> /// <returns>Configuration.</returns> private static IgniteConfigurationEx CreateConfiguration(string name, string springCfg) { IgniteConfigurationEx cfg = new IgniteConfigurationEx(); PortableConfiguration portCfg = new PortableConfiguration(); ICollection <PortableTypeConfiguration> portTypeCfgs = new List <PortableTypeConfiguration>(); portTypeCfgs.Add(new PortableTypeConfiguration(typeof(DynamicTestKey))); portTypeCfgs.Add(new PortableTypeConfiguration(typeof(DynamicTestValue))); portCfg.TypeConfigurations = portTypeCfgs; cfg.GridName = name; cfg.PortableConfiguration = portCfg; cfg.JvmClasspath = TestUtils.CreateTestClasspath(); cfg.JvmOptions = TestUtils.TestJavaOptions(); cfg.SpringConfigUrl = springCfg; return(cfg); }
/// <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 PortableConfiguration(); ICollection <PortableTypeConfiguration> portTypeCfgs = new List <PortableTypeConfiguration>(); portTypeCfgs.Add(new PortableTypeConfiguration(typeof(RemoteConfiguration))); portTypeCfgs.Add(new PortableTypeConfiguration(typeof(RemoteConfigurationClosure))); portCfg.TypeConfigurations = portTypeCfgs; cfg.PortableConfiguration = 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> /// Constructor. /// </summary> /// <param name="cfg">Portable configuration.</param> /// <param name="id">Type ID.</param> public PortableSurrogateTypeDescriptor(PortableConfiguration cfg, int id) { _cfg = cfg; _id = id; }
/// <summary> /// Constructor. /// </summary> /// <param name="cfg">Configurtaion.</param> public PortableMarshaller(PortableConfiguration cfg) { // Validation. if (cfg == null) { cfg = new PortableConfiguration(); } if (cfg.TypeConfigurations == null) { cfg.TypeConfigurations = new List <PortableTypeConfiguration>(); } foreach (PortableTypeConfiguration typeCfg in cfg.TypeConfigurations) { if (string.IsNullOrEmpty(typeCfg.TypeName)) { throw new PortableException("Type name cannot be null or empty: " + typeCfg); } if (typeCfg.AssemblyName != null && typeCfg.AssemblyName.Length == 0) { throw new PortableException("Assembly name cannot be empty string: " + typeCfg); } } // Define predefined types. AddPredefinedType(typeof(bool), PortableUtils.TypeBool, PortableSystemHandlers.WriteHndBoolTyped, PortableSystemHandlers.WriteHndBool); AddPredefinedType(typeof(byte), PortableUtils.TypeByte, PortableSystemHandlers.WriteHndByteTyped, PortableSystemHandlers.WriteHndByte); AddPredefinedType(typeof(short), PortableUtils.TypeShort, PortableSystemHandlers.WriteHndShortTyped, PortableSystemHandlers.WriteHndShort); AddPredefinedType(typeof(char), PortableUtils.TypeChar, PortableSystemHandlers.WriteHndCharTyped, PortableSystemHandlers.WriteHndChar); AddPredefinedType(typeof(int), PortableUtils.TypeInt, PortableSystemHandlers.WriteHndIntTyped, PortableSystemHandlers.WriteHndInt); AddPredefinedType(typeof(long), PortableUtils.TypeLong, PortableSystemHandlers.WriteHndLongTyped, PortableSystemHandlers.WriteHndLong); AddPredefinedType(typeof(float), PortableUtils.TypeFloat, PortableSystemHandlers.WriteHndFloatTyped, PortableSystemHandlers.WriteHndFloat); AddPredefinedType(typeof(double), PortableUtils.TypeDouble, PortableSystemHandlers.WriteHndDoubleTyped, PortableSystemHandlers.WriteHndDouble); AddPredefinedType(typeof(string), PortableUtils.TypeString, PortableSystemHandlers.WriteHndStringTyped, PortableSystemHandlers.WriteHndString); AddPredefinedType(typeof(decimal), PortableUtils.TypeDecimal, PortableSystemHandlers.WriteHndDecimalTyped, PortableSystemHandlers.WriteHndDecimal); AddPredefinedType(typeof(DateTime), PortableUtils.TypeDate, PortableSystemHandlers.WriteHndDateTyped, PortableSystemHandlers.WriteHndDate); AddPredefinedType(typeof(Guid), PortableUtils.TypeGuid, PortableSystemHandlers.WriteHndGuidTyped, PortableSystemHandlers.WriteHndGuid); // TODO: Remove this registration AddPredefinedType(typeof(PortableUserObject), PortableUtils.TypePortable, PortableSystemHandlers.WriteHndPortableTyped, PortableSystemHandlers.WriteHndPortable); AddPredefinedType(typeof(bool[]), PortableUtils.TypeArrayBool, PortableSystemHandlers.WriteHndBoolArrayTyped, PortableSystemHandlers.WriteHndBoolArray); AddPredefinedType(typeof(byte[]), PortableUtils.TypeArrayByte, PortableSystemHandlers.WriteHndByteArrayTyped, PortableSystemHandlers.WriteHndByteArray); AddPredefinedType(typeof(short[]), PortableUtils.TypeArrayShort, PortableSystemHandlers.WriteHndShortArrayTyped, PortableSystemHandlers.WriteHndShortArray); AddPredefinedType(typeof(char[]), PortableUtils.TypeArrayChar, PortableSystemHandlers.WriteHndCharArrayTyped, PortableSystemHandlers.WriteHndCharArray); AddPredefinedType(typeof(int[]), PortableUtils.TypeArrayInt, PortableSystemHandlers.WriteHndIntArrayTyped, PortableSystemHandlers.WriteHndIntArray); AddPredefinedType(typeof(long[]), PortableUtils.TypeArrayLong, PortableSystemHandlers.WriteHndLongArrayTyped, PortableSystemHandlers.WriteHndLongArray); AddPredefinedType(typeof(float[]), PortableUtils.TypeArrayFloat, PortableSystemHandlers.WriteHndFloatArrayTyped, PortableSystemHandlers.WriteHndFloatArray); AddPredefinedType(typeof(double[]), PortableUtils.TypeArrayDouble, PortableSystemHandlers.WriteHndDoubleArrayTyped, PortableSystemHandlers.WriteHndDoubleArray); AddPredefinedType(typeof(decimal[]), PortableUtils.TypeArrayDecimal, PortableSystemHandlers.WriteHndDecimalArrayTyped, PortableSystemHandlers.WriteHndDecimalArray); AddPredefinedType(typeof(string[]), PortableUtils.TypeArrayString, PortableSystemHandlers.WriteHndStringArrayTyped, PortableSystemHandlers.WriteHndStringArray); AddPredefinedType(typeof(DateTime?[]), PortableUtils.TypeArrayDate, PortableSystemHandlers.WriteHndDateArrayTyped, PortableSystemHandlers.WriteHndDateArray); AddPredefinedType(typeof(Guid?[]), PortableUtils.TypeArrayGuid, PortableSystemHandlers.WriteHndGuidArrayTyped, PortableSystemHandlers.WriteHndGuidArray); // 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 PortableReflectiveSerializer() : null; var typeResolver = new TypeResolver(); ICollection <PortableTypeConfiguration> typeCfgs = cfg.TypeConfigurations; if (typeCfgs != null) { foreach (PortableTypeConfiguration typeCfg in typeCfgs) { AddUserType(cfg, typeCfg, typeResolver, dfltSerializer); } } ICollection <string> types = cfg.Types; if (types != null) { foreach (string type in types) { AddUserType(cfg, new PortableTypeConfiguration(type), typeResolver, dfltSerializer); } } if (cfg.DefaultSerializer == null) { cfg.DefaultSerializer = dfltSerializer; } _cfg = cfg; }