001/* 002 * #%L 003 * Netarchivesuite - wayback 004 * %% 005 * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library, 006 * the National Library of France and the Austrian National Library. 007 * %% 008 * This program is free software: you can redistribute it and/or modify 009 * it under the terms of the GNU Lesser General Public License as 010 * published by the Free Software Foundation, either version 2.1 of the 011 * License, or (at your option) any later version. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Lesser Public License for more details. 017 * 018 * You should have received a copy of the GNU General Lesser Public 019 * License along with this program. If not, see 020 * <http://www.gnu.org/licenses/lgpl-2.1.html>. 021 * #L% 022 */ 023package dk.netarkivet.wayback.indexer; 024 025import org.slf4j.Logger; 026import org.slf4j.LoggerFactory; 027 028/** 029 * Utility to enable retry of indexing for selected files after they have reached maxFailedAttempts. 030 */ 031public class ResetFailedFiles { 032 033 /** The logger for this class. */ 034 private static final Logger log = LoggerFactory.getLogger(ResetFailedFiles.class); 035 036 /** 037 * Usage: java -cp dk.netarkivet.wayback.jar 038 * -Ddk.netarkivet.settings.file=/home/test/TEST12/conf/settings_WaybackIndexerApplication.xml 039 * -Dsettings.common.applicationInstanceId=RESET_FILES dk.netarkivet.wayback.indexer.ResetFailedFiles file1 file2 040 * ... 041 * <p> 042 * The given files are reset so that they appear never to have failed an indexing attempt. They will therefore be 043 * placed in the index queue the next time the indexer runs. 044 * 045 * @param args the file names 046 */ 047 public static void main(String[] args) { 048 ArchiveFileDAO dao = new ArchiveFileDAO(); 049 for (String filename : args) { 050 ArchiveFile archiveFile = dao.read(filename); 051 if (archiveFile != null) { 052 log.info("Resetting to 0 failures for '{}'", archiveFile.getFilename()); 053 archiveFile.setIndexingFailedAttempts(0); 054 dao.update(archiveFile); 055 } else { 056 log.warn("Attempt to process unknown file '{}'", filename); 057 } 058 } 059 } 060 061}