Search in sources :

Example 16 with Pin

use of org.dcache.pinmanager.model.Pin in project dcache by dCache.

the class TestPoolManagerStub method testUnpinningByRequestId.

@Test
public void testUnpinningByRequestId() throws Exception {
    TestDao dao = new TestDao();
    Pin pin = dao.create(dao.set().subject(Subjects.ROOT).requestId(REQUEST_ID1).expirationTime(new Date(now() + 30)).pnfsId(PNFS_ID1).pool(POOL1.getName()).sticky(STICKY1).state(PINNED));
    UnpinRequestProcessor processor = new UnpinRequestProcessor();
    processor.setDao(dao);
    processor.setAuthorizationPolicy(new DefaultAuthorizationPolicy());
    PinManagerUnpinMessage message = new PinManagerUnpinMessage(PNFS_ID1);
    message.setRequestId(pin.getRequestId());
    message = processor.messageArrived(message);
    assertEquals(0, message.getReturnCode());
    assertEquals(pin.getPinId(), (long) message.getPinId());
    assertEquals(pin.getRequestId(), message.getRequestId());
    Pin newPin = dao.get(dao.where().id(pin.getPinId()));
    assertEquals(PNFS_ID1, newPin.getPnfsId());
    assertEquals(pin.getPool(), newPin.getPool());
    assertEquals(READY_TO_UNPIN, newPin.getState());
    assertEquals(pin.getSticky(), newPin.getSticky());
}
Also used : Pin(org.dcache.pinmanager.model.Pin) Date(java.util.Date) Test(org.junit.Test)

Example 17 with Pin

use of org.dcache.pinmanager.model.Pin in project dcache by dCache.

the class TestPoolManagerStub method delete.

@Override
public int delete(PinCriterion criterion) {
    int cnt = 0;
    Iterator<Pin> iterator = _pins.values().iterator();
    while (iterator.hasNext()) {
        Pin pin = iterator.next();
        if (((TestCriterion) criterion).matches(pin)) {
            iterator.remove();
            cnt++;
        }
    }
    return cnt;
}
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