SOLR-6637: Better error handling when retrieving checksums (Fixes Policeman Jenkins Failure #2134)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1671400 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Varun Thacker 2015-04-05 14:59:02 +00:00
parent 2418769c85
commit f7d633a56e
3 changed files with 15 additions and 6 deletions

View File

@ -17,6 +17,7 @@ package org.apache.solr.handler;
* limitations under the License.
*/
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.Callable;
@ -72,9 +73,14 @@ public class RestoreCore implements Callable<Boolean> {
//Move all files from backupDir to restoreIndexDir
for (String filename : backupDir.listAll()) {
checkInterrupted();
log.info("Copying over file to restore directory " + filename);
log.info("Copying file {} to restore directory ", filename);
try (IndexInput indexInput = backupDir.openInput(filename, IOContext.READONCE)) {
long checksum = CodecUtil.retrieveChecksum(indexInput);
Long checksum = null;
try {
checksum = CodecUtil.retrieveChecksum(indexInput);
} catch (Exception e) {
log.warn("Could not read checksum from index file: " + filename, e);
}
long length = indexInput.length();
IndexFetcher.CompareResult compareResult = IndexFetcher.compareFile(indexDir, filename, length, checksum);
if (!compareResult.equal || (!compareResult.checkSummed && (filename.endsWith(".si")

View File

@ -127,7 +127,7 @@ public class SnapShooter {
}
void createSnapshot(final IndexCommit indexCommit, ReplicationHandler replicationHandler) {
LOG.info("Creating backup snapshot " + (snapshotName == null ? "<not named>" : snapshotName));
LOG.info("Creating backup snapshot " + (snapshotName == null ? "<not named>" : snapshotName) + " at " + snapDir);
NamedList<Object> details = new NamedList<>();
details.add("startTime", new Date().toString());
try {
@ -144,7 +144,8 @@ public class SnapShooter {
details.add("status", "success");
details.add("snapshotCompletedAt", new Date().toString());
details.add("snapshotName", snapshotName);
LOG.info("Done creating backup snapshot: " + (snapshotName == null ? "<not named>" : snapshotName));
LOG.info("Done creating backup snapshot: " + (snapshotName == null ? "<not named>" : snapshotName) +
" at " + snapDir);
} catch (Exception e) {
IndexFetcher.delTree(snapShotDir);
LOG.error("Exception while creating snapshot", e);

View File

@ -26,6 +26,7 @@ import java.net.URLEncoder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
@ -226,8 +227,9 @@ public class TestRestoreCore extends SolrJettyTestBase {
URL url = new URL(masterUrl);
stream = url.openStream();
String response = IOUtils.toString(stream, "UTF-8");
if(pException.matcher(response).find()) {
fail("Failed to complete restore action");
Matcher matcher = pException.matcher(response);
if(matcher.find()) {
fail("Failed to complete restore action with exception " + matcher.group(1));
}
if(response.contains("<str name=\"status\">success</str>")) {
return true;