summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Petretti2014-06-11 13:36:06 +0200
committerMichael Petretti2014-06-11 13:36:06 +0200
commit3ce1e77a76992a1c3011fcb663ebec040c2e5dca (patch)
tree21bc76288e768b3411dcd0c6ad4a696ebc2626ea
parentAdded log messages. (diff)
downloadsatellite-daemon-3ce1e77a76992a1c3011fcb663ebec040c2e5dca.tar.gz
satellite-daemon-3ce1e77a76992a1c3011fcb663ebec040c2e5dca.tar.xz
satellite-daemon-3ce1e77a76992a1c3011fcb663ebec040c2e5dca.zip
Narrowed the problem down to ThriftConnection class line 127 throwing a TTransportException.
-rw-r--r--src/main/java/org/openslx/satellitedaemon/App.java2
-rw-r--r--src/main/java/org/openslx/satellitedaemon/db/DbImage.java4
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java1
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java45
4 files changed, 36 insertions, 16 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/App.java b/src/main/java/org/openslx/satellitedaemon/App.java
index c5bad11..30382db 100644
--- a/src/main/java/org/openslx/satellitedaemon/App.java
+++ b/src/main/java/org/openslx/satellitedaemon/App.java
@@ -9,6 +9,7 @@ import java.security.SignatureException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
+import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
import org.openslx.imagemaster.thrift.iface.ServerAuthenticationException;
import org.openslx.satellitedaemon.ftp.FtpUploadWorker;
@@ -25,6 +26,7 @@ public class App
throws NoSuchAlgorithmException, KeyStoreException, CertificateException, FileNotFoundException, IOException, ServerAuthenticationException, UnrecoverableKeyException,
InvalidKeyException, SignatureException
{
+ BasicConfigurator.configure();
try {
Globals.loadProperties();
if ( !Globals.propertiesValid() ) {
diff --git a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
index 02d396a..0ed8efd 100644
--- a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
+++ b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
@@ -16,8 +16,10 @@ public class DbImage
public final String creator;
public final long fileSize;
- public DbImage(String guid, String name, int rid, String path, String creator, long fileSize)
+ public DbImage(String guid, String name, Integer rid, String path, String creator, Long fileSize)
{
+ if (rid == null) rid = -1;
+ if (fileSize == null) fileSize = (long) -1;
this.guid = guid;
this.name = name;
this.rid = rid;
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
index 6b213b1..8174787 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
@@ -31,6 +31,7 @@ public class FtpUploadWorker implements Runnable
{
while ( true ) {
List<DbImage> imageList = DbImage.getAllMarkedForUpload();
+ log.info( "FtpUploadWorker: imageList Contains " + imageList.size() + " items." );
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,
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
index e7fe0b8..c3fb21c 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
@@ -44,14 +44,15 @@ public class ThriftConnection
*/
public static FtpCredentials getFtpCredentials( ImageData imDat )
{
+ ImageServer.Client theClient = null;
try {
- client = getConnection();
- if ( client == null ) {
+ theClient = getConnection();
+ if ( theClient == null ) {
log.error( "Client was null!" );
return null;
}
- return client.submitImage( sSD.sessionId, imDat );
+ return theClient.submitImage( sSD.sessionId, imDat );
} catch ( TException e ) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -95,41 +96,54 @@ public class ThriftConnection
IOException, InvalidKeyException, SignatureException
{
ImageServer.Client theClient = null;
- if ( client == null ) {
- theClient = newClient();
- } else {
- theClient = client;
- }
boolean isAuthenticated = false;
- try {
- isAuthenticated = theClient.ping();
- } catch ( TException x ) {
+ if ( client == null ) {
+ log.info( "The global client was null. Making a new client ..." );
theClient = newClient();
if ( theClient == null ) {
+ log.debug( "ThriftConnection: The client was null after newClient()" );
return null;
}
+ } else {
+ log.info( "The global Client was already used. Setting isAuthenticated = true." );
+ theClient = client;
+ isAuthenticated = true;
}
+ // try {
+ // isAuthenticated = theClient.ping();
+ // } catch ( TException x ) {
+ // theClient = newClient();
+ // if ( theClient == null ) {
+ // return null;
+ // }
+ // }
if ( !isAuthenticated ) {
log.info( "ThriftConnection: Client not yet Authenticated. Trying..." );
String toEncrypt;
+ if ( theClient == null ) {
+ log.debug( "The client was null" );
+ }
try {
- toEncrypt = client.startServerAuthentication( "uni-freiburg.de" );
- // System.out.println( toEncrypt );
+ toEncrypt = theClient.startServerAuthentication( "michis-test.de" );
+ log.info( "The random String we want to encrypt: " + toEncrypt );
EncryptWithServerIdPublicKey rse = new EncryptWithServerIdPublicKey( "serverid", "password",
"/home/michael/satellite-daemon/config/serverid.jks" );
byte[] byteArray = rse.encryptString( toEncrypt );
- sSD = client.serverAuthenticate(
- "uni-freiburg.de", ByteBuffer.wrap( byteArray ) );
+ sSD = theClient.serverAuthenticate(
+ "michis-test.de", ByteBuffer.wrap( byteArray ) );
} catch ( ServerAuthenticationException e ) {
log.error( "ThriftConnection: Server Authetication was not sucessful." );
e.printStackTrace();
+ return null;
} catch ( TException e ) {
log.error( "ThriftConnection: Server Authetication was not sucessful." );
e.printStackTrace();
+ return null;
}
log.info( "is Authenticated." );
}
+ client = theClient;
return theClient;
}
@@ -142,6 +156,7 @@ public class ThriftConnection
transport.open();
TProtocol protocol = new TBinaryProtocol( transport );
newClient = new ImageServer.Client( protocol );
+ log.debug( "ThriftConnection: Made a new Client" );
} catch ( TException x ) {
log.error( "ThriftConnection coudn't create new client." );
x.printStackTrace();