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;
}
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;
}
Aggregations