From 499610f9c7622bab98cb2c2da46408839063c6f7 Mon Sep 17 00:00:00 2001 From: Michael Petretti Date: Wed, 23 Jul 2014 14:57:48 +0200 Subject: day two of debuging with nils. --- .../filetransfer/FileUploadWorker.java | 41 +++++++++------------- .../filetransfer/ThriftConnection.java | 32 +++++++++++++++++ 2 files changed, 49 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java index 62885c9..d88cd90 100644 --- a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java +++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java @@ -1,7 +1,6 @@ package org.openslx.satellitedaemon.filetransfer; import java.util.List; -import java.util.UUID; import org.apache.log4j.Logger; import org.openslx.filetransfer.Uploader; @@ -26,14 +25,14 @@ public class FileUploadWorker implements Runnable // Upload one Image after the other. for ( DbImage image : imageList ) { - // TODO: still some fields for ImageData, which i can't fill with info from DbImage. - // ImageData imDat = new ImageData( image.guid, image.rid, - // image.name, System.currentTimeMillis(), System.currentTimeMillis(), image.creator, "anyThing", - // true, false, "best", "theVeryBest", image.fileSize ); +// TODO: still some fields for ImageData, which i can't fill with info from DbImage. + ImageData imDat = new ImageData( image.guid, image.rid, + image.name, System.currentTimeMillis(), System.currentTimeMillis(), image.creator, "anyThing", + true, false, "best", "theVeryBest", image.fileSize ); - ImageData imDat = new ImageData( UUID.randomUUID().toString(), image.rid, - image.name, System.currentTimeMillis(), System.currentTimeMillis(), image.creator, "anyThing", - true, false, "best", "theVeryBest", image.fileSize ); +// ImageData imDat = new ImageData( UUID.randomUUID().toString(), image.rid, +// image.name, System.currentTimeMillis(), System.currentTimeMillis(), image.creator, "anyThing", +// true, false, "best", "theVeryBest", image.fileSize ); // uploadInfo and ThriftAuthentication String crcPath = image.path.concat( ".crc" ); @@ -41,9 +40,7 @@ public class FileUploadWorker implements Runnable if ( upInfos == null ) { log.error( "The UploadInfos returned by ThriftConnection Class are null" ); - return; - - // FIXME: And then..? If you just continue, you'll run into a null pointer exception + continue; } log.info( "Got upInfos. Trying to create Uploader with token: " + upInfos.token ); @@ -52,28 +49,24 @@ public class FileUploadWorker implements Runnable Uploader u = new Uploader( Globals.getPropertyString( PropString.FILETRANSFERSERVERIP ), upInfos.port, Globals.getMasterServerSslContext() ); u.sendToken( upInfos.token ); + log.info( "upInfos.getMissingBlocks().size() = " + upInfos.getMissingBlocks().size() ); + // continue sending Blocks until getMissingBlocks is empty. while ( !upInfos.getMissingBlocks().isEmpty() ) { - // Send all Blocks from upInfos.getMissingBlocks() in ranges. List blocks = upInfos.getMissingBlocks(); - int start = 0; - for ( int i = 0; i < blocks.size() - 1; i++ ) { - if ( blocks.get( i ) != ( blocks.get( i + 1 ) - 1 ) ) { - u.sendRange( start * Globals.getPropertyInt( PropInt.BLOCKSIZE ), i * Globals.getPropertyInt( PropInt.BLOCKSIZE ) ); - u.sendFile( image.path ); - start = i + 1; - } - if ( i == blocks.size() - 2 ) { - u.sendRange( start * Globals.getPropertyInt( PropInt.BLOCKSIZE ), ( blocks.size() - 1 ) * Globals.getPropertyInt( PropInt.BLOCKSIZE ) ); - u.sendFile( image.path ); - } + log.info( "Anzahl angeforderter Blöcke : " + blocks.size() ); + log.info( blocks ); + for ( int i = 0; i < blocks.size(); i++ ) { + u.sendRange( blocks.get( i ) * Globals.getPropertyInt( PropInt.BLOCKSIZE ), ( ( blocks.get( i ) + 1 ) * Globals.getPropertyInt( PropInt.BLOCKSIZE ) - 1 ) ); + u.sendFile( image.path ); + log.info( "Block number " + blocks.get(i) + " uploaded."); } upInfos = ThriftConnection.getUploadInfos( imDat ); } u.close(); } try { - Thread.sleep( 5 * 60 * 1000 ); + Thread.sleep( 1 * 60 * 1000 ); // Thread.sleep( 1000 ); } catch ( InterruptedException e ) { Thread.currentThread().interrupt(); diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java index b656a84..e1b9378 100644 --- a/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java +++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java @@ -71,25 +71,39 @@ public class ThriftConnection log.info( "First call of submitImage following..." ); crc = new CRCFile( filename ); log.info( "Made CRCFile from " + filename ); + log.info( "crc.getCrcSums( ).size = " + crc.getCrcSums().size()); + log.info( "crc.getMasterSum() : " + crc.getMasterSum()); + for (int i = 0; i < crc.getCrcSums().size() - 1; i++){ + log.info( "crc.getCRCSum() : " + crc.getCRCSum( i )); + } return theClient.submitImage( sSD.sessionId, imDat, crc.getCrcSums() ); } catch ( TException e ) { log.error("TException"); + e.printStackTrace(); } catch ( UnrecoverableKeyException e ) { log.error("UnrecoverableKeyException"); + e.printStackTrace(); } catch ( InvalidKeyException e ) { log.error("InvalidKeyException"); + e.printStackTrace(); } catch ( NoSuchAlgorithmException e ) { log.error("NoSuchAlgorithmException"); + e.printStackTrace(); } catch ( CertificateException e ) { log.error("CertificateException"); + e.printStackTrace(); } catch ( FileNotFoundException e ) { log.error("FileNotFoundException"); + e.printStackTrace(); } catch ( KeyStoreException e ) { log.error("KeyStoreException"); + e.printStackTrace(); } catch ( SignatureException e ) { log.error("SignatureException"); + e.printStackTrace(); } catch ( IOException e ) { log.error("IOException"); + e.printStackTrace(); } return null; } @@ -117,22 +131,31 @@ public class ThriftConnection return theClient.submitImage( sSD.sessionId, imDat, crc.getCrcSums() ); } catch ( TException e ) { log.error("TException"); + e.printStackTrace(); } catch ( UnrecoverableKeyException e ) { log.error("UnrecoverableKeyException"); + e.printStackTrace(); } catch ( InvalidKeyException e ) { log.error("InvalidKeyException"); + e.printStackTrace(); } catch ( NoSuchAlgorithmException e ) { log.error("NoSuchAlgorithmException"); + e.printStackTrace(); } catch ( CertificateException e ) { log.error("CertificateException"); + e.printStackTrace(); } catch ( FileNotFoundException e ) { log.error("FileNotFoundException"); + e.printStackTrace(); } catch ( KeyStoreException e ) { log.error("KeyStoreException"); + e.printStackTrace(); } catch ( SignatureException e ) { log.error("SignatureException"); + e.printStackTrace(); } catch ( IOException e ) { log.error("IOException"); + e.printStackTrace(); } return null; } @@ -157,22 +180,31 @@ public class ThriftConnection return theClient.getImage( imDat.guid, sSD.sessionId, range ); } catch ( TException e ) { log.error("TException"); + e.printStackTrace(); } catch ( UnrecoverableKeyException e ) { log.error("UnrecoverableKeyException"); + e.printStackTrace(); } catch ( InvalidKeyException e ) { log.error("InvalidKeyException"); + e.printStackTrace(); } catch ( NoSuchAlgorithmException e ) { log.error("NoSuchAlgorithmException"); + e.printStackTrace(); } catch ( CertificateException e ) { log.error("CertificateException"); + e.printStackTrace(); } catch ( FileNotFoundException e ) { log.error("FileNotFoundException"); + e.printStackTrace(); } catch ( KeyStoreException e ) { log.error("KeyStoreException"); + e.printStackTrace(); } catch ( SignatureException e ) { log.error("SignatureException"); + e.printStackTrace(); } catch ( IOException e ) { log.error("IOException"); + e.printStackTrace(); } return null; } -- cgit v1.2.3-55-g7522