You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@gora.apache.org by ilhami Kalkan <il...@intellica.net> on 2014/07/15 11:37:19 UTC

Cassandra lose datas

Hi all,
I'm new to Gora. I want to insert datas to cassandra with gora. I have 
successfully saved datas to db but about 1 minute they are removed from 
db. Do you know why? I add my source codes below

public class CassandraTest {

     public static void main(String[] args) {

         DataStore<String, users> datastore = null;

         try {
             datastore = DataStoreFactory.createDataStore(
                     (Class<? extends DataStore<String, users>>) Class
.forName("org.apache.gora.cassandra.store.CassandraStore"),
                     String.class, users.class, new Configuration());
         } catch (GoraException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         } catch (ClassNotFoundException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }


         users user = users.newBuilder().build();
         user.setAge(1);
         user.setName(new Utf8("foo1"));
         user.setSurname(new Utf8("example"));

         datastore.put(user.getName().toString(), user);
         datastore.flush();

         datastore.close();
     }

Re: Cassandra lose datas

Posted by Lewis John Mcgibbney <le...@gmail.com>.
Hi ilhami,

On Tue, Jul 15, 2014 at 5:37 AM, ilhami Kalkan <il...@intellica.net>
wrote:

> Hi all,
> I'm new to Gora.


WELCOME :) :)


> I want to insert datas to cassandra with gora. I have successfully saved
> datas to db but about 1 minute they are removed from db. Do you know why? I
> add my source codes below
>
>
You're code is absolutely fine. The 'problem' is with your mapping settings
in gora-cassandra-mapping.xml. Please see the documentation [0],
specifically relating to the values for 'gc_grace_seconds' and also 'ttl'.
If you have some other problems then please write here and we will help you
out on this one.
Thanks
Lewis

[0] http://gora.apache.org/current/gora-cassandra.html