Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ftp: Refactor FTP door to separate FTP interpreter from I/O logic
This patch splits the FTP protocol interpreter logic from the low level I/O logic. This structure mimics a similar split in the DCAP door. The refactoring improves coherence, makes the FTP interpreter easier to unit test, and is a step towards alternative implementations of the I/O logic (e.g. using Netty). Target: trunk Require-notes: no Require-book: no Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de> Patch: http://rb.dcache.org/r/6280/
- Loading branch information
Showing
9 changed files
with
507 additions
and
424 deletions.
There are no files selected for viewing
432 changes: 71 additions & 361 deletions
432
modules/dcache-ftp/src/main/java/diskCacheV111/doors/AbstractFtpDoorV1.java
Large diffs are not rendered by default.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
...ache-ftp/src/main/java/diskCacheV111/doors/AbstractInterruptibleLineBasedInterpreter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package diskCacheV111.doors; | ||
|
||
public abstract class AbstractInterruptibleLineBasedInterpreter implements LineBasedDoor.LineBasedInterpreter | ||
{ | ||
private boolean isStopped; | ||
|
||
/** | ||
* The thread to interrupt when the command poller is | ||
* closed. May be null if interrupts are disabled. | ||
*/ | ||
private Thread executingThread; | ||
|
||
/** | ||
* Enables interrupt upon stop. Until the next call of | ||
* disableInterrupt(), a call to <code>stop</code> will cause | ||
* the calling thread to be interrupted. | ||
* | ||
* @throws InterruptedException if command poller is already | ||
* closed | ||
*/ | ||
protected synchronized void enableInterrupt() | ||
throws InterruptedException | ||
{ | ||
if (isStopped) { | ||
throw new InterruptedException(); | ||
} | ||
executingThread = Thread.currentThread(); | ||
} | ||
|
||
/** | ||
* Disables interrupt upon stop. | ||
*/ | ||
protected synchronized void disableInterrupt() | ||
{ | ||
executingThread = null; | ||
} | ||
|
||
public synchronized void shutdown() | ||
{ | ||
if (!isStopped) { | ||
isStopped = true; | ||
|
||
if (executingThread != null) { | ||
executingThread.interrupt(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.