Skip to content

Commit

Permalink
more internal refactoring in directory providers
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchy committed Sep 22, 2011
1 parent 25fe56c commit c1ca21f
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 68 deletions.
Expand Up @@ -27,7 +27,7 @@
*/
public interface DirectoryService {

Directory build() throws IOException;
Directory[] build() throws IOException;

void renameFile(Directory dir, String from, String to) throws IOException;

Expand Down

Large diffs are not rendered by default.

Expand Up @@ -19,6 +19,7 @@

package org.elasticsearch.index.store;

import org.apache.lucene.store.Directory;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand All @@ -39,14 +40,25 @@ public class StoreFileMetaData implements Streamable {

private String checksum;

private transient Directory directory;

StoreFileMetaData() {
}

public StoreFileMetaData(String name, long length, long lastModified, String checksum) {
this(name, length, lastModified, checksum, null);
}

public StoreFileMetaData(String name, long length, long lastModified, String checksum, @Nullable Directory directory) {
this.name = name;
this.lastModified = lastModified;
this.length = length;
this.checksum = checksum;
this.directory = directory;
}

public Directory directory() {
return this.directory;
}

public String name() {
Expand Down
Expand Up @@ -39,9 +39,9 @@ public class MmapFsDirectoryService extends FsDirectoryService {
super(shardId, indexSettings, indexStore);
}

@Override public Directory build() throws IOException {
@Override public Directory[] build() throws IOException {
File location = indexStore.shardIndexLocation(shardId);
FileSystemUtils.mkdirs(location);
return new MMapDirectory(location, buildLockFactory());
return new Directory[]{new MMapDirectory(location, buildLockFactory())};
}
}
Expand Up @@ -39,9 +39,9 @@ public class NioFsDirectoryService extends FsDirectoryService {
super(shardId, indexSettings, indexStore);
}

@Override public Directory build() throws IOException {
@Override public Directory[] build() throws IOException {
File location = indexStore.shardIndexLocation(shardId);
FileSystemUtils.mkdirs(location);
return new NIOFSDirectory(location, buildLockFactory());
return new Directory[]{new NIOFSDirectory(location, buildLockFactory())};
}
}
Expand Up @@ -39,9 +39,9 @@ public class SimpleFsDirectoryService extends FsDirectoryService {
super(shardId, indexSettings, indexStore);
}

@Override public Directory build() throws IOException {
@Override public Directory[] build() throws IOException {
File location = indexStore.shardIndexLocation(shardId);
FileSystemUtils.mkdirs(location);
return new SimpleFSDirectory(location, buildLockFactory());
return new Directory[]{new SimpleFSDirectory(location, buildLockFactory())};
}
}
Expand Up @@ -46,8 +46,8 @@ public class ByteBufferDirectoryService extends AbstractIndexShardComponent impl
this.byteBufferCache = byteBufferCache;
}

@Override public Directory build() {
return new CustomByteBufferDirectory(byteBufferCache);
@Override public Directory[] build() {
return new Directory[]{new CustomByteBufferDirectory(byteBufferCache)};
}

@Override public void renameFile(Directory dir, String from, String to) throws IOException {
Expand Down
Expand Up @@ -40,8 +40,8 @@ public class RamDirectoryService extends AbstractIndexShardComponent implements
super(shardId, indexSettings);
}

@Override public Directory build() {
return new CustomRAMDirectory();
@Override public Directory[] build() {
return new Directory[]{new CustomRAMDirectory()};
}

@Override public void renameFile(Directory dir, String from, String to) throws IOException {
Expand Down

0 comments on commit c1ca21f

Please sign in to comment.