From 80f916780798162a5c68875fed10ef1ff132c8f7 Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Mon, 22 Aug 2016 13:58:03 +0530 Subject: [PATCH] SOLR-9310: PeerSync fails on a node restart due to IndexFingerPrint mismatch, precommit errors fixed --- .../solr/cloud/PeerSyncReplicationTest.java | 73 +++++++++---------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java index d8131771a52..abdd646a6e3 100644 --- a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java @@ -1,3 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package org.apache.solr.cloud; import java.io.IOException; @@ -7,12 +25,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; -import java.util.Random; import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; import java.util.stream.Collectors; import org.apache.commons.lang.RandomStringUtils; @@ -32,27 +45,9 @@ import org.apache.solr.handler.ReplicationHandler; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - /** * Test sync peer sync when a node restarts and documents are indexed when node was down. - * + * * This test is modeled after SyncSliceTest */ @Slow @@ -177,23 +172,23 @@ public class PeerSyncReplicationTest extends AbstractFullDistribZkTestBase { } } - - private Future indexInBackground(int numDocs) { - ExecutorService executorService = Executors.newSingleThreadExecutor(); - Future f = (Future) executorService.submit(new Callable() { - @Override - public Void call() throws Exception { - for (int i = 0; i < numDocs; i++) { - indexDoc(id, docId, i1, 50, tlong, 50, t1, "document number " + docId++); - // slow down adds, to get documents indexed while in PeerSync - Thread.sleep(100); - } - return null; + private void indexInBackground(int numDocs) { + new Thread(() -> { + try { + for (int i = 0; i < numDocs; i++) { + indexDoc(id, docId, i1, 50, tlong, 50, t1, "document number " + docId++); + // slow down adds, to get documents indexed while in PeerSync + Thread.sleep(100); + } + } catch (Exception e) { + throw new RuntimeException(e); + } - }); + }, getClassName()) + .start(); + - return f; } @@ -343,7 +338,7 @@ public class PeerSyncReplicationTest extends AbstractFullDistribZkTestBase { SolrInputDocument doc = new SolrInputDocument(); addFields(doc, fields); - addFields(doc, "rnd_s", RandomStringUtils.random(new Random().nextInt(100) + 100)); + addFields(doc, "rnd_s", RandomStringUtils.random(random().nextInt(100) + 100)); UpdateRequest ureq = new UpdateRequest(); ureq.add(doc);