Skip to content

Commit

Permalink
Fixed constructor to actually take the mlock parameter
Browse files Browse the repository at this point in the history
made it true by default
  • Loading branch information
abh1nay committed Nov 29, 2012
1 parent 2f5e776 commit 7c49c64
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/java/voldemort/server/VoldemortConfig.java
Expand Up @@ -270,7 +270,8 @@ public VoldemortConfig(Props props) {
this.fetcherBufferSize = (int) props.getBytes("hdfs.fetcher.buffer.size",
DEFAULT_BUFFER_SIZE);

this.setUseMlock(props.getBoolean("readonly.mlock.index", false));
// TODO probably turn to false by default?
this.setUseMlock(props.getBoolean("readonly.mlock.index", true));

this.mysqlUsername = props.getString("mysql.user", "root");
this.mysqlPassword = props.getString("mysql.password", "");
Expand Down
32 changes: 16 additions & 16 deletions src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java
Expand Up @@ -110,21 +110,7 @@ public ReadOnlyStorageEngine(String name,
int nodeId,
File storeDir,
int numBackups) {
this.storeDir = storeDir;
this.numBackups = numBackups;
this.name = Utils.notNull(name);
this.searchStrategy = searchStrategy;
this.routingStrategy = Utils.notNull(routingStrategy);
this.nodeId = nodeId;
this.fileSet = null;
this.currentVersionId = 0L;
/*
* A lock that blocks reads during swap(), open(), and close()
* operations
*/
this.fileModificationLock = new ReentrantReadWriteLock();
this.isOpen = false;
open(null);
this(name, searchStrategy, routingStrategy, nodeId, storeDir, numBackups, 0, false);
}

/*
Expand All @@ -139,8 +125,22 @@ public ReadOnlyStorageEngine(String name,
int deleteBackupMs,
boolean enforceMlock) {

this(name, searchStrategy, routingStrategy, nodeId, storeDir, numBackups, deleteBackupMs);
this.enforceMlock = enforceMlock;
this.storeDir = storeDir;
this.numBackups = numBackups;
this.name = Utils.notNull(name);
this.searchStrategy = searchStrategy;
this.routingStrategy = Utils.notNull(routingStrategy);
this.nodeId = nodeId;
this.fileSet = null;
this.currentVersionId = 0L;
/*
* A lock that blocks reads during swap(), open(), and close()
* operations
*/
this.fileModificationLock = new ReentrantReadWriteLock();
this.isOpen = false;
open(null);
}

/**
Expand Down
10 changes: 6 additions & 4 deletions src/java/voldemort/store/readonly/chunk/ChunkedFileSet.java
Expand Up @@ -61,11 +61,8 @@ public ChunkedFileSet(File directory,
RoutingStrategy routingStrategy,
int nodeId,
boolean enforceMlock) {
this(directory, routingStrategy, nodeId);
this.enforceMlock = enforceMlock;
}

public ChunkedFileSet(File directory, RoutingStrategy routingStrategy, int nodeId) {
this.enforceMlock = enforceMlock;
this.baseDir = directory;
if(!Utils.isReadableDir(directory))
throw new VoldemortException(directory.getAbsolutePath()
Expand Down Expand Up @@ -116,6 +113,11 @@ public ChunkedFileSet(File directory, RoutingStrategy routingStrategy, int nodeI
+ " chunks and format " + storageFormat);
}

public ChunkedFileSet(File directory, RoutingStrategy routingStrategy, int nodeId) {
this(directory, routingStrategy, nodeId, false);

}

public DataFileChunkSet toDataFileChunkSet() {

// Convert the index file into chunk set
Expand Down
1 change: 0 additions & 1 deletion src/java/voldemort/store/readonly/io/MappedFileReader.java
Expand Up @@ -50,7 +50,6 @@ private void init(File file) throws IOException {
*/
public MappedByteBuffer map(boolean setAutoLock) throws IOException {

setAutoLock = true; // remove this!
try {

if(mappedByteBuffer == null) {
Expand Down

0 comments on commit 7c49c64

Please sign in to comment.