Search in sources :

Example 1 with Pin

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"));
}
Also used : Pin(org.dcache.pinmanager.model.Pin) PnfsId(diskCacheV111.util.PnfsId) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Example 2 with Pin

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;
}
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 3 with Pin

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;
}
Also used : Pin(org.dcache.pinmanager.model.Pin) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) CellEndpoint(dmg.cells.nucleus.CellEndpoint)

Example 4 with Pin

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);
}
Also used : Pin(org.dcache.pinmanager.model.Pin)

Example 5 with 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--;
        }
    }
}
Also used : Pin(org.dcache.pinmanager.model.Pin) CellEndpoint(dmg.cells.nucleus.CellEndpoint)

Aggregations

Pin (org.dcache.pinmanager.model.Pin)17 Date (java.util.Date)7 CacheException (diskCacheV111.util.CacheException)4 PnfsId (diskCacheV111.util.PnfsId)4 Test (org.junit.Test)4 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)3 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)3 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)3 CellEndpoint (dmg.cells.nucleus.CellEndpoint)3 PoolSetStickyMessage (diskCacheV111.vehicles.PoolSetStickyMessage)2 CellAddressCore (dmg.cells.nucleus.CellAddressCore)2 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)2 Timestamp (java.sql.Timestamp)2 SelectedPool (org.dcache.poolmanager.SelectedPool)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Pool (diskCacheV111.poolManager.Pool)1 PoolMonitorV5 (diskCacheV111.poolManager.PoolMonitorV5)1 PoolCostInfo (diskCacheV111.pools.PoolCostInfo)1 CheckStagePermission (diskCacheV111.util.CheckStagePermission)1