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");
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations