Search in sources :

Example 1 with PoolMonitor

use of org.dcache.poolmanager.PoolMonitor in project dcache by dCache.

the class TestPoolManagerStub method testExtendLifetime.

@Test
public void testExtendLifetime() 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));
    Pool pool = new Pool(POOL1.getName());
    pool.setActive(true);
    pool.setAddress(POOL1.getAddress());
    PoolMonitor poolMonitor = mock(PoolMonitor.class, RETURNS_DEEP_STUBS);
    when(poolMonitor.getPoolSelectionUnit().getPool(POOL1.getName())).thenReturn(pool);
    MovePinRequestProcessor processor = new MovePinRequestProcessor();
    processor.setDao(dao);
    processor.setPoolStub(new TestStub(new CellAddressCore("PinManager")) {

        public PoolSetStickyMessage messageArrived(PoolSetStickyMessage msg) {
            return msg;
        }
    });
    processor.setAuthorizationPolicy(new DefaultAuthorizationPolicy());
    processor.setMaxLifetime(-1);
    processor.setPoolMonitor(poolMonitor);
    Date expiration = new Date(now() + 60);
    PinManagerExtendPinMessage message = new PinManagerExtendPinMessage(getAttributes(PNFS_ID1), pin.getPinId(), 60);
    message = processor.messageArrived(message);
    assertEquals(0, message.getReturnCode());
    assertFalse(message.getExpirationTime().before(expiration));
    Pin newPin = dao.get(dao.where().id(pin.getPinId()));
    assertEquals(PNFS_ID1, newPin.getPnfsId());
    assertEquals(pin.getCreationTime(), newPin.getCreationTime());
    assertEquals(message.getExpirationTime(), newPin.getExpirationTime());
    assertEquals(pin.getUid(), newPin.getUid());
    assertEquals(pin.getGid(), newPin.getGid());
    assertEquals(pin.getRequestId(), newPin.getRequestId());
    assertEquals(pin.getPool(), newPin.getPool());
    assertEquals(pin.getState(), newPin.getState());
    assertValidSticky(newPin.getSticky());
}
Also used : CellAddressCore(dmg.cells.nucleus.CellAddressCore) Pin(org.dcache.pinmanager.model.Pin) SelectedPool(org.dcache.poolmanager.SelectedPool) Pool(diskCacheV111.poolManager.Pool) PoolMonitor(org.dcache.poolmanager.PoolMonitor) PoolSetStickyMessage(diskCacheV111.vehicles.PoolSetStickyMessage) Date(java.util.Date) Test(org.junit.Test)

Example 2 with PoolMonitor

use of org.dcache.poolmanager.PoolMonitor in project dcache by dCache.

the class InstanceData method loadStorage.

private OptionalLong loadStorage() {
    PoolMonitor monitor;
    OptionalLong space = OptionalLong.empty();
    try {
        monitor = poolManagerStub.sendAndWait(new PoolManagerGetPoolMonitor(), 20000, CellEndpoint.SendFlag.RETRY_ON_NO_ROUTE_TO_CELL).getPoolMonitor();
        CostModule costModule = monitor.getCostModule();
        Collection<PoolCostInfo> costInfos = costModule.getPoolCostInfos();
        space = OptionalLong.of(costModule.getPoolCostInfos().stream().map(PoolCostInfo::getSpaceInfo).mapToLong(PoolCostInfo.PoolSpaceInfo::getTotalSpace).sum());
    } catch (CacheException | InterruptedException | NoRouteToCellException e) {
        LOGGER.error("Could not get storage information; set storage to -1.0. This was caused by: ", e);
    }
    return space;
}
Also used : CacheException(diskCacheV111.util.CacheException) CostModule(diskCacheV111.poolManager.CostModule) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) OptionalLong(java.util.OptionalLong) PoolMonitor(org.dcache.poolmanager.PoolMonitor) PoolManagerGetPoolMonitor(diskCacheV111.vehicles.PoolManagerGetPoolMonitor) PoolManagerGetPoolMonitor(diskCacheV111.vehicles.PoolManagerGetPoolMonitor) PoolCostInfo(diskCacheV111.pools.PoolCostInfo)

Aggregations

PoolMonitor (org.dcache.poolmanager.PoolMonitor)2 CostModule (diskCacheV111.poolManager.CostModule)1 Pool (diskCacheV111.poolManager.Pool)1 PoolCostInfo (diskCacheV111.pools.PoolCostInfo)1 CacheException (diskCacheV111.util.CacheException)1 PoolManagerGetPoolMonitor (diskCacheV111.vehicles.PoolManagerGetPoolMonitor)1 PoolSetStickyMessage (diskCacheV111.vehicles.PoolSetStickyMessage)1 CellAddressCore (dmg.cells.nucleus.CellAddressCore)1 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)1 Date (java.util.Date)1 OptionalLong (java.util.OptionalLong)1 Pin (org.dcache.pinmanager.model.Pin)1 SelectedPool (org.dcache.poolmanager.SelectedPool)1 Test (org.junit.Test)1