Search in sources :

Example 1 with PoolMgrSelectPoolMsg

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

the class TransferManagerHandler method selectPool.

public void selectPool() {
    protocol_info = manager.getProtocolInfo(transferRequest);
    PoolMgrSelectPoolMsg request = store ? new PoolMgrSelectWritePoolMsg(fileAttributes, protocol_info) : new PoolMgrSelectReadPoolMsg(fileAttributes, protocol_info, _readPoolSelectionContext);
    request.setBillingPath(pnfsPath);
    request.setSubject(transferRequest.getSubject());
    LOGGER.debug("PoolMgrSelectPoolMsg: {}", request);
    setState(WAITING_FOR_POOL_INFO_STATE);
    manager.persist(this);
    CellStub.addCallback(manager.getPoolManagerStub().sendAsync(request), this, executor);
}
Also used : PoolMgrSelectReadPoolMsg(diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg) PoolMgrSelectPoolMsg(diskCacheV111.vehicles.PoolMgrSelectPoolMsg) PoolMgrSelectWritePoolMsg(diskCacheV111.vehicles.PoolMgrSelectWritePoolMsg)

Example 2 with PoolMgrSelectPoolMsg

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

the class Transfer method selectPoolAsync.

/**
 * Selects a pool suitable for the transfer.
 */
public ListenableFuture<Void> selectPoolAsync(long timeout) {
    if (getPool() != null) {
        // we have a valid preselected pool. Let use it as long as clearPoolSelection is not called.
        return immediateFuture(null);
    }
    FileAttributes fileAttributes = getFileAttributes();
    ProtocolInfo protocolInfo = getProtocolInfoForPoolManager();
    ListenableFuture<? extends PoolMgrSelectPoolMsg> reply;
    if (isWrite()) {
        long allocated = _allocated;
        if (allocated == 0 && fileAttributes.isDefined(SIZE)) {
            allocated = fileAttributes.getSize();
        }
        PoolMgrSelectWritePoolMsg request = new PoolMgrSelectWritePoolMsg(fileAttributes, protocolInfo, allocated);
        request.setId(_id);
        request.setSubject(_subject);
        request.setBillingPath(getBillingPath());
        request.setTransferPath(getTransferPath());
        request.setIoQueueName(getIoQueue());
        request.setExcludedHosts(_tried);
        reply = _poolManager.sendAsync(request, timeout);
    } else {
        EnumSet<RequestState> allowedStates = getAllowedRequestStates();
        try {
            if (allowedStates.contains(RequestState.ST_STAGE) && !_checkStagePermission.canPerformStaging(_subject, fileAttributes, protocolInfo)) {
                allowedStates.remove(RequestState.ST_STAGE);
            }
        } catch (IOException e) {
            return immediateFailedFuture(new CacheException(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e.getMessage()));
        }
        PoolMgrSelectReadPoolMsg request = new PoolMgrSelectReadPoolMsg(fileAttributes, protocolInfo, getReadPoolSelectionContext(), allowedStates);
        request.setId(_id);
        request.setSubject(_subject);
        request.setBillingPath(getBillingPath());
        request.setTransferPath(getTransferPath());
        request.setIoQueueName(getIoQueue());
        request.setExcludedHosts(_tried);
        reply = Futures.transform(_poolManager.sendAsync(request, timeout), (PoolMgrSelectReadPoolMsg msg) -> {
            setReadPoolSelectionContext(msg.getContext());
            return msg;
        });
    }
    setStatusUntil("PoolManager: Selecting pool", reply);
    return CellStub.transform(reply, (PoolMgrSelectPoolMsg msg) -> {
        setPool(msg.getPool());
        setFileAttributes(msg.getFileAttributes());
        return null;
    });
}
Also used : PoolMgrSelectReadPoolMsg(diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg) RequestState(diskCacheV111.poolManager.RequestContainerV5.RequestState) PoolMgrSelectPoolMsg(diskCacheV111.vehicles.PoolMgrSelectPoolMsg) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotFileCacheException(diskCacheV111.util.NotFileCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) PoolMgrSelectWritePoolMsg(diskCacheV111.vehicles.PoolMgrSelectWritePoolMsg) ProtocolInfo(diskCacheV111.vehicles.ProtocolInfo) IOException(java.io.IOException) FileAttributes(org.dcache.vehicles.FileAttributes) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes)

Example 3 with PoolMgrSelectPoolMsg

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

the class TransferManagerHandler method success.

@Override
public void success(Message message) {
    try {
        if (message instanceof PnfsCreateEntryMessage) {
            PnfsCreateEntryMessage create_msg = (PnfsCreateEntryMessage) message;
            if (state == WAITING_FOR_PNFS_ENTRY_CREATION_INFO_STATE) {
                setState(RECEIVED_PNFS_ENTRY_CREATION_INFO_STATE);
                createEntryResponseArrived(create_msg);
                return;
            }
            LOGGER.error(this.toString() + " got unexpected PnfsCreateEntryMessage " + " : " + create_msg + " ; Ignoring");
        } else if (message instanceof PnfsGetFileAttributes) {
            PnfsGetFileAttributes attributesMessage = (PnfsGetFileAttributes) message;
            if (state == WAITING_FOR_PNFS_INFO_STATE) {
                setState(RECEIVED_PNFS_INFO_STATE);
                FileAttributes attributes = attributesMessage.getFileAttributes();
                if (!attributes.isDefined(SIZE)) {
                    sendErrorReply(CacheException.FILE_IS_NEW, new FileIsNewCacheException());
                    return;
                }
                storageInfoArrived(attributesMessage.getPnfsId(), attributes);
                return;
            } else if (state == WAITING_FOR_PNFS_CHECK_BEFORE_DELETE_STATE) {
                state = RECEIVED_PNFS_CHECK_BEFORE_DELETE_STATE;
                deletePnfsEntry();
                return;
            } else if (state == WAITING_FOR_CREATED_FILE_INFO_STATE) {
                state = RECEIVED_CREATED_FILE_INFO_STATE;
                getFileAttributesArrived(attributesMessage.getFileAttributes());
                return;
            }
            LOGGER.error(this.toString() + " got unexpected PnfsGetStorageInfoMessage " + " : " + attributesMessage + " ; Ignoring");
        } else if (message instanceof PoolMgrSelectPoolMsg) {
            PoolMgrSelectPoolMsg select_pool_msg = (PoolMgrSelectPoolMsg) message;
            if (state == WAITING_FOR_POOL_INFO_STATE) {
                setState(RECEIVED_POOL_INFO_STATE);
                poolInfoArrived(select_pool_msg);
                return;
            }
            LOGGER.error(this.toString() + " got unexpected PoolMgrSelectPoolMsg " + " : " + select_pool_msg + " ; Ignoring");
        } else if (message instanceof PoolIoFileMessage) {
            PoolIoFileMessage first_pool_reply = (PoolIoFileMessage) message;
            if (state == WAITING_FIRST_POOL_REPLY_STATE) {
                setState(RECEIVED_FIRST_POOL_REPLY_STATE);
                poolFirstReplyArrived(first_pool_reply);
                return;
            }
            LOGGER.error(this.toString() + " got unexpected PoolIoFileMessage " + " : " + first_pool_reply + " ; Ignoring");
        } else if (message instanceof PnfsDeleteEntryMessage) {
            PnfsDeleteEntryMessage deleteReply = (PnfsDeleteEntryMessage) message;
            if (state == WAITING_FOR_PNFS_ENTRY_DELETE) {
                setState(RECEIVED_PNFS_ENTRY_DELETE);
                LOGGER.debug("Received PnfsDeleteEntryMessage, Deleted  : {}", deleteReply.getPnfsPath());
                sendErrorReply();
            }
        }
        manager.persist(this);
    } catch (RuntimeException e) {
        LOGGER.error("Bug detected in transfermanager, please report this to <support@dCache.org>", e);
        failure(1, "Bug detected: " + e);
    }
}
Also used : PoolMgrSelectPoolMsg(diskCacheV111.vehicles.PoolMgrSelectPoolMsg) PoolIoFileMessage(diskCacheV111.vehicles.PoolIoFileMessage) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) PnfsCreateEntryMessage(diskCacheV111.vehicles.PnfsCreateEntryMessage) PnfsDeleteEntryMessage(diskCacheV111.vehicles.PnfsDeleteEntryMessage) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileAttributes(org.dcache.vehicles.FileAttributes) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes)

Aggregations

PoolMgrSelectPoolMsg (diskCacheV111.vehicles.PoolMgrSelectPoolMsg)3 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)2 PoolMgrSelectReadPoolMsg (diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg)2 PoolMgrSelectWritePoolMsg (diskCacheV111.vehicles.PoolMgrSelectWritePoolMsg)2 FileAttributes (org.dcache.vehicles.FileAttributes)2 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)2 RequestState (diskCacheV111.poolManager.RequestContainerV5.RequestState)1 CacheException (diskCacheV111.util.CacheException)1 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)1 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)1 NotFileCacheException (diskCacheV111.util.NotFileCacheException)1 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)1 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)1 PnfsCreateEntryMessage (diskCacheV111.vehicles.PnfsCreateEntryMessage)1 PnfsDeleteEntryMessage (diskCacheV111.vehicles.PnfsDeleteEntryMessage)1 PoolIoFileMessage (diskCacheV111.vehicles.PoolIoFileMessage)1 ProtocolInfo (diskCacheV111.vehicles.ProtocolInfo)1 IOException (java.io.IOException)1