use of org.dcache.poolmanager.SelectedPool in project dcache by dCache.
the class PinRequestProcessor method selectReadPool.
private void selectReadPool(final PinTask task) throws CacheException {
try {
PoolSelector poolSelector = _poolMonitor.getPoolSelector(task.getFileAttributes(), task.getProtocolInfo(), null, Collections.EMPTY_SET);
SelectedPool pool = poolSelector.selectPinPool();
setPool(task, pool.name());
setStickyFlag(task, pool.name(), pool.address());
} catch (FileNotOnlineCacheException e) {
askPoolManager(task);
}
}
use of org.dcache.poolmanager.SelectedPool in project dcache by dCache.
the class TestPoolManagerStub method testPinning.
@Test
public void testPinning() throws Exception {
TestDao dao = new TestDao();
PinRequestProcessor processor = new PinRequestProcessor();
processor.setScheduledExecutor(new TestExecutor());
processor.setExecutor(MoreExecutors.directExecutor());
processor.setDao(dao);
processor.setPoolStub(new TestStub(new CellAddressCore("PinManager")) {
public PoolSetStickyMessage messageArrived(PoolSetStickyMessage msg) {
return msg;
}
});
processor.setPoolManagerStub(new TestPoolManagerStub(new CellAddressCore("PinManager")) {
public PoolMgrSelectReadPoolMsg messageArrived(PoolMgrSelectReadPoolMsg msg) {
msg.setPool(POOL1);
return msg;
}
});
processor.setMaxLifetime(-1);
processor.setStagePermission(new CheckStagePermission(null));
processor.setPoolMonitor(new PoolMonitorV5() {
@Override
public PoolSelector getPoolSelector(FileAttributes fileAttributes, ProtocolInfo protocolInfo, String linkGroup, Set<String> excludes) {
return new PoolMonitorV5.PnfsFileLocation(fileAttributes, protocolInfo, linkGroup, excludes) {
@Override
public SelectedPool selectPinPool() {
return new SelectedPool(new PoolInfo(POOL1.getAddress(), new PoolCostInfo(POOL1.getName(), IoQueueManager.DEFAULT_QUEUE), ImmutableMap.of()));
}
};
}
});
Date expiration = new Date(now() + 30);
PinManagerPinMessage message = new PinManagerPinMessage(getAttributes(PNFS_ID1), PROTOCOL_INFO, REQUEST_ID1, 30);
Date start = new Date();
message = processor.messageArrived(message).get();
Date stop = new Date();
assertEquals(0, message.getReturnCode());
assertFalse(message.getExpirationTime().before(expiration));
Pin pin = dao.get(dao.where().id(message.getPinId()));
assertEquals(PNFS_ID1, pin.getPnfsId());
assertBetween(start, stop, pin.getCreationTime());
assertEquals(message.getExpirationTime(), pin.getExpirationTime());
assertEquals(0, pin.getUid());
assertEquals(0, pin.getGid());
assertEquals(REQUEST_ID1, pin.getRequestId());
assertEquals(POOL1.getName(), pin.getPool());
assertEquals(PINNED, pin.getState());
assertValidSticky(pin.getSticky());
}
Aggregations