From 3aa85cd588b745fb2537dbe748580d9c3b980133 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 8 Sep 2015 17:38:07 +0200 Subject: Compilable... --- .../imagemaster/serverconnection/CrcScheduler.java | 78 ---------------------- 1 file changed, 78 deletions(-) delete mode 100644 src/main/java/org/openslx/imagemaster/serverconnection/CrcScheduler.java (limited to 'src/main/java/org/openslx/imagemaster/serverconnection/CrcScheduler.java') diff --git a/src/main/java/org/openslx/imagemaster/serverconnection/CrcScheduler.java b/src/main/java/org/openslx/imagemaster/serverconnection/CrcScheduler.java deleted file mode 100644 index 031a807..0000000 --- a/src/main/java/org/openslx/imagemaster/serverconnection/CrcScheduler.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.openslx.imagemaster.serverconnection; - -import java.io.IOException; -import java.util.Iterator; -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; - -import org.apache.log4j.Logger; -import org.openslx.imagemaster.Globals; -import org.openslx.imagemaster.crcchecker.CrcChecker; - -/** - * Class to schedule CRC checks. - * CRC checks of uploading images are so done parallel to the connection. - */ -public class CrcScheduler extends TimerTask -{ - - private static Logger log = Logger.getLogger( CrcScheduler.class ); - - @Override - public void run() - { - List list = ImageProcessor.getImagesToCheck(); - if ( list == null || list.isEmpty() ) - return; - log.debug( "Starting checks: " + list ); - Iterator iter = list.iterator(); - // iterate over the uploading images that need to be checked - while ( iter.hasNext() ) { - UploadingImage image = iter.next(); - log.debug( "Checking blocks of " + image.getUuid() ); - CrcChecker crcChecker = new CrcChecker( image.getImageFile(), image.getCrcFile() ); - log.debug( "CRCFile is valid: " + crcChecker.hasValidCrcFile() ); - if ( !crcChecker.hasValidCrcFile() ) { - image.setCrcFile( null ); // set crc file to null, so that the image processor will try to write it again. - crcChecker.done(); - continue; - } - for ( int block = 0; block < image.getNumberOfBlocks(); block++ ) { - if ( image.needsCheck( block ) ) { - try { - if ( crcChecker.checkBlock( block ) ) { - image.setValid( block ); - log.debug( block + " was valid" ); - } else { - image.setNeedsRequest( block ); - log.debug( block + " was NOT valid" ); - } - } catch ( IOException e ) { - if ( e.getMessage().equalsIgnoreCase( "crc" ) ) { - image.setCrcFile( null ); // set crc file to null, so that the imageprocessor will try to write it again. - image.updateDb(); - crcChecker.done(); - break; - } else { - // could not read image file - log.error( "Could not read from image file on disk. Pleas contact the server administrator. Image: '" + image.getImageFile().toString() + "'" ); - } - } - } - } - image.updateDb(); // writes valid blocks to database - crcChecker.done(); // closes image file - } - log.debug( "... done" ); - } - - public static void startScheduling() - { - Timer timer = new Timer( "CRCScheduler" ); - - // start now and fire every 60 s - timer.schedule( new CrcScheduler(), 0, Globals.getCrcSchedulingInterval() * 1000L ); - } - -} -- cgit v1.2.3-55-g7522