#
# Autogenerated by Thrift Compiler (0.7.0)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#

from thrift.Thrift import *
from ttypes import *
from thrift.Thrift import TProcessor
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol, TProtocol
try:
  from thrift.protocol import fastbinary
except:
  fastbinary = None


class Iface:
  def recoverBlock(self, datanode, namespaceId, block, keepLength, targets, deadline):
    """
    Parameters:
     - datanode
     - namespaceId
     - block
     - keepLength
     - targets
     - deadline
    """
    pass

  def getBlockInfo(self, datanode, namespaceid, block):
    """
    Parameters:
     - datanode
     - namespaceid
     - block
    """
    pass

  def copyBlock(self, datanode, srcNamespaceId, srcblock, dstNamespaceId, destBlock, target, asynchronous):
    """
    Parameters:
     - datanode
     - srcNamespaceId
     - srcblock
     - dstNamespaceId
     - destBlock
     - target
     - asynchronous
    """
    pass

  def getBlockPathInfo(self, datanode, namespaceId, block):
    """
    Parameters:
     - datanode
     - namespaceId
     - block
    """
    pass


class Client(Iface):
  def __init__(self, iprot, oprot=None):
    self._iprot = self._oprot = iprot
    if oprot is not None:
      self._oprot = oprot
    self._seqid = 0

  def recoverBlock(self, datanode, namespaceId, block, keepLength, targets, deadline):
    """
    Parameters:
     - datanode
     - namespaceId
     - block
     - keepLength
     - targets
     - deadline
    """
    self.send_recoverBlock(datanode, namespaceId, block, keepLength, targets, deadline)
    return self.recv_recoverBlock()

  def send_recoverBlock(self, datanode, namespaceId, block, keepLength, targets, deadline):
    self._oprot.writeMessageBegin('recoverBlock', TMessageType.CALL, self._seqid)
    args = recoverBlock_args()
    args.datanode = datanode
    args.namespaceId = namespaceId
    args.block = block
    args.keepLength = keepLength
    args.targets = targets
    args.deadline = deadline
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_recoverBlock(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = recoverBlock_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.success is not None:
      return result.success
    if result.ouch is not None:
      raise result.ouch
    raise TApplicationException(TApplicationException.MISSING_RESULT, "recoverBlock failed: unknown result");

  def getBlockInfo(self, datanode, namespaceid, block):
    """
    Parameters:
     - datanode
     - namespaceid
     - block
    """
    self.send_getBlockInfo(datanode, namespaceid, block)
    return self.recv_getBlockInfo()

  def send_getBlockInfo(self, datanode, namespaceid, block):
    self._oprot.writeMessageBegin('getBlockInfo', TMessageType.CALL, self._seqid)
    args = getBlockInfo_args()
    args.datanode = datanode
    args.namespaceid = namespaceid
    args.block = block
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_getBlockInfo(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = getBlockInfo_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.success is not None:
      return result.success
    if result.ouch is not None:
      raise result.ouch
    raise TApplicationException(TApplicationException.MISSING_RESULT, "getBlockInfo failed: unknown result");

  def copyBlock(self, datanode, srcNamespaceId, srcblock, dstNamespaceId, destBlock, target, asynchronous):
    """
    Parameters:
     - datanode
     - srcNamespaceId
     - srcblock
     - dstNamespaceId
     - destBlock
     - target
     - asynchronous
    """
    self.send_copyBlock(datanode, srcNamespaceId, srcblock, dstNamespaceId, destBlock, target, asynchronous)
    self.recv_copyBlock()

  def send_copyBlock(self, datanode, srcNamespaceId, srcblock, dstNamespaceId, destBlock, target, asynchronous):
    self._oprot.writeMessageBegin('copyBlock', TMessageType.CALL, self._seqid)
    args = copyBlock_args()
    args.datanode = datanode
    args.srcNamespaceId = srcNamespaceId
    args.srcblock = srcblock
    args.dstNamespaceId = dstNamespaceId
    args.destBlock = destBlock
    args.target = target
    args.asynchronous = asynchronous
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_copyBlock(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = copyBlock_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.ouch is not None:
      raise result.ouch
    return

  def getBlockPathInfo(self, datanode, namespaceId, block):
    """
    Parameters:
     - datanode
     - namespaceId
     - block
    """
    self.send_getBlockPathInfo(datanode, namespaceId, block)
    return self.recv_getBlockPathInfo()

  def send_getBlockPathInfo(self, datanode, namespaceId, block):
    self._oprot.writeMessageBegin('getBlockPathInfo', TMessageType.CALL, self._seqid)
    args = getBlockPathInfo_args()
    args.datanode = datanode
    args.namespaceId = namespaceId
    args.block = block
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_getBlockPathInfo(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = getBlockPathInfo_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.success is not None:
      return result.success
    if result.ouch is not None:
      raise result.ouch
    raise TApplicationException(TApplicationException.MISSING_RESULT, "getBlockPathInfo failed: unknown result");


class Processor(Iface, TProcessor):
  def __init__(self, handler):
    self._handler = handler
    self._processMap = {}
    self._processMap["recoverBlock"] = Processor.process_recoverBlock
    self._processMap["getBlockInfo"] = Processor.process_getBlockInfo
    self._processMap["copyBlock"] = Processor.process_copyBlock
    self._processMap["getBlockPathInfo"] = Processor.process_getBlockPathInfo

  def process(self, iprot, oprot):
    (name, type, seqid) = iprot.readMessageBegin()
    if name not in self._processMap:
      iprot.skip(TType.STRUCT)
      iprot.readMessageEnd()
      x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name))
      oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)
      x.write(oprot)
      oprot.writeMessageEnd()
      oprot.trans.flush()
      return
    else:
      self._processMap[name](self, seqid, iprot, oprot)
    return True

  def process_recoverBlock(self, seqid, iprot, oprot):
    args = recoverBlock_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = recoverBlock_result()
    try:
      result.success = self._handler.recoverBlock(args.datanode, args.namespaceId, args.block, args.keepLength, args.targets, args.deadline)
    except ThriftIOException, ouch:
      result.ouch = ouch
    oprot.writeMessageBegin("recoverBlock", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()

  def process_getBlockInfo(self, seqid, iprot, oprot):
    args = getBlockInfo_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = getBlockInfo_result()
    try:
      result.success = self._handler.getBlockInfo(args.datanode, args.namespaceid, args.block)
    except ThriftIOException, ouch:
      result.ouch = ouch
    oprot.writeMessageBegin("getBlockInfo", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()

  def process_copyBlock(self, seqid, iprot, oprot):
    args = copyBlock_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = copyBlock_result()
    try:
      self._handler.copyBlock(args.datanode, args.srcNamespaceId, args.srcblock, args.dstNamespaceId, args.destBlock, args.target, args.asynchronous)
    except ThriftIOException, ouch:
      result.ouch = ouch
    oprot.writeMessageBegin("copyBlock", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()

  def process_getBlockPathInfo(self, seqid, iprot, oprot):
    args = getBlockPathInfo_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = getBlockPathInfo_result()
    try:
      result.success = self._handler.getBlockPathInfo(args.datanode, args.namespaceId, args.block)
    except ThriftIOException, ouch:
      result.ouch = ouch
    oprot.writeMessageBegin("getBlockPathInfo", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()


# HELPER FUNCTIONS AND STRUCTURES

class recoverBlock_args:
  """
  Attributes:
   - datanode
   - namespaceId
   - block
   - keepLength
   - targets
   - deadline
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'datanode', (TDatanodeID, TDatanodeID.thrift_spec), None, ), # 1
    (2, TType.STRUCT, 'namespaceId', (ThdfsNamespaceId, ThdfsNamespaceId.thrift_spec), None, ), # 2
    (3, TType.STRUCT, 'block', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 3
    (4, TType.BOOL, 'keepLength', None, None, ), # 4
    (5, TType.LIST, 'targets', (TType.STRUCT,(TDatanodeID, TDatanodeID.thrift_spec)), None, ), # 5
    (6, TType.I64, 'deadline', None, None, ), # 6
  )

  def __init__(self, datanode=None, namespaceId=None, block=None, keepLength=None, targets=None, deadline=None,):
    self.datanode = datanode
    self.namespaceId = namespaceId
    self.block = block
    self.keepLength = keepLength
    self.targets = targets
    self.deadline = deadline

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRUCT:
          self.datanode = TDatanodeID()
          self.datanode.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRUCT:
          self.namespaceId = ThdfsNamespaceId()
          self.namespaceId.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.STRUCT:
          self.block = ThdfsBlock()
          self.block.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 4:
        if ftype == TType.BOOL:
          self.keepLength = iprot.readBool();
        else:
          iprot.skip(ftype)
      elif fid == 5:
        if ftype == TType.LIST:
          self.targets = []
          (_etype3, _size0) = iprot.readListBegin()
          for _i4 in xrange(_size0):
            _elem5 = TDatanodeID()
            _elem5.read(iprot)
            self.targets.append(_elem5)
          iprot.readListEnd()
        else:
          iprot.skip(ftype)
      elif fid == 6:
        if ftype == TType.I64:
          self.deadline = iprot.readI64();
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('recoverBlock_args')
    if self.datanode is not None:
      oprot.writeFieldBegin('datanode', TType.STRUCT, 1)
      self.datanode.write(oprot)
      oprot.writeFieldEnd()
    if self.namespaceId is not None:
      oprot.writeFieldBegin('namespaceId', TType.STRUCT, 2)
      self.namespaceId.write(oprot)
      oprot.writeFieldEnd()
    if self.block is not None:
      oprot.writeFieldBegin('block', TType.STRUCT, 3)
      self.block.write(oprot)
      oprot.writeFieldEnd()
    if self.keepLength is not None:
      oprot.writeFieldBegin('keepLength', TType.BOOL, 4)
      oprot.writeBool(self.keepLength)
      oprot.writeFieldEnd()
    if self.targets is not None:
      oprot.writeFieldBegin('targets', TType.LIST, 5)
      oprot.writeListBegin(TType.STRUCT, len(self.targets))
      for iter6 in self.targets:
        iter6.write(oprot)
      oprot.writeListEnd()
      oprot.writeFieldEnd()
    if self.deadline is not None:
      oprot.writeFieldBegin('deadline', TType.I64, 6)
      oprot.writeI64(self.deadline)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class recoverBlock_result:
  """
  Attributes:
   - success
   - ouch
  """

  thrift_spec = (
    (0, TType.STRUCT, 'success', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 0
    (1, TType.STRUCT, 'ouch', (ThriftIOException, ThriftIOException.thrift_spec), None, ), # 1
  )

  def __init__(self, success=None, ouch=None,):
    self.success = success
    self.ouch = ouch

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 0:
        if ftype == TType.STRUCT:
          self.success = ThdfsBlock()
          self.success.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 1:
        if ftype == TType.STRUCT:
          self.ouch = ThriftIOException()
          self.ouch.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('recoverBlock_result')
    if self.success is not None:
      oprot.writeFieldBegin('success', TType.STRUCT, 0)
      self.success.write(oprot)
      oprot.writeFieldEnd()
    if self.ouch is not None:
      oprot.writeFieldBegin('ouch', TType.STRUCT, 1)
      self.ouch.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getBlockInfo_args:
  """
  Attributes:
   - datanode
   - namespaceid
   - block
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'datanode', (TDatanodeID, TDatanodeID.thrift_spec), None, ), # 1
    (2, TType.STRUCT, 'namespaceid', (ThdfsNamespaceId, ThdfsNamespaceId.thrift_spec), None, ), # 2
    (3, TType.STRUCT, 'block', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 3
  )

  def __init__(self, datanode=None, namespaceid=None, block=None,):
    self.datanode = datanode
    self.namespaceid = namespaceid
    self.block = block

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRUCT:
          self.datanode = TDatanodeID()
          self.datanode.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRUCT:
          self.namespaceid = ThdfsNamespaceId()
          self.namespaceid.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.STRUCT:
          self.block = ThdfsBlock()
          self.block.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getBlockInfo_args')
    if self.datanode is not None:
      oprot.writeFieldBegin('datanode', TType.STRUCT, 1)
      self.datanode.write(oprot)
      oprot.writeFieldEnd()
    if self.namespaceid is not None:
      oprot.writeFieldBegin('namespaceid', TType.STRUCT, 2)
      self.namespaceid.write(oprot)
      oprot.writeFieldEnd()
    if self.block is not None:
      oprot.writeFieldBegin('block', TType.STRUCT, 3)
      self.block.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getBlockInfo_result:
  """
  Attributes:
   - success
   - ouch
  """

  thrift_spec = (
    (0, TType.STRUCT, 'success', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 0
    (1, TType.STRUCT, 'ouch', (ThriftIOException, ThriftIOException.thrift_spec), None, ), # 1
  )

  def __init__(self, success=None, ouch=None,):
    self.success = success
    self.ouch = ouch

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 0:
        if ftype == TType.STRUCT:
          self.success = ThdfsBlock()
          self.success.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 1:
        if ftype == TType.STRUCT:
          self.ouch = ThriftIOException()
          self.ouch.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getBlockInfo_result')
    if self.success is not None:
      oprot.writeFieldBegin('success', TType.STRUCT, 0)
      self.success.write(oprot)
      oprot.writeFieldEnd()
    if self.ouch is not None:
      oprot.writeFieldBegin('ouch', TType.STRUCT, 1)
      self.ouch.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class copyBlock_args:
  """
  Attributes:
   - datanode
   - srcNamespaceId
   - srcblock
   - dstNamespaceId
   - destBlock
   - target
   - asynchronous
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'datanode', (TDatanodeID, TDatanodeID.thrift_spec), None, ), # 1
    (2, TType.STRUCT, 'srcNamespaceId', (ThdfsNamespaceId, ThdfsNamespaceId.thrift_spec), None, ), # 2
    (3, TType.STRUCT, 'srcblock', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 3
    (4, TType.STRUCT, 'dstNamespaceId', (ThdfsNamespaceId, ThdfsNamespaceId.thrift_spec), None, ), # 4
    (5, TType.STRUCT, 'destBlock', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 5
    (6, TType.STRUCT, 'target', (TDatanodeID, TDatanodeID.thrift_spec), None, ), # 6
    (7, TType.BOOL, 'asynchronous', None, None, ), # 7
  )

  def __init__(self, datanode=None, srcNamespaceId=None, srcblock=None, dstNamespaceId=None, destBlock=None, target=None, asynchronous=None,):
    self.datanode = datanode
    self.srcNamespaceId = srcNamespaceId
    self.srcblock = srcblock
    self.dstNamespaceId = dstNamespaceId
    self.destBlock = destBlock
    self.target = target
    self.asynchronous = asynchronous

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRUCT:
          self.datanode = TDatanodeID()
          self.datanode.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRUCT:
          self.srcNamespaceId = ThdfsNamespaceId()
          self.srcNamespaceId.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.STRUCT:
          self.srcblock = ThdfsBlock()
          self.srcblock.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 4:
        if ftype == TType.STRUCT:
          self.dstNamespaceId = ThdfsNamespaceId()
          self.dstNamespaceId.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 5:
        if ftype == TType.STRUCT:
          self.destBlock = ThdfsBlock()
          self.destBlock.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 6:
        if ftype == TType.STRUCT:
          self.target = TDatanodeID()
          self.target.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 7:
        if ftype == TType.BOOL:
          self.asynchronous = iprot.readBool();
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('copyBlock_args')
    if self.datanode is not None:
      oprot.writeFieldBegin('datanode', TType.STRUCT, 1)
      self.datanode.write(oprot)
      oprot.writeFieldEnd()
    if self.srcNamespaceId is not None:
      oprot.writeFieldBegin('srcNamespaceId', TType.STRUCT, 2)
      self.srcNamespaceId.write(oprot)
      oprot.writeFieldEnd()
    if self.srcblock is not None:
      oprot.writeFieldBegin('srcblock', TType.STRUCT, 3)
      self.srcblock.write(oprot)
      oprot.writeFieldEnd()
    if self.dstNamespaceId is not None:
      oprot.writeFieldBegin('dstNamespaceId', TType.STRUCT, 4)
      self.dstNamespaceId.write(oprot)
      oprot.writeFieldEnd()
    if self.destBlock is not None:
      oprot.writeFieldBegin('destBlock', TType.STRUCT, 5)
      self.destBlock.write(oprot)
      oprot.writeFieldEnd()
    if self.target is not None:
      oprot.writeFieldBegin('target', TType.STRUCT, 6)
      self.target.write(oprot)
      oprot.writeFieldEnd()
    if self.asynchronous is not None:
      oprot.writeFieldBegin('asynchronous', TType.BOOL, 7)
      oprot.writeBool(self.asynchronous)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class copyBlock_result:
  """
  Attributes:
   - ouch
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'ouch', (ThriftIOException, ThriftIOException.thrift_spec), None, ), # 1
  )

  def __init__(self, ouch=None,):
    self.ouch = ouch

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRUCT:
          self.ouch = ThriftIOException()
          self.ouch.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('copyBlock_result')
    if self.ouch is not None:
      oprot.writeFieldBegin('ouch', TType.STRUCT, 1)
      self.ouch.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getBlockPathInfo_args:
  """
  Attributes:
   - datanode
   - namespaceId
   - block
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'datanode', (TDatanodeID, TDatanodeID.thrift_spec), None, ), # 1
    (2, TType.STRUCT, 'namespaceId', (ThdfsNamespaceId, ThdfsNamespaceId.thrift_spec), None, ), # 2
    (3, TType.STRUCT, 'block', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 3
  )

  def __init__(self, datanode=None, namespaceId=None, block=None,):
    self.datanode = datanode
    self.namespaceId = namespaceId
    self.block = block

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRUCT:
          self.datanode = TDatanodeID()
          self.datanode.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRUCT:
          self.namespaceId = ThdfsNamespaceId()
          self.namespaceId.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.STRUCT:
          self.block = ThdfsBlock()
          self.block.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getBlockPathInfo_args')
    if self.datanode is not None:
      oprot.writeFieldBegin('datanode', TType.STRUCT, 1)
      self.datanode.write(oprot)
      oprot.writeFieldEnd()
    if self.namespaceId is not None:
      oprot.writeFieldBegin('namespaceId', TType.STRUCT, 2)
      self.namespaceId.write(oprot)
      oprot.writeFieldEnd()
    if self.block is not None:
      oprot.writeFieldBegin('block', TType.STRUCT, 3)
      self.block.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getBlockPathInfo_result:
  """
  Attributes:
   - success
   - ouch
  """

  thrift_spec = (
    (0, TType.STRUCT, 'success', (ThdfsBlockPath, ThdfsBlockPath.thrift_spec), None, ), # 0
    (1, TType.STRUCT, 'ouch', (ThriftIOException, ThriftIOException.thrift_spec), None, ), # 1
  )

  def __init__(self, success=None, ouch=None,):
    self.success = success
    self.ouch = ouch

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 0:
        if ftype == TType.STRUCT:
          self.success = ThdfsBlockPath()
          self.success.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 1:
        if ftype == TType.STRUCT:
          self.ouch = ThriftIOException()
          self.ouch.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getBlockPathInfo_result')
    if self.success is not None:
      oprot.writeFieldBegin('success', TType.STRUCT, 0)
      self.success.write(oprot)
      oprot.writeFieldEnd()
    if self.ouch is not None:
      oprot.writeFieldBegin('ouch', TType.STRUCT, 1)
      self.ouch.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

#
# Autogenerated by Thrift Compiler (0.7.0)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#

from thrift.Thrift import *
from ttypes import *
from thrift.Thrift import TProcessor
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol, TProtocol
try:
  from thrift.protocol import fastbinary
except:
  fastbinary = None


class Iface:
  def recoverBlock(self, datanode, namespaceId, block, keepLength, targets, deadline):
    """
    Parameters:
     - datanode
     - namespaceId
     - block
     - keepLength
     - targets
     - deadline
    """
    pass

  def getBlockInfo(self, datanode, namespaceid, block):
    """
    Parameters:
     - datanode
     - namespaceid
     - block
    """
    pass

  def copyBlock(self, datanode, srcNamespaceId, srcblock, dstNamespaceId, destBlock, target, asynchronous):
    """
    Parameters:
     - datanode
     - srcNamespaceId
     - srcblock
     - dstNamespaceId
     - destBlock
     - target
     - asynchronous
    """
    pass

  def getBlockPathInfo(self, datanode, namespaceId, block):
    """
    Parameters:
     - datanode
     - namespaceId
     - block
    """
    pass


class Client(Iface):
  def __init__(self, iprot, oprot=None):
    self._iprot = self._oprot = iprot
    if oprot is not None:
      self._oprot = oprot
    self._seqid = 0

  def recoverBlock(self, datanode, namespaceId, block, keepLength, targets, deadline):
    """
    Parameters:
     - datanode
     - namespaceId
     - block
     - keepLength
     - targets
     - deadline
    """
    self.send_recoverBlock(datanode, namespaceId, block, keepLength, targets, deadline)
    return self.recv_recoverBlock()

  def send_recoverBlock(self, datanode, namespaceId, block, keepLength, targets, deadline):
    self._oprot.writeMessageBegin('recoverBlock', TMessageType.CALL, self._seqid)
    args = recoverBlock_args()
    args.datanode = datanode
    args.namespaceId = namespaceId
    args.block = block
    args.keepLength = keepLength
    args.targets = targets
    args.deadline = deadline
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_recoverBlock(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = recoverBlock_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.success is not None:
      return result.success
    if result.ouch is not None:
      raise result.ouch
    raise TApplicationException(TApplicationException.MISSING_RESULT, "recoverBlock failed: unknown result");

  def getBlockInfo(self, datanode, namespaceid, block):
    """
    Parameters:
     - datanode
     - namespaceid
     - block
    """
    self.send_getBlockInfo(datanode, namespaceid, block)
    return self.recv_getBlockInfo()

  def send_getBlockInfo(self, datanode, namespaceid, block):
    self._oprot.writeMessageBegin('getBlockInfo', TMessageType.CALL, self._seqid)
    args = getBlockInfo_args()
    args.datanode = datanode
    args.namespaceid = namespaceid
    args.block = block
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_getBlockInfo(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = getBlockInfo_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.success is not None:
      return result.success
    if result.ouch is not None:
      raise result.ouch
    raise TApplicationException(TApplicationException.MISSING_RESULT, "getBlockInfo failed: unknown result");

  def copyBlock(self, datanode, srcNamespaceId, srcblock, dstNamespaceId, destBlock, target, asynchronous):
    """
    Parameters:
     - datanode
     - srcNamespaceId
     - srcblock
     - dstNamespaceId
     - destBlock
     - target
     - asynchronous
    """
    self.send_copyBlock(datanode, srcNamespaceId, srcblock, dstNamespaceId, destBlock, target, asynchronous)
    self.recv_copyBlock()

  def send_copyBlock(self, datanode, srcNamespaceId, srcblock, dstNamespaceId, destBlock, target, asynchronous):
    self._oprot.writeMessageBegin('copyBlock', TMessageType.CALL, self._seqid)
    args = copyBlock_args()
    args.datanode = datanode
    args.srcNamespaceId = srcNamespaceId
    args.srcblock = srcblock
    args.dstNamespaceId = dstNamespaceId
    args.destBlock = destBlock
    args.target = target
    args.asynchronous = asynchronous
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_copyBlock(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = copyBlock_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.ouch is not None:
      raise result.ouch
    return

  def getBlockPathInfo(self, datanode, namespaceId, block):
    """
    Parameters:
     - datanode
     - namespaceId
     - block
    """
    self.send_getBlockPathInfo(datanode, namespaceId, block)
    return self.recv_getBlockPathInfo()

  def send_getBlockPathInfo(self, datanode, namespaceId, block):
    self._oprot.writeMessageBegin('getBlockPathInfo', TMessageType.CALL, self._seqid)
    args = getBlockPathInfo_args()
    args.datanode = datanode
    args.namespaceId = namespaceId
    args.block = block
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_getBlockPathInfo(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = getBlockPathInfo_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.success is not None:
      return result.success
    if result.ouch is not None:
      raise result.ouch
    raise TApplicationException(TApplicationException.MISSING_RESULT, "getBlockPathInfo failed: unknown result");


class Processor(Iface, TProcessor):
  def __init__(self, handler):
    self._handler = handler
    self._processMap = {}
    self._processMap["recoverBlock"] = Processor.process_recoverBlock
    self._processMap["getBlockInfo"] = Processor.process_getBlockInfo
    self._processMap["copyBlock"] = Processor.process_copyBlock
    self._processMap["getBlockPathInfo"] = Processor.process_getBlockPathInfo

  def process(self, iprot, oprot):
    (name, type, seqid) = iprot.readMessageBegin()
    if name not in self._processMap:
      iprot.skip(TType.STRUCT)
      iprot.readMessageEnd()
      x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name))
      oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)
      x.write(oprot)
      oprot.writeMessageEnd()
      oprot.trans.flush()
      return
    else:
      self._processMap[name](self, seqid, iprot, oprot)
    return True

  def process_recoverBlock(self, seqid, iprot, oprot):
    args = recoverBlock_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = recoverBlock_result()
    try:
      result.success = self._handler.recoverBlock(args.datanode, args.namespaceId, args.block, args.keepLength, args.targets, args.deadline)
    except ThriftIOException, ouch:
      result.ouch = ouch
    oprot.writeMessageBegin("recoverBlock", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()

  def process_getBlockInfo(self, seqid, iprot, oprot):
    args = getBlockInfo_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = getBlockInfo_result()
    try:
      result.success = self._handler.getBlockInfo(args.datanode, args.namespaceid, args.block)
    except ThriftIOException, ouch:
      result.ouch = ouch
    oprot.writeMessageBegin("getBlockInfo", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()

  def process_copyBlock(self, seqid, iprot, oprot):
    args = copyBlock_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = copyBlock_result()
    try:
      self._handler.copyBlock(args.datanode, args.srcNamespaceId, args.srcblock, args.dstNamespaceId, args.destBlock, args.target, args.asynchronous)
    except ThriftIOException, ouch:
      result.ouch = ouch
    oprot.writeMessageBegin("copyBlock", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()

  def process_getBlockPathInfo(self, seqid, iprot, oprot):
    args = getBlockPathInfo_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = getBlockPathInfo_result()
    try:
      result.success = self._handler.getBlockPathInfo(args.datanode, args.namespaceId, args.block)
    except ThriftIOException, ouch:
      result.ouch = ouch
    oprot.writeMessageBegin("getBlockPathInfo", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()


# HELPER FUNCTIONS AND STRUCTURES

class recoverBlock_args:
  """
  Attributes:
   - datanode
   - namespaceId
   - block
   - keepLength
   - targets
   - deadline
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'datanode', (TDatanodeID, TDatanodeID.thrift_spec), None, ), # 1
    (2, TType.STRUCT, 'namespaceId', (ThdfsNamespaceId, ThdfsNamespaceId.thrift_spec), None, ), # 2
    (3, TType.STRUCT, 'block', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 3
    (4, TType.BOOL, 'keepLength', None, None, ), # 4
    (5, TType.LIST, 'targets', (TType.STRUCT,(TDatanodeID, TDatanodeID.thrift_spec)), None, ), # 5
    (6, TType.I64, 'deadline', None, None, ), # 6
  )

  def __init__(self, datanode=None, namespaceId=None, block=None, keepLength=None, targets=None, deadline=None,):
    self.datanode = datanode
    self.namespaceId = namespaceId
    self.block = block
    self.keepLength = keepLength
    self.targets = targets
    self.deadline = deadline

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRUCT:
          self.datanode = TDatanodeID()
          self.datanode.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRUCT:
          self.namespaceId = ThdfsNamespaceId()
          self.namespaceId.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.STRUCT:
          self.block = ThdfsBlock()
          self.block.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 4:
        if ftype == TType.BOOL:
          self.keepLength = iprot.readBool();
        else:
          iprot.skip(ftype)
      elif fid == 5:
        if ftype == TType.LIST:
          self.targets = []
          (_etype3, _size0) = iprot.readListBegin()
          for _i4 in xrange(_size0):
            _elem5 = TDatanodeID()
            _elem5.read(iprot)
            self.targets.append(_elem5)
          iprot.readListEnd()
        else:
          iprot.skip(ftype)
      elif fid == 6:
        if ftype == TType.I64:
          self.deadline = iprot.readI64();
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('recoverBlock_args')
    if self.datanode is not None:
      oprot.writeFieldBegin('datanode', TType.STRUCT, 1)
      self.datanode.write(oprot)
      oprot.writeFieldEnd()
    if self.namespaceId is not None:
      oprot.writeFieldBegin('namespaceId', TType.STRUCT, 2)
      self.namespaceId.write(oprot)
      oprot.writeFieldEnd()
    if self.block is not None:
      oprot.writeFieldBegin('block', TType.STRUCT, 3)
      self.block.write(oprot)
      oprot.writeFieldEnd()
    if self.keepLength is not None:
      oprot.writeFieldBegin('keepLength', TType.BOOL, 4)
      oprot.writeBool(self.keepLength)
      oprot.writeFieldEnd()
    if self.targets is not None:
      oprot.writeFieldBegin('targets', TType.LIST, 5)
      oprot.writeListBegin(TType.STRUCT, len(self.targets))
      for iter6 in self.targets:
        iter6.write(oprot)
      oprot.writeListEnd()
      oprot.writeFieldEnd()
    if self.deadline is not None:
      oprot.writeFieldBegin('deadline', TType.I64, 6)
      oprot.writeI64(self.deadline)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class recoverBlock_result:
  """
  Attributes:
   - success
   - ouch
  """

  thrift_spec = (
    (0, TType.STRUCT, 'success', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 0
    (1, TType.STRUCT, 'ouch', (ThriftIOException, ThriftIOException.thrift_spec), None, ), # 1
  )

  def __init__(self, success=None, ouch=None,):
    self.success = success
    self.ouch = ouch

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 0:
        if ftype == TType.STRUCT:
          self.success = ThdfsBlock()
          self.success.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 1:
        if ftype == TType.STRUCT:
          self.ouch = ThriftIOException()
          self.ouch.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('recoverBlock_result')
    if self.success is not None:
      oprot.writeFieldBegin('success', TType.STRUCT, 0)
      self.success.write(oprot)
      oprot.writeFieldEnd()
    if self.ouch is not None:
      oprot.writeFieldBegin('ouch', TType.STRUCT, 1)
      self.ouch.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getBlockInfo_args:
  """
  Attributes:
   - datanode
   - namespaceid
   - block
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'datanode', (TDatanodeID, TDatanodeID.thrift_spec), None, ), # 1
    (2, TType.STRUCT, 'namespaceid', (ThdfsNamespaceId, ThdfsNamespaceId.thrift_spec), None, ), # 2
    (3, TType.STRUCT, 'block', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 3
  )

  def __init__(self, datanode=None, namespaceid=None, block=None,):
    self.datanode = datanode
    self.namespaceid = namespaceid
    self.block = block

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRUCT:
          self.datanode = TDatanodeID()
          self.datanode.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRUCT:
          self.namespaceid = ThdfsNamespaceId()
          self.namespaceid.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.STRUCT:
          self.block = ThdfsBlock()
          self.block.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getBlockInfo_args')
    if self.datanode is not None:
      oprot.writeFieldBegin('datanode', TType.STRUCT, 1)
      self.datanode.write(oprot)
      oprot.writeFieldEnd()
    if self.namespaceid is not None:
      oprot.writeFieldBegin('namespaceid', TType.STRUCT, 2)
      self.namespaceid.write(oprot)
      oprot.writeFieldEnd()
    if self.block is not None:
      oprot.writeFieldBegin('block', TType.STRUCT, 3)
      self.block.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getBlockInfo_result:
  """
  Attributes:
   - success
   - ouch
  """

  thrift_spec = (
    (0, TType.STRUCT, 'success', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 0
    (1, TType.STRUCT, 'ouch', (ThriftIOException, ThriftIOException.thrift_spec), None, ), # 1
  )

  def __init__(self, success=None, ouch=None,):
    self.success = success
    self.ouch = ouch

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 0:
        if ftype == TType.STRUCT:
          self.success = ThdfsBlock()
          self.success.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 1:
        if ftype == TType.STRUCT:
          self.ouch = ThriftIOException()
          self.ouch.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getBlockInfo_result')
    if self.success is not None:
      oprot.writeFieldBegin('success', TType.STRUCT, 0)
      self.success.write(oprot)
      oprot.writeFieldEnd()
    if self.ouch is not None:
      oprot.writeFieldBegin('ouch', TType.STRUCT, 1)
      self.ouch.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class copyBlock_args:
  """
  Attributes:
   - datanode
   - srcNamespaceId
   - srcblock
   - dstNamespaceId
   - destBlock
   - target
   - asynchronous
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'datanode', (TDatanodeID, TDatanodeID.thrift_spec), None, ), # 1
    (2, TType.STRUCT, 'srcNamespaceId', (ThdfsNamespaceId, ThdfsNamespaceId.thrift_spec), None, ), # 2
    (3, TType.STRUCT, 'srcblock', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 3
    (4, TType.STRUCT, 'dstNamespaceId', (ThdfsNamespaceId, ThdfsNamespaceId.thrift_spec), None, ), # 4
    (5, TType.STRUCT, 'destBlock', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 5
    (6, TType.STRUCT, 'target', (TDatanodeID, TDatanodeID.thrift_spec), None, ), # 6
    (7, TType.BOOL, 'asynchronous', None, None, ), # 7
  )

  def __init__(self, datanode=None, srcNamespaceId=None, srcblock=None, dstNamespaceId=None, destBlock=None, target=None, asynchronous=None,):
    self.datanode = datanode
    self.srcNamespaceId = srcNamespaceId
    self.srcblock = srcblock
    self.dstNamespaceId = dstNamespaceId
    self.destBlock = destBlock
    self.target = target
    self.asynchronous = asynchronous

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRUCT:
          self.datanode = TDatanodeID()
          self.datanode.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRUCT:
          self.srcNamespaceId = ThdfsNamespaceId()
          self.srcNamespaceId.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.STRUCT:
          self.srcblock = ThdfsBlock()
          self.srcblock.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 4:
        if ftype == TType.STRUCT:
          self.dstNamespaceId = ThdfsNamespaceId()
          self.dstNamespaceId.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 5:
        if ftype == TType.STRUCT:
          self.destBlock = ThdfsBlock()
          self.destBlock.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 6:
        if ftype == TType.STRUCT:
          self.target = TDatanodeID()
          self.target.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 7:
        if ftype == TType.BOOL:
          self.asynchronous = iprot.readBool();
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('copyBlock_args')
    if self.datanode is not None:
      oprot.writeFieldBegin('datanode', TType.STRUCT, 1)
      self.datanode.write(oprot)
      oprot.writeFieldEnd()
    if self.srcNamespaceId is not None:
      oprot.writeFieldBegin('srcNamespaceId', TType.STRUCT, 2)
      self.srcNamespaceId.write(oprot)
      oprot.writeFieldEnd()
    if self.srcblock is not None:
      oprot.writeFieldBegin('srcblock', TType.STRUCT, 3)
      self.srcblock.write(oprot)
      oprot.writeFieldEnd()
    if self.dstNamespaceId is not None:
      oprot.writeFieldBegin('dstNamespaceId', TType.STRUCT, 4)
      self.dstNamespaceId.write(oprot)
      oprot.writeFieldEnd()
    if self.destBlock is not None:
      oprot.writeFieldBegin('destBlock', TType.STRUCT, 5)
      self.destBlock.write(oprot)
      oprot.writeFieldEnd()
    if self.target is not None:
      oprot.writeFieldBegin('target', TType.STRUCT, 6)
      self.target.write(oprot)
      oprot.writeFieldEnd()
    if self.asynchronous is not None:
      oprot.writeFieldBegin('asynchronous', TType.BOOL, 7)
      oprot.writeBool(self.asynchronous)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class copyBlock_result:
  """
  Attributes:
   - ouch
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'ouch', (ThriftIOException, ThriftIOException.thrift_spec), None, ), # 1
  )

  def __init__(self, ouch=None,):
    self.ouch = ouch

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRUCT:
          self.ouch = ThriftIOException()
          self.ouch.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('copyBlock_result')
    if self.ouch is not None:
      oprot.writeFieldBegin('ouch', TType.STRUCT, 1)
      self.ouch.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getBlockPathInfo_args:
  """
  Attributes:
   - datanode
   - namespaceId
   - block
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'datanode', (TDatanodeID, TDatanodeID.thrift_spec), None, ), # 1
    (2, TType.STRUCT, 'namespaceId', (ThdfsNamespaceId, ThdfsNamespaceId.thrift_spec), None, ), # 2
    (3, TType.STRUCT, 'block', (ThdfsBlock, ThdfsBlock.thrift_spec), None, ), # 3
  )

  def __init__(self, datanode=None, namespaceId=None, block=None,):
    self.datanode = datanode
    self.namespaceId = namespaceId
    self.block = block

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRUCT:
          self.datanode = TDatanodeID()
          self.datanode.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRUCT:
          self.namespaceId = ThdfsNamespaceId()
          self.namespaceId.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.STRUCT:
          self.block = ThdfsBlock()
          self.block.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getBlockPathInfo_args')
    if self.datanode is not None:
      oprot.writeFieldBegin('datanode', TType.STRUCT, 1)
      self.datanode.write(oprot)
      oprot.writeFieldEnd()
    if self.namespaceId is not None:
      oprot.writeFieldBegin('namespaceId', TType.STRUCT, 2)
      self.namespaceId.write(oprot)
      oprot.writeFieldEnd()
    if self.block is not None:
      oprot.writeFieldBegin('block', TType.STRUCT, 3)
      self.block.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getBlockPathInfo_result:
  """
  Attributes:
   - success
   - ouch
  """

  thrift_spec = (
    (0, TType.STRUCT, 'success', (ThdfsBlockPath, ThdfsBlockPath.thrift_spec), None, ), # 0
    (1, TType.STRUCT, 'ouch', (ThriftIOException, ThriftIOException.thrift_spec), None, ), # 1
  )

  def __init__(self, success=None, ouch=None,):
    self.success = success
    self.ouch = ouch

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 0:
        if ftype == TType.STRUCT:
          self.success = ThdfsBlockPath()
          self.success.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 1:
        if ftype == TType.STRUCT:
          self.ouch = ThriftIOException()
          self.ouch.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getBlockPathInfo_result')
    if self.success is not None:
      oprot.writeFieldBegin('success', TType.STRUCT, 0)
      self.success.write(oprot)
      oprot.writeFieldEnd()
    if self.ouch is not None:
      oprot.writeFieldBegin('ouch', TType.STRUCT, 1)
      self.ouch.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

# # Autogenerated by Thrift Compiler (0.7.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # Parameters:      - datanode      - namespaceId      - block      - keepLength      - targets      - deadline Parameters:      - datanode      - namespaceid      - block Parameters:      - datanode      - srcNamespaceId      - srcblock      - dstNamespaceId      - destBlock      - target      - asynchronous Parameters:      - datanode      - namespaceId      - block Parameters:      - datanode      - namespaceId      - block      - keepLength      - targets      - deadline Parameters:      - datanode      - namespaceid      - block Parameters:      - datanode      - srcNamespaceId      - srcblock      - dstNamespaceId      - destBlock      - target      - asynchronous Parameters:      - datanode      - namespaceId      - block # HELPER FUNCTIONS AND STRUCTURES Attributes:    - datanode    - namespaceId    - block    - keepLength    - targets    - deadline # 0 # 1 # 2 # 3 # 4 # 5 # 6 Attributes:    - success    - ouch # 0 # 1 Attributes:    - datanode    - namespaceid    - block # 0 # 1 # 2 # 3 Attributes:    - success    - ouch # 0 # 1 Attributes:    - datanode    - srcNamespaceId    - srcblock    - dstNamespaceId    - destBlock    - target    - asynchronous # 0 # 1 # 2 # 3 # 4 # 5 # 6 # 7 Attributes:    - ouch # 0 # 1 Attributes:    - datanode    - namespaceId    - block # 0 # 1 # 2 # 3 Attributes:    - success    - ouch # 0 # 1