Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #155 from ghedsouza/master
Browse files Browse the repository at this point in the history
Add details to Exception when data_xciever.connect() fails.
  • Loading branch information
Wouter de Bie committed Jul 4, 2015
2 parents 774af1c + 8feb080 commit 17dec4b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
24 changes: 15 additions & 9 deletions snakebite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@

import snakebite.protobuf.ClientNamenodeProtocol_pb2 as client_proto
import snakebite.glob as glob
from snakebite.errors import RequestError
from snakebite.service import RpcService
from snakebite.errors import FileAlreadyExistsException
from snakebite.errors import FileNotFoundException
from snakebite.errors import DirectoryException
from snakebite.errors import FileException
from snakebite.errors import InvalidInputException
from snakebite.errors import OutOfNNException
from snakebite.channel import DataXceiverChannel
from snakebite.config import HDFSConfig
from snakebite.errors import (
ConnectionFailureException,
DirectoryException,
FileAlreadyExistsException,
FileException,
FileNotFoundException,
InvalidInputException,
OutOfNNException,
RequestError,
)
from snakebite.namenode import Namenode
from snakebite.service import RpcService

import Queue
import zlib
Expand Down Expand Up @@ -1140,7 +1143,10 @@ def _read_file(self, path, node, tail_only, check_crc, tail_length=1024):
failed_nodes.append(location.id.storageID)
successful_read = False
else:
raise Exception
raise ConnectionFailureException(
u"Failure to connect to data node at ({}:{})".format(
host, port
))
if successful_read:
break
if successful_read is False:
Expand Down
25 changes: 15 additions & 10 deletions snakebite/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@
# the License.


class FileNotFoundException(Exception):
class ConnectionFailureException(Exception):
def __init__(self, msg):
super(FileNotFoundException, self).__init__(msg)
super(ConnectionFailureException, self).__init__(msg)


class FileAlreadyExistsException(Exception):
class DirectoryException(Exception):
def __init__(self, msg):
super(FileAlreadyExistsException, self).__init__(msg)
super(DirectoryException, self).__init__(msg)


class RequestError(Exception):
class FileAlreadyExistsException(Exception):
def __init__(self, msg):
super(RequestError, self).__init__(msg)
super(FileAlreadyExistsException, self).__init__(msg)


class DirectoryException(Exception):
class FileException(Exception):
def __init__(self, msg):
super(DirectoryException, self).__init__(msg)
super(FileException, self).__init__(msg)


class FileException(Exception):
class FileNotFoundException(Exception):
def __init__(self, msg):
super(FileException, self).__init__(msg)
super(FileNotFoundException, self).__init__(msg)


class InvalidInputException(Exception):
Expand All @@ -47,3 +47,8 @@ def __init__(self, msg):
class OutOfNNException(Exception):
def __init__(self, msg):
super(OutOfNNException, self).__init__(msg)


class RequestError(Exception):
def __init__(self, msg):
super(RequestError, self).__init__(msg)

0 comments on commit 17dec4b

Please sign in to comment.