Search in sources :

Example 1 with CellAddressCore

use of dmg.cells.nucleus.CellAddressCore in project dcache by dCache.

the class TestPoolManagerStub method testExtendLifetime.

@Test
public void testExtendLifetime() throws Exception {
    TestDao dao = new TestDao();
    Pin pin = dao.create(dao.set().subject(Subjects.ROOT).requestId(REQUEST_ID1).expirationTime(new Date(now() + 30)).pnfsId(PNFS_ID1).pool(POOL1.getName()).sticky(STICKY1).state(PINNED));
    Pool pool = new Pool(POOL1.getName());
    pool.setActive(true);
    pool.setAddress(POOL1.getAddress());
    PoolMonitor poolMonitor = mock(PoolMonitor.class, RETURNS_DEEP_STUBS);
    when(poolMonitor.getPoolSelectionUnit().getPool(POOL1.getName())).thenReturn(pool);
    MovePinRequestProcessor processor = new MovePinRequestProcessor();
    processor.setDao(dao);
    processor.setPoolStub(new TestStub(new CellAddressCore("PinManager")) {

        public PoolSetStickyMessage messageArrived(PoolSetStickyMessage msg) {
            return msg;
        }
    });
    processor.setAuthorizationPolicy(new DefaultAuthorizationPolicy());
    processor.setMaxLifetime(-1);
    processor.setPoolMonitor(poolMonitor);
    Date expiration = new Date(now() + 60);
    PinManagerExtendPinMessage message = new PinManagerExtendPinMessage(getAttributes(PNFS_ID1), pin.getPinId(), 60);
    message = processor.messageArrived(message);
    assertEquals(0, message.getReturnCode());
    assertFalse(message.getExpirationTime().before(expiration));
    Pin newPin = dao.get(dao.where().id(pin.getPinId()));
    assertEquals(PNFS_ID1, newPin.getPnfsId());
    assertEquals(pin.getCreationTime(), newPin.getCreationTime());
    assertEquals(message.getExpirationTime(), newPin.getExpirationTime());
    assertEquals(pin.getUid(), newPin.getUid());
    assertEquals(pin.getGid(), newPin.getGid());
    assertEquals(pin.getRequestId(), newPin.getRequestId());
    assertEquals(pin.getPool(), newPin.getPool());
    assertEquals(pin.getState(), newPin.getState());
    assertValidSticky(newPin.getSticky());
}
Also used : CellAddressCore(dmg.cells.nucleus.CellAddressCore) Pin(org.dcache.pinmanager.model.Pin) SelectedPool(org.dcache.poolmanager.SelectedPool) Pool(diskCacheV111.poolManager.Pool) PoolMonitor(org.dcache.poolmanager.PoolMonitor) PoolSetStickyMessage(diskCacheV111.vehicles.PoolSetStickyMessage) Date(java.util.Date) Test(org.junit.Test)

Example 2 with CellAddressCore

use of dmg.cells.nucleus.CellAddressCore 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 3 with CellAddressCore

use of dmg.cells.nucleus.CellAddressCore in project dcache by dCache.

the class HsmRestoreTest method testRestoreNoLocations.

@Test
public void testRestoreNoLocations() 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("irrelevant"), null);
        envelope.addSourceAddress(new CellAddressCore(pool));
        PoolManagerPoolUpMessage poolUpMessage = new PoolManagerPoolUpMessage(pool, serialId, poolMode, poolCostInfo);
        prepareSelectionUnit(pool, poolMode, connectedHSM);
        _costModule.messageArrived(envelope, poolUpMessage);
    }
    final AtomicInteger stageRequests = new AtomicInteger(0);
    MessageAction messageAction = new StageMessageAction(stageRequests);
    _cell.registerAction("pool1", PoolFetchFileMessage.class, messageAction);
    _cell.registerAction("pool2", PoolFetchFileMessage.class, messageAction);
    PoolMgrSelectReadPoolMsg selectReadPool = new PoolMgrSelectReadPoolMsg(attributes, _protocolInfo, null);
    CellMessage cellMessage = new CellMessage(new CellAddressCore("PoolManager"), selectReadPool);
    _rc.messageArrived(cellMessage, selectReadPool);
    assertEquals("No stage request sent to pools", 1, stageRequests.get());
}
Also used : CellPath(dmg.cells.nucleus.CellPath) PoolMgrSelectReadPoolMsg(diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg) CellAddressCore(dmg.cells.nucleus.CellAddressCore) 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 CellAddressCore

use of dmg.cells.nucleus.CellAddressCore in project dcache by dCache.

the class PoolCostInfoHelper method setCost.

public static void setCost(CostModuleV1 cm, String pool, long total, long free, long precious, long removable) {
    PoolV2Mode poolMode = new PoolV2Mode(PoolV2Mode.ENABLED);
    long serialId = System.currentTimeMillis();
    PoolCostInfo poolCost = new PoolCostInfo(pool, IoQueueManager.DEFAULT_QUEUE);
    poolCost.setSpaceUsage(total, free, precious, removable);
    CellMessage envelope = new CellMessage(new CellAddressCore("PoolManager"), null);
    envelope.addSourceAddress(new CellAddressCore(pool));
    PoolManagerPoolUpMessage poolUpMessage = new PoolManagerPoolUpMessage(pool, serialId, poolMode, poolCost);
    cm.messageArrived(envelope, poolUpMessage);
}
Also used : CellMessage(dmg.cells.nucleus.CellMessage) CellAddressCore(dmg.cells.nucleus.CellAddressCore) PoolManagerPoolUpMessage(diskCacheV111.vehicles.PoolManagerPoolUpMessage) PoolV2Mode(diskCacheV111.pools.PoolV2Mode) PoolCostInfo(diskCacheV111.pools.PoolCostInfo)

Example 5 with CellAddressCore

use of dmg.cells.nucleus.CellAddressCore in project dcache by dCache.

the class PoolMonitorTest method prepareCostModule.

private void prepareCostModule(boolean linkPerPool) throws Exception {
    if (linkPerPool) {
        PoolMonitorHelper.prepareLinkPerPool(_selectionUnit, _access, _pools);
    } else {
        PoolMonitorHelper.prepareSelectionUnit(_selectionUnit, _access, _pools);
    }
    long serialId = System.currentTimeMillis();
    /*
         * make pools know to 'PoolManager'
         */
    PoolV2Mode poolMode = new PoolV2Mode(PoolV2Mode.ENABLED);
    PoolCostInfo poolCost1 = new PoolCostInfo("pool1", IoQueueManager.DEFAULT_QUEUE);
    PoolCostInfo poolCost2 = new PoolCostInfo("pool2", IoQueueManager.DEFAULT_QUEUE);
    poolCost1.setSpaceUsage(100, 20, 30, 50);
    poolCost2.setSpaceUsage(100, 20, 30, 50);
    PoolManagerPoolUpMessage pool1UpMessage = new PoolManagerPoolUpMessage("pool1", serialId, poolMode, poolCost1);
    PoolManagerPoolUpMessage pool2UpMessage = new PoolManagerPoolUpMessage("pool2", serialId, poolMode, poolCost2);
    pool1UpMessage.setHostName(_localhost);
    pool2UpMessage.setHostName(_localhost);
    CellMessage envelope1 = new CellMessage(new CellAddressCore("PoolManager"), null);
    envelope1.addSourceAddress(new CellAddressCore("pool1"));
    CellMessage envelope2 = new CellMessage(new CellAddressCore("PoolManager"), null);
    envelope2.addSourceAddress(new CellAddressCore("pool2"));
    _costModule.messageArrived(envelope1, pool1UpMessage);
    _costModule.messageArrived(envelope2, pool2UpMessage);
}
Also used : CellMessage(dmg.cells.nucleus.CellMessage) CellAddressCore(dmg.cells.nucleus.CellAddressCore) PoolManagerPoolUpMessage(diskCacheV111.vehicles.PoolManagerPoolUpMessage) PoolV2Mode(diskCacheV111.pools.PoolV2Mode) PoolCostInfo(diskCacheV111.pools.PoolCostInfo)

Aggregations

CellAddressCore (dmg.cells.nucleus.CellAddressCore)47 CellMessage (dmg.cells.nucleus.CellMessage)16 Test (org.junit.Test)15 CellPath (dmg.cells.nucleus.CellPath)12 PoolCostInfo (diskCacheV111.pools.PoolCostInfo)9 PoolV2Mode (diskCacheV111.pools.PoolV2Mode)8 HashSet (java.util.HashSet)7 PoolManagerPoolUpMessage (diskCacheV111.vehicles.PoolManagerPoolUpMessage)6 ArrayList (java.util.ArrayList)6 FileAttributes (org.dcache.vehicles.FileAttributes)6 PnfsId (diskCacheV111.util.PnfsId)5 PoolMgrSelectReadPoolMsg (diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg)5 CellEndpoint (dmg.cells.nucleus.CellEndpoint)5 CacheException (diskCacheV111.util.CacheException)4 Message (diskCacheV111.vehicles.Message)4 URI (java.net.URI)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 FileAttribute (org.dcache.namespace.FileAttribute)4 MessageAction (org.dcache.tests.cells.MockCellEndpoint.MessageAction)4 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)4