summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2022-03-16 14:21:35 +0100
committerSimon Rettberg2022-03-16 14:21:35 +0100
commitc1999e96a70df04013717cf05b7d75a4c8bbe839 (patch)
tree1e8d33cc3bccaef94d20ec588bb518e9a40d43f6
parentImprove logging a bit, fix spelling (diff)
downloadmaster-sync-shared-c1999e96a70df04013717cf05b7d75a4c8bbe839.tar.gz
master-sync-shared-c1999e96a70df04013717cf05b7d75a4c8bbe839.tar.xz
master-sync-shared-c1999e96a70df04013717cf05b7d75a4c8bbe839.zip
Add more log output to file transfer classes
-rw-r--r--src/main/java/org/openslx/filetransfer/util/ChunkList.java29
-rw-r--r--src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java13
2 files changed, 39 insertions, 3 deletions
diff --git a/src/main/java/org/openslx/filetransfer/util/ChunkList.java b/src/main/java/org/openslx/filetransfer/util/ChunkList.java
index a7e0fdd..bd927b1 100644
--- a/src/main/java/org/openslx/filetransfer/util/ChunkList.java
+++ b/src/main/java/org/openslx/filetransfer/util/ChunkList.java
@@ -415,6 +415,35 @@ public class ChunkList
return sb.toString();
}
+ public synchronized String getStats()
+ {
+ int complete = 0, copying = 0, hashing = 0, missing = 0, qfc = 0, uploading = 0;
+ for ( FileChunk chunk : allChunks ) {
+ switch ( chunk.status ) {
+ case COMPLETE:
+ complete++;
+ break;
+ case COPYING:
+ copying++;
+ break;
+ case HASHING:
+ hashing++;
+ break;
+ case MISSING:
+ missing++;
+ break;
+ case QUEUED_FOR_COPY:
+ qfc++;
+ break;
+ case UPLOADING:
+ uploading++;
+ break;
+ }
+ }
+ return "(" + allChunks.size() + ":" + completeChunks.size() + "/" + pendingChunks.size() + "/" + missingChunks.size() + ")"
+ + " (" + complete + "/" + copying + "/" + hashing + "/" + missing + "/" + qfc + "/" + uploading + ")";
+ }
+
public synchronized boolean isEmpty()
{
return allChunks.isEmpty();
diff --git a/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java b/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java
index dfe007b..9c322fd 100644
--- a/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java
+++ b/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java
@@ -154,7 +154,9 @@ public abstract class IncomingTransferBase extends AbstractTransfer implements H
@Override
public final int getActiveConnectionCount()
{
- return downloads.size();
+ synchronized ( downloads ) {
+ return downloads.size();
+ }
}
public final boolean hashesEqual( List<ByteBuffer> blockHashes )
@@ -390,7 +392,7 @@ public abstract class IncomingTransferBase extends AbstractTransfer implements H
currentChunk = chunks.getMissing();
} catch ( InterruptedException e ) {
Thread.currentThread().interrupt();
- LOGGER.info("Incoming transfer connection was interrupted");
+ LOGGER.info( "Incoming transfer connection was interrupted" );
return null;
}
if ( currentChunk == null ) {
@@ -464,6 +466,7 @@ public abstract class IncomingTransferBase extends AbstractTransfer implements H
@Override
public void run()
{
+ int active;
try {
CbHandler cbh = new CbHandler( connection );
if ( connection.download( cbh, cbh ) ) {
@@ -482,7 +485,7 @@ public abstract class IncomingTransferBase extends AbstractTransfer implements H
}
chunkStatusChanged( cbh.currentChunk );
}
- LOGGER.debug( "Connection for " + getTmpFileName().getAbsolutePath() + " dropped" );
+ LOGGER.info( "Connection for " + getTmpFileName().getAbsolutePath() + " dropped prematurely" );
}
if ( state != TransferState.FINISHED && state != TransferState.ERROR ) {
lastActivityTime.set( System.currentTimeMillis() );
@@ -490,6 +493,7 @@ public abstract class IncomingTransferBase extends AbstractTransfer implements H
} finally {
synchronized ( downloads ) {
downloads.remove( connection );
+ active = downloads.size();
}
}
if ( chunks.isComplete() ) {
@@ -500,6 +504,9 @@ public abstract class IncomingTransferBase extends AbstractTransfer implements H
if ( localCopyManager != null ) {
localCopyManager.trigger();
}
+ LOGGER.info( "Downloader disconnected, " + active + " still running. " + chunks.getStats() );
+ } else {
+ LOGGER.info( "Downloader disconnected, state=" + state + ". " + chunks.getStats() );
}
}
} );