summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/openslx/satellitedaemon/App.java2
-rw-r--r--src/main/java/org/openslx/satellitedaemon/Globals.java5
-rw-r--r--src/main/java/org/openslx/satellitedaemon/db/DbImage.java19
-rw-r--r--src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java13
-rw-r--r--src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java6
5 files changed, 36 insertions, 9 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/App.java b/src/main/java/org/openslx/satellitedaemon/App.java
index cdbab6c..356034f 100644
--- a/src/main/java/org/openslx/satellitedaemon/App.java
+++ b/src/main/java/org/openslx/satellitedaemon/App.java
@@ -17,11 +17,13 @@ public class App
public static void main( String[] args )
{
BasicConfigurator.configure();
+ // Loads all entries from the configuration file config/globals.properties
Globals.init();
if (!Globals.masterServerSslContextInit()){
log.error( "Problem with initializing the SSLContext" );
System.exit( 1 );
}
+ // Start Up- and Download.
Thread uploadWorker = new Thread( new FileUploadWorker() );
uploadWorker.start();
Thread downloadWorker = new Thread( new FileDownloadWorker() );
diff --git a/src/main/java/org/openslx/satellitedaemon/Globals.java b/src/main/java/org/openslx/satellitedaemon/Globals.java
index fd8458d..72cd423 100644
--- a/src/main/java/org/openslx/satellitedaemon/Globals.java
+++ b/src/main/java/org/openslx/satellitedaemon/Globals.java
@@ -27,6 +27,11 @@ public class Globals {
public static void init() {
}
+ /***********************************************************************************************/
+ /**
+ * A call of Globals.getXXXXXX() returns the corresponding entry in config/global.properties
+ */
+
// * Properties *//
// Strings //
diff --git a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
index 10438f8..a7dcbc3 100644
--- a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
+++ b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
@@ -52,6 +52,14 @@ public class DbImage
" WHERE image_syncMode = 'to_be_published'" );
}
+ /**
+ * Returns a list of all images on this satellite that should be
+ * downloaded from the central server.
+ *
+ * @return list of images that are marked for download, where the download
+ * was either not started yet, or is incomplete
+ */
+
public static List<DbImage> getAllMarkedForDownload()
{
return MySQL.findAll( DbImage.class, "SELECT image.GUID_imageID, image.image_name, image.imageVersion, image.image_path," +
@@ -62,11 +70,22 @@ public class DbImage
" WHERE image_syncMode = 'to_be_decentralized'" );
}
+ /**
+ * Method for updating the status of an Image in the db. For example after a succesfull upload.
+ *
+ * @param status : possible statuses are : "only_local, to_be_published, being_published,
+ * successfully_published, to_be_decentralized, being_decentralized, successfully_decentralized"
+ */
public void updateStatus( Status status )
{
MySQL.update( "UPDATE m_VLData_imageInfo SET image_syncMode=? WHERE GUID_imageID=?", status.toString(), this.guid);
}
+ /**
+ * Method for updating the size of an Image in the db.
+ *
+ * @param filesize is the size of the file
+ */
public void updateFilesize( long filesize )
{
MySQL.update( "UPDATE m_VLData_imageInfo SET image_filesize=? WHERE GUID_imageID=?", filesize, this.guid );
diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
index 829a903..2677c53 100644
--- a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
@@ -27,23 +27,22 @@ 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.
+ // 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", // TODO: fields in databases need to fit somehow...
// true, false, "best", "theVeryBest", image.fileSize);
+ // Only for testing because a random UUID is used. Later the method above should be used.
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" );
- UploadInfos upInfos = ThriftConnection.getUploadInfos( imDat,
- crcPath );
+ // ThriftConnection.getUploadInfos returns uploadInfo and handles ThriftAuthentication
+ UploadInfos upInfos = ThriftConnection.getUploadInfos( imDat, crcPath );
if ( upInfos == null ) {
log.error( "The UploadInfos returned by ThriftConnection Class are null" );
continue;
@@ -61,6 +60,7 @@ public class FileUploadWorker implements Runnable
+ e.toString() );
continue;
}
+ // Necessary authentication before upload.
u.sendToken( upInfos.token );
log.info( "upInfos.getMissingBlocks().size() = "
@@ -73,8 +73,7 @@ public class FileUploadWorker implements Runnable
log.info( "Anzahl angeforderter Blöcke : " + blocks.size() );
log.info( blocks );
for ( int i = 0; i < blocks.size(); i++ ) {
- int startOffset = blocks.get( i ) * Globals.BLOCKSIZE; // TODO:
- // long
+ int startOffset = blocks.get( i ) * Globals.BLOCKSIZE; // TODO: long
int endOffset = startOffset + Globals.BLOCKSIZE;
if ( endOffset > fileSize )
endOffset = (int)fileSize; // TODO: Long
diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java
index c77d6d6..22f270a 100644
--- a/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java
+++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java
@@ -114,7 +114,7 @@ public class ThriftConnection {
// SessionID is not valid
// TODO: Code for new SSID
} else if (e.getNumber().equals(AuthorizationError.NO_PERMISSION)) {
- // Gibts noch gar nicht
+ // not yet implemented.
} else {
e.printStackTrace();
@@ -338,6 +338,8 @@ public class ThriftConnection {
theClient = client;
isAuthenticated = true;
}
+ // here the client was already used so we are just assuming that the client is still
+ // authenticated. Should be checked with the ping() method.
// try {
// isAuthenticated = theClient.ping();
// } catch ( TException x ) {
@@ -387,8 +389,8 @@ public class ThriftConnection {
/***********************************************************************************************/
/**
+ * Method for creating a new Client for Thrift communication.
*
- * @return
* @throws IOException
*/
private static ImageServer.Client newClient() throws IOException {