add missing succes=true in NRT replicator; remove some dead code

This commit is contained in:
Mike McCandless 2016-07-11 09:23:11 -04:00
parent 044aabfb30
commit de6485ea6a
2 changed files with 12 additions and 3 deletions

View File

@ -97,6 +97,7 @@ public abstract class ReplicaNode extends Node {
state = "init";
deleter = new ReplicaFileDeleter(this, dir);
success = true;
} catch (Throwable t) {
message("exc on init:");
t.printStackTrace(printStream);
@ -219,8 +220,6 @@ public abstract class ReplicaNode extends Node {
message("top: init: sync sis.version=" + job.getCopyState().version);
Collection<String> fileNamesToCopy = job.getFileNamesToCopy();
// Force this copy job to finish while we wait, now. Note that this can be very time consuming!
// NOTE: newNRTPoint detects we are still in init (mgr is null) and does not cancel our copy if a flush happens
try {
@ -718,7 +717,6 @@ public abstract class ReplicaNode extends Node {
* files that need copying */
public List<Map.Entry<String,FileMetaData>> getFilesToCopy(Map<String,FileMetaData> files) throws IOException {
boolean doCopyCommitFiles = false;
List<Map.Entry<String,FileMetaData>> toCopy = new ArrayList<>();
for (Map.Entry<String,FileMetaData> ent : files.entrySet()) {
String fileName = ent.getKey();

View File

@ -30,6 +30,9 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Pattern;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LineFileDocs;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
@ -695,6 +698,12 @@ public class TestNRTReplication extends LuceneTestCase {
replica.close();
}
private void assertWriteLockHeld(Path path) throws Exception {
try (FSDirectory dir = FSDirectory.open(path)) {
expectThrows(LockObtainFailedException.class, () -> {dir.obtainLock(IndexWriter.WRITE_LOCK_NAME);});
}
}
public void testCrashReplica() throws Exception {
Path path1 = createTempDir("1");
@ -703,6 +712,8 @@ public class TestNRTReplication extends LuceneTestCase {
Path path2 = createTempDir("2");
NodeProcess replica = startNode(primary.tcpPort, 1, path2, -1, true);
assertWriteLockHeld(path2);
sendReplicasToPrimary(primary, replica);
// Index 10 docs into primary: