summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2014-11-20 18:46:02 +0100
committerSimon Rettberg2014-11-20 18:46:02 +0100
commit030a82473e065d027ca3309cc2c4b8381736ab5f (patch)
tree84dfdbe46e04ca2312f146dcc56eb20be1b8a581
parentEnable TLS support for thrift connection aswell (diff)
downloadmasterserver-030a82473e065d027ca3309cc2c4b8381736ab5f.tar.gz
masterserver-030a82473e065d027ca3309cc2c4b8381736ab5f.tar.xz
masterserver-030a82473e065d027ca3309cc2c4b8381736ab5f.zip
Remove some debug messages, fix possible race condition in ImageProcessor
-rw-r--r--src/main/java/org/openslx/imagemaster/App.java13
-rw-r--r--src/main/java/org/openslx/imagemaster/serverconnection/CrcScheduler.java9
-rw-r--r--src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java15
-rw-r--r--src/main/properties/log4j.properties4
4 files changed, 27 insertions, 14 deletions
diff --git a/src/main/java/org/openslx/imagemaster/App.java b/src/main/java/org/openslx/imagemaster/App.java
index 7a6a1ad..24dfffc 100644
--- a/src/main/java/org/openslx/imagemaster/App.java
+++ b/src/main/java/org/openslx/imagemaster/App.java
@@ -1,9 +1,11 @@
package org.openslx.imagemaster;
+import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
+import org.apache.thrift.transport.TTransportException;
import org.openslx.imagemaster.serverconnection.CrcScheduler;
import org.openslx.imagemaster.thrift.server.BinaryListener;
import org.slf4j.LoggerFactory;
@@ -24,16 +26,23 @@ public class App
LoggerFactory.getLogger( "ROOT" );
}
- public static void main( String[] args )
+ public static void main( String[] args ) throws TTransportException, NoSuchAlgorithmException
{
// Init logging
log.info( "Starting Application" );
// Create binary listener
Thread t;
- t = new Thread( new BinaryListener(), "BinaryListener" );
+ t = new Thread( new BinaryListener( 9090, false ), "Thrift PLAIN" );
servers.add( t );
t.start();
+ try {
+ t = new Thread( new BinaryListener( 9091, true ), "Thrift TLS" );
+ servers.add( t );
+ t.start();
+ } catch ( Exception e ) {
+ log.warn( "No TLS available:", e );
+ }
// start the crc checking scheduler
CrcScheduler.startScheduling();
diff --git a/src/main/java/org/openslx/imagemaster/serverconnection/CrcScheduler.java b/src/main/java/org/openslx/imagemaster/serverconnection/CrcScheduler.java
index ff1374c..031a807 100644
--- a/src/main/java/org/openslx/imagemaster/serverconnection/CrcScheduler.java
+++ b/src/main/java/org/openslx/imagemaster/serverconnection/CrcScheduler.java
@@ -12,7 +12,7 @@ import org.openslx.imagemaster.crcchecker.CrcChecker;
/**
* Class to schedule CRC checks.
- * CRC checks of uploading images are so done parallel to the connection.
+ * CRC checks of uploading images are so done parallel to the connection.
*/
public class CrcScheduler extends TimerTask
{
@@ -22,9 +22,10 @@ public class CrcScheduler extends TimerTask
@Override
public void run()
{
- log.debug( "Starting checks..." );
List<UploadingImage> list = ImageProcessor.getImagesToCheck();
- log.debug( list );
+ if ( list == null || list.isEmpty() )
+ return;
+ log.debug( "Starting checks: " + list );
Iterator<UploadingImage> iter = list.iterator();
// iterate over the uploading images that need to be checked
while ( iter.hasNext() ) {
@@ -71,7 +72,7 @@ public class CrcScheduler extends TimerTask
Timer timer = new Timer( "CRCScheduler" );
// start now and fire every 60 s
- timer.schedule( new CrcScheduler(), 0, Globals.getCrcSchedulingInterval() * 1000L );
+ timer.schedule( new CrcScheduler(), 0, Globals.getCrcSchedulingInterval() * 1000L );
}
}
diff --git a/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java b/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java
index 1f41be8..15de77b 100644
--- a/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java
+++ b/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java
@@ -3,7 +3,6 @@ package org.openslx.imagemaster.serverconnection;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -137,13 +136,15 @@ public class ImageProcessor
public static List<UploadingImage> getImagesToCheck()
{
- List<UploadingImage> result = new LinkedList<>();
- Iterator<String> iter = imagesToCheck.iterator();
- log.debug( imagesToCheck );
- while ( iter.hasNext() ) {
- result.add( uploadingImages.get( iter.next() ) );
+ synchronized ( imagesToCheck ) {
+ if ( imagesToCheck.isEmpty() )
+ return null;
+ List<UploadingImage> result = new ArrayList<>( imagesToCheck.size() );
+ for ( String uuid : imagesToCheck ) {
+ result.add( uploadingImages.get( uuid ) );
+ }
+ return result;
}
- return result;
}
public static List<Integer> getRequestedBlocks( String token )
diff --git a/src/main/properties/log4j.properties b/src/main/properties/log4j.properties
index 1a15589..5452d52 100644
--- a/src/main/properties/log4j.properties
+++ b/src/main/properties/log4j.properties
@@ -9,4 +9,6 @@ log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %F - %m%n
log4j.logger.org.apache.directory=ERROR
log4j.logger.org.apache.mina=ERROR
log4j.logger.org.apache.ftpserver=ERROR
-log4j.logger.org.openslx.filetransfer=ERROR \ No newline at end of file
+log4j.logger.org.openslx.filetransfer=ERROR
+
+org.apache.thrift.server.AbstractNonblockingServer=ERROR \ No newline at end of file