点燃卡桑德拉缓存配置 - CodecNotFoundException

问题描述:

我想卡桑德拉配置作为一个Apache点燃2.0缓存持久性存储。作为测试,我想键值对映射到这个简单的卡桑德拉表:点燃卡桑德拉缓存配置 - CodecNotFoundException

CREATE TABLE ignite.cache_test(
    key text PRIMARY KEY, 
    value int) 

这是相关联的持久性配置XML我使用:

<persistence keyspace="ignite" table="cache_test" ttl="86400">  
    <keyspaceOptions> 
     REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} 
     AND DURABLE_WRITES = true 
    </keyspaceOptions> 
    <tableOptions> 
     comment = 'Cache test' 
     AND read_repair_chance = 0.2 
    </tableOptions> 
    <keyPersistence class="java.lang.String" strategy="PRIMITIVE" column="key" /> 
    <valuePersistence class="java.lang.Integer" strategy="PRIMITIVE" column="value" /> 
</persistence> 

当我试图把元素使用Ignite REST接口缓存我得到:

com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [int <-> java.lang.String] 

就好像我试图将int映射到String类型。我相信这是一个愚蠢的配置错误,但我尝试了几个组合,但没有成功。

为了完整起见,这就是HTTP调用我送:

http://localhost:8080/ignite?cmd=put&key=testkey&val=1&cacheName=cache1 

谢谢大家的帮助

变化的值类型为文本

所以表模式:

CREATE TABLE ignite.cache_test(
    key text PRIMARY KEY, 
    value text 
); 

而conf配置:

<persistence keyspace="ignite" table="cache_test" ttl="86400">  
    <keyspaceOptions> 
     REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} 
     AND DURABLE_WRITES = true 
    </keyspaceOptions> 
    <tableOptions> 
     comment = 'Cache test' 
     AND read_repair_chance = 0.2 
    </tableOptions> 
    <keyPersistence class="java.lang.String" strategy="PRIMITIVE" column="key" /> 
    <valuePersistence class="java.lang.String" strategy="PRIMITIVE" column="value" /> 
</persistence> 
+0

是否可以将其他类型映射为字符串类型以外的值与PRIMITIVE策略? – riccamini

+0

@riccamini我还没有与Apache点火工作。你的错误意味着您正试图插入字符串转换成int类型的字段和我检查自己的REST API调用https://apacheignite.readme.io/v2.0/docs/rest-api#put他们说清楚,关键是字符串键入 –

+0

我没有将键字段指定为字符串类型吗?或者你建议使用web api的所有类型都将被视为字符串? – riccamini