Newbie question about embedded usage

102 views
Skip to first unread message

Vanessa Williams

unread,
Oct 12, 2012, 4:15:01 PM10/12/12
to project-...@googlegroups.com
Hi, I'm just trying Voldemort for the first time as part of an evaluation. It's a possible solution to a clustering problem we have. 

Anyway, ideally (for now at least) we'd use it in embedded mode. I've got a simple example working using the "single_node_cluster" config, using BDB. However, the data I write to Voldemort does not survive re-running the program. Is this because starting the server overwrites the previous store? Is there a way to make data survive a server restart? It seems as if there must be, but I can't find any specific information. 

Since my code is so small, I've put the entire contents of the main class below (minus the package and imports). Note that the output is always "Putting new value" followed by "All is good".

Regards,
Vanessa

public class Voldemort {


/**

* @param args

*/

public static void main(String[] args) {

instance = new Voldemort("tcp://localhost:6666");

instance.doSomeStuff();

}


public Voldemort(String bootstrapUrl) {

VoldemortConfig config = VoldemortConfig.loadFromEnvironmentVariable();

VoldemortServer server = new VoldemortServer(config);

server.start();

StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl));

 

// create a client that executes operations on a single store

client = factory.getStoreClient(STORE_NAME);

}

private void doSomeStuff() {

// do some random pointless operations

Versioned<String> value = client.get(KEY_BASE);

if (value == null) {

value = new Versioned<String>(TURTLE_1);

System.out.println("Putting new value");

}

else {

value.setObject(TURTLE_1);

System.out.println("Replaceing existing value");

}

client.put(KEY_BASE, value);

value = client.get(KEY_BASE);

assert value.equals(TURTLE_1);

System.out.println("All is good");

}

private static Voldemort instance;

private StoreClient<String, String> client;

private static final String STORE_NAME = "directory_store";

private static final String KEY_BASE = "foo";

private static final String TURTLE_1"bar";

private static final Logger LOG = Logger.getLogger(Voldemort.class);

}


Vanessa Williams

unread,
Oct 12, 2012, 4:54:05 PM10/12/12
to project-...@googlegroups.com
Ok, I can half answer my own question. By adding a server.stop() call before exit, I can make the data survive restart. However, that would imply that if a node goes down hard the data would be lost. That seems counterintuitive, so I must be missing something. Any hints much appreciated.

Regards,
Vanessa

gxm

unread,
Oct 13, 2012, 12:40:12 PM10/13/12
to project-...@googlegroups.com
Hi Vanessa,

When you call
   VoldemortConfig config = VoldemortConfig.loadFromEnvironmentVariable();
Voldemort loads the required configuration from the file system.
One of the files, stores.xml defines the what type of persistence to use.  If you want persistence, I recommend starting with bdb.
Another file, server.properties, lets you define characteristics of bdb's persistence. Using
   bdb.write.transactions=true
should give you the behavior you are looking for.

You can read more about configurations here - http://www.project-voldemort.com/voldemort/configuration.html

Cheers,

Greg

Vanessa Williams

unread,
Oct 15, 2012, 11:32:29 AM10/15/12
to project-...@googlegroups.com
Thanks, Greg. The gdb.write.transactions=true setting did indeed solve my problem.

Cheers,
Vanessa
Reply all
Reply to author
Forward
0 new messages