summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Schwabe2014-07-25 11:37:42 +0200
committerNils Schwabe2014-07-25 11:37:42 +0200
commita345d4a7af3a9017506e714fd7d548f42cc4492a (patch)
treea55973bd67861d4c47237ea12bf8c287d5e39f80
parentAdd "synchronized" to UploadingImage (diff)
downloadmasterserver-a345d4a7af3a9017506e714fd7d548f42cc4492a.tar.gz
masterserver-a345d4a7af3a9017506e714fd7d548f42cc4492a.tar.xz
masterserver-a345d4a7af3a9017506e714fd7d548f42cc4492a.zip
Make trasmit times configurabl
Make new globals.properties.example
-rw-r--r--config/global.properties.example30
-rw-r--r--src/main/java/org/openslx/imagemaster/Globals.java5
-rw-r--r--src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java2
-rw-r--r--src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java50
4 files changed, 45 insertions, 42 deletions
diff --git a/config/global.properties.example b/config/global.properties.example
index 668bfdb..d4f46a2 100644
--- a/config/global.properties.example
+++ b/config/global.properties.example
@@ -44,27 +44,25 @@ session_timeout_user=600
session_timeout_server=600
#####################
-# FTP Server #
+# Ssl Socket #
#####################
-# the base dir of the ftp server (should exists)
-ftp_base_dir=/tmp
+# port that is used for data connection between satellite and master
+ssl_socket_port=56456
-# the port of the ftp server
-ftp_port=2221
-
-# timeout for kicking idling ftp users (in minutes)
-ftp_timeout=30
-
-#####################
-# Keystore #
-#####################
+# timeout for kicking idling clients (in minutes)
+ssl_socket_timeout=1
# keystore (.jks format)
-keystore_file=./config/keystore.jks
+ssl_keystore_file=./config/sslsocket.jks
# keystore alias
-keystore_alias=ftp
+ssl_keystore_alias=alias
+
+# keystore password
+ssl_keystore_password=password
-#keystore password
-keystore_password=password \ No newline at end of file
+# how often should the masterserver request a block
+# from the satellite if the check sum fails
+# until an error is sent
+ssl_socket_transmit_times=20 \ No newline at end of file
diff --git a/src/main/java/org/openslx/imagemaster/Globals.java b/src/main/java/org/openslx/imagemaster/Globals.java
index b6848bb..a16e009 100644
--- a/src/main/java/org/openslx/imagemaster/Globals.java
+++ b/src/main/java/org/openslx/imagemaster/Globals.java
@@ -109,6 +109,11 @@ public class Globals
{
return Util.tryToParseInt( properties.getProperty( "ssl_socket_timeout" ) );
}
+
+ public static int getSslTransmitTimes()
+ {
+ return Util.tryToParseInt( properties.getProperty( "ssl_socket_transmit_times" ) );
+ }
/* STRINGS */
diff --git a/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java b/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java
index b872b25..e40778e 100644
--- a/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java
+++ b/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java
@@ -215,7 +215,7 @@ public class ImageProcessor
log.debug( i );
if ( image.needsRequest( i ) ) {
int times = image.getTimesTransmitted( i );
- if ( times > 20 ) { // TODO: make configurable
+ if ( times > Globals.getSslTransmitTimes() ) {
log.debug( "Block " + i + " is probably broken." );
throw new UploadException( UploadError.BROKEN_BLOCK, "Block " + i + " was transmitted "
+ times + " and is still not valid." );
diff --git a/src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java b/src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java
index feb2a1e..7c491f6 100644
--- a/src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java
+++ b/src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java
@@ -50,24 +50,24 @@ public class UploadingImage
{
if ( blockStatus == null )
return;
- synchronized(blockStatus) {
+ synchronized ( blockStatus ) {
blockStatus[index] = valid;
}
}
-
+
protected void updateDb()
{
if ( blockStatus == null )
return;
-
- List<Integer> missingBlocks = new ArrayList<>();
-
- synchronized(blockStatus) {
- for (int block = 0; block < blockStatus.length; block++) {
- if (blockStatus[block] != valid) {
- missingBlocks.add( block );
- }
- }
+
+ List<Integer> missingBlocks = new ArrayList<>();
+
+ synchronized ( blockStatus ) {
+ for ( int block = 0; block < blockStatus.length; block++ ) {
+ if ( blockStatus[block] != valid ) {
+ missingBlocks.add( block );
+ }
+ }
}
dbImage.updateMissingBlocks( missingBlocks );
}
@@ -76,7 +76,7 @@ public class UploadingImage
{
if ( blockStatus == null )
return;
- synchronized(blockStatus) {
+ synchronized ( blockStatus ) {
blockStatus[index] = missing;
}
}
@@ -85,7 +85,7 @@ public class UploadingImage
{
if ( blockStatus == null )
return;
- synchronized(blockStatus) {
+ synchronized ( blockStatus ) {
blockStatus[index] *= ( blockStatus[index] < missing ) ? -1 : 1; // switch to positive value if needed
}
}
@@ -94,7 +94,7 @@ public class UploadingImage
{
if ( blockStatus == null )
return;
- synchronized(blockStatus) {
+ synchronized ( blockStatus ) {
blockStatus[index] *= ( blockStatus[index] > missing ) ? -1 : 1; // switch to negative value if needed
}
}
@@ -103,15 +103,15 @@ public class UploadingImage
{
if ( blockStatus == null || blockStatus[index] == 200 )
return;
- synchronized(blockStatus) {
+ synchronized ( blockStatus ) {
blockStatus[index] += ( blockStatus[index] <= missing ) ? -1 : 1; // increase in both directions
}
}
protected int getTimesTransmitted( int index )
{
- synchronized(blockStatus) {
- return Math.abs( blockStatus[index] );
+ synchronized ( blockStatus ) {
+ return ( blockStatus[index] > 0 ) ? blockStatus[index] : ( -1 ) * blockStatus[index];
}
}
@@ -124,7 +124,7 @@ public class UploadingImage
{
if ( blockStatus == null )
return false;
- synchronized(blockStatus) {
+ synchronized ( blockStatus ) {
return ( ( blockStatus[index] >= missing ) && ( blockStatus[index] != valid ) );
}
}
@@ -133,7 +133,7 @@ public class UploadingImage
{
if ( blockStatus == null )
return false;
- synchronized(blockStatus) {
+ synchronized ( blockStatus ) {
return ( blockStatus[index] < missing );
}
}
@@ -192,16 +192,16 @@ public class UploadingImage
}
return result;
}
-
+
public boolean allBlocksValid()
{
if ( blockStatus == null )
return false;
- synchronized(blockStatus) {
- for ( int i : blockStatus ) {
- if ( i != 200 )
- return false;
- }
+ synchronized ( blockStatus ) {
+ for ( int i : blockStatus ) {
+ if ( i != 200 )
+ return false;
+ }
}
return true;
}