pool: Fix race condition in migration module

Addresses an IllegalStateException in migration module.

The following exception can occur:

java.lang.IllegalStateException: Unexpected source pool list: Exactly one item was expected, but it contained 0
        at org.dcache.pool.migration.PoolListFilter.getSource(PoolListFilter.java:116) ~[dcache-core-2.6.17.jar:2.6.17]
        at org.dcache.pool.migration.PoolListFilter.evaluate(PoolListFilter.java:126) ~[dcache-core-2.6.17.jar:2.6.17]
        at org.dcache.pool.migration.PoolListFilter.isExcluded(PoolListFilter.java:101) ~[dcache-core-2.6.17.jar:2.6.17]
        at org.dcache.pool.migration.PoolListFilter.getPools(PoolListFilter.java:76) ~[dcache-core-2.6.17.jar:2.6.17]
        at org.dcache.pool.migration.Task.getPools(Task.java:195) ~[dcache-core-2.6.17.jar:2.6.17]
        at org.dcache.pool.migration.Task.setLocations(Task.java:266) ~[dcache-core-2.6.17.jar:2.6.17]
        at org.dcache.pool.migration.Task.access$000(Task.java:38) ~[dcache-core-2.6.17.jar:2.6.17]
        at org.dcache.pool.migration.Task$1.success(Task.java:253) ~[dcache-core-2.6.17.jar:2.6.17]
        at org.dcache.pool.migration.Task$1.success(Task.java:249) ~[dcache-core-2.6.17.jar:2.6.17]
        at org.dcache.cells.AbstractMessageCallback.success(AbstractMessageCallback.java:31) ~[dcache-core-2.6.17.jar:2.6.17]
        at org.dcache.cells.CellStub$CellCallback.answerArrived(CellStub.java:416) ~[dcache-core-2.6.17.jar:2.6.17]
        at dmg.cells.nucleus.CellNucleus$CallbackTask.innerRun(CellNucleus.java:983) ~[cells-2.6.17.jar:2.6.17]
        at dmg.cells.nucleus.CellNucleus$AbstractNucleusTask.run(CellNucleus.java:941) ~[cells-2.6.17.jar:2.6.17]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_17]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_17]
        at java.lang.Thread.run(Thread.java:722) [na:1.7.0_17]

The problem occurs if migration module queries information about itself
from pool manager before pool manager has registered that information.
In that case a valid, but empty, reply from pool manager is received
and a pre-condition check in the migration module fails.

Target: trunk
Request: 2.7
Request: 2.6
Request: 2.2
Require-notes: yes
Require-book: no
Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Acked-by: Paul Millar <paul.millar@desy.de>
Patch: http://rb.dcache.org/r/6283/
ftp: Add LoginCellProvider for FTP

Adding a dedicating FTP provider for LoginCellFactory
allows the shared executor to be bound to the lifetime
of the LoginManager.

Target: trunk
Require-notes: no
Require-book: no
Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Patch: http://rb.dcache.org/r/6310/
ftp: Fix deadlock introduced in recent refactoring

Recent changes to the FTP door introduced a deadlock:

"pool-116-thread-7":
        at org.dcache.ftp.door.AbstractFtpDoorV1.setTransfer(AbstractFtpDoorV1.java:2380)
        - waiting to lock <0x00000007c5eade98> (a org.dcache.ftp.door.GsiFtpDoorV1)
        at org.dcache.ftp.door.AbstractFtpDoorV1$FtpTransfer.transferCompleted(AbstractFtpDoorV1.java:1022)
        - locked <0x00000007c5eb3860> (a org.dcache.ftp.door.AbstractFtpDoorV1$FtpTransfer)
        at org.dcache.ftp.door.AbstractFtpDoorV1$FtpTransfer.finished(AbstractFtpDoorV1.java:972)
        at org.dcache.util.Transfer.finished(Transfer.java:464)
        - locked <0x00000007c5eb3860> (a org.dcache.ftp.door.AbstractFtpDoorV1$FtpTransfer)
        at org.dcache.ftp.door.AbstractFtpDoorV1.messageArrived(AbstractFtpDoorV1.java:1444)
        at sun.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.dcache.cells.CellMessageDispatcher$ShortReceiver.deliver(CellMessageDispatcher.java:289)
        at org.dcache.cells.CellMessageDispatcher.call(CellMessageDispatcher.java:202)
        at org.dcache.cells.AbstractCell.messageArrived(AbstractCell.java:859)
        at dmg.cells.nucleus.CellAdapter.messageArrived(CellAdapter.java:981)
        at dmg.cells.nucleus.CellNucleus$DeliverMessageTask.innerRun(CellNucleus.java:1037)
        at dmg.cells.nucleus.CellNucleus$AbstractNucleusTask.run(CellNucleus.java:946)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)
"Thread-160":
        at org.dcache.ftp.door.AbstractFtpDoorV1$FtpTransfer.abort(AbstractFtpDoorV1.java:1060)
        - waiting to lock <0x00000007c5eb3860> (a org.dcache.ftp.door.AbstractFtpDoorV1$FtpTransfer)
        at org.dcache.ftp.door.AbstractFtpDoorV1$FtpTransfer.abort(AbstractFtpDoorV1.java:1036)
        at org.dcache.ftp.door.AbstractFtpDoorV1.shutdown(AbstractFtpDoorV1.java:1363)
        - locked <0x00000007c5eade98> (a org.dcache.ftp.door.GsiFtpDoorV1)
        at diskCacheV111.doors.LineBasedDoor$CommandQueue.stop(LineBasedDoor.java:343)
        - locked <0x00000007c5ed1290> (a diskCacheV111.doors.LineBasedDoor$CommandQueue)
        at diskCacheV111.doors.LineBasedDoor.run(LineBasedDoor.java:176)
        at java.lang.Thread.run(Thread.java:744)

This deadlock is caused by unnecessary synchronization in the shutdown
method. This synchronization did not exist in the old code.

The patch also adds an accessor for the transfer field, thus solving
potential race conditions.

Target: trunk
Require-notes: no
Require-book: no
Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Patch: http://rb.dcache.org/r/6318/
ftp: Fix race that lead to erroneous error message in log file

Removes the following error message:

05 dec 2013 14:35:34 (httpd) [door:httpd@dCacheDomain:1386250529077 door:httpd@dCacheDomain:1386250530581 door:httpd@dCacheDomain:1386250530980 door:httpd@dCacheDomain:13
86250531049 door:httpd@dCacheDomain:1386250531677 door:httpd@dCacheDomain:1386250531744 door:httpd@dCacheDomain:1386250533468 door:httpd@dCacheDomain:1386250533660 door:h
ttpd@dCacheDomain:1386250534760] Cannot abort transfer that already completed: 451 Aborting transfer due to session termination

This error is a result of a race in which door shutdown and
the transfer termination sequence conincide. The patch
rearranges the termination sequence to mark the transfer
as completed before providing the final reply to the client.
The patch also removes the error logging.

Target: trunk
Require-notes: no
Require-book: no
Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Patch: http://rb.dcache.org/r/6320/
ftp: Fix race conditions caused by message reordering

Since DoorTransferFinished and GftpTransferStarted take different
routes, it is possible for these messages to be delivered out of
order. As a result the FTP door produces a 226 reply earlier than
is allowed.

This patch introduces an abstract base class for asynchronous
redirected transfers. That class deals with out of order
notifications. As a side effect, a small pause during transfer
abortion has been removed.

The patch also replaces several 426 replies with 451. 451 is for
internal errors while 426 is for client initiated transfer
abort.

Target: trunk
Require-notes: yes
Require-book: no
Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Patch: http://rb.dcache.org/r/6322/
commons: use long to store updates count of a gauge

to prevent integer overflow

Ticket: #8158
Acked-by: Gerd Behrmann
Target: master
Require-book: no
Require-notes: no