You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Som Som <2a...@gmail.com> on 2018/09/13 14:36:04 UTC
rest api question
Hi.
What is a right way to add TestEntity(it has 2 fields) into the cache via
REST API.
This is how I created TestEntity cache:
public class TestEntity
{
public string ValueString { get; set; }
public DateTime ValueDateTime { get; set; }
}
class Program
{
static void Main(string[] args)
{
var ignite = Ignition.StartClient(newIgniteClientConfiguration
{
Host = "127.0.0.1"
,
BinaryConfiguration = newApache.Ignite.Core.Binary.
BinaryConfiguration { Serializer = new Apache.Ignite.Core.Binary.
BinaryReflectiveSerializer { ForceTimestamp = true } }
});
var queryEntity = new QueryEntity();
queryEntity.KeyTypeName =typeof(int).FullName;
queryEntity.KeyType = typeof(int);
queryEntity.ValueTypeName =typeof(TestEntity).FullName;
queryEntity.ValueType = typeof(TestEntity);
queryEntity.Fields = new QueryField[]
{ new QueryField("ValueString", typeof(string))
, new QueryField("ValueDateTime",typeof(DateTime))
};
var cache = ignite.GetOrCreateCache<int,TestEntity>(
newCacheClientConfiguration(
"TestEntity", queryEntity) { SqlSchema = "PUBLIC" });
//cache.Put(1, new TestEntity { ValueString = "test",
ValueDateTime = DateTime.UtcNow });
ignite.Dispose();
}
}
Re: rest api question
Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!
In order to use HTTP REST API with non-primitive objects you will have to
implement ConnectorMessageInterceptor
<https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/ConnectorMessageInterceptor.html>
in Java. Then you can hook it in Ignite Spring XML config. Unfortunately,
there's no support for writing it on DotNet side currently, but you can
carry it around as a Java library.
Regards.
--
Ilya Kasnacheev
чт, 13 сент. 2018 г. в 17:36, Som Som <2a...@gmail.com>:
> Hi.
>
>
>
> What is a right way to add TestEntity(it has 2 fields) into the cache via
> REST API.
>
>
>
> This is how I created TestEntity cache:
>
>
>
> public class TestEntity
>
> {
>
> public string ValueString { get; set; }
>
>
>
> public DateTime ValueDateTime { get; set; }
>
> }
>
>
>
> class Program
>
> {
>
> static void Main(string[] args)
>
> {
>
> var ignite = Ignition.StartClient(newIgniteClientConfiguration
>
> {
>
> Host = "127.0.0.1"
>
> ,
>
> BinaryConfiguration = newApache.Ignite.Core.Binary.
> BinaryConfiguration { Serializer = new Apache.Ignite.Core.Binary.
> BinaryReflectiveSerializer { ForceTimestamp = true } }
>
> });
>
>
>
> var queryEntity = new QueryEntity();
>
> queryEntity.KeyTypeName =typeof(int).FullName;
>
> queryEntity.KeyType = typeof(int);
>
>
>
> queryEntity.ValueTypeName =typeof(TestEntity).FullName;
>
> queryEntity.ValueType = typeof(TestEntity);
>
>
>
> queryEntity.Fields = new QueryField[]
>
> { new QueryField("ValueString", typeof(string))
>
> , new QueryField("ValueDateTime",typeof(DateTime))
>
> };
>
>
>
> var cache = ignite.GetOrCreateCache<int,TestEntity>(
>
> newCacheClientConfiguration(
> "TestEntity", queryEntity) { SqlSchema = "PUBLIC" });
>
>
>
>
>
> //cache.Put(1, new TestEntity { ValueString = "test",
> ValueDateTime = DateTime.UtcNow });
>
>
>
> ignite.Dispose();
>
> }
>
> }
>