Search in sources :

Example 1 with PoolMonitorV5

use of diskCacheV111.poolManager.PoolMonitorV5 in project dcache by dCache.

the class PoolMonitorBuilder method build.

public PoolMonitorV5 build() {
    PoolMonitorV5 monitor = mock(PoolMonitorV5.class);
    BDDMockito.given(monitor.getPoolSelector(any(), any(), any(), any())).willReturn(requireNonNull(selector));
    return monitor;
}
Also used : PoolMonitorV5(diskCacheV111.poolManager.PoolMonitorV5)

Example 2 with PoolMonitorV5

use of diskCacheV111.poolManager.PoolMonitorV5 in project dcache by dCache.

the class HsmRestoreTest method setUp.

@Before
public void setUp() throws Exception {
    _counter = _counter + 1;
    _cell = new MockCellEndpoint("HsmRestoreTest" + _counter);
    _protocolInfo = new DCapProtocolInfo("DCap", 3, 0, new InetSocketAddress("127.0.0.1", 17));
    _storageInfo = new OSMStorageInfo("h1", "rawd");
    _partitionManager = new PartitionManager();
    PoolSelectionUnitV2 psu = new PoolSelectionUnitV2();
    _access = psu;
    _selectionUnit = psu;
    _costModule = new CostModuleV1();
    _pnfsHandler = new PnfsHandler(new CellPath("PnfsManager"));
    _pnfsHandler.setCellEndpoint(_cell);
    _poolMonitor = new PoolMonitorV5();
    _poolMonitor.setPoolSelectionUnit(_selectionUnit);
    _poolMonitor.setCostModule(_costModule);
    _poolMonitor.setPartitionManager(_partitionManager);
    /*
         * allow stage
         */
    _partitionManager.setProperties(null, ImmutableMap.of("stage-allowed", "yes"));
    _rc = new RequestContainerV5(RETRY_INTERVAL);
    _rc.setPoolSelectionUnit(_selectionUnit);
    _rc.setPnfsHandler(_pnfsHandler);
    _rc.setPoolMonitor(_poolMonitor);
    _rc.setPartitionManager(_partitionManager);
    _rc.setExecutor(MoreExecutors.directExecutor());
    _rc.setCellEndpoint(_cell);
    _rc.ac_rc_set_retry_$_1(new Args("0"));
    _rc.setStageConfigurationFile(null);
    _rc.setPnfsHandler(_pnfsHandler);
    _rc.start();
    __messages = new ArrayList<>();
}
Also used : CellPath(dmg.cells.nucleus.CellPath) MockCellEndpoint(org.dcache.tests.cells.MockCellEndpoint) Args(org.dcache.util.Args) PartitionManager(org.dcache.poolmanager.PartitionManager) InetSocketAddress(java.net.InetSocketAddress) PoolSelectionUnitV2(diskCacheV111.poolManager.PoolSelectionUnitV2) CostModuleV1(diskCacheV111.poolManager.CostModuleV1) PnfsHandler(diskCacheV111.util.PnfsHandler) OSMStorageInfo(diskCacheV111.vehicles.OSMStorageInfo) DCapProtocolInfo(diskCacheV111.vehicles.DCapProtocolInfo) PoolMonitorV5(diskCacheV111.poolManager.PoolMonitorV5) RequestContainerV5(diskCacheV111.poolManager.RequestContainerV5) Before(org.junit.Before)

Example 3 with PoolMonitorV5

use of diskCacheV111.poolManager.PoolMonitorV5 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)

Example 4 with PoolMonitorV5

use of diskCacheV111.poolManager.PoolMonitorV5 in project dcache by dCache.

the class DcacheResourceFactory method list.

/**
 * Performs a directory listing, writing an HTML view to an output stream.
 */
public void list(FsPath path, Writer out) throws InterruptedException, CacheException, IOException {
    if (!_isAnonymousListingAllowed && Subjects.isNobody(getSubject())) {
        throw new PermissionDeniedCacheException("Access denied");
    }
    final ST t = _template.getInstanceOf(HTML_TEMPLATE_LISTING_NAME);
    if (t == null) {
        out.append(DcacheHtmlResponseHandler.templateNotFoundErrorPage(_template.getPath(), HTML_TEMPLATE_LISTING_NAME));
        return;
    }
    addTemplateAttributes(t);
    DirectoryListPrinter printer = new DirectoryListPrinter() {

        @Override
        public Set<FileAttribute> getRequiredAttributes() {
            return EnumSet.copyOf(Sets.union(PoolMonitorV5.getRequiredAttributesForFileLocality(), EnumSet.of(MODIFICATION_TIME, TYPE, SIZE)));
        }

        private FileAttributes entryAttributes(FsPath dir, DirectoryEntry entry) {
            FileAttributes attr = entry.getFileAttributes();
            switch(attr.getFileType()) {
                case LINK:
                    String entryPath = dir.child(entry.getName()).toString();
                    try {
                        return _pnfs.getFileAttributes(entryPath, getRequiredAttributes());
                    } catch (CacheException e) {
                        LOGGER.debug("Symlink lookup of {} failed with {}", entryPath, e.getMessage());
                        return attr;
                    }
                default:
                    return attr;
            }
        }

        @Override
        public void print(FsPath dir, FileAttributes dirAttr, DirectoryEntry entry) {
            FileAttributes attr = entryAttributes(dir, entry);
            Date mtime = new Date(attr.getModificationTime());
            UrlPathWrapper name = UrlPathWrapper.forPath(entry.getName());
            /* FIXME: SIZE is defined if client specifies the
                       * file's size before uploading.
                       */
            boolean isUploading = !attr.isDefined(SIZE);
            FileLocality locality = _poolMonitor.getFileLocality(attr, getRemoteAddr());
            t.addAggr("files.{name,isDirectory,showGhosted,mtime,size,isUploading,locality}", name, attr.getFileType() == DIR, attr.getFileType() == LINK, mtime, attr.getSizeIfPresent().map(SizeWrapper::new).orElse(null), isUploading, new FileLocalityWrapper(locality));
        }
    };
    _list.printDirectory(getSubject(), getRestriction(), printer, path, null, Range.<Integer>all());
    t.write(new AutoIndentWriter(out));
}
Also used : ST(org.stringtemplate.v4.ST) DirectoryListPrinter(org.dcache.util.list.DirectoryListPrinter) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) DirectoryEntry(org.dcache.util.list.DirectoryEntry) Date(java.util.Date) AutoIndentWriter(org.stringtemplate.v4.AutoIndentWriter) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileAttributes(org.dcache.vehicles.FileAttributes) FileLocality(diskCacheV111.util.FileLocality) FileAttribute(org.dcache.namespace.FileAttribute) FsPath(diskCacheV111.util.FsPath)

Example 5 with PoolMonitorV5

use of diskCacheV111.poolManager.PoolMonitorV5 in project dcache by dCache.

the class PoolMonitorTest method setUp.

@Before
public void setUp() throws Exception {
    PoolSelectionUnitV2 psu = new PoolSelectionUnitV2();
    _access = psu;
    _selectionUnit = psu;
    _costModule = new CostModuleV1();
    _poolMonitor = new PoolMonitorV5();
    _poolMonitor.setPoolSelectionUnit(_selectionUnit);
    _poolMonitor.setCostModule(_costModule);
    _poolMonitor.setPartitionManager(_partitionManager);
    _pnfsId = new PnfsId("000000000000000000000000000000000001");
    _pools = Arrays.asList("pool1", "pool2");
    _localhost = InetAddress.getLocalHost().getCanonicalHostName();
}
Also used : PoolSelectionUnitV2(diskCacheV111.poolManager.PoolSelectionUnitV2) PnfsId(diskCacheV111.util.PnfsId) CostModuleV1(diskCacheV111.poolManager.CostModuleV1) PoolMonitorV5(diskCacheV111.poolManager.PoolMonitorV5) Before(org.junit.Before)

Aggregations

PoolMonitorV5 (diskCacheV111.poolManager.PoolMonitorV5)4 FileAttributes (org.dcache.vehicles.FileAttributes)3 CostModuleV1 (diskCacheV111.poolManager.CostModuleV1)2 PoolSelectionUnitV2 (diskCacheV111.poolManager.PoolSelectionUnitV2)2 CacheException (diskCacheV111.util.CacheException)2 FileLocality (diskCacheV111.util.FileLocality)2 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)2 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)2 PnfsHandler (diskCacheV111.util.PnfsHandler)2 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)2 DCapProtocolInfo (diskCacheV111.vehicles.DCapProtocolInfo)2 Date (java.util.Date)2 FileAttribute (org.dcache.namespace.FileAttribute)2 Before (org.junit.Before)2 RequestContainerV5 (diskCacheV111.poolManager.RequestContainerV5)1 PoolCostInfo (diskCacheV111.pools.PoolCostInfo)1 GetFileSpaceTokensMessage (diskCacheV111.services.space.message.GetFileSpaceTokensMessage)1 CheckStagePermission (diskCacheV111.util.CheckStagePermission)1 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)1 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)1