ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guilherme Melo <guilherme...@gmail.com>
Subject Re: LocalDateTime field being ignored on Cassandra write through
Date Mon, 17 Apr 2017 17:16:59 GMT
Hello,
The Spring config:

 @Bean
    public IgniteConfiguration getIgniteConfiguration() {
        IgniteConfiguration cfg = new IgniteConfiguration();
        //cfg.setClientMode(true);
        cfg.setClientMode(false);

        //orders
        CacheConfiguration orderCache = new CacheConfiguration();
        orderCache.setName("thirdCache");
        orderCache.setBackups(1);
        orderCache.setCacheMode(CacheMode.PARTITIONED);
        orderCache.setCacheStoreFactory(getCassandraCacheStoreFactory());
        orderCache.setReadThrough(true);
        orderCache.setWriteThrough(true);

        cfg.setCacheConfiguration(
                orderCache);
        return cfg;
    }

    @Bean
    public CassandraCacheStoreFactory getCassandraCacheStoreFactory() {
        CassandraCacheStoreFactory cassandraCacheStoreFactory = new
CassandraCacheStoreFactory();
        cassandraCacheStoreFactory.setDataSource(getCassandraDataSource());
        cassandraCacheStoreFactory.setPersistenceSettings(getPersistenceSettings());
        return cassandraCacheStoreFactory;
    }

    @Bean
    public DataSource getCassandraDataSource() {
    DataSource dataSource = new DataSource();
        dataSource.setContactPoints("127.0.0.1");

        return dataSource;
    }

    @Bean
    public KeyValuePersistenceSettings getPersistenceSettings() {
        Resource resource = new ClassPathResource("persistence-settings.xml");

        KeyValuePersistenceSettings keyValuePersistenceSettings = new
KeyValuePersistenceSettings(resource);
        return keyValuePersistenceSettings;
    }

The Persistence.xml

<persistence keyspace="my_keyspace" table="my_table" ttl="86400">
    <!--
    Specifies Cassandra keyspace options which should be used to
create provided keyspace if it doesn't exist.

    Note: optional element
    -->
    <keyspaceOptions>
        REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 3}
        AND DURABLE_WRITES = true
    </keyspaceOptions>

    <!--
    Specifies Cassandra table options which should be used to create
provided table if it doesn't exist.

    Note: optional element
    -->
    <tableOptions>
        comment = 'A most excellent and useful table'
        AND read_repair_chance = 0.2
    </tableOptions>

    <!--
    Specifies persistent settings for Ignite cache keys.

    Note: required element

    Attributes:
      1) class      [required] - java class name for Ignite cache key
      2) strategy   [required] - one of three possible persistent strategies:
            a) PRIMITIVE - stores key value as is, by mapping it to
Cassandra table column with corresponding type.
                Should be used only for simple java types (int, long,
String, double, Date) which could be mapped
                to corresponding Cassadra types.
            b) BLOB - stores key value as BLOB, by mapping it to
Cassandra table column with blob type.
                Could be used for any java object. Conversion of java
object to BLOB is handled by "serializer"
                which could be specified in serializer attribute (see below).
            c) POJO - stores each field of an object as a column
having corresponding type in Cassandra table.
                Provides ability to utilize Cassandra secondary
indexes for object fields.
      3) serializer [optional] - specifies serializer class for BLOB
strategy. Shouldn't be used for PRIMITIVE and
        POJO strategies. Available implementations:
            a) org.apache.ignite.cache.store.cassandra.serializer.JavaSerializer
- uses standard Java
                serialization framework
            b) org.apache.ignite.cache.store.cassandra.serializer.KryoSerializer
- uses Kryo
                serialization framework
      4) column     [optional] - specifies column name for PRIMITIVE
and BLOB strategies where to store key value.
        If not specified column having 'key' name will be used.
Shouldn't be used for POJO strategy.
    -->
    <keyPersistence class="java.lang.String" strategy="PRIMITIVE">
        <!--serializer="..." column="..." -->
        <!--
        Specifies partition key fields if POJO strategy used.

        Note: optional element, only required for POJO strategy in
case you want to manually specify
            POJO fields to Cassandra columns mapping, instead of
relying on dynamic discovering of
            POJO fields and mapping them to the same columns of Cassandra table.
        -->
        <partitionKey>
            <!--
             Specifies mapping from POJO field to Cassandra table column.

             Note: required element

             Attributes:
               1) name   [required] - POJO field name
               2) column [optional] - Cassandra table column name. If
not specified lowercase
                  POJO field name will be used.
            -->
            <!--<field name="companyCode" column="company"/>-->
        </partitionKey>

        <!--
        Specifies cluster key fields if POJO strategy used.

        Note: optional element, only required for POJO strategy in
case you want to manually specify
            POJO fields to Cassandra columns mapping, instead of
relying on dynamic discovering of
            POJO fields and mapping them to the same columns of Cassandra table.
        -->
        <clusterKey>
            <!--
             Specifies mapping from POJO field to Cassandra table column.

             Note: required element

             Attributes:
               1) name   [required] - POJO field name
               2) column [optional] - Cassandra table column name. If
not specified lowercase
                  POJO field name will be used.
               3) sort   [optional] - specifies sort order (asc or desc)
            -->
            <field name="id"/>
            <!--column="number" sort="desc"/>-->
            <!--...-->
            <!--...-->
        </clusterKey>
    </keyPersistence>

    <!--
    Specifies persistent settings for Ignite cache values.

    Note: required element

    Attributes:
      1) class      [required] - java class name for Ignite cache value
      2) strategy   [required] - one of three possible persistent strategies:
            a) PRIMITIVE - stores key value as is, by mapping it to
Cassandra table column with corresponding type.
                Should be used only for simple java types (int, long,
String, double, Date) which could be mapped
                to corresponding Cassadra types.
            b) BLOB - stores key value as BLOB, by mapping it to
Cassandra table column with blob type.
                Could be used for any java object. Conversion of java
object to BLOB is handled by "serializer"
                which could be specified in serializer attribute (see below).
            c) POJO - stores each field of an object as a column
having corresponding type in Cassandra table.
                Provides ability to utilize Cassandra secondary
indexes for object fields.
      3) serializer [optional] - specifies serializer class for BLOB
strategy. Shouldn't be used for PRIMITIVE and
        POJO strategies. Available implementations:
            a) org.apache.ignite.cache.store.cassandra.serializer.JavaSerializer
- uses standard Java
                serialization framework
            b) org.apache.ignite.cache.store.cassandra.serializer.KryoSerializer
- uses Kryo
                serialization framework
      4) column     [optional] - specifies column name for PRIMITIVE
and BLOB strategies where to store value.
        If not specified column having 'value' name will be used.
Shouldn't be used for POJO strategy.
    -->
    <valuePersistence
class="org.gmelo.investigation.ignite.model.SampleModel"
strategy="POJO">
                      <!--serializer="..." column="">-->
        <!--
         Specifies mapping from POJO field to Cassandra table column.

         Note: required element

         Attributes:
           1) name         [required] - POJO field name
           2) column       [optional] - Cassandra table column name.
If not specified lowercase
              POJO field name will be used.
           3) static       [optional] - boolean flag which specifies
that column is static withing a given partition
           4) index        [optional] - boolean flag specifying that
secondary index should be created for the field
           5) indexClass   [optional] - custom index java class name
if you want to use custom index
           6) indexOptions [optional] - custom index options
        -->
        <!--<field name="firstName" column="first_name" static="..."
index="..." indexClass="..." indexOptions="..."/>-->
        <!--<field name="timestampVal" column="timestampVal" />-->
    </valuePersistence>
</persistence>

I've also tried:

@Field(codec = LocalDateTimeCodec.class)
private LocalDateTime timestampVal;

But to no avail.

Thanks Dmitry


Guilherme Melo
www.gmelo.org

Mime
View raw message