On Saturday, October 13, 2012 12:40:12 PM UTC-4, gxm wrote:
> 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
> On Friday, October 12, 2012 1:15:01 PM UTC-7, Vanessa Williams wrote:
>> 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*);
>> }