use of org.dcache.pinmanager.model.Pin in project dcache by dCache.
the class JdbcDao method toPin.
private Pin toPin(JdbcUpdate update) {
Timestamp createdAt = (Timestamp) update.get("created_at");
Timestamp expiresAt = (Timestamp) update.get("expires_at");
return new Pin((long) update.get("id"), new PnfsId((String) update.get("pnfsid")), (String) update.get("request_id"), new Date(createdAt.getTime()), (expiresAt == null) ? null : new Date(expiresAt.getTime()), (long) update.get("uid"), (long) update.get("gid"), Pin.State.valueOf((String) update.get("state")), (String) update.get("pool"), (String) update.get("sticky"));
}
use of org.dcache.pinmanager.model.Pin 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.pinmanager.model.Pin in project dcache by dCache.
the class TestPoolManagerStub method update.
@Override
public int update(PinCriterion criterion, PinUpdate update) {
TestUpdate u = (TestUpdate) update;
int cnt = 0;
for (Map.Entry<Long, Pin> e : _pins.entrySet()) {
if (((TestCriterion) criterion).matches(e.getValue())) {
cnt++;
e.setValue(u.apply(e.getValue()));
}
}
return cnt;
}
use of org.dcache.pinmanager.model.Pin in project dcache by dCache.
the class TestPoolManagerStub method update.
@Override
public Pin update(UniquePinCriterion criterion, PinUpdate update) {
Pin pin = get(criterion);
if (pin == null) {
return null;
}
update((PinCriterion) criterion, update);
return ((TestUpdate) update).apply(pin);
}
use of org.dcache.pinmanager.model.Pin in project dcache by dCache.
the class TestPoolManagerStub method doChunkedForeach.
private void doChunkedForeach(PinCriterion criterion, InterruptibleConsumer<Pin> f, int limit) throws InterruptedException {
boolean limited = limit != NO_QUERY_LIMIT;
int counter = limit;
for (Pin pin : _pins.values()) {
if (limited && counter <= 0) {
break;
}
if (((TestCriterion) criterion).matches(pin)) {
f.accept(pin);
counter--;
}
}
}
Aggregations