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