Search in sources :

Example 1 with SelectedPool

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);
    }
}
Also used : SelectedPool(org.dcache.poolmanager.SelectedPool) PoolSelector(org.dcache.poolmanager.PoolSelector) FileNotOnlineCacheException(diskCacheV111.util.FileNotOnlineCacheException)

Example 2 with SelectedPool

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());
}
Also used : PoolMgrSelectReadPoolMsg(diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg) CellAddressCore(dmg.cells.nucleus.CellAddressCore) SelectedPool(org.dcache.poolmanager.SelectedPool) PoolSetStickyMessage(diskCacheV111.vehicles.PoolSetStickyMessage) Date(java.util.Date) Pin(org.dcache.pinmanager.model.Pin) CheckStagePermission(diskCacheV111.util.CheckStagePermission) ProtocolInfo(diskCacheV111.vehicles.ProtocolInfo) DCapProtocolInfo(diskCacheV111.vehicles.DCapProtocolInfo) PoolInfo(org.dcache.poolmanager.PoolInfo) PoolMonitorV5(diskCacheV111.poolManager.PoolMonitorV5) FileAttributes(org.dcache.vehicles.FileAttributes) PoolCostInfo(diskCacheV111.pools.PoolCostInfo) PoolSelector(org.dcache.poolmanager.PoolSelector) Test(org.junit.Test)

Aggregations

PoolSelector (org.dcache.poolmanager.PoolSelector)2 SelectedPool (org.dcache.poolmanager.SelectedPool)2 PoolMonitorV5 (diskCacheV111.poolManager.PoolMonitorV5)1 PoolCostInfo (diskCacheV111.pools.PoolCostInfo)1 CheckStagePermission (diskCacheV111.util.CheckStagePermission)1 FileNotOnlineCacheException (diskCacheV111.util.FileNotOnlineCacheException)1 DCapProtocolInfo (diskCacheV111.vehicles.DCapProtocolInfo)1 PoolMgrSelectReadPoolMsg (diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg)1 PoolSetStickyMessage (diskCacheV111.vehicles.PoolSetStickyMessage)1 ProtocolInfo (diskCacheV111.vehicles.ProtocolInfo)1 CellAddressCore (dmg.cells.nucleus.CellAddressCore)1 Date (java.util.Date)1 Pin (org.dcache.pinmanager.model.Pin)1 PoolInfo (org.dcache.poolmanager.PoolInfo)1 FileAttributes (org.dcache.vehicles.FileAttributes)1 Test (org.junit.Test)1