Merge branch 'master' into mockfilesystem

Conflicts:
	src/main/java/org/elasticsearch/index/translog/Translog.java
	src/main/java/org/elasticsearch/index/translog/fs/FsTranslog.java
This commit is contained in:
Robert Muir 2015-04-15 18:34:24 -04:00
commit fb481bc145
5 changed files with 12 additions and 16 deletions

View File

@ -33,7 +33,6 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Streamable;
import org.elasticsearch.common.lease.Releasable;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.lucene.uid.Versions;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.index.VersionType;
@ -41,7 +40,6 @@ import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.shard.IndexShardComponent;
import java.io.Closeable;
import java.io.EOFException;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
@ -145,10 +143,9 @@ public interface Translog extends IndexShardComponent, Closeable, Accountable {
public Path[] locations();
/**
* Returns the translog file with the given id as a Path. This
* will return a filename.
* Returns the translog filename for the given id.
*/
String getPath(long translogId);
String getFilename(long translogId);
/**
* return stats

View File

@ -239,7 +239,7 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog
}
}
try {
newFile = type.create(shardId, id, new InternalChannelReference(location.resolve(getPath(id)), StandardOpenOption.READ, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW), bufferSize);
newFile = type.create(shardId, id, new InternalChannelReference(location.resolve(getFilename(id)), StandardOpenOption.READ, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW), bufferSize);
} catch (IOException e) {
throw new TranslogException(shardId, "failed to create new translog file", e);
}
@ -265,7 +265,7 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog
location = file;
}
}
this.trans = type.create(shardId, id, new InternalChannelReference(location.resolve(getPath(id)), StandardOpenOption.READ, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW), transientBufferSize);
this.trans = type.create(shardId, id, new InternalChannelReference(location.resolve(getFilename(id)), StandardOpenOption.READ, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW), transientBufferSize);
} catch (IOException e) {
throw new TranslogException(shardId, "failed to create new translog file", e);
} finally {
@ -431,7 +431,7 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog
}
@Override
public String getPath(long translogId) {
public String getFilename(long translogId) {
return TRANSLOG_FILE_PREFIX + translogId;
}
@ -473,7 +473,7 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog
@Override
public OperationIterator openIterator(long translogId) throws IOException {
final String translogName = getPath(translogId);
final String translogName = getFilename(translogId);
Path recoveringTranslogFile = null;
logger.trace("try open translog file {} locations: {}", translogName, Arrays.toString(locations()));
OUTER:

View File

@ -383,16 +383,16 @@ public abstract class AbstractSimpleTranslogTests extends ElasticsearchTestCase
public void assertFileIsPresent(Translog translog, long id) {
for (Path location : translog.locations()) {
if (Files.exists(location.resolve(translog.getPath(id)))) {
if (Files.exists(location.resolve(translog.getFilename(id)))) {
return;
}
}
fail(translog.getPath(id) + " is not present in any location: " + Arrays.toString(translog.locations()));
fail(translog.getFilename(id) + " is not present in any location: " + Arrays.toString(translog.locations()));
}
public void assertFileDeleted(Translog translog, long id) {
for (Path location : translog.locations()) {
assertFalse(Files.exists(location.resolve(translog.getPath(id))));
assertFalse(Files.exists(location.resolve(translog.getFilename(id))));
}
}

View File

@ -25,15 +25,12 @@ import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
import org.apache.lucene.util.TimeUnits;
import org.elasticsearch.test.junit.listeners.LoggingListener;
import org.elasticsearch.test.junit.listeners.ReproduceInfoPrinter;
import org.junit.AfterClass;
/**
@ -47,7 +44,7 @@ import org.junit.AfterClass;
@ThreadLeakLingering(linger = 5000) // 5 sec lingering
@TimeoutSuite(millis = TimeUnits.HOUR)
@LuceneTestCase.SuppressSysoutChecks(bugUrl = "we log a lot on purpose")
@SuppressFileSystems("ExtrasFS") // we aren't ready for this yet.
@SuppressFileSystems("*") // we aren't ready for this yet.
public abstract class ElasticsearchLuceneTestCase extends LuceneTestCase {
private static final Codec DEFAULT_CODEC = Codec.getDefault();

View File

@ -27,6 +27,7 @@ import com.google.common.collect.ImmutableList;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.AbstractRandomizedTest;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TimeUnits;
import org.apache.lucene.uninverting.UninvertingReader;
import org.elasticsearch.Version;
@ -79,6 +80,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllS
@ThreadLeakLingering(linger = 5000) // 5 sec lingering
@TimeoutSuite(millis = 20 * TimeUnits.MINUTE) // timeout the suite after 20min and fail the test.
@Listeners(LoggingListener.class)
@LuceneTestCase.SuppressFileSystems("*") // we aren't ready for this yet.
public abstract class ElasticsearchTestCase extends AbstractRandomizedTest {
private static Thread.UncaughtExceptionHandler defaultHandler;