Search in sources :

Example 1 with PnfsCancelUpload

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

the class PnfsManagerTest method testCancelUpload.

@Test
public void testCancelUpload() throws ChimeraFsException {
    FsPath root = FsPath.ROOT;
    FsPath path = FsPath.create("/test");
    PnfsCreateUploadPath create = new PnfsCreateUploadPath(Subjects.ROOT, Restrictions.none(), path, root, null, null, null, null, EnumSet.noneOf(CreateOption.class));
    _pnfsManager.createUploadPath(create);
    assertThat(create.getReturnCode(), is(0));
    PnfsCancelUpload cancel = new PnfsCancelUpload(Subjects.ROOT, Restrictions.none(), create.getUploadPath(), path, EnumSet.noneOf(FileAttribute.class), "request aborted");
    _pnfsManager.cancelUpload(cancel);
    assertThat(cancel.getReturnCode(), is(0));
    assertNotExists(create.getUploadPath().toString());
    assertNotExists("/test");
}
Also used : PnfsCreateUploadPath(diskCacheV111.vehicles.PnfsCreateUploadPath) PnfsCancelUpload(diskCacheV111.vehicles.PnfsCancelUpload) CreateOption(org.dcache.namespace.CreateOption) FsPath(diskCacheV111.util.FsPath) FileAttribute(org.dcache.namespace.FileAttribute) Test(org.junit.Test)

Example 2 with PnfsCancelUpload

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

the class PnfsManagerV3 method cancelUpload.

void cancelUpload(PnfsCancelUpload message) {
    Subject subject = message.getSubject();
    String explanation = message.getExplanation();
    try {
        checkRestriction(message, UPLOAD);
        Set<FileAttribute> requested = message.getRequestedAttributes();
        requested.addAll(EnumSet.of(PNFSID, NLINK, SIZE));
        Collection<FileAttributes> deletedFiles = _nameSpaceProvider.cancelUpload(subject, message.getUploadPath(), message.getPath(), requested, explanation);
        deletedFiles.stream().filter(// currently uploading
        f -> f.isUndefined(SIZE)).filter(// with no hard links
        f -> f.getNlink() == 1).map(FileAttributes::getPnfsId).forEach(id -> _cancelUploadNotificationTargets.stream().map(CellPath::new).forEach(p -> _stub.notify(p, new DoorCancelledUploadNotificationMessage(subject, id, explanation))));
        message.setDeletedFiles(deletedFiles);
        message.setSucceeded();
    } catch (CacheException e) {
        message.setFailed(e.getRc(), e.getMessage());
    } catch (RuntimeException e) {
        LOGGER.error("Cancel upload path failed", e);
        message.setFailed(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e);
    }
}
Also used : PnfsRemoveExtendedAttributesMessage(diskCacheV111.vehicles.PnfsRemoveExtendedAttributesMessage) Arrays(java.util.Arrays) Restriction(org.dcache.auth.attributes.Restriction) Subjects(org.dcache.auth.Subjects) CellMessage(dmg.cells.nucleus.CellMessage) PermissionHandler(org.dcache.namespace.PermissionHandler) NLINK(org.dcache.namespace.FileAttribute.NLINK) UnixPermission(org.dcache.chimera.UnixPermission) Command(dmg.util.command.Command) MODIFICATION_TIME(org.dcache.namespace.FileAttribute.MODIFICATION_TIME) ACCESS_ALLOWED(org.dcache.acl.enums.AccessType.ACCESS_ALLOWED) READ_METADATA(org.dcache.auth.attributes.Activity.READ_METADATA) Map(java.util.Map) PnfsRenameMessage(diskCacheV111.vehicles.PnfsRenameMessage) SIZE(org.dcache.namespace.FileAttribute.SIZE) EnumSet(java.util.EnumSet) PnfsCreateSymLinkMessage(org.dcache.vehicles.PnfsCreateSymLinkMessage) CDC(dmg.cells.nucleus.CDC) DELETE(org.dcache.auth.attributes.Activity.DELETE) PrintWriter(java.io.PrintWriter) PnfsManagerGetQuotaMessage(org.dcache.vehicles.quota.PnfsManagerGetQuotaMessage) ACCESS_TIME(org.dcache.namespace.FileAttribute.ACCESS_TIME) PnfsManagerSetQuotaMessage(org.dcache.vehicles.quota.PnfsManagerSetQuotaMessage) PNFSID(org.dcache.namespace.FileAttribute.PNFSID) MissingResourceCacheException(diskCacheV111.util.MissingResourceCacheException) UPDATE_METADATA(org.dcache.auth.attributes.Activity.UPDATE_METADATA) Set(java.util.Set) BlockingQueue(java.util.concurrent.BlockingQueue) Executors(java.util.concurrent.Executors) PnfsFlagMessage(diskCacheV111.vehicles.PnfsFlagMessage) PnfsListExtendedAttributesMessage(diskCacheV111.vehicles.PnfsListExtendedAttributesMessage) AbstractCellComponent(dmg.cells.nucleus.AbstractCellComponent) PnfsCommitUpload(diskCacheV111.vehicles.PnfsCommitUpload) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) UPLOAD(org.dcache.auth.attributes.Activity.UPLOAD) PnfsCreateEntryMessage(diskCacheV111.vehicles.PnfsCreateEntryMessage) PnfsCreateUploadPath(diskCacheV111.vehicles.PnfsCreateUploadPath) LeaderLatchListener(org.apache.curator.framework.recipes.leader.LeaderLatchListener) FsPath(diskCacheV111.util.FsPath) PnfsSetFileAttributes(org.dcache.vehicles.PnfsSetFileAttributes) SimpleDateFormat(java.text.SimpleDateFormat) Callable(java.util.concurrent.Callable) ACCESS_UNDEFINED(org.dcache.acl.enums.AccessType.ACCESS_UNDEFINED) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ColumnWriter(org.dcache.util.ColumnWriter) PnfsReadExtendedAttributesMessage(diskCacheV111.vehicles.PnfsReadExtendedAttributesMessage) Strings(com.google.common.base.Strings) OWNER(org.dcache.namespace.FileAttribute.OWNER) NotDirCacheException(diskCacheV111.util.NotDirCacheException) CellStub(org.dcache.cells.CellStub) TYPE(org.dcache.namespace.FileAttribute.TYPE) PnfsListDirectoryMessage(org.dcache.vehicles.PnfsListDirectoryMessage) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) FileType(org.dcache.namespace.FileType) PnfsManagerRemoveQuotaMessage(org.dcache.vehicles.quota.PnfsManagerRemoveQuotaMessage) PnfsId(diskCacheV111.util.PnfsId) ROOT(org.dcache.auth.Subjects.ROOT) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) QuotaInfo(org.dcache.quota.data.QuotaInfo) FutureCallback(com.google.common.util.concurrent.FutureCallback) File(java.io.File) LIST(org.dcache.auth.attributes.Activity.LIST) Futures(com.google.common.util.concurrent.Futures) CREATION_TIME(org.dcache.namespace.FileAttribute.CREATION_TIME) PnfsRemoveLabelsMessage(diskCacheV111.vehicles.PnfsRemoveLabelsMessage) TransactionException(org.springframework.transaction.TransactionException) FileAttribute(org.dcache.namespace.FileAttribute) ByteUnit(org.dcache.util.ByteUnit) PnfsMapPathMessage(diskCacheV111.vehicles.PnfsMapPathMessage) ScheduledFuture(java.util.concurrent.ScheduledFuture) SortedSet(java.util.SortedSet) AccessLatency(diskCacheV111.util.AccessLatency) ACCESS_DENIED(org.dcache.acl.enums.AccessType.ACCESS_DENIED) ChecksumType(org.dcache.util.ChecksumType) LoggerFactory(org.slf4j.LoggerFactory) Random(java.util.Random) XATTR(org.dcache.namespace.FileAttribute.XATTR) PnfsCancelUpload(diskCacheV111.vehicles.PnfsCancelUpload) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) AccessType(org.dcache.acl.enums.AccessType) Locale(java.util.Locale) RequestCounters(org.dcache.commons.stats.RequestCounters) QuotaHandler(org.dcache.chimera.quota.QuotaHandler) PnfsWriteExtendedAttributesMessage(diskCacheV111.vehicles.PnfsWriteExtendedAttributesMessage) Splitter(com.google.common.base.Splitter) FileAttributes(org.dcache.vehicles.FileAttributes) PnfsManagerQuotaMessage(org.dcache.vehicles.quota.PnfsManagerQuotaMessage) CellMessageReceiver(dmg.cells.nucleus.CellMessageReceiver) PnfsGetParentMessage(diskCacheV111.vehicles.PnfsGetParentMessage) CommandException(dmg.util.CommandException) CHANGE_TIME(org.dcache.namespace.FileAttribute.CHANGE_TIME) Collection(java.util.Collection) PnfsGetCacheLocationsMessage(diskCacheV111.vehicles.PnfsGetCacheLocationsMessage) CellCommandListener(dmg.cells.nucleus.CellCommandListener) Instant(java.time.Instant) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Collectors(java.util.stream.Collectors) List(java.util.List) UOID(dmg.cells.nucleus.UOID) Activity(org.dcache.auth.attributes.Activity) Optional(java.util.Optional) MODE(org.dcache.namespace.FileAttribute.MODE) CellPath(dmg.cells.nucleus.CellPath) RetentionPolicy(diskCacheV111.util.RetentionPolicy) Argument(dmg.util.command.Argument) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) CellInfoProvider(dmg.cells.nucleus.CellInfoProvider) PnfsClearCacheLocationMessage(diskCacheV111.vehicles.PnfsClearCacheLocationMessage) PnfsDeleteEntryMessage(diskCacheV111.vehicles.PnfsDeleteEntryMessage) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) PnfsMessage(diskCacheV111.vehicles.PnfsMessage) QuotaRequest(org.dcache.quota.data.QuotaRequest) CellAddressCore(dmg.cells.nucleus.CellAddressCore) StorageInfos(diskCacheV111.vehicles.StorageInfos) Message(diskCacheV111.vehicles.Message) DOWNLOAD(org.dcache.auth.attributes.Activity.DOWNLOAD) QuotaType(org.dcache.quota.data.QuotaType) CacheException(diskCacheV111.util.CacheException) StorageInfo(diskCacheV111.vehicles.StorageInfo) Objects.requireNonNull(java.util.Objects.requireNonNull) ListHandler(org.dcache.namespace.ListHandler) MANAGE(org.dcache.auth.attributes.Activity.MANAGE) PoolFileFlushedMessage(diskCacheV111.vehicles.PoolFileFlushedMessage) TimeUtils(org.dcache.util.TimeUtils) ExecutorService(java.util.concurrent.ExecutorService) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) FireAndForgetTask(org.dcache.util.FireAndForgetTask) RequestExecutionTimeGauges(org.dcache.commons.stats.RequestExecutionTimeGauges) Subject(javax.security.auth.Subject) TabulatedRow(org.dcache.util.ColumnWriter.TabulatedRow) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) TimeUnit(java.util.concurrent.TimeUnit) Checksum(org.dcache.util.Checksum) PnfsRemoveChecksumMessage(org.dcache.vehicles.PnfsRemoveChecksumMessage) DoorCancelledUploadNotificationMessage(diskCacheV111.vehicles.DoorCancelledUploadNotificationMessage) Quota(org.dcache.chimera.quota.Quota) Args(org.dcache.util.Args) Option(dmg.util.command.Option) AccessMask(org.dcache.acl.enums.AccessMask) OWNER_GROUP(org.dcache.namespace.FileAttribute.OWNER_GROUP) PnfsAddCacheLocationMessage(diskCacheV111.vehicles.PnfsAddCacheLocationMessage) CommandLine(dmg.util.command.CommandLine) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Required(org.springframework.beans.factory.annotation.Required) Collections(java.util.Collections) JdbcQuota(org.dcache.chimera.quota.JdbcQuota) Transactional(org.springframework.transaction.annotation.Transactional) CellPath(dmg.cells.nucleus.CellPath) DoorCancelledUploadNotificationMessage(diskCacheV111.vehicles.DoorCancelledUploadNotificationMessage) MissingResourceCacheException(diskCacheV111.util.MissingResourceCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) PnfsSetFileAttributes(org.dcache.vehicles.PnfsSetFileAttributes) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) FileAttributes(org.dcache.vehicles.FileAttributes) Subject(javax.security.auth.Subject) FileAttribute(org.dcache.namespace.FileAttribute)

Example 3 with PnfsCancelUpload

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

the class Storage method messageArrived.

public void messageArrived(PnfsCreateUploadPath msg) {
    // Catches replies for which the callback timed out
    if (msg.isReply() && msg.getReturnCode() == 0) {
        PnfsCancelUpload message = new PnfsCancelUpload(msg.getSubject(), msg.getRestriction(), msg.getUploadPath(), msg.getPath(), EnumSet.noneOf(FileAttribute.class), "SRM upload aborted: timeout creating upload path");
        _pnfsStub.notify(message);
    }
}
Also used : PnfsCancelUpload(diskCacheV111.vehicles.PnfsCancelUpload) FileAttribute(org.dcache.namespace.FileAttribute)

Example 4 with PnfsCancelUpload

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

the class Storage method abortPut.

@Override
public void abortPut(SRMUser user, String localTransferPath, URI surl, String reason) throws SRMException {
    try {
        if (localTransferPath.startsWith("/")) {
            // safe-guard against incompatible file id from earlier versions
            Subject subject = (user == null) ? Subjects.ROOT : asDcacheUser(user).getSubject();
            Restriction restriction = (user == null) ? Restrictions.none() : asDcacheUser(user).getRestriction();
            FsPath actualPnfsPath = getPath(surl);
            PnfsCancelUpload msg = new PnfsCancelUpload(subject, restriction, FsPath.create(localTransferPath), actualPnfsPath, EnumSet.noneOf(FileAttribute.class), "SRM upload aborted: " + reason);
            _pnfsStub.sendAndWait(msg);
            DoorRequestInfoMessage infoMsg = new DoorRequestInfoMessage(getCellAddress());
            infoMsg.setSubject(subject);
            infoMsg.setBillingPath(actualPnfsPath.toString());
            infoMsg.setTransaction(CDC.getSession());
            infoMsg.setPnfsId(msg.getPnfsId());
            infoMsg.setResult(CacheException.DEFAULT_ERROR_CODE, reason);
            Origin origin = Subjects.getOrigin(subject);
            if (origin != null) {
                infoMsg.setClient(origin.getAddress().getHostAddress());
            }
            _billingStub.notify(infoMsg);
        }
    } catch (PermissionDeniedCacheException e) {
        throw new SRMAuthorizationException("Permission denied.", e);
    } catch (CacheException e) {
        throw new SRMInternalErrorException(e.getMessage(), e);
    } catch (InterruptedException e) {
        throw new SRMInternalErrorException("Operation interrupted", e);
    } catch (NoRouteToCellException e) {
        throw new SRMInternalErrorException("Communication failure", e);
    }
}
Also used : DoorRequestInfoMessage(diskCacheV111.vehicles.DoorRequestInfoMessage) Origin(org.dcache.auth.Origin) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) PnfsCancelUpload(diskCacheV111.vehicles.PnfsCancelUpload) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) Subject(javax.security.auth.Subject) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) Restriction(org.dcache.auth.attributes.Restriction) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) FsPath(diskCacheV111.util.FsPath) FileAttribute(org.dcache.namespace.FileAttribute)

Example 5 with PnfsCancelUpload

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

the class XrootdTransferService method handleUploadAbort.

private void handleUploadAbort(NettyMover<XrootdProtocolInfo> mover, Throwable cause) throws CacheException {
    try {
        PnfsCancelUpload msg = new PnfsCancelUpload(mover.getSubject(), mover.getProtocolInfo().getRestriction(), FsPath.create(mover.getTransferPath()), FsPath.create(mover.getBillingPath()), EnumSet.noneOf(FileAttribute.class), "upload aborted: " + Exceptions.meaningfulMessage(cause));
        pnfsStub.sendAndWait(msg);
    } catch (InterruptedException ex) {
        throw new CacheException("Operation interrupted", ex);
    } catch (NoRouteToCellException ex) {
        throw new CacheException("Internal communication failure", ex);
    }
}
Also used : PnfsCancelUpload(diskCacheV111.vehicles.PnfsCancelUpload) CacheException(diskCacheV111.util.CacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) FileAttribute(org.dcache.namespace.FileAttribute)

Aggregations

PnfsCancelUpload (diskCacheV111.vehicles.PnfsCancelUpload)6 FileAttribute (org.dcache.namespace.FileAttribute)6 FsPath (diskCacheV111.util.FsPath)4 CacheException (diskCacheV111.util.CacheException)3 PnfsCreateUploadPath (diskCacheV111.vehicles.PnfsCreateUploadPath)3 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)3 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)2 NotDirCacheException (diskCacheV111.util.NotDirCacheException)2 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)2 Subject (javax.security.auth.Subject)2 Restriction (org.dcache.auth.attributes.Restriction)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Splitter (com.google.common.base.Splitter)1 Strings (com.google.common.base.Strings)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1