Search in sources :

Example 1 with ReplicaStatusMessage

use of org.dcache.vehicles.qos.ReplicaStatusMessage 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 ReplicaStatusMessage

use of org.dcache.vehicles.qos.ReplicaStatusMessage in project dcache by dCache.

the class RepositoryReplicaVerifier method verifyLocations.

/**
 * Scatter-gather on pools to determine gather replica status.
 *
 * @param locations the putative replica locations
 * @return the messages as returned by the pools
 */
public static Collection<ReplicaStatusMessage> verifyLocations(PnfsId pnfsId, Collection<String> locations, CellStub stub) throws InterruptedException {
    SpreadAndWait<ReplicaStatusMessage> controller = new SpreadAndWait<>(stub);
    for (String pool : locations) {
        LOGGER.trace("Sending query to {} to verify replica.", pool);
        ReplicaStatusMessage request = new ReplicaStatusMessage(pool, pnfsId);
        controller.send(new CellPath(pool), ReplicaStatusMessage.class, request);
    }
    LOGGER.trace("Waiting for replies from {}.", locations);
    controller.waitForReplies();
    Collection<ReplicaStatusMessage> replies = controller.getReplies().values();
    LOGGER.trace("Got {} replies for {}; {} replicas exist.", replies, pnfsId, getExists(replies).size());
    return replies;
}
Also used : ReplicaStatusMessage(org.dcache.vehicles.qos.ReplicaStatusMessage) CellPath(dmg.cells.nucleus.CellPath) SpreadAndWait(diskCacheV111.util.SpreadAndWait)

Aggregations

ReplicaStatusMessage (org.dcache.vehicles.qos.ReplicaStatusMessage)2 FileNotInCacheException (diskCacheV111.util.FileNotInCacheException)1 PnfsId (diskCacheV111.util.PnfsId)1 SpreadAndWait (diskCacheV111.util.SpreadAndWait)1 Message (diskCacheV111.vehicles.Message)1 CellPath (dmg.cells.nucleus.CellPath)1 MessageReply (org.dcache.cells.MessageReply)1 CacheEntry (org.dcache.pool.repository.CacheEntry)1 StickyRecord (org.dcache.pool.repository.StickyRecord)1 ChangePreciousBitMessage (org.dcache.vehicles.qos.ChangePreciousBitMessage)1 ChangeStickyBitMessage (org.dcache.vehicles.qos.ChangeStickyBitMessage)1