Search in sources :

Example 1 with PoolFetchFileMessage

use of diskCacheV111.vehicles.PoolFetchFileMessage in project dcache by dCache.

the class HsmRestoreTest method testRestoreNoLocationsOnePoolCantStage.

@Test
public void testRestoreNoLocationsOnePoolCantStage() throws Exception {
    PnfsId pnfsId = new PnfsId("000000000000000000000000000000000001");
    /*
         * pre-configure pool selection unit
         */
    List<String> pools = new ArrayList<>(3);
    pools.add("pool1");
    pools.add("pool2");
    PoolMonitorHelper.prepareSelectionUnit(_selectionUnit, _access, pools);
    /*
         * prepare reply for GetStorageInfo
         */
    _storageInfo.addLocation(new URI("osm://osm?"));
    _storageInfo.setIsNew(false);
    PnfsGetFileAttributes fileAttributesMessage = new PnfsGetFileAttributes(pnfsId, EnumSet.noneOf(FileAttribute.class));
    FileAttributes attributes = new FileAttributes();
    StorageInfos.injectInto(_storageInfo, attributes);
    attributes.setPnfsId(pnfsId);
    attributes.setLocations(Collections.<String>emptyList());
    attributes.setSize(5);
    attributes.setAccessLatency(StorageInfo.DEFAULT_ACCESS_LATENCY);
    attributes.setRetentionPolicy(StorageInfo.DEFAULT_RETENTION_POLICY);
    attributes.setChecksums(Collections.emptySet());
    fileAttributesMessage.setFileAttributes(attributes);
    _cell.prepareMessage(new CellPath("PnfsManager"), fileAttributesMessage, true);
    /*
         * make pools know to 'PoolManager'
         */
    long serialId = System.currentTimeMillis();
    PoolV2Mode poolMode = new PoolV2Mode(PoolV2Mode.ENABLED);
    Set<String> connectedHSM = new HashSet<>(1);
    connectedHSM.add("osm");
    for (String pool : pools) {
        PoolCostInfo poolCostInfo = new PoolCostInfo(pool, IoQueueManager.DEFAULT_QUEUE);
        poolCostInfo.setSpaceUsage(100, 20, 30, 50);
        poolCostInfo.setQueueSizes(0, 10, 0, 0, 10, 0);
        poolCostInfo.addExtendedMoverQueueSizes(IoQueueManager.DEFAULT_QUEUE, 0, 10, 0, 0, 0);
        CellMessage envelope = new CellMessage(new CellAddressCore("PoolManager"), null);
        envelope.addSourceAddress(new CellAddressCore(pool));
        PoolManagerPoolUpMessage poolUpMessage = new PoolManagerPoolUpMessage(pool, serialId, poolMode, poolCostInfo);
        prepareSelectionUnit(pool, poolMode, connectedHSM);
        _costModule.messageArrived(envelope, poolUpMessage);
    }
    final AtomicInteger stageRequests1 = new AtomicInteger(0);
    final AtomicInteger stageRequests2 = new AtomicInteger(0);
    final AtomicInteger replyRequest = new AtomicInteger(0);
    MessageAction messageAction1 = new StageMessageAction(stageRequests1);
    MessageAction messageAction2 = new StageMessageAction(stageRequests2);
    MessageAction messageAction3 = new StageMessageAction(replyRequest);
    _cell.registerAction("pool1", PoolFetchFileMessage.class, messageAction1);
    _cell.registerAction("pool2", PoolFetchFileMessage.class, messageAction2);
    _cell.registerAction("door", PoolMgrSelectReadPoolMsg.class, messageAction3);
    PoolMgrSelectReadPoolMsg selectReadPool = new PoolMgrSelectReadPoolMsg(attributes, _protocolInfo, null);
    CellMessage cellMessage = new CellMessage(new CellAddressCore("PoolManager"), selectReadPool);
    cellMessage.getSourcePath().add(new CellAddressCore("door", "local"));
    _rc.messageArrived(cellMessage, selectReadPool);
    // first pool replies with an error
    CellMessage m = __messages.remove(0);
    PoolFetchFileMessage ff = (PoolFetchFileMessage) m.getMessageObject();
    ff.setFailed(17, "pech");
    _rc.messageArrived(m, m.getMessageObject());
    // pool manager bounces request back to door
    m = __messages.remove(0);
    selectReadPool = (PoolMgrSelectReadPoolMsg) m.getMessageObject();
    assertEquals("Unexpected reply from pool manager", 17, selectReadPool.getReturnCode());
    // resubmit request
    PoolMgrSelectReadPoolMsg selectReadPool2 = new PoolMgrSelectReadPoolMsg(attributes, _protocolInfo, selectReadPool.getContext());
    CellMessage cellMessage2 = new CellMessage(new CellAddressCore("PoolManager"), selectReadPool2);
    _rc.messageArrived(cellMessage2, selectReadPool2);
    assertEquals("No stage request sent to pools1", 1, stageRequests1.get());
    assertEquals("No stage request sent to pools2", 1, stageRequests2.get());
}
Also used : CellPath(dmg.cells.nucleus.CellPath) PoolMgrSelectReadPoolMsg(diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg) CellAddressCore(dmg.cells.nucleus.CellAddressCore) PoolFetchFileMessage(diskCacheV111.vehicles.PoolFetchFileMessage) PnfsId(diskCacheV111.util.PnfsId) ArrayList(java.util.ArrayList) URI(java.net.URI) CellMessage(dmg.cells.nucleus.CellMessage) PoolManagerPoolUpMessage(diskCacheV111.vehicles.PoolManagerPoolUpMessage) PoolV2Mode(diskCacheV111.pools.PoolV2Mode) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MessageAction(org.dcache.tests.cells.MockCellEndpoint.MessageAction) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) FileAttributes(org.dcache.vehicles.FileAttributes) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) PoolCostInfo(diskCacheV111.pools.PoolCostInfo) FileAttribute(org.dcache.namespace.FileAttribute) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with PoolFetchFileMessage

use of diskCacheV111.vehicles.PoolFetchFileMessage in project dcache by dCache.

the class PoolV4 method messageArrived.

public Object messageArrived(PoolFetchFileMessage msg) throws CacheException {
    if (_poolMode.isDisabled(PoolV2Mode.DISABLED_STAGE)) {
        LOGGER.warn("PoolFetchFileMessage request rejected due to {}", _poolMode);
        throw new CacheException(CacheException.POOL_DISABLED, "Pool is disabled");
    }
    if (!_hasTapeBackend) {
        LOGGER.warn("PoolFetchFileMessage request rejected due to LFS mode");
        throw new CacheException(CacheException.POOL_DISABLED, "Pool has no tape backend");
    }
    FileAttributes fileAttributes = msg.getFileAttributes();
    String hsm = _hsmSet.getInstanceName(fileAttributes);
    LOGGER.info("Pool {} asked to fetch file {} (hsm={})", _poolName, fileAttributes.getPnfsId(), hsm);
    ReplyToPoolFetch reply = new ReplyToPoolFetch(msg);
    _storageHandler.stage(hsm, fileAttributes, reply);
    return reply;
}
Also used : LockedCacheException(diskCacheV111.util.LockedCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) FileInCacheException(diskCacheV111.util.FileInCacheException) OutOfDateCacheException(diskCacheV111.util.OutOfDateCacheException) CacheException(diskCacheV111.util.CacheException) FileNotInCacheException(diskCacheV111.util.FileNotInCacheException) FileAttributes(org.dcache.vehicles.FileAttributes)

Example 3 with PoolFetchFileMessage

use of diskCacheV111.vehicles.PoolFetchFileMessage in project dcache by dCache.

the class HsmRestoreTest method testRestoreNoLocationsAllPoolsCantStage.

@Test
public void testRestoreNoLocationsAllPoolsCantStage() throws Exception {
    PnfsId pnfsId = new PnfsId("000000000000000000000000000000000001");
    /*
         * pre-configure pool selection unit
         */
    List<String> pools = new ArrayList<>(3);
    pools.add("pool1");
    pools.add("pool2");
    PoolMonitorHelper.prepareSelectionUnit(_selectionUnit, _access, pools);
    /*
         * prepare reply for GetStorageInfo
         */
    _storageInfo.addLocation(new URI("osm://osm?"));
    _storageInfo.setIsNew(false);
    PnfsGetFileAttributes fileAttributesMessage = new PnfsGetFileAttributes(pnfsId, EnumSet.noneOf(FileAttribute.class));
    FileAttributes attributes = new FileAttributes();
    StorageInfos.injectInto(_storageInfo, attributes);
    attributes.setPnfsId(pnfsId);
    attributes.setLocations(Collections.<String>emptyList());
    attributes.setSize(5);
    attributes.setAccessLatency(StorageInfo.DEFAULT_ACCESS_LATENCY);
    attributes.setRetentionPolicy(StorageInfo.DEFAULT_RETENTION_POLICY);
    attributes.setChecksums(Collections.emptySet());
    fileAttributesMessage.setFileAttributes(attributes);
    _cell.prepareMessage(new CellPath("PnfsManager"), fileAttributesMessage, true);
    /*
         * make pools know to 'PoolManager'
         */
    long serialId = System.currentTimeMillis();
    PoolV2Mode poolMode = new PoolV2Mode(PoolV2Mode.ENABLED);
    Set<String> connectedHSM = new HashSet<>(1);
    connectedHSM.add("osm");
    for (String pool : pools) {
        PoolCostInfo poolCostInfo = new PoolCostInfo(pool, IoQueueManager.DEFAULT_QUEUE);
        poolCostInfo.setSpaceUsage(100, 20, 30, 50);
        poolCostInfo.setQueueSizes(0, 10, 0, 0, 10, 0);
        poolCostInfo.addExtendedMoverQueueSizes(IoQueueManager.DEFAULT_QUEUE, 0, 10, 0, 0, 0);
        CellMessage envelope = new CellMessage(new CellAddressCore("PoolManager"), null);
        envelope.addSourceAddress(new CellAddressCore(pool));
        PoolManagerPoolUpMessage poolUpMessage = new PoolManagerPoolUpMessage(pool, serialId, poolMode, poolCostInfo);
        prepareSelectionUnit(pool, poolMode, connectedHSM);
        _costModule.messageArrived(envelope, poolUpMessage);
    }
    final AtomicInteger stageRequests1 = new AtomicInteger(0);
    final AtomicInteger stageRequests2 = new AtomicInteger(0);
    final AtomicInteger replyRequest = new AtomicInteger(0);
    MessageAction messageAction1 = new StageMessageAction(stageRequests1);
    MessageAction messageAction2 = new StageMessageAction(stageRequests2);
    MessageAction messageAction3 = new StageMessageAction(replyRequest);
    _cell.registerAction("pool1", PoolFetchFileMessage.class, messageAction1);
    _cell.registerAction("pool2", PoolFetchFileMessage.class, messageAction2);
    _cell.registerAction("door", PoolMgrSelectReadPoolMsg.class, messageAction3);
    PoolMgrSelectReadPoolMsg selectReadPool = new PoolMgrSelectReadPoolMsg(attributes, _protocolInfo, null);
    CellMessage cellMessage = new CellMessage(new CellAddressCore("PoolManager"), selectReadPool);
    cellMessage.getSourcePath().add(new CellAddressCore("door", "local"));
    _rc.messageArrived(cellMessage, selectReadPool);
    // first pool replies with an error
    CellMessage m = __messages.remove(0);
    PoolFetchFileMessage ff = (PoolFetchFileMessage) m.getMessageObject();
    ff.setFailed(17, "pech");
    _rc.messageArrived(m, m.getMessageObject());
    // pool manager bounces request back to door
    m = __messages.remove(0);
    selectReadPool = (PoolMgrSelectReadPoolMsg) m.getMessageObject();
    assertEquals("Unexpected reply from pool manager", 17, selectReadPool.getReturnCode());
    // resubmit request
    PoolMgrSelectReadPoolMsg selectReadPool2 = new PoolMgrSelectReadPoolMsg(attributes, _protocolInfo, selectReadPool.getContext());
    CellMessage cellMessage2 = new CellMessage(new CellAddressCore("PoolManager"), selectReadPool2);
    cellMessage2.getSourcePath().add(new CellAddressCore("door", "local"));
    _rc.messageArrived(cellMessage2, selectReadPool2);
    // second pool replies with an error
    m = __messages.remove(0);
    ff = (PoolFetchFileMessage) m.getMessageObject();
    ff.setFailed(17, "pech");
    _rc.messageArrived(m, m.getMessageObject());
    // pool manager bounces request back to door
    m = __messages.remove(0);
    selectReadPool2 = (PoolMgrSelectReadPoolMsg) m.getMessageObject();
    assertEquals("Unexpected reply from pool manager", 17, selectReadPool.getReturnCode());
    // resubmit request
    PoolMgrSelectReadPoolMsg selectReadPool3 = new PoolMgrSelectReadPoolMsg(attributes, _protocolInfo, selectReadPool2.getContext());
    CellMessage cellMessage3 = new CellMessage(new CellAddressCore("PoolManager"), selectReadPool2);
    _rc.messageArrived(cellMessage3, selectReadPool3);
    assertEquals("Three stage requests where expected", 3, stageRequests1.get() + stageRequests2.get());
    assertTrue("No stage requests sent to pool1", stageRequests1.get() != 0);
    assertTrue("No stage requests sent to pool2", stageRequests2.get() != 0);
}
Also used : CellPath(dmg.cells.nucleus.CellPath) PoolMgrSelectReadPoolMsg(diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg) CellAddressCore(dmg.cells.nucleus.CellAddressCore) PoolFetchFileMessage(diskCacheV111.vehicles.PoolFetchFileMessage) PnfsId(diskCacheV111.util.PnfsId) ArrayList(java.util.ArrayList) URI(java.net.URI) CellMessage(dmg.cells.nucleus.CellMessage) PoolManagerPoolUpMessage(diskCacheV111.vehicles.PoolManagerPoolUpMessage) PoolV2Mode(diskCacheV111.pools.PoolV2Mode) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MessageAction(org.dcache.tests.cells.MockCellEndpoint.MessageAction) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) FileAttributes(org.dcache.vehicles.FileAttributes) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) PoolCostInfo(diskCacheV111.pools.PoolCostInfo) FileAttribute(org.dcache.namespace.FileAttribute) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with PoolFetchFileMessage

use of diskCacheV111.vehicles.PoolFetchFileMessage in project dcache by dCache.

the class HsmRestoreTest method testRestoreNoLocationsSinglePool.

@Test
public void testRestoreNoLocationsSinglePool() throws Exception {
    PnfsId pnfsId = new PnfsId("000000000000000000000000000000000001");
    /*
         * pre-configure pool selection unit
         */
    List<String> pools = new ArrayList<>(3);
    pools.add("pool1");
    PoolMonitorHelper.prepareSelectionUnit(_selectionUnit, _access, pools);
    /*
         * prepare reply for GetStorageInfo
         */
    _storageInfo.addLocation(new URI("osm://osm?"));
    _storageInfo.setIsNew(false);
    PnfsGetFileAttributes fileAttributesMessage = new PnfsGetFileAttributes(pnfsId, EnumSet.noneOf(FileAttribute.class));
    FileAttributes attributes = new FileAttributes();
    StorageInfos.injectInto(_storageInfo, attributes);
    attributes.setPnfsId(pnfsId);
    attributes.setLocations(Collections.<String>emptyList());
    attributes.setSize(5);
    attributes.setAccessLatency(StorageInfo.DEFAULT_ACCESS_LATENCY);
    attributes.setRetentionPolicy(StorageInfo.DEFAULT_RETENTION_POLICY);
    attributes.setChecksums(Collections.emptySet());
    fileAttributesMessage.setFileAttributes(attributes);
    _cell.prepareMessage(new CellPath("PnfsManager"), fileAttributesMessage, true);
    /*
         * make pools know to 'PoolManager'
         */
    long serialId = System.currentTimeMillis();
    PoolV2Mode poolMode = new PoolV2Mode(PoolV2Mode.ENABLED);
    Set<String> connectedHSM = new HashSet<>(1);
    connectedHSM.add("osm");
    for (String pool : pools) {
        PoolCostInfo poolCostInfo = new PoolCostInfo(pool, IoQueueManager.DEFAULT_QUEUE);
        poolCostInfo.setSpaceUsage(100, 20, 30, 50);
        poolCostInfo.setQueueSizes(0, 10, 0, 0, 10, 0);
        poolCostInfo.addExtendedMoverQueueSizes(IoQueueManager.DEFAULT_QUEUE, 0, 10, 0, 0, 0);
        CellMessage envelope = new CellMessage(new CellAddressCore("PoolManager"), null);
        envelope.addSourceAddress(new CellAddressCore(pool));
        PoolManagerPoolUpMessage poolUpMessage = new PoolManagerPoolUpMessage(pool, serialId, poolMode, poolCostInfo);
        prepareSelectionUnit(pool, poolMode, connectedHSM);
        _costModule.messageArrived(envelope, poolUpMessage);
    }
    final AtomicInteger stageRequests1 = new AtomicInteger(0);
    final AtomicInteger replyRequest = new AtomicInteger(0);
    MessageAction messageAction1 = new StageMessageAction(stageRequests1);
    MessageAction messageAction2 = new StageMessageAction(replyRequest);
    _cell.registerAction("pool1", PoolFetchFileMessage.class, messageAction1);
    _cell.registerAction("door", PoolMgrSelectReadPoolMsg.class, messageAction2);
    PoolMgrSelectReadPoolMsg selectReadPool = new PoolMgrSelectReadPoolMsg(attributes, _protocolInfo, null);
    CellMessage cellMessage = new CellMessage(new CellAddressCore("PoolManager"), selectReadPool);
    cellMessage.getSourcePath().add(new CellAddressCore("door", "local"));
    _rc.messageArrived(cellMessage, selectReadPool);
    // pool replies with an error
    CellMessage m = __messages.remove(0);
    PoolFetchFileMessage ff = (PoolFetchFileMessage) m.getMessageObject();
    ff.setFailed(17, "pech");
    _rc.messageArrived(m, m.getMessageObject());
    // pool manager bounces request back to door
    m = __messages.remove(0);
    selectReadPool = (PoolMgrSelectReadPoolMsg) m.getMessageObject();
    assertEquals("Unexpected reply from pool manager", 17, selectReadPool.getReturnCode());
    // resubmit request
    PoolMgrSelectReadPoolMsg selectReadPool2 = new PoolMgrSelectReadPoolMsg(attributes, _protocolInfo, selectReadPool.getContext());
    CellMessage cellMessage2 = new CellMessage(new CellAddressCore("PoolManager"), selectReadPool2);
    _rc.messageArrived(cellMessage2, selectReadPool2);
    assertEquals("Single Pool excluded on second shot", 2, stageRequests1.get());
}
Also used : CellPath(dmg.cells.nucleus.CellPath) PoolMgrSelectReadPoolMsg(diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg) CellAddressCore(dmg.cells.nucleus.CellAddressCore) PoolFetchFileMessage(diskCacheV111.vehicles.PoolFetchFileMessage) PnfsId(diskCacheV111.util.PnfsId) ArrayList(java.util.ArrayList) URI(java.net.URI) CellMessage(dmg.cells.nucleus.CellMessage) PoolManagerPoolUpMessage(diskCacheV111.vehicles.PoolManagerPoolUpMessage) PoolV2Mode(diskCacheV111.pools.PoolV2Mode) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MessageAction(org.dcache.tests.cells.MockCellEndpoint.MessageAction) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) FileAttributes(org.dcache.vehicles.FileAttributes) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) PoolCostInfo(diskCacheV111.pools.PoolCostInfo) FileAttribute(org.dcache.namespace.FileAttribute) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

FileAttributes (org.dcache.vehicles.FileAttributes)4 PoolCostInfo (diskCacheV111.pools.PoolCostInfo)3 PoolV2Mode (diskCacheV111.pools.PoolV2Mode)3 PnfsId (diskCacheV111.util.PnfsId)3 PoolFetchFileMessage (diskCacheV111.vehicles.PoolFetchFileMessage)3 PoolManagerPoolUpMessage (diskCacheV111.vehicles.PoolManagerPoolUpMessage)3 PoolMgrSelectReadPoolMsg (diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg)3 CellAddressCore (dmg.cells.nucleus.CellAddressCore)3 CellMessage (dmg.cells.nucleus.CellMessage)3 CellPath (dmg.cells.nucleus.CellPath)3 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 FileAttribute (org.dcache.namespace.FileAttribute)3 MessageAction (org.dcache.tests.cells.MockCellEndpoint.MessageAction)3 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)3 Test (org.junit.Test)3 CacheException (diskCacheV111.util.CacheException)1 FileInCacheException (diskCacheV111.util.FileInCacheException)1