Search in sources :

Example 1 with ReplicaState

use of org.dcache.pool.repository.ReplicaState in project dcache by dCache.

the class P2PClient method newCompanion.

public synchronized int newCompanion(String sourcePoolName, FileAttributes fileAttributes, ReplicaState targetState, List<StickyRecord> stickyRecords, CacheFileAvailable callback, boolean forceSourceMode, Long atime) throws IOException, CacheException, InterruptedException, IllegalStateException {
    if (getCellEndpoint() == null) {
        throw new IllegalStateException("Endpoint not initialized");
    }
    if (_pool == null) {
        throw new IllegalStateException("Pool stub not initialized");
    }
    if (_executor == null) {
        throw new IllegalStateException("Executor not initialized");
    }
    if (_repository == null) {
        throw new IllegalStateException("Repository not initialized");
    }
    if (_checksumModule == null) {
        throw new IllegalStateException("Checksum module not initialized");
    }
    if (_pnfs == null) {
        throw new IllegalStateException("PNFS stub not initialized");
    }
    ReplicaState state = _repository.getState(fileAttributes.getPnfsId());
    if (state != ReplicaState.NEW) {
        throw new IllegalStateException("Replica exists with state: " + state);
    }
    Callback cb = new Callback(callback);
    Companion companion = new Companion(_executor, _interface, _repository, _checksumModule, _pnfs, _pool, fileAttributes, sourcePoolName, getCellName(), getCellDomainName(), targetState, stickyRecords, cb, forceSourceMode, atime, getContextIfNeeded);
    int id = addCompanion(companion);
    cb.setId(id);
    return id;
}
Also used : ReplicaState(org.dcache.pool.repository.ReplicaState)

Example 2 with ReplicaState

use of org.dcache.pool.repository.ReplicaState in project dcache by dCache.

the class PoolV4 method messageArrived.

public DelayedReply messageArrived(Pool2PoolTransferMsg msg) throws CacheException, IOException, InterruptedException {
    if (_poolMode.isDisabled(PoolV2Mode.DISABLED_P2P_CLIENT)) {
        LOGGER.warn("Pool2PoolTransferMsg request rejected due to {}", _poolMode);
        throw new CacheException(CacheException.POOL_DISABLED, "Pool is disabled");
    }
    String poolName = msg.getPoolName();
    FileAttributes fileAttributes = msg.getFileAttributes();
    CompanionFileAvailableCallback callback = new CompanionFileAvailableCallback(msg);
    ReplicaState targetState = ReplicaState.CACHED;
    int fileMode = msg.getDestinationFileStatus();
    if (fileMode != Pool2PoolTransferMsg.UNDETERMINED) {
        if (fileMode == Pool2PoolTransferMsg.PRECIOUS) {
            targetState = ReplicaState.PRECIOUS;
        }
    } else if (!_hasTapeBackend && !_isVolatile && (_p2pFileMode == P2P_PRECIOUS)) {
        targetState = ReplicaState.PRECIOUS;
    }
    List<StickyRecord> stickyRecords = Collections.emptyList();
    _p2pClient.newCompanion(poolName, fileAttributes, targetState, stickyRecords, callback, false, null);
    return callback;
}
Also used : StickyRecord(org.dcache.pool.repository.StickyRecord) LockedCacheException(diskCacheV111.util.LockedCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) FileInCacheException(diskCacheV111.util.FileInCacheException) OutOfDateCacheException(diskCacheV111.util.OutOfDateCacheException) CacheException(diskCacheV111.util.CacheException) FileNotInCacheException(diskCacheV111.util.FileNotInCacheException) FileAttributes(org.dcache.vehicles.FileAttributes) ReplicaState(org.dcache.pool.repository.ReplicaState)

Example 3 with ReplicaState

use of org.dcache.pool.repository.ReplicaState in project dcache by dCache.

the class ReplicaRepository method loadRecord.

private PnfsId loadRecord(PnfsId id) throws CacheException, IllegalStateException, InterruptedException {
    ReplicaRecord entry = readReplicaRecord(id);
    if (entry != null) {
        ReplicaState state = entry.getState();
        LOGGER.debug("{} {}", id, state);
    }
    // Lazily check if repository was closed
    if (_state != State.LOADING) {
        throw new IllegalStateException("Repository was closed during loading.");
    }
    return id;
}
Also used : ReplicaRecord(org.dcache.pool.repository.ReplicaRecord) ReplicaState(org.dcache.pool.repository.ReplicaState)

Example 4 with ReplicaState

use of org.dcache.pool.repository.ReplicaState in project dcache by dCache.

the class CacheRepositoryEntryImpl method incrementLinkCount.

@Override
public synchronized int incrementLinkCount() {
    ReplicaState state = getState();
    if (state == REMOVED || state == DESTROYED) {
        throw new IllegalStateException("Entry is marked as removed");
    }
    _linkCount++;
    return _linkCount;
}
Also used : ReplicaState(org.dcache.pool.repository.ReplicaState)

Example 5 with ReplicaState

use of org.dcache.pool.repository.ReplicaState 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

ReplicaState (org.dcache.pool.repository.ReplicaState)8 StickyRecord (org.dcache.pool.repository.StickyRecord)4 FileNotInCacheException (diskCacheV111.util.FileNotInCacheException)3 CacheException (diskCacheV111.util.CacheException)2 FileInCacheException (diskCacheV111.util.FileInCacheException)2 ReplicaRecord (org.dcache.pool.repository.ReplicaRecord)2 FileAttributes (org.dcache.vehicles.FileAttributes)2 EnvironmentFailureException (com.sleepycat.je.EnvironmentFailureException)1 OperationFailureException (com.sleepycat.je.OperationFailureException)1 DiskErrorCacheException (diskCacheV111.util.DiskErrorCacheException)1 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)1 LockedCacheException (diskCacheV111.util.LockedCacheException)1 OutOfDateCacheException (diskCacheV111.util.OutOfDateCacheException)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 IOException (java.io.IOException)1 OptionalLong (java.util.OptionalLong)1