Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

read_only store modified.

  • Loading branch information...
commit 7d77574c1b4d1ceaebe50fa7499d4a294620101c 1 parent b373eaa
@bbansal bbansal authored
View
3  bin/voldemort-server.sh
@@ -18,4 +18,5 @@ do
CLASSPATH=$CLASSPATH:$file
done
-java -Xmx2G -server -cp $CLASSPATH -Dcom.sun.management.jmxremote voldemort.server.VoldemortServer ${1}
+echo classpath=$CLASSPATH
+java -Xmx2G -server -cp $CLASSPATH -Dcom.sun.management.jmxremote voldemort.server.VoldemortServer ${1}
View
6 config/single_node_cluster/config/server.properties
@@ -22,4 +22,8 @@ mysql.host=localhost
mysql.port=1521
mysql.user=root
mysql.password=3306
-mysql.database=test
+mysql.database=test
+
+#ReadOnly
+enable.readonly.engine=true
+
View
77 config/single_node_cluster/config/stores.xml
@@ -1,18 +1,83 @@
<stores>
<store>
- <name>test</name>
- <persistence>cache</persistence>
- <routing>client</routing>
- <replication-factor>1</replication-factor>
+ <name>company</name>
+ <persistence>read-only</persistence>
+ <routing>client</routing>
+ <replication-factor>1</replication-factor>
<required-reads>1</required-reads>
<required-writes>1</required-writes>
<key-serializer>
<type>json</type>
- <schema-info>"string"</schema-info>
+ <schema-info>"int32"</schema-info>
</key-serializer>
<value-serializer>
<type>json</type>
- <schema-info>"string"</schema-info>
+ <schema-info>
+ {
+ "company_id":"int32",
+ "universal_name": "string",
+ "company_size": "string",
+ "company_type": "string",
+ "industry": "int32",
+ "symbol": "string",
+ "company_url": "string",
+ "hq_country_code": "string",
+ "exchange_symbol": "string",
+ "exact_size": "int32",
+ "status_code": "string",
+ "founded_year": "int32",
+ "end_year": "int32",
+ "tags": "string",
+ "blog_url": "string",
+ "blog_rss_url":"string",
+ "hq_street1":"string",
+ "hq_street2":"string",
+ "hq_city":"string",
+ "hq_state":"string",
+ "hq_postal_code":"string",
+ "region_code_1":"int32",
+ "region_code_2":"int32",
+ "hq_phone1":"string",
+ "hq_phone2":"string",
+ "hq_fax":"string",
+ "changeset_id":"int32",
+ "active":"boolean",
+ "logo_media_id":"string",
+ "txn":"int64"
+ }
+ </schema-info>
+ </value-serializer>
+ </store>
+ <store>
+ <name>members</name>
+ <persistence>read-only</persistence>
+ <routing>client</routing>
+ <replication-factor>1</replication-factor>
+ <required-reads>1</required-reads>
+ <required-writes>1</required-writes>
+ <key-serializer>
+ <type>json</type>
+ <schema-info>"int32"</schema-info>
+ </key-serializer>
+ <value-serializer>
+ <type>json</type>
+ <schema-info>
+ {
+ "session_id": "int64",
+ "member_id": "int32",
+ "tracking_time": "int64",
+ "page_seq": "int32",
+ "page_key": "string",
+ "tracking_info": "string",
+ "bl_time": "int32",
+ "total_time": "int32",
+ "tracking_code": "string",
+ "error_key": "string",
+ "error_id": "int32",
+ "browser_id": "string",
+ "locale": "string"
+ }
+ </schema-info>
</value-serializer>
</store>
</stores>
View
4 src/java/voldemort/VoldemortClientShell.java
@@ -12,6 +12,8 @@
import java.util.Set;
import java.util.concurrent.Executors;
+import org.apache.log4j.Logger;
+
import voldemort.client.DefaultStoreClient;
import voldemort.client.SocketStoreClientFactory;
import voldemort.client.StoreClientFactory;
@@ -30,6 +32,7 @@
public class VoldemortClientShell {
private static final String PROMPT = "> ";
+ private static final Logger logger = Logger.getLogger(VoldemortClientShell.class.getName());
public static void main(String[] args) throws Exception {
if (args.length < 2 || args.length > 3)
@@ -72,6 +75,7 @@ public static void main(String[] args) throws Exception {
client.put(tightenNumericTypes(jsonReader.read()),
tightenNumericTypes(jsonReader.read()));
} else if (line.toLowerCase().startsWith("get")) {
+ logger.info ("get called:");
JsonReader jsonReader = new JsonReader(new StringReader(line.substring("get".length())));
printVersioned(client.get(tightenNumericTypes(jsonReader.read())));
} else if (line.toLowerCase().startsWith("delete")) {
View
3  src/java/voldemort/client/AbstractStoreClientFactory.java
@@ -54,7 +54,7 @@
private final ExecutorService threadPool;
private final SerializerFactory serializerFactory;
private final URI[] bootstrapUrls;
- private final boolean enableVerboseLogging = false;
+ private final boolean enableVerboseLogging = true;
public AbstractStoreClientFactory(ExecutorService threadPool,
SerializerFactory serializerFactory,
@@ -94,6 +94,7 @@ public AbstractStoreClientFactory(ExecutorService threadPool,
// construct mapping
Map<Integer, Store<byte[], byte[]>> clientMapping = Maps.newHashMap();
for(Node node : cluster.getNodes()) {
+ logger.info ("Adding node :" + node.getId() + " Store:" + storeDef.getName() + " host:" + node.getHost() + " port:" + getPort(node));
Store<byte[], byte[]> store = getStore(storeDef.getName(),
node.getHost(),
getPort(node));
View
4 src/java/voldemort/server/VoldemortConfig.java
@@ -114,7 +114,7 @@ public VoldemortConfig(Props props) {
this.readOnlyFileHandles = props.getInt("readonly.file.handles", 5);
this.readOnlyStorageDir = props.getString("readonly.data.directory", this.dataDirectory
+ File.separator
- + "readonly");
+ + "read-only");
this.slopStoreType = StorageEngineType.fromDisplay(props.getString("slop.store.engine",
StorageEngineType.BDB.toDisplay()));
@@ -553,7 +553,7 @@ public void setEnableReadOnlyEngine(boolean enableReadOnlyEngine) {
public boolean isCacheEngineEnabled() {
return enableCacheEngine;
}
-
+
public void setEnableCacheEngine(boolean enableCacheEngine) {
this.enableCacheEngine = enableCacheEngine;
}
View
5 src/java/voldemort/server/storage/StorageService.java
@@ -40,6 +40,7 @@
import voldemort.store.memory.InMemoryStorageConfiguration;
import voldemort.store.metadata.MetadataStore;
import voldemort.store.mysql.MysqlStorageConfiguration;
+import voldemort.store.readonly.RandomAccessFileStorageConfiguration;
import voldemort.store.serialized.SerializingStore;
import voldemort.store.slop.Slop;
import voldemort.store.slop.SlopDetectingStore;
@@ -95,7 +96,9 @@ public StorageService(String name,
configs.put(StorageEngineType.MEMORY, new InMemoryStorageConfiguration());
if(config.isCacheEngineEnabled())
configs.put(StorageEngineType.CACHE, new CacheStorageConfiguration());
-
+ if(config.isReadOnlyEngineEnabled())
+ configs.put(StorageEngineType.READONLY, new RandomAccessFileStorageConfiguration(config));
+
if(configs.size() == 0)
throw new ConfigurationException("No storage engine has been enabled!");
View
76 src/java/voldemort/store/readonly/RandomAccessFileStore.java
@@ -6,6 +6,7 @@
import java.io.RandomAccessFile;
import java.util.Collections;
import java.util.List;
+import java.util.RandomAccess;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
@@ -76,11 +77,9 @@ public RandomAccessFileStore(String name,
public void open() {
fileModificationLock.writeLock().lock();
try {
- this.indexFileSize = getFileSize(indexFiles);
- this.dataFileSize = getFileSize(dataFiles);
this.indexFiles = new ArrayBlockingQueue<RandomAccessFile>(numFileHandles);
this.dataFiles = new ArrayBlockingQueue<RandomAccessFile>(numFileHandles);
- for(int i = 0; i < numFileHandles; i++) {
+ for(int i = 0 ; i < numFileHandles; i++) {
indexFiles.add(new RandomAccessFile(indexFile, "r"));
dataFiles.add(new RandomAccessFile(dataFile, "r"));
}
@@ -89,6 +88,8 @@ public void open() {
} finally {
fileModificationLock.writeLock().unlock();
}
+ this.indexFileSize = getFileSize(indexFiles);
+ this.dataFileSize = getFileSize(dataFiles);
}
public void swapFiles(String newIndexFile, String newDataFile) {
@@ -161,33 +162,37 @@ private long getFileSize(BlockingQueue<RandomAccessFile> files) {
}
public List<Versioned<byte[]>> get(byte[] key) throws VoldemortException {
- RandomAccessFile index = null;
- RandomAccessFile data = null;
- try {
- fileModificationLock.readLock().lock();
- index = indexFiles.poll(waitTimeoutMs, TimeUnit.MILLISECONDS);
- long valueLocation = getValueLocation(index, key);
- if(valueLocation < 0) {
- return Collections.emptyList();
- } else {
- data = dataFiles.poll(waitTimeoutMs, TimeUnit.MILLISECONDS);
- data.seek(valueLocation);
- int size = data.readInt();
- byte[] value = new byte[size];
- data.readFully(value);
- return Collections.singletonList(new Versioned<byte[]>(value, new VectorClock()));
- }
- } catch(InterruptedException e) {
- throw new VoldemortException("Thread was interrupted.", e);
- } catch(IOException e) {
- throw new PersistenceFailureException(e);
- } finally {
- fileModificationLock.readLock().unlock();
- if(index != null)
- indexFiles.add(index);
- if(data != null)
- dataFiles.add(data);
- }
+ logger.info("Original key: size:" + key.length + " val:" + ByteUtils.toHexString(key));
+ logger.info("MD5 val: size:" + ByteUtils.md5(key).length + " val:" + ByteUtils.toHexString(ByteUtils.md5(key)));
+
+ return Collections.EMPTY_LIST;
+// RandomAccessFile index = null;
+// RandomAccessFile data = null;
+// try {
+// fileModificationLock.readLock().lock();
+// index = indexFiles.poll(waitTimeoutMs, TimeUnit.MILLISECONDS);
+// long valueLocation = getValueLocation(index, key);
+// if(valueLocation < 0) {
+// return Collections.emptyList();
+// } else {
+// data = dataFiles.poll(waitTimeoutMs, TimeUnit.MILLISECONDS);
+// data.seek(valueLocation);
+// int size = data.readInt();
+// byte[] value = new byte[size];
+// data.readFully(value);
+// return Collections.singletonList(new Versioned<byte[]>(value, new VectorClock()));
+// }
+// } catch(InterruptedException e) {
+// throw new VoldemortException("Thread was interrupted.", e);
+// } catch(IOException e) {
+// throw new PersistenceFailureException(e);
+// } finally {
+// fileModificationLock.readLock().unlock();
+// if(index != null)
+// indexFiles.add(index);
+// if(data != null)
+// dataFiles.add(data);
+// }
}
private long getValueLocation(RandomAccessFile index, byte[] key) throws IOException,
@@ -236,18 +241,27 @@ public String getName() {
}
public void close() throws VoldemortException {
+ logger.info("Close called for read-only store.");
this.fileModificationLock.writeLock().lock();
try {
while(this.indexFiles.size() > 0) {
+ logger.info("close file channel Index");
RandomAccessFile f = this.indexFiles.poll();
f.close();
}
+
+ while(this.dataFiles.size() > 0) {
+ logger.info("close file channel Data");
+ RandomAccessFile f = this.dataFiles.poll();
+ f.close();
+ }
} catch(IOException e) {
throw new VoldemortException("Error while closing store.", e);
} finally {
+ logger.info("Trying to unlock lock");
this.fileModificationLock.writeLock().unlock();
}
-
+ logger.info("read-only store closed.");
}
}
View
11 src/java/voldemort/store/routed/RoutedStore.java
@@ -120,9 +120,9 @@ public RoutedStore(String name,
long nodeBannageMs,
Time time) {
if(requiredReads < 1)
- throw new IllegalArgumentException("Cannot have a requiredReads number greater less than 1.");
+ throw new IllegalArgumentException("Cannot have a requiredReads number less than 1.");
if(requiredWrites < 1)
- throw new IllegalArgumentException("Cannot have a requiredWrites number greater less than 1.");
+ throw new IllegalArgumentException("Cannot have a requiredWrites number less than 1.");
if(preferredReads < requiredReads)
throw new IllegalArgumentException("preferredReads must be greater or equal to requiredReads.");
if(preferredWrites < requiredWrites)
@@ -237,6 +237,7 @@ public void run() {
public List<Versioned<byte[]>> get(final byte[] key) throws VoldemortException {
StoreUtils.assertValidKey(key);
final List<Node> nodes = routingStrategy.routeRequest(key);
+ System.out.println("Get called: key:" + key);
// quickly fail if there aren't enough nodes to meet the requirement
if(nodes.size() < this.requiredReads)
@@ -258,11 +259,17 @@ public void run() {
int nodeIndex = 0;
for(; nodeIndex < this.preferredReads; nodeIndex++) {
final Node node = nodes.get(nodeIndex);
+ System.out.println("Querying node:" + node.getId() + " key:" + key);
if(isAvailable(node)) {
+ System.out.println("Available node:" + node.getId() + " key:" + key);
this.executor.execute(new Runnable() {
public void run() {
try {
+ for (Store store: innerStores.values())
+ {
+ logger.info("storeID: " + store.getName() + " Class:" + store.getClass().toString());
+ }
List<Versioned<byte[]>> fetched = innerStores.get(node.getId())
.get(key);
retrieved.addAll(fetched);
Please sign in to comment.
Something went wrong with that request. Please try again.