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