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