Commit c7e3ac8d authored by Giuseppe Lo Presti's avatar Giuseppe Lo Presti
Browse files

Properly use the now introduced custom exceptions in the case of transfers...

Properly use the now introduced custom exceptions in the case of transfers that failed to start because of the stager
parent 58e5b22c
......@@ -27,12 +27,19 @@
class TransferCanceled(Exception):
"""Exception sent by the transfermanager when a transfer that
would like to start was already started somewhere else or
was actually canceled in the mean time"""
would like to start was already started somewhere else"""
def __init__(self, message):
"""constructor"""
super(TransferCanceled, self).__init__(message)
class TransferFailed(Exception):
"""Exception sent by the transfermanager when a transfer that
would like to start was failed or canceled in the stager database.
In this case we want to tell the client about the failure."""
def __init__(self, message):
"""constructor"""
super(TransferFailed, self).__init__(message)
class SourceNotStarted(Exception):
"""Exception sent by the transfermanager when a d2ddst transfer
that would like to start should be put on hold until the
......
......@@ -31,7 +31,7 @@ import Crypto.PublicKey.RSA as RSA
import Crypto.Signature.PKCS1_v1_5 as PKCS1
import base64
import connectionpool, dlf, clientsreplier
from commonexceptions import TransferCanceled, SourceNotStarted
from commonexceptions import TransferCanceled, TransferFailed, SourceNotStarted
from diskmanagerdlf import msgs
from transfer import TransferType, RunningTransfer
......@@ -231,13 +231,11 @@ class ActivityControlThread(threading.Thread):
reqid=transfer.reqId, fileId=transfer.fileId, originalError='Timeout', error=e)
except TransferCanceled, e:
# 'Transfer start canceled' message
dlf.writedebug(msgs.TRANSFERSTARTCANCELED, reason=e.args, subreqId=transfer.transferId,
fileId=transfer.fileId)
dlf.writedebug(msgs.TRANSFERSTARTCANCELED, reason=e.args, subreqId=transfer.transferId, fileId=transfer.fileId)
# the transfer has already started somewhere else, or has been canceled, so give up
except IOError, e:
except TransferFailed, e:
# 'Transfer start canceled' message
dlf.write(msgs.TRANSFERSTARTCANCELED, errCode=e.errno, reason=e.strerror,
subreqId=transfer.transferId, fileId=transfer.fileId)
dlf.write(msgs.TRANSFERSTARTCANCELED, reason=e.args, subreqId=transfer.transferId, fileId=transfer.fileId)
# this is a permanent failure because of the stager, so try and inform the client that the transfer cannot take place
ioresp = clientsreplier.IOResponse(clientsreplier.IOResponse.FAILED, '', 0, transfer.fileId, transfer.transferId, \
e.errno, e.strerror, transfer.reqId, transfer.reqId, 0, transfer.protocol)
......
......@@ -33,7 +33,7 @@ import threading
import socket
import daemon
import castor_tools, connectionpool, dispatcher, serverqueue, aborter
from commonexceptions import TransferCanceled
from commonexceptions import TransferCanceled, TransferFailed
import synchronizer, suicider, reportmanager, diskserverlistcache, modifydiskservers
import dlf
from transfermanagerdlf import msgs
......@@ -455,11 +455,11 @@ class TransferManagerService(rpyc.Service):
if errorcode == 20110: # disk2DiskCopyStart DB errors
# cleanup source
queueingTransfers.d2dendById(transfer.transferId)
# raise ValueError to tell the upper layer to give up
# raise exception to tell the upper layer to give up
raise TransferCanceled(error.message)
elif errorcode in (20104, 20114): # getStart, putStart DB errors
# raise ValueError to tell the upper layer to give up
raise TransferCanceled(error.message)
# raise exception to tell the upper layer to give up
raise TransferFailed(error.message)
# otherwise reraise for the upper layer
raise e
finally:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment