Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 046E9200C50 for ; Fri, 24 Mar 2017 09:51:48 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 02E14160B82; Fri, 24 Mar 2017 08:51:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0843D160B93 for ; Fri, 24 Mar 2017 09:51:46 +0100 (CET) Received: (qmail 89243 invoked by uid 500); 24 Mar 2017 08:51:46 -0000 Mailing-List: contact user-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ignite.apache.org Delivered-To: mailing list user@ignite.apache.org Received: (qmail 89234 invoked by uid 99); 24 Mar 2017 08:51:46 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Mar 2017 08:51:46 +0000 Received: from mail-ot0-f169.google.com (mail-ot0-f169.google.com [74.125.82.169]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id A80CA1A0185 for ; Fri, 24 Mar 2017 08:51:45 +0000 (UTC) Received: by mail-ot0-f169.google.com with SMTP id i1so4825439ota.3 for ; Fri, 24 Mar 2017 01:51:45 -0700 (PDT) X-Gm-Message-State: AFeK/H0UA8l25oFx7FDOIyEi6XoFkB33C3Uw3QL4oQ90Zzm5r0frMXSKd65+EuHN2aBcpjo/V9F8tui7xJvKnVMT X-Received: by 10.157.16.112 with SMTP id o45mr3704714oto.259.1490345504548; Fri, 24 Mar 2017 01:51:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.84.22 with HTTP; Fri, 24 Mar 2017 01:51:14 -0700 (PDT) In-Reply-To: <1490344357758-11414.post@n6.nabble.com> References: <1490279196388-11394.post@n6.nabble.com> <1490344357758-11414.post@n6.nabble.com> From: Pavel Tupitsyn Date: Fri, 24 Mar 2017 11:51:14 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Load data to cache To: user@ignite.apache.org Content-Type: multipart/alternative; boundary=001a1141dbd064481f054b761acf archived-at: Fri, 24 Mar 2017 08:51:48 -0000 --001a1141dbd064481f054b761acf Content-Type: text/plain; charset=UTF-8 You have to include Person class in binary configuration: IIgnite ignite = Ignition.Start(new IgniteConfiguration { SpringConfigUrl = @"F:\Visual Studio 2015\Projects\CreateCluster\CreateCluster\my-file.xml", BinaryConfiguration = new BinaryConfiguration(typeof(Person)) }); Also you have different cache names in config (personCache) and code (Mycache). Use GetCache instead of GetOrCreateCache to make sure that cache is started from XML config. On Fri, Mar 24, 2017 at 11:32 AM, kavitha wrote: > Hi, > > I am using following code to load data in Ignite cluster. But I got below > error. > > my-file.xml code: > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans.xsd"> > class="org.apache.ignite.configuration.IgniteConfiguration"> > > > > > > class="org.apache.ignite.configuration.CacheConfiguration"> > > > > > value="java.lang.Long"> > value="ignite.myexamples.model.Person"> > > > value="java.lang.Long"> > value="java.lang.String"> > value="java.lang.Long"> > value="java.lang.Integer"> > > > > > > > > > > > > > > > class Person :IBinarizable > { > public long id { get; set; } > public long orgId { get; set; } > public string name { get; set; } > public int salary { get; set; } > > public Person(long a, long b, string c, int d) > { > id = a; > orgId = b; > name = c; > salary = d; > } > public void WriteBinary(IBinaryWriter writer) > { > var rawWriter = writer.GetRawWriter(); > > rawWriter.WriteString(name); > rawWriter.WriteInt(salary); > } > > public void ReadBinary(IBinaryReader reader) > { > var rawReader = reader.GetRawReader(); > > name = rawReader.ReadString(); > salary = rawReader.ReadInt(); > } > > } > > class Program > { > static void Main(string[] args) > { > Person obj = new Person(1,1000, "John",20000); > Person obj1 = new Person(2,2000, "Smith", 38000); > > IIgnite ignite = Ignition.Start(@"F:Visual Studio > 2015\Projects\CreateCluster\CreateCluster\my-file.xml"); > var cache = ignite.GetOrCreateCache("Mycache"); > cache.Put(1,obj); > cache.Put(2,obj1); > } > } > } > > > Error: An unhandled exception of type > 'Apache.Ignite.Core.Binary.BinaryObjectException' occurred in > Apache.Ignite.Core.dll > > Additional information: Unsupported object type [type=CreateCluster.Person, > object=CreateCluster.Person]. > > Specified type can not be serialized by Ignite: it is neither > [Serializable], nor registered in IgniteConfiguration.BinaryConfiguration. > > > > -- > View this message in context: http://apache-ignite-users. > 70518.x6.nabble.com/Load-data-to-cache-tp11394p11414.html > Sent from the Apache Ignite Users mailing list archive at Nabble.com. > --001a1141dbd064481f054b761acf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
You have to include Person class in binary configuration:<= div>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 IIgnite i= gnite =3D Ignition.Start(new IgniteConfiguration
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 SpringConfigUrl =3D @"F:\Visual Studio 2015\Proje= cts\CreateCluster\CreateCluster\my-file.xml",
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BinaryConfiguration =3D new Binar= yConfiguration(typeof(Person))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 });

Also you have different cache names in= config (personCache) and code (Mycache).<= /span>
Use GetCache instead of G= etOrCreateCache to make sure that cache is started from XML config.<= /div>


<= br>
On Fri, Mar 24, 2017 at 11:32 AM, kavitha <kavithamrgsn@gmail.com> wrote:
Hi,

I am using following code to load data in Ignite cluster. But I got below error.

my-file.xml code:
<?xml version=3D"1.0" encoding=3D"UTF-8"?>

<beans xmlns=3D"http://www.springframework.o= rg/schema/beans"
=C2=A0 =C2=A0 =C2=A0 =C2=A0xmlns:xsi=3D"http://www.w3.= org/2001/XMLSchema-instance"
=C2=A0 =C2=A0 =C2=A0 =C2=A0xsi:schemaLocation=3D"htt= p://www.springframework.org/schema/beans
=C2=A0 =C2=A0 =C2=A0 =C2=A0 http://www.s= pringframework.org/schema/beans/spring-beans.xsd"> <bean id=3D"ignite.cfg"
class=3D"org.apache.ignite.configuration.IgniteConfiguration= ">
=C2=A0 <property name=3D"odbcConfiguration">
=C2=A0 =C2=A0 <bean class=3D"org.apache.ignite.configuration.<= wbr>OdbcConfiguration"/>
=C2=A0 </property>
=C2=A0<property name=3D"cacheConfiguration">
=C2=A0 =C2=A0 =C2=A0 =C2=A0 <list>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <bean
class=3D"org.apache.ignite.configuration.CacheConfiguration&= quot;>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <property name= =3D"name" value=3D"personCache"></property&g= t;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <property name=3D"queryEntit= ies">
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <l= ist>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 <bean class=3D"org.apache.ignite.cache.QueryEntity&= quot;>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 <property name=3D"keyType"
value=3D"java.lang.Long"></property>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 <property name=3D"valueType"
value=3D"ignite.myexamples.model.Person"></property>= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 <property name=3D"fields">
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <map>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <entry key=3D"= id"
value=3D"java.lang.Long"></entry>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <entry key=3D"= name"
value=3D"java.lang.String"></entry>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <entry key=3D"= orgId"
value=3D"java.lang.Long"></entry>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <entry key=3D"= salary"
value=3D"java.lang.Integer"></entry>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </map>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 </property>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 </bean>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </= list>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </property> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </bean>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </list>
=C2=A0 =C2=A0 </property>

=C2=A0 =C2=A0 <property name=3D"peerClassLoadingEnabled" value= =3D"true"></property>

=C2=A0 =C2=A0 =C2=A0 =C2=A0 </bean>
</beans>

class Person :IBinarizable
=C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 public long id { get; set; }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 public long orgId { get; set; }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 public string name { get; set; }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 public int salary { get; set; }

=C2=A0 =C2=A0 =C2=A0 =C2=A0 public Person(long a, long b, string c, int d)<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 id =3D a;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 orgId =3D b;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 name =3D c;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 salary =3D d;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 public void WriteBinary(IBinaryWriter writer) =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 var rawWriter =3D writer.GetRawWr= iter();

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 rawWriter.WriteString(name);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 rawWriter.WriteInt(salary);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }

=C2=A0 =C2=A0 =C2=A0 =C2=A0 public void ReadBinary(IBinaryReader reader) =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 var rawReader =3D reader.GetRawRe= ader();

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 name =3D rawReader.ReadString();<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 salary =3D rawReader.ReadInt(); =C2=A0 =C2=A0 =C2=A0 =C2=A0 }

=C2=A0 =C2=A0 }

=C2=A0class Program
=C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 static void Main(string[] args)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Person obj =3D new Person(1,1000,= "John",20000);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Person obj1 =3D new Person(2,2000= , "Smith", 38000);

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 IIgnite ignite =3D Ignition.Start= (@"F:Visual Studio
2015\Projects\CreateCluster\CreateCluster\my-file.xml");
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 var cache =3D ignite.GetOrCreateC= ache<int, Person>("Mycache");
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cache.Put(1,obj);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cache.Put(2,obj1);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0}
}


Error: An unhandled exception of type
'Apache.Ignite.Core.Binary.BinaryObjectException' occurred in<= br> Apache.Ignite.Core.dll

Additional information: Unsupported object type [type=3DCreateCluster.Perso= n,
object=3DCreateCluster.Person].

Specified type can not be serialized by Ignite: it is neither
[Serializable], nor registered in IgniteConfiguration.BinaryConfigurat= ion.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Load-data= -to-cache-tp11394p11414.html
Sent from the Apache Ignite Users m= ailing list archive at Nabble.com.

--001a1141dbd064481f054b761acf--