write behind is not triggering for created table through query

classic Classic list List threaded Threaded
6 messages Options
siva siva
Reply | Threaded
Open this post in threaded view
|

write behind is not triggering for created table through query

This post was updated on .
Hi,
I am using .Net Core for client and Server Ignite v2.7.6.

*Create Cache and  configuration*:
-----------------------------------
cacheCfg = new CacheConfiguration
                {
                    Name = tenantId,
                    CacheStoreFactory = new TenantCacheStoreFactory(_logger, connectionString),
                    KeepBinaryInStore = false,  // Cache store works with deserialized data.
                    ReadThrough = true,
                    WriteThrough = true,
                    WriteBehindEnabled = true,
                    QueryEntities = queryList,
                    WriteBehindFlushThreadCount=2,
                    CacheMode = CacheMode.Partitioned,
                    Backups = 0,
                    DataRegionName = "IgniteDataRegion",
                    EvictionPolicy = new LruEvictionPolicy
                    {
                        MaxSize = 100000
                    }
                };
 ICache<KeyModel, ICustomCacheStore> cache = Ignite.GetOrCreateCache<KeyModel, ICustomCacheStore>(cacheCfg);


where cache name is 32 bit guid(e.g:"C091E548-B45A-49B4-B8EC-2CB5E27C7AF6")

i have created table from sqlline on cache
create table "C091E548-B45A-49B4-B8EC-2CB5E27C7AF6".Person(id int,name varchar,Primary Key(id));

after that ,did insert statement:
insert into Person(id,name) values(1,"Ram");

where some other table and indexes created at the time of cache configuration.

persist store
C:\server\storage\node00-e03ee70f-0903-41db-beb7-190ead503597
where i found two folder for the cache,name as
1.cache-C091E548-B45A-49B4-B8EC-2CB5E27C7AF6
2.cache-SQL_C091E548-B45A-49B4-B8EC-2CB5E27C7AF6_PERSON

recorded inserted successfully in cache,
but write behind is not called/triggering...any configuration/implementation
needed?




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: write behind is not triggering for created table through query

Hello!

You need to employ cache configuration templates to add Write Behind to cache configured via SQL:


In your case, you created two caches: one is empty but with write behind, other is with SQL-inserted data but without Write Behind.

Regards,
--
Ilya Kasnacheev


вс, 12 янв. 2020 г. в 19:56, siva <[hidden email]>:
Hi,
I am using .Net Core for client and Server Ignite v2.7.6.

*Create Cache and  configuration*:
-----------------------------------



where cache name is 32 bit guid(e.g:"C091E548-B45A-49B4-B8EC-2CB5E27C7AF6")

*i have created table from sqlline on cache*


after that ,did *insert statement*:
insert into Person(id,name) values(1,"Ram");

where some of table and indexes created at the time of cache configuration.

*persist store*
C:\server\storage\node00-e03ee70f-0903-41db-beb7-190ead503597
where i found two folder for the cache,name as
1.cache-C091E548-B45A-49B4-B8EC-2CB5E27C7AF6
2.cache-SQL_C091E548-B45A-49B4-B8EC-2CB5E27C7AF6_PERSON

recorded inserted successfully in cache,
but write behind is not called/triggering...any configuration/implementation
needed?




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
siva siva
Reply | Threaded
Open this post in threaded view
|

Re: write behind is not triggering for created table through query

Hi,
Thanks for reply...write behind triggering now.but getting exception in
writeAll() method.

I have one query on insert what will be the key and value for writeAll()
method,if i defined or not in create query commond key_type and
value_type?.is this key_type and value_type needed.?

but in case of cache.putAsync(key,tableModel); working properly.

WriteAll(IEnumerable<KeyValuePair&lt;string, ICustomCacheStore>> entries){
List<KeyValuePair&lt;string, ICustomCacheStore>> entityList =
entries.ToList();//on sql insert error
foreach (var recordEntry in entityList)
 {
   ....
   ....
 }
}

*create and insert query*:
--------------
CREATE TABLE IF NOT EXISTS
"C091E548-B45A-49B4-B8EC-2CB5E27C7AF6".EntitiesPulsarTest(EntityId
varchar,EntityType varchar,EntityInfoJson varchar,TenantName
varchar,TenantId varchar,Fabric varchar,EntityName varchar,SequenceNumber
Double,PRIMARY KEY(EntityId)) WITH
"template=CacheConfigurationTemplate,backups=0,key_type=TableName,value_type=EntitiesPulsarTest";


INSERT INTO
"C091E548-B45A-49B4-B8EC-2CB5E27C7AF6".EntitiesPulsarTest(EntityId,EntityInfoJson,EntityName,EntityType,Fabric,SequenceNumber,TenantId,TenantName)
VALUES ('0-pulsar', '{}', 'Testing Topic0 Name', 'testpulsarType',
'pulsarFabric', 0.0, 'pulsar-123-tenantid', 'pulsar-tenantName');

Exception:
Apache.Ignite.Core.Binary.BinaryObjectException: Invalid header on
deserialization [pos=136, hdr=0]
   at Apache.Ignite.Core.Impl.Binary.BinaryReader.TryDeserialize[T](T& res,
Type typeOverride)
   at Apache.Ignite.Core.Impl.Binary.BinaryReader.Deserialize[T](Type
typeOverride)
   at
Apache.Ignite.Core.Impl.Cache.Store.CacheStoreInternal`2.<ReadPairs>d__14.MoveNext()
   at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1
enumerable)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at
IgnitePersistenceApp.CacheStore.TenantCacheStore.WriteAll(IEnumerable`1
entries)

anything i have to change in create or insert query?




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: write behind is not triggering for created table through query

Hello!

Can you show complete cache configuration (template)?

I imagine it's possible that your cache ends up having primitive type as key, yet you try to use it as binary object in cache store.

Regards,
--
Ilya Kasnacheev


пн, 13 янв. 2020 г. в 15:10, siva <[hidden email]>:
Hi,
Thanks for reply...write behind triggering now.but getting exception in
writeAll() method.

I have one query on insert what will be the key and value for writeAll()
method,if i defined or not in create query commond key_type and
value_type?.is this key_type and value_type needed.?

but in case of cache.putAsync(key,tableModel); working properly.

WriteAll(IEnumerable<KeyValuePair&lt;string, ICustomCacheStore>> entries){
List<KeyValuePair&lt;string, ICustomCacheStore>> entityList =
entries.ToList();//on sql insert error
foreach (var recordEntry in entityList)
 {
   ....
   ....
 }
}

*create and insert query*:
--------------
CREATE TABLE IF NOT EXISTS
"C091E548-B45A-49B4-B8EC-2CB5E27C7AF6".EntitiesPulsarTest(EntityId
varchar,EntityType varchar,EntityInfoJson varchar,TenantName
varchar,TenantId varchar,Fabric varchar,EntityName varchar,SequenceNumber
Double,PRIMARY KEY(EntityId)) WITH
"template=CacheConfigurationTemplate,backups=0,key_type=TableName,value_type=EntitiesPulsarTest";


INSERT INTO
"C091E548-B45A-49B4-B8EC-2CB5E27C7AF6".EntitiesPulsarTest(EntityId,EntityInfoJson,EntityName,EntityType,Fabric,SequenceNumber,TenantId,TenantName)
VALUES ('0-pulsar', '{}', 'Testing Topic0 Name', 'testpulsarType',
'pulsarFabric', 0.0, 'pulsar-123-tenantid', 'pulsar-tenantName');

Exception:
Apache.Ignite.Core.Binary.BinaryObjectException: Invalid header on
deserialization [pos=136, hdr=0]
   at Apache.Ignite.Core.Impl.Binary.BinaryReader.TryDeserialize[T](T& res,
Type typeOverride)
   at Apache.Ignite.Core.Impl.Binary.BinaryReader.Deserialize[T](Type
typeOverride)
   at
Apache.Ignite.Core.Impl.Cache.Store.CacheStoreInternal`2.<ReadPairs>d__14.MoveNext()
   at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1
enumerable)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at
IgnitePersistenceApp.CacheStore.TenantCacheStore.WriteAll(IEnumerable`1
entries)

anything i have to change in create or insert query?




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
siva siva
Reply | Threaded
Open this post in threaded view
|

Re: write behind is not triggering for created table through query

Hi,
yes,type of key is string.
String cacheName="C091E548-B45A-49B4-B8EC-2CB5E27C7AF6";
cacheCfg = new CacheConfiguration(cacheName)
                {
                    Name = cacheName,
                    CacheStoreFactory = new TenantCacheStoreFactory(_logger,
connectionString),
                    KeepBinaryInStore = false,  // Cache store works with
deserialized data.
                    ReadThrough = true,
                    WriteThrough = true,
                    WriteBehindEnabled = true,
                    QueryEntities = queryList,
                    WriteBehindFlushThreadCount = 2,
                    CacheMode = CacheMode.Partitioned,
                    Backups = 0,
                    DataRegionName = "IgniteDataRegion",
                    EvictionPolicy = new LruEvictionPolicy
                    {
                        MaxSize = 100000
                    }
                };

Table Create query:
---------------------------------
CREATE TABLE IF NOT EXISTS
"C091E548-B45A-49B4-B8EC-2CB5E27C7AF6".EntitiesPulsarTest(EntityId
varchar,EntityType varchar,EntityInfoJson varchar,TenantName
varchar,TenantId varchar,Fabric varchar,EntityName varchar,SequenceNumber
Double,PRIMARY KEY(EntityId)) WITH
"template=CacheConfigurationTemplate,backups=0";






--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: write behind is not triggering for created table through query

Hello!

You should not specify key_type in this case.

Can you show code of your cache store / factory?

Regards,
--
Ilya Kasnacheev


вт, 14 янв. 2020 г. в 19:18, siva <[hidden email]>:
Hi,
yes,type of key is string.
String cacheName="C091E548-B45A-49B4-B8EC-2CB5E27C7AF6";
cacheCfg = new CacheConfiguration(cacheName)
                {
                    Name = cacheName,
                    CacheStoreFactory = new TenantCacheStoreFactory(_logger,
connectionString),
                    KeepBinaryInStore = false,  // Cache store works with
deserialized data.
                    ReadThrough = true,
                    WriteThrough = true,
                    WriteBehindEnabled = true,
                    QueryEntities = queryList,
                    WriteBehindFlushThreadCount = 2,
                    CacheMode = CacheMode.Partitioned,
                    Backups = 0,
                    DataRegionName = "IgniteDataRegion",
                    EvictionPolicy = new LruEvictionPolicy
                    {
                        MaxSize = 100000
                    }
                };

Table Create query:
---------------------------------
CREATE TABLE IF NOT EXISTS
"C091E548-B45A-49B4-B8EC-2CB5E27C7AF6".EntitiesPulsarTest(EntityId
varchar,EntityType varchar,EntityInfoJson varchar,TenantName
varchar,TenantId varchar,Fabric varchar,EntityName varchar,SequenceNumber
Double,PRIMARY KEY(EntityId)) WITH
"template=CacheConfigurationTemplate,backups=0";






--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/