Message from discussion
Newbie question about embedded usage
Date: Fri, 12 Oct 2012 13:54:05 -0700 (PDT)
From: Vanessa Williams <fridgeb...@gmail.com>
To: project-voldemort@googlegroups.com
Message-Id: <9f758c41-c009-4c58-8ef6-2fdc1f616fed@googlegroups.com>
In-Reply-To: <19f1eca6-af2d-432a-8f83-e2e51a3e1e91@googlegroups.com>
References: <19f1eca6-af2d-432a-8f83-e2e51a3e1e91@googlegroups.com>
Subject: Re: Newbie question about embedded usage
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_3007_27871230.1350075246033"
------=_Part_3007_27871230.1350075246033
Content-Type: multipart/alternative;
boundary="----=_Part_3008_11900511.1350075246033"
------=_Part_3008_11900511.1350075246033
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
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
On Friday, October 12, 2012 4:15:01 PM UTC-4, 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*);
>
> }
>
>
------=_Part_3008_11900511.1350075246033
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Ok, I can half answer my own question. By adding a server.stop() call befor=
e 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 counterintuiti=
ve, so I must be missing something. Any hints much appreciated.<div><br></d=
iv><div>Regards,</div><div>Vanessa<br><br>On Friday, October 12, 2012 4:15:=
01 PM UTC-4, Vanessa Williams wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;">Hi, I'm just trying Voldemort for the first time as part of an evalua=
tion. It's a possible solution to a clustering problem we have. <div><=
br></div><div>Anyway, ideally (for now at least) we'd use it in embedded mo=
de. I've got a simple example working using the "single_node_cluster" confi=
g, using BDB. However, the data I write to Voldemort does not survive re-ru=
nning the program. Is this because starting the server overwrites the previ=
ous store? Is there a way to make data survive a server restart? It seems a=
s if there must be, but I can't find any specific information. </div><=
div><br></div><div>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 outp=
ut is always "<font size=3D"2" face=3D"arial, sans-serif" color=3D"#000000"=
>Putting new value" followed by "All is good".</font></div><div><br></div><=
div>Regards,</div><div>Vanessa</div><div><br></div><div><p style=3D"margin-=
bottom:0px;font-size:14px;line-height:normal;font-family:Menlo"><span style=
=3D"color:#931a68"><b>public</b></span> <span style=3D"color:#931a68"><b>cl=
ass</b></span> Voldemort {</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><br></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;color:rgb(79,118,203)"><span style=3D"color:#000000"><span style=3D"=
white-space:pre">=09</span></span>/**</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;color:rgb(79,118,203)"><span style=3D"white-space:pre">=09</span> * =
<span style=3D"color:#91afcb"><b>@param</b></span> args</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;color:rgb(79,118,203)"><span style=3D"white-space:pre">=09</span> */=
</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09</span><span style=3D"color:#931=
a68"><b>public</b></span> <span style=3D"color:#931a68"><b>static</b></span=
> <span style=3D"color:#931a68"><b>void</b></span> main(String[] args) {</p=
>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><span style=3D"white-space:pre">=09=09</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;color:rgb(57,51,255)"><span style=3D"color:#000000"><span style=3D"w=
hite-space:pre">=09=09</span></span><span style=3D"color:#0326cc"><i>instan=
ce</i></span><span style=3D"color:#000000"> =3D </span><span style=3D"color=
:#931a68"><b>new</b></span><span style=3D"color:#000000"> Voldemort(</span>=
"tcp://localhost:<wbr>6666"<span style=3D"color:#000000">);</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span><span style=3D"color:#=
0326cc"><i>instance</i></span>.doSomeStuff();</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09</span>}</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><br></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09</span><span style=3D"color:#931=
a68"><b>public</b></span> Voldemort(String bootstrapUrl) {</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><span style=3D"white-space:pre">=09=09</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span>VoldemortConfig config=
=3D VoldemortConfig.<i>loadFromEnviro<wbr>nmentVariable</i>();</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span>VoldemortServer server=
=3D <span style=3D"color:#931a68"><b>new</b></span> VoldemortServer(config=
);</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span>server.start();</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><span style=3D"white-space:pre">=09=09</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span>StoreClientFactory fac=
tory =3D <span style=3D"color:#931a68"><b>new</b></span> SocketStoreClientF=
actory(<span style=3D"color:#931a68"><b>new</b></span> ClientConfig().<wbr>=
setBootstrapUrls(bootstrapUrl)<wbr>);</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><span style=3D"white-space:pre">=09=09</span> =
</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;color:rgb(78,144,114)"><span style=3D"color:#000000"><span style=3D"=
white-space:pre">=09=09</span></span>// create a client that executes opera=
tions on a single store</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span><span style=3D"color:#=
0326cc">client</span> =3D factory.getStoreClient(<span style=3D"color:#0326=
cc"><i>STORE_<wbr>NAME</i></span>);</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><span style=3D"white-space:pre">=09=09</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09</span>}</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><span style=3D"white-space:pre">=09</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09</span><span style=3D"color:#931=
a68"><b>private</b></span> <span style=3D"color:#931a68"><b>void</b></span>=
doSomeStuff() {</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;color:rgb(78,144,114)"><span style=3D"color:#000000"><span style=3D"=
white-space:pre">=09=09</span></span>// do some random pointless operations=
</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span>Versioned<String>=
; value =3D <span style=3D"color:#0326cc">client</span>.get(<span style=3D"=
color:#0326cc"><i>KEY_BASE</i></span>);</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span><span style=3D"color:#=
931a68"><b>if</b></span> (value =3D=3D <span style=3D"color:#931a68"><b>nul=
l</b></span>) {</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09=09</span>value =3D <span sty=
le=3D"color:#931a68"><b>new</b></span> Versioned<String>(<span style=
=3D"color:#0326cc"><i>TURTLE_1</i></span>);</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09=09</span>System.<span style=
=3D"color:#0326cc"><i>out</i></span>.println(<span style=3D"color:#3933ff">=
"Putting new value"</span>);</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span>}</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span><span style=3D"color:#=
931a68"><b>else</b></span> {</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09=09</span>value.setObject(<sp=
an style=3D"color:#0326cc"><i>TURTLE_1</i></span>);</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;color:rgb(57,51,255)"><span style=3D"color:#000000"><span style=3D"w=
hite-space:pre">=09=09=09</span>System.</span><span style=3D"color:#0326cc"=
><i>out</i></span><span style=3D"color:#000000">.println(</span>"Replaceing=
existing value"<span style=3D"color:#000000">);</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span>}</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span><span style=3D"color:#=
0326cc">client</span>.put(<span style=3D"color:#0326cc"><i>KEY_BASE</i></sp=
an>, value);</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><span style=3D"white-space:pre">=09=09</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span>value =3D <span style=
=3D"color:#0326cc">client</span>.get(<span style=3D"color:#0326cc"><i>KEY_B=
ASE</i></span>);</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span><span style=3D"color:#=
931a68"><b>assert</b></span> value.equals(<span style=3D"color:#0326cc"><i>=
TURTLE_1</i></span>);</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><span style=3D"white-space:pre">=09=09</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09=09</span>System.<span style=3D"=
color:#0326cc"><i>out</i></span>.println(<span style=3D"color:#3933ff">"All=
is good"</span>);</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09</span>}</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><span style=3D"white-space:pre">=09</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09</span><span style=3D"color:#931=
a68"><b>private</b></span> <span style=3D"color:#931a68"><b>static</b></spa=
n> Voldemort <span style=3D"color:#0326cc"><i>instance</i></span>;</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><span style=3D"white-space:pre">=09</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09</span><span style=3D"color:#931=
a68"><b>private</b></span> StoreClient<String, String> <span style=3D=
"color:#0326cc">client</span>;</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><span style=3D"white-space:pre">=09</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;color:rgb(147,26,104)"><span style=3D"color:#000000"><span style=3D"=
white-space:pre">=09</span></span><b>private</b><span style=3D"color:#00000=
0"> </span><b>static</b><span style=3D"color:#000000"> </span><b>final</b><=
span style=3D"color:#000000"> String </span><span style=3D"color:#0326cc"><=
i>STORE_NAME</i></span><span style=3D"color:#000000"> =3D </span><span styl=
e=3D"color:#3933ff">"directory_store"</span><span style=3D"color:#000000">;=
</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;color:rgb(57,51,255)"><span style=3D"color:#000000"><span style=3D"w=
hite-space:pre">=09</span></span><span style=3D"color:#931a68"><b>private</=
b></span><span style=3D"color:#000000"> </span><span style=3D"color:#931a68=
"><b>static</b></span><span style=3D"color:#000000"> </span><span style=3D"=
color:#931a68"><b>final</b></span><span style=3D"color:#000000"> String </s=
pan><span style=3D"color:#0326cc"><i>KEY_BASE</i></span><span style=3D"colo=
r:#000000"> =3D </span>"foo"<span style=3D"color:#000000">;</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;color:rgb(147,26,104)"><span style=3D"color:#000000"><span style=3D"=
white-space:pre">=09</span></span><b>private</b><span style=3D"color:#00000=
0"> </span><b>static</b><span style=3D"color:#000000"> </span><b>final</b><=
span style=3D"color:#000000"> String </span><span style=3D"color:#0326cc"><=
i>TURTLE_1</i></span><span style=3D"color:#000000"> =3D </span><span s=
tyle=3D"color:rgb(57,51,255)">"bar</span><span style=3D"color:rgb(57,51,255=
)">"</span><span style=3D"color:rgb(0,0,0)">;</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo;min-height:16px"><span style=3D"white-space:pre">=09</span></p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo"><span style=3D"white-space:pre">=09</span><span style=3D"color:#931=
a68"><b>private</b></span> <span style=3D"color:#931a68"><b>static</b></spa=
n> <span style=3D"color:#931a68"><b>final</b></span> Logger <span style=3D"=
text-decoration:underline;color:#0326cc"><i>LOG</i></span> =3D Logger.<i>ge=
tLogger</i>(Voldemort.<span style=3D"color:#931a68"><b>cla<wbr>ss</b></span=
>);</p>
<p style=3D"margin-bottom:0px;font-size:14px;line-height:normal;font-family=
:Menlo">}</p></div><div><br></div></blockquote></div>
------=_Part_3008_11900511.1350075246033--
------=_Part_3007_27871230.1350075246033--