Search in sources :

Example 1 with StickyRecord

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

the class QoSMessageHandler method messageArrived.

/**
 * Returns whether replica exists, the status of its system sticky flag and whether its state
 * allows for reading and removal.
 */
public Reply messageArrived(ReplicaStatusMessage message) {
    MessageReply<Message> reply = new MessageReply<>();
    executor.execute(() -> {
        PnfsId pnfsId = message.getPnfsId();
        try {
            CacheEntry entry = repository.getEntry(pnfsId);
            message.setExists(true);
            switch(entry.getState()) {
                case FROM_CLIENT:
                case FROM_POOL:
                case FROM_STORE:
                    message.setWaiting(true);
                    break;
                case CACHED:
                    message.setReadable(true);
                    message.setRemovable(true);
                    break;
                case BROKEN:
                    message.setBroken(true);
                    message.setRemovable(true);
                    break;
                case PRECIOUS:
                    message.setReadable(true);
                    message.setPrecious(true);
                    break;
                default:
                    break;
            }
            Collection<StickyRecord> records = entry.getStickyRecords();
            for (StickyRecord record : records) {
                if (record.owner().equals(SYSTEM_OWNER) && record.isNonExpiring()) {
                    message.setSystemSticky(true);
                    break;
                }
            }
            reply.reply(message);
        } catch (FileNotInCacheException e) {
            reply.reply(message);
        } catch (Exception e) {
            reply.fail(message, e);
        }
    });
    return reply;
}
Also used : StickyRecord(org.dcache.pool.repository.StickyRecord) ChangePreciousBitMessage(org.dcache.vehicles.qos.ChangePreciousBitMessage) Message(diskCacheV111.vehicles.Message) ChangeStickyBitMessage(org.dcache.vehicles.qos.ChangeStickyBitMessage) ReplicaStatusMessage(org.dcache.vehicles.qos.ReplicaStatusMessage) MessageReply(org.dcache.cells.MessageReply) PnfsId(diskCacheV111.util.PnfsId) CacheEntry(org.dcache.pool.repository.CacheEntry) FileNotInCacheException(diskCacheV111.util.FileNotInCacheException) FileNotInCacheException(diskCacheV111.util.FileNotInCacheException)

Example 2 with StickyRecord

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

the class Job method getTargetStickyRecords.

private List<StickyRecord> getTargetStickyRecords(CacheEntry entry) {
    List<StickyRecord> result = new ArrayList<>();
    if (_definition.targetMode.state == CacheEntryMode.State.SAME) {
        for (StickyRecord record : entry.getStickyRecords()) {
            if (!isPin(record)) {
                result.add(record);
            }
        }
    }
    result.addAll(_definition.targetMode.stickyRecords);
    return result;
}
Also used : StickyRecord(org.dcache.pool.repository.StickyRecord) ArrayList(java.util.ArrayList)

Example 3 with StickyRecord

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

the class ResilienceMessageHandler method messageArrived.

/**
 * <p>Returns whether replica exists, the status of its system sticky flag
 * and whether its state allows for reading and removal.</p>
 */
public Reply messageArrived(ReplicaStatusMessage message) {
    MessageReply<Message> reply = new MessageReply<>();
    executor.execute(() -> {
        PnfsId pnfsId = message.getPnfsId();
        if (pnfsId == null) {
            reply.fail(message, new IllegalArgumentException("no pnfsid"));
            return;
        }
        try {
            CacheEntry entry = repository.getEntry(pnfsId);
            message.setExists(true);
            switch(entry.getState()) {
                case FROM_CLIENT:
                case FROM_POOL:
                case FROM_STORE:
                    message.setWaiting(true);
                    break;
                case CACHED:
                    message.setReadable(true);
                    message.setRemovable(true);
                    break;
                case BROKEN:
                    message.setBroken(true);
                    message.setRemovable(true);
                    break;
                case PRECIOUS:
                    message.setReadable(true);
                    break;
                default:
                    break;
            }
            Collection<StickyRecord> records = entry.getStickyRecords();
            for (StickyRecord record : records) {
                if (record.owner().equals(SYSTEM_OWNER) && record.isNonExpiring()) {
                    message.setSystemSticky(true);
                    break;
                }
            }
            reply.reply(message);
        } catch (FileNotInCacheException e) {
            reply.reply(message);
        } catch (Exception e) {
            reply.fail(message, e);
        }
    });
    return reply;
}
Also used : StickyRecord(org.dcache.pool.repository.StickyRecord) RemoveReplicaMessage(org.dcache.vehicles.resilience.RemoveReplicaMessage) ReplicaStatusMessage(org.dcache.vehicles.resilience.ReplicaStatusMessage) Message(diskCacheV111.vehicles.Message) ForceSystemStickyBitMessage(org.dcache.vehicles.resilience.ForceSystemStickyBitMessage) MessageReply(org.dcache.cells.MessageReply) PnfsId(diskCacheV111.util.PnfsId) CacheEntry(org.dcache.pool.repository.CacheEntry) FileNotInCacheException(diskCacheV111.util.FileNotInCacheException) FileNotInCacheException(diskCacheV111.util.FileNotInCacheException)

Example 4 with StickyRecord

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

the class MovePinRequestProcessor method messageArrived.

public PinManagerMovePinMessage messageArrived(PinManagerMovePinMessage message) throws CacheException, InterruptedException {
    try {
        PnfsId pnfsId = message.getPnfsId();
        String source = message.getSourcePool();
        String target = message.getTargetPool();
        Collection<Pin> pins = _dao.get(_dao.where().pnfsId(pnfsId).pool(source));
        /* Remove all stale sticky flags.
             */
        for (StickyRecord record : message.getRecords()) {
            if (!containsPin(pins, record.owner())) {
                setSticky(source, pnfsId, false, record.owner(), 0);
            }
        }
        /* Move all pins to the target pool.
             */
        for (Pin pin : pins) {
            Pin tmpPin = move(pin, target, pin.getExpirationTime());
            setSticky(tmpPin.getPool(), tmpPin.getPnfsId(), false, tmpPin.getSticky(), 0);
            _dao.delete(tmpPin);
        }
        LOGGER.info("Moved pins for {} from {} to {}", pnfsId, source, target);
    } catch (NoRouteToCellException e) {
        throw new CacheException("Failed to move pin due to communication failure: " + e.getDestinationPath(), e);
    }
    return message;
}
Also used : StickyRecord(org.dcache.pool.repository.StickyRecord) Pin(org.dcache.pinmanager.model.Pin) CacheException(diskCacheV111.util.CacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) PnfsId(diskCacheV111.util.PnfsId) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException)

Example 5 with StickyRecord

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

Aggregations

StickyRecord (org.dcache.pool.repository.StickyRecord)17 CacheException (diskCacheV111.util.CacheException)6 FileNotInCacheException (diskCacheV111.util.FileNotInCacheException)6 PnfsId (diskCacheV111.util.PnfsId)6 ReplicaState (org.dcache.pool.repository.ReplicaState)4 FileInCacheException (diskCacheV111.util.FileInCacheException)3 CacheEntry (org.dcache.pool.repository.CacheEntry)3 ReplicaDescriptor (org.dcache.pool.repository.ReplicaDescriptor)3 DiskErrorCacheException (diskCacheV111.util.DiskErrorCacheException)2 LockedCacheException (diskCacheV111.util.LockedCacheException)2 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)2 Message (diskCacheV111.vehicles.Message)2 CellPath (dmg.cells.nucleus.CellPath)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 MessageReply (org.dcache.cells.MessageReply)2 OpenFlags (org.dcache.pool.repository.Repository.OpenFlags)2 CellStubHelper (org.dcache.tests.cells.CellStubHelper)2 FileAttributes (org.dcache.vehicles.FileAttributes)2 PnfsSetFileAttributes (org.dcache.vehicles.PnfsSetFileAttributes)2