# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc

from protocol import DataForMaster_pb2 as DataForMaster__pb2


class DFMStub(object):
  """这是数据服务器Server为控制服务器Master提供的服务DFM的协议

  """

  def __init__(self, channel):
    """Constructor.

    Args:
      channel: A grpc.Channel.
    """
    self.deleteChunkOnDataServer = channel.unary_unary(
        '/DFM/deleteChunkOnDataServer',
        request_serializer=DataForMaster__pb2.chunkID.SerializeToString,
        response_deserializer=DataForMaster__pb2.ACK1.FromString,
        )
    self.copyChunkBetweenDataServer = channel.unary_unary(
        '/DFM/copyChunkBetweenDataServer',
        request_serializer=DataForMaster__pb2.copyChunk.SerializeToString,
        response_deserializer=DataForMaster__pb2.ACK1.FromString,
        )
    self.recommitChunk = channel.unary_unary(
        '/DFM/recommitChunk',
        request_serializer=DataForMaster__pb2.chunkID.SerializeToString,
        response_deserializer=DataForMaster__pb2.ACK1.FromString,
        )
    self.heartbeat = channel.unary_unary(
        '/DFM/heartbeat',
        request_serializer=DataForMaster__pb2.heartrequest.SerializeToString,
        response_deserializer=DataForMaster__pb2.ACK1.FromString,
        )


class DFMServicer(object):
  """这是数据服务器Server为控制服务器Master提供的服务DFM的协议

  """

  def deleteChunkOnDataServer(self, request, context):
    """事物：chunk删除
    服务：master删除数据服务器上的chunk
    请求：chunkID
    返回：状态码
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def copyChunkBetweenDataServer(self, request, context):
    """事物：异常处理、备份
    服务：chunk从服务器复制到别的服务器上
    请求：将被复制的cid，发往新的服务器ip，port，新的cid
    返回：状态码
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def recommitChunk(self, request, context):
    """服务：提交文件块
    请求：文件块id
    返回：状态🏇
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def heartbeat(self, request, context):
    """服务：心跳包
    请求：无
    返回：状态
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')


def add_DFMServicer_to_server(servicer, server):
  rpc_method_handlers = {
      'deleteChunkOnDataServer': grpc.unary_unary_rpc_method_handler(
          servicer.deleteChunkOnDataServer,
          request_deserializer=DataForMaster__pb2.chunkID.FromString,
          response_serializer=DataForMaster__pb2.ACK1.SerializeToString,
      ),
      'copyChunkBetweenDataServer': grpc.unary_unary_rpc_method_handler(
          servicer.copyChunkBetweenDataServer,
          request_deserializer=DataForMaster__pb2.copyChunk.FromString,
          response_serializer=DataForMaster__pb2.ACK1.SerializeToString,
      ),
      'recommitChunk': grpc.unary_unary_rpc_method_handler(
          servicer.recommitChunk,
          request_deserializer=DataForMaster__pb2.chunkID.FromString,
          response_serializer=DataForMaster__pb2.ACK1.SerializeToString,
      ),
      'heartbeat': grpc.unary_unary_rpc_method_handler(
          servicer.heartbeat,
          request_deserializer=DataForMaster__pb2.heartrequest.FromString,
          response_serializer=DataForMaster__pb2.ACK1.SerializeToString,
      ),
  }
  generic_handler = grpc.method_handlers_generic_handler(
      'DFM', rpc_method_handlers)
  server.add_generic_rpc_handlers((generic_handler,))
