Search in sources :

Example 1 with CellPath

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

the class NfsTransferService method notifyDoorWithRedirect.

public void notifyDoorWithRedirect(NfsMover mover) {
    CellPath directDoorPath = new CellPath(mover.getPathToDoor().getDestinationAddress());
    final org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateId = mover.getProtocolInfo().stateId();
    _door.notify(directDoorPath, new PoolPassiveIoFileMessage<>(_cellAddress.getCellName(), _localSocketAddresses, legacyStateId, _bootVerifier));
}
Also used : CellPath(dmg.cells.nucleus.CellPath)

Example 2 with CellPath

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

the class Task method selectPool.

/**
 * Returns a pool from the pool list using the pool selection strategy.
 */
private CellPath selectPool() throws NoSuchElementException {
    List<PoolManagerPoolInformation> pools = _parameters.poolList.getPools().stream().filter(pool -> !_replicas.contains(pool.getName())).collect(toList());
    PoolManagerPoolInformation pool = _parameters.selectionStrategy.select(pools);
    if (pool == null) {
        if (pools.isEmpty()) {
            throw new NoSuchElementException("No pools available.");
        }
        throw new NoSuchElementException("All target pools are full.");
    }
    return new CellPath(pool.getName());
}
Also used : PinManagerMovePinMessage(org.dcache.services.pinmanager1.PinManagerMovePinMessage) ScheduledFuture(java.util.concurrent.ScheduledFuture) ReflectionUtils(org.dcache.util.ReflectionUtils) PoolManagerPoolInformation(diskCacheV111.vehicles.PoolManagerPoolInformation) Deque(java.util.Deque) Message(diskCacheV111.vehicles.Message) HashSet(java.util.HashSet) StickyRecord(org.dcache.pool.repository.StickyRecord) Collectors.toCollection(java.util.stream.Collectors.toCollection) CellStub(org.dcache.cells.CellStub) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AbstractMessageCallback(org.dcache.cells.AbstractMessageCallback) ReplicaState(org.dcache.pool.repository.ReplicaState) NoSuchElementException(java.util.NoSuchElementException) Method(java.lang.reflect.Method) PrintWriter(java.io.PrintWriter) FileAttributes(org.dcache.vehicles.FileAttributes) PnfsId(diskCacheV111.util.PnfsId) FireAndForgetTask(org.dcache.util.FireAndForgetTask) TransitionUndefinedException(statemap.TransitionUndefinedException) Collection(java.util.Collection) Set(java.util.Set) UUID(java.util.UUID) PnfsGetCacheLocationsMessage(diskCacheV111.vehicles.PnfsGetCacheLocationsMessage) Preconditions.checkState(com.google.common.base.Preconditions.checkState) InvocationTargetException(java.lang.reflect.InvocationTargetException) TimeUnit(java.util.concurrent.TimeUnit) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Stream(java.util.stream.Stream) Optional(java.util.Optional) FileAttribute(org.dcache.namespace.FileAttribute) CellPath(dmg.cells.nucleus.CellPath) ArrayDeque(java.util.ArrayDeque) CellPath(dmg.cells.nucleus.CellPath) PoolManagerPoolInformation(diskCacheV111.vehicles.PoolManagerPoolInformation) NoSuchElementException(java.util.NoSuchElementException)

Example 3 with CellPath

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

the class XrootdDoor method messageArrived.

/**
 * Requests to start movers are processed synchronously by the Transfer class. This message
 * handler will only ever receive replies for those requests for which the Transfer class timed
 * out or interrupted.
 * <p>
 * To avoid that orphaned movers fill a transfer slot on the pool, we kill it right away.
 */
public void messageArrived(PoolIoFileMessage message) {
    if (message.getReturnCode() == 0) {
        String pool = message.getPoolName();
        _poolStub.notify(new CellPath(pool), new PoolMoverKillMessage(pool, message.getMoverId(), "door timed out before pool"));
    }
}
Also used : CellPath(dmg.cells.nucleus.CellPath) PoolMoverKillMessage(diskCacheV111.vehicles.PoolMoverKillMessage)

Example 4 with CellPath

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

the class FileOperationHandler method handleStaging.

/**
 * <p>Called when there are no available replicas, but the file
 * can be retrieved from an HSM.</p>
 *
 * <p>Issues a fire and forget request.  Task is considered complete at
 * that point.</p>
 *
 * <p>When staging actually completes on the PoolManager end, the new
 * cache location message should be processed by Resilience as a new FileOperation.</p>
 *
 * <p>Should staging not complete before the pool is once again scanned,
 * PoolManager should collapse the repeated staging request.</p>
 */
public void handleStaging(PnfsId pnfsId, ResilientFileTask task) {
    try {
        FileOperation operation = fileOpMap.getOperation(pnfsId);
        FileAttributes attributes = namespace.getRequiredAttributesForStaging(pnfsId);
        String poolGroup = poolInfoMap.getGroup(operation.getPoolGroup());
        LOGGER.trace("handleStaging {}, pool group {}.", pnfsId, poolGroup);
        migrationTaskService.schedule(() -> {
            try {
                PoolMgrSelectReadPoolMsg msg = new PoolMgrSelectReadPoolMsg(attributes, getProtocolInfo(), null);
                msg.setSubject(Subjects.ROOT);
                msg.setPoolGroup(poolGroup);
                CellMessage cellMessage = new CellMessage(new CellPath(poolManagerAddress), msg);
                ACTIVITY_LOGGER.info("Staging {}", pnfsId);
                endpoint.sendMessage(cellMessage);
                LOGGER.trace("handleStaging, sent select read pool message " + "for {} to poolManager.", pnfsId);
                completionHandler.taskCompleted(pnfsId);
            } catch (URISyntaxException e) {
                completionHandler.taskFailed(pnfsId, CacheExceptionUtils.getCacheException(CacheException.INVALID_ARGS, "could not construct HTTP protocol: %s.", pnfsId, Type.WAIT_FOR_STAGE, e.getMessage(), null));
            }
        }, 0, TimeUnit.MILLISECONDS);
    } catch (CacheException ce) {
        completionHandler.taskFailed(pnfsId, ce);
    }
}
Also used : PoolMgrSelectReadPoolMsg(diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg) CellMessage(dmg.cells.nucleus.CellMessage) CellPath(dmg.cells.nucleus.CellPath) CacheException(diskCacheV111.util.CacheException) FileOperation(org.dcache.resilience.data.FileOperation) URISyntaxException(java.net.URISyntaxException) FileAttributes(org.dcache.vehicles.FileAttributes)

Example 5 with CellPath

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

the class FileOperationHandler method handleStagingReply.

/**
 * <p>If the reply from the Pool Manager indicates that the file has
 * been staged to a pool outside the pool group, resend the message with refreshed attributes to
 * trigger a p2p by the Pool Manager to a readable resilient pool in the correct group.
 * Otherwise, discard the message.</p>
 */
public void handleStagingReply(PoolMgrSelectReadPoolMsg reply) {
    PnfsId pnfsId = reply.getPnfsId();
    try {
        if (reply.getReturnCode() == CacheException.OUT_OF_DATE) {
            FileAttributes attributes = namespace.getRequiredAttributesForStaging(pnfsId);
            /*
                 *  Check to see if one of the new locations is not resilient.
                 */
            Collection<String> locations = attributes.getLocations();
            List<String> valid = poolInfoMap.getReadableLocations(locations).stream().filter(poolInfoMap::isResilientPool).collect(Collectors.toList());
            LOGGER.trace("{}, handleStagingReply, readable resilience " + "locations are now {}.", valid);
            if (valid.size() == 0) {
                LOGGER.trace("{}, handleStagingReply, " + "PoolManager staged to" + " a non-resilient pool, " + "requesting p2p.", pnfsId);
                /*
                     *  Figure out on which pool group this should be.
                     *
                     *  It's possible that the file was "resilient" when the
                     *  stage request was sent and a subsequently configuration
                     *  change has resulted in the file no longer being
                     *  "resilient".  If this happens, the file may have no
                     *  corresponding resilient pool group.
                     *
                     *  Another possibility is the lack of resilient pool group
                     *  is due to a bug somewhere.
                     */
                Integer gIndex = null;
                for (String loc : locations) {
                    Integer pIndex = poolInfoMap.getPoolIndex(loc);
                    gIndex = poolInfoMap.getResilientPoolGroup(pIndex);
                    if (gIndex != null) {
                        break;
                    }
                }
                if (gIndex == null) {
                    LOGGER.warn("{}, handleStagingReply, file no longer" + " hosted on resilient pool group", pnfsId);
                    return;
                }
                final String poolGroup = poolInfoMap.getGroup(gIndex);
                LOGGER.trace("{}, handleStagingReply, resilient pool group " + "for p2p request: {}.", pnfsId, poolGroup);
                migrationTaskService.schedule(() -> {
                    PoolMgrSelectReadPoolMsg msg = new PoolMgrSelectReadPoolMsg(attributes, reply.getProtocolInfo(), reply.getContext(), reply.getAllowedStates());
                    msg.setSubject(reply.getSubject());
                    msg.setPoolGroup(poolGroup);
                    CellMessage cellMessage = new CellMessage(new CellPath(poolManagerAddress), msg);
                    ACTIVITY_LOGGER.info("Selecting read pool for file {}" + " staged to a non-resilient pool", pnfsId);
                    endpoint.sendMessage(cellMessage);
                    LOGGER.trace("handleStagingReply, resent select read pool " + "message for {} to poolManager.", pnfsId);
                }, 0, TimeUnit.MILLISECONDS);
                return;
            }
        }
        LOGGER.trace("{} handleStagingReply {}, nothing to do.", pnfsId, reply);
    } catch (CacheException ce) {
        LOGGER.error("handleStagingReply failed: {}.", ce.toString());
    }
}
Also used : PoolMgrSelectReadPoolMsg(diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg) CellMessage(dmg.cells.nucleus.CellMessage) CellPath(dmg.cells.nucleus.CellPath) CacheException(diskCacheV111.util.CacheException) PnfsId(diskCacheV111.util.PnfsId) FileAttributes(org.dcache.vehicles.FileAttributes)

Aggregations

CellPath (dmg.cells.nucleus.CellPath)77 CacheException (diskCacheV111.util.CacheException)20 CellMessage (dmg.cells.nucleus.CellMessage)19 CellAddressCore (dmg.cells.nucleus.CellAddressCore)15 PnfsId (diskCacheV111.util.PnfsId)14 FileAttributes (org.dcache.vehicles.FileAttributes)14 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)12 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)9 CellStub (org.dcache.cells.CellStub)9 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)9 HashSet (java.util.HashSet)8 ExecutionException (java.util.concurrent.ExecutionException)8 FileAttribute (org.dcache.namespace.FileAttribute)8 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)7 PoolMoverKillMessage (diskCacheV111.vehicles.PoolMoverKillMessage)7 Map (java.util.Map)7 PoolMgrSelectReadPoolMsg (diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg)6 IOException (java.io.IOException)6 PoolV2Mode (diskCacheV111.pools.PoolV2Mode)5