summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2014-07-25 14:40:06 +0200
committerSimon Rettberg2014-07-25 14:40:06 +0200
commit3c2dd50f0638f42fd8bda4f4a85c631f7c4f81e0 (patch)
treec498576334b62c137ba121d0aba0ad86b4796f98
parentday two of debuging with nils. (diff)
downloadsatellite-daemon-3c2dd50f0638f42fd8bda4f4a85c631f7c4f81e0.tar.gz
satellite-daemon-3c2dd50f0638f42fd8bda4f4a85c631f7c4f81e0.tar.xz
satellite-daemon-3c2dd50f0638f42fd8bda4f4a85c631f7c4f81e0.zip
Adapt to changes in master-sync-shared
-rw-r--r--src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java15
-rw-r--r--src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java19
2 files changed, 27 insertions, 7 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java
index 84405c6..a6431f5 100644
--- a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java
@@ -1,5 +1,6 @@
package org.openslx.satellitedaemon.filetransfer;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -31,13 +32,21 @@ public class FileDownloadWorker implements Runnable
DownloadInfos downInfos = ThriftConnection.getDownloadInfos( image, range );
if ( downInfos == null ) {
log.error( "The DownloadInfos returned by ThriftConnection class are null" );
+ continue;
}
- Downloader d = new Downloader( Globals.getPropertyString( PropString.FILETRANSFERSERVERIP ), downInfos.port, Globals.getMasterServerSslContext() );
+ Downloader d;
+ try {
+ d = new Downloader( Globals.getPropertyString( PropString.FILETRANSFERSERVERIP ), downInfos.port, Globals.getMasterServerSslContext() );
+ } catch ( IOException e ) {
+ log.warn( "Could not connect for download: " + e.toString() );
+ e.printStackTrace();
+ continue;
+ }
d.sendToken( downInfos.token );
d.setOutputFilename( "/home/michael/Downloads/tescht.whatever" );
- while ( d.readMetaData() )
- d.readBinary();
+ while ( d.readMetaData() ) // TODO: Request range...
+ d.receiveBinary();
}
try {
Thread.sleep( 5 * 60 * 1000 );
diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
index d88cd90..48e467b 100644
--- a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
@@ -1,5 +1,7 @@
package org.openslx.satellitedaemon.filetransfer;
+import java.io.File;
+import java.io.IOException;
import java.util.List;
import org.apache.log4j.Logger;
@@ -39,17 +41,22 @@ public class FileUploadWorker implements Runnable
UploadInfos upInfos = ThriftConnection.getUploadInfos( imDat, crcPath );
if ( upInfos == null ) {
log.error( "The UploadInfos returned by ThriftConnection Class are null" );
-
continue;
-
}
log.info( "Got upInfos. Trying to create Uploader with token: " + upInfos.token );
// creating the uploader with the "context"-item.
- Uploader u = new Uploader( Globals.getPropertyString( PropString.FILETRANSFERSERVERIP ), upInfos.port, Globals.getMasterServerSslContext() );
+ Uploader u;
+ try {
+ u = new Uploader( Globals.getPropertyString( PropString.FILETRANSFERSERVERIP ), upInfos.port, Globals.getMasterServerSslContext() );
+ } catch ( IOException e ) {
+ log.warn( "Could not connect for uploading an image: " + e.toString() );
+ continue;
+ }
u.sendToken( upInfos.token );
log.info( "upInfos.getMissingBlocks().size() = " + upInfos.getMissingBlocks().size() );
+ long fileSize = new File(image.path).length();
// continue sending Blocks until getMissingBlocks is empty.
while ( !upInfos.getMissingBlocks().isEmpty() ) {
@@ -57,7 +64,11 @@ public class FileUploadWorker implements Runnable
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 ) );
+ int startOffset = blocks.get( i ) * Globals.getPropertyInt( PropInt.BLOCKSIZE ); // TODO: long
+ int endOffset = startOffset + Globals.getPropertyInt( PropInt.BLOCKSIZE );
+ if (endOffset >fileSize )
+ endOffset = (int)fileSize; // TODO: Long
+ u.prepareSendRange( startOffset, endOffset );
u.sendFile( image.path );
log.info( "Block number " + blocks.get(i) + " uploaded.");
}