Search in sources :

Example 1 with MoverFactory

use of org.dcache.pool.movers.MoverFactory in project dcache by dCache.

the class PoolV4 method createMover.

// //////////////////////////////////////////////////////////////
// 
// The io File Part
// 
// 
public Mover<?> createMover(CellMessage envelop, PoolIoFileMessage message) throws CacheException {
    CellPath source = envelop.getSourcePath().revert();
    FileAttributes attributes = message.getFileAttributes();
    PnfsId pnfsId = attributes.getPnfsId();
    ProtocolInfo pi = message.getProtocolInfo();
    MoverFactory moverFactory = _transferServices.getMoverFactory(pi);
    ReplicaDescriptor handle;
    try {
        if (message instanceof PoolAcceptFileMessage) {
            OptionalLong maximumSize = ((PoolAcceptFileMessage) message).getMaximumSize();
            List<StickyRecord> stickyRecords = _replicaStatePolicy.getStickyRecords(attributes);
            ReplicaState targetState = _replicaStatePolicy.getTargetState(attributes);
            handle = _repository.createEntry(attributes, ReplicaState.FROM_CLIENT, targetState, stickyRecords, moverFactory.getChannelCreateOptions(), maximumSize);
        } else {
            Set<? extends OpenOption> openFlags = message.isPool2Pool() ? EnumSet.of(Repository.OpenFlags.NOATIME) : EnumSet.noneOf(Repository.OpenFlags.class);
            handle = _repository.openEntry(pnfsId, openFlags);
        }
    } catch (FileNotInCacheException e) {
        throw new FileNotInCacheException("File " + pnfsId + " does not exist in " + _poolName, e);
    } catch (FileInCacheException e) {
        throw new FileInCacheException("File " + pnfsId + " already exists in " + _poolName, e);
    }
    try {
        return moverFactory.createMover(handle, message, source);
    } catch (Throwable t) {
        handle.close();
        throw t;
    }
}
Also used : CellPath(dmg.cells.nucleus.CellPath) PnfsId(diskCacheV111.util.PnfsId) ReplicaState(org.dcache.pool.repository.ReplicaState) StickyRecord(org.dcache.pool.repository.StickyRecord) MoverFactory(org.dcache.pool.movers.MoverFactory) ReplicaDescriptor(org.dcache.pool.repository.ReplicaDescriptor) FileInCacheException(diskCacheV111.util.FileInCacheException) ProtocolInfo(diskCacheV111.vehicles.ProtocolInfo) DCapProtocolInfo(diskCacheV111.vehicles.DCapProtocolInfo) OptionalLong(java.util.OptionalLong) PoolAcceptFileMessage(diskCacheV111.vehicles.PoolAcceptFileMessage) FileAttributes(org.dcache.vehicles.FileAttributes) FileNotInCacheException(diskCacheV111.util.FileNotInCacheException)

Aggregations

FileInCacheException (diskCacheV111.util.FileInCacheException)1 FileNotInCacheException (diskCacheV111.util.FileNotInCacheException)1 PnfsId (diskCacheV111.util.PnfsId)1 DCapProtocolInfo (diskCacheV111.vehicles.DCapProtocolInfo)1 PoolAcceptFileMessage (diskCacheV111.vehicles.PoolAcceptFileMessage)1 ProtocolInfo (diskCacheV111.vehicles.ProtocolInfo)1 CellPath (dmg.cells.nucleus.CellPath)1 OptionalLong (java.util.OptionalLong)1 MoverFactory (org.dcache.pool.movers.MoverFactory)1 ReplicaDescriptor (org.dcache.pool.repository.ReplicaDescriptor)1 ReplicaState (org.dcache.pool.repository.ReplicaState)1 StickyRecord (org.dcache.pool.repository.StickyRecord)1 FileAttributes (org.dcache.vehicles.FileAttributes)1