Skip to content

Commit

Permalink
ftp: Refactor FTP door to separate FTP interpreter from I/O logic
Browse files Browse the repository at this point in the history
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
gbehrmann committed Dec 2, 2013
1 parent 1e7f211 commit 4395eca
Show file tree
Hide file tree
Showing 9 changed files with 507 additions and 424 deletions.

Large diffs are not rendered by default.

@@ -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();
}
}
}
}
Expand Up @@ -24,9 +24,6 @@
import diskCacheV111.util.CacheException;
import diskCacheV111.util.PermissionDeniedCacheException;

import dmg.util.Args;
import dmg.util.StreamEngine;

import org.dcache.auth.LoginNamePrincipal;
import org.dcache.auth.Subjects;
import org.dcache.cells.Option;
Expand Down Expand Up @@ -71,22 +68,13 @@ public class GsiFtpDoorV1 extends GssFtpDoorV1

private String _user;

/** Creates a new instance of GsiFtpDoorV1 */
public GsiFtpDoorV1(String name, StreamEngine engine, Args args)
{
super(name,engine,args);
}

@Override
protected void init()
throws Exception
public void init()
{
super.init();
cf = CertificateFactories.newX509CertificateFactory();

_gssFlavor = "gsi";

ftpDoorName="GSI FTP";
cf = CertificateFactories.newX509CertificateFactory();
super.init();
}

@Override
Expand Down
Expand Up @@ -16,9 +16,7 @@

import diskCacheV111.util.Base64;

import dmg.util.Args;
import dmg.util.CommandExitException;
import dmg.util.StreamEngine;

import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getFirst;
Expand All @@ -39,18 +37,11 @@ public abstract class GssFtpDoorV1 extends AbstractFtpDoorV1
// GSS GSI context and others
protected GSSContext _serviceContext;

/** Creates a new instance of GsiFtpDoorV1 */
public GssFtpDoorV1(String name, StreamEngine engine, Args args)
{
super(name,engine,args);
}

@Override
protected void init()
throws Exception
public void init()
{
super.init();
_gssFlavor = "unknown";
super.init();
}

@Override
Expand Down
Expand Up @@ -20,16 +20,9 @@
import diskCacheV111.util.CacheException;
import diskCacheV111.util.PermissionDeniedCacheException;

import dmg.util.Args;
import dmg.util.StreamEngine;
import dmg.util.command.Option;

import org.dcache.auth.LoginNamePrincipal;
import org.dcache.auth.Subjects;

//java net
//cells
//jgss
import org.dcache.cells.Option;

/**
*
Expand All @@ -49,22 +42,16 @@ public class KerberosFtpDoorV1 extends GssFtpDoorV1 {

private String[] _kdcList;

/** Creates a new instance of KerberosFtpDoorV1 */
public KerberosFtpDoorV1(String name, StreamEngine engine, Args args)
{
super(name,engine,args);
}

@Override
protected void init()
throws Exception
public void init()
{
super.init();
_gssFlavor = "k5";
ftpDoorName = "Kerberos FTP";
if (_kdcListOption != null) {
_kdcList = _kdcListOption.split(",");
}
super.init();
}

@Override
Expand Down

0 comments on commit 4395eca

Please sign in to comment.