Skip to content

Instantly share code, notes, and snippets.

@AshwinJay
Created July 12, 2010 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AshwinJay/472163 to your computer and use it in GitHub Desktop.
Save AshwinJay/472163 to your computer and use it in GitHub Desktop.
Simple Voldemort test
#Run 1:
Put: anybody-home = version(0:1)/first-at-1278912876950
Process finished with exit code 0
#Run 2:
Got: anybody-home = version(0:1)/first-at-1278912876950
Put: anybody-home = version(0:2)/first-at-1278912876950-then-1278912880137
Process finished with exit code 0
#Run 3:
Got: anybody-home = version(0:2)/first-at-1278912876950-then-1278912880137
Put: anybody-home = version(0:3)/first-at-1278912876950-then-1278912880137-then-1278912883287
Process finished with exit code 0
AshwinJay@RedStar /cygdrive/d/Dump/voldemort-0.81
$ bin/voldemort-server.sh config/single_node_cluster/
[2010-07-11 22:34:29,387 voldemort.store.metadata.MetadataStore] INFO metadata init().
[2010-07-11 22:34:29,487 voldemort.cluster.Node] WARN admin-port not defined for node:0 using default value(socket_port + 1):6667
... snip snip ...
[2010-07-11 22:34:29,679 voldemort.server.VoldemortService] INFO Starting storage-service
[2010-07-11 22:34:29,726 voldemort.server.storage.StorageService] INFO Initializing bdb storage engine.
[2010-07-11 22:34:29,730 voldemort.server.storage.StorageService] INFO Initializing read-only storage engine.
[2010-07-11 22:34:29,731 voldemort.store.bdb.BdbStorageConfiguration] INFO Creating BDB data directory 'D:\Dump\voldemort-0.81\config\single_node_cluster\data\bdb.
[2010-07-11 22:34:30,020 voldemort.store.bdb.BdbStorageConfiguration] INFO Creating shared BDB environment:
[2010-07-11 22:34:30,021 voldemort.store.bdb.BdbStorageConfiguration] INFO BDB cache size = 1073741824
[2010-07-11 22:34:30,021 voldemort.store.bdb.BdbStorageConfiguration] INFO BDB je.cleaner.threads = 1
[2010-07-11 22:34:30,021 voldemort.store.bdb.BdbStorageConfiguration] INFO BDB je.cleaner.minUtilization = 50
[2010-07-11 22:34:30,023 voldemort.store.bdb.BdbStorageConfiguration] INFO BDB je.cleaner.minFileUtilization = 5
[2010-07-11 22:34:30,023 voldemort.store.bdb.BdbStorageConfiguration] INFO BDB je.log.fileMax = 62914560
... snip snip ...
[2010-07-11 22:34:30,226 voldemort.server.socket.SocketServer[socket-server]] INFO Starting voldemort socket server (socket-server) on port 6666
[2010-07-11 22:34:30,236 voldemort.server.VoldemortService] INFO Starting rebalance-service
[2010-07-11 22:34:30,238 voldemort.server.VoldemortService] INFO Starting socket-service
[2010-07-11 22:34:30,239 voldemort.server.socket.SocketServer[admin-server]] INFO Starting voldemort socket server (admin-server) on port 6667
[2010-07-11 22:34:30,247 voldemort.server.VoldemortService] INFO Starting jmx-service
[2010-07-11 22:34:30,265 voldemort.server.jmx.JmxService] WARN Overwriting mbean voldemort.server.socket:type=SocketService
[2010-07-11 22:34:30,273 voldemort.server.VoldemortServer] INFO Startup completed in 594 ms.
[2010-07-11 22:34:36,738 voldemort.server.socket.SocketServerSession] INFO Client /127.0.0.1:54503 connected successfully with protocol vp1
[2010-07-11 22:34:36,955 voldemort.server.socket.SocketServerSession] INFO Client /127.0.0.1:54503 disconnected.
import voldemort.client.ClientConfig;
import voldemort.client.SocketStoreClientFactory;
import voldemort.client.StoreClient;
import voldemort.client.StoreClientFactory;
import voldemort.versioning.ObsoleteVersionException;
import voldemort.versioning.Versioned;
/*
* Author: Ashwin Jayaprakash / Date: Jul 11, 2010 / Time: 10:05:56 PM / Contact: http://www.ashwinjayaprakash.com
*/
public class SimpleVTest {
public static void main(String[] args) {
String bootstrapUrl = "tcp://localhost:6666";
StoreClientFactory factory =
new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl));
StoreClient<String, String> client = factory.getStoreClient("test");
String key = "anybody-home";
for (;/*Keep trying until we can put*/ ;) {
try {
Versioned<String> version = client.get(key);
//First time will be null.
if (version == null) {
version = new Versioned<String>("first-at-" + System.currentTimeMillis());
}
else {
System.out.println(
"Got: " + key + " = " + version.getVersion() + "/" +
version.getValue());
version.setObject(version.getValue() + "-then-" + System.currentTimeMillis());
}
//---------------
client.put(key, version);
System.out.println(
"Put: " + key + " = " + version.getVersion() + "/" + version.getValue());
//Success.
break;
}
catch (ObsoleteVersionException e) {
System.err.println("Put failed. Will retry...");
e.printStackTrace();
}
}
factory.close();
}
}
#!/bin/bash
#
# Copyright 2008-2009 LinkedIn, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
## Ashwin: Minor correction here ##
if [ $# -lt 1 ];
then
echo 'USAGE: bin/voldemort-server.sh [voldemort_home]'
exit 1
fi
base_dir=$(dirname $0)/..
for file in $base_dir/dist/*.jar;
do
CLASSPATH=$CLASSPATH:$file
done
for file in $base_dir/lib/*.jar;
do
CLASSPATH=$CLASSPATH:$file
done
for file in $base_dir/contrib/hadoop-store-builder/lib/*.jar;
do
CLASSPATH=$CLASSPATH:$file
done
CLASSPATH=$CLASSPATH:$base_dir/dist/resources
if [ -z "$VOLD_OPTS" ]; then
VOLD_OPTS="-Xmx2G -server -Dcom.sun.management.jmxremote"
fi
## Ashwin: Minor correction here. Wrap paths within $(cygpath -w -p -l -a $XYZ) ##
java -Dlog4j.configuration=src/java/log4j.properties $VOLD_OPTS -cp $(cygpath -w -p -l -a $CLASSPATH) voldemort.server.VoldemortServer $(cygpath -w -p -l -a $@)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment