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

from . import MasterForClient_pb2 as MasterForClient__pb2


class MFCStub(object):
  """这是控制服务器Master为客户Client提供的服务MFC的协议

  """

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

    Args:
      channel: A grpc.Channel.
    """
    self.getFiletree = channel.unary_stream(
        '/MFC/getFiletree',
        request_serializer=MasterForClient__pb2.EmptyArg.SerializeToString,
        response_deserializer=MasterForClient__pb2.Str.FromString,
        )
    self.getChunkInfoAndAllocatedDataServer = channel.unary_stream(
        '/MFC/getChunkInfoAndAllocatedDataServer',
        request_serializer=MasterForClient__pb2.getChunkInfoAndAllocatedDataServerRequest.SerializeToString,
        response_deserializer=MasterForClient__pb2.ChunkStructor.FromString,
        )
    self.createFolder = channel.unary_unary(
        '/MFC/createFolder',
        request_serializer=MasterForClient__pb2.createFolderRequest.SerializeToString,
        response_deserializer=MasterForClient__pb2.ACK.FromString,
        )
    self.requestDownloadFromMaster = channel.unary_stream(
        '/MFC/requestDownloadFromMaster',
        request_serializer=MasterForClient__pb2.downloadRequestInfo.SerializeToString,
        response_deserializer=MasterForClient__pb2.targetInfo.FromString,
        )
    self.deleteFile = channel.unary_unary(
        '/MFC/deleteFile',
        request_serializer=MasterForClient__pb2.FilePath.SerializeToString,
        response_deserializer=MasterForClient__pb2.ACK.FromString,
        )


class MFCServicer(object):
  """这是控制服务器Master为客户Client提供的服务MFC的协议

  """

  def getFiletree(self, request, context):
    """服务：为客户提供文件目录树结构
    请求：无内容请求
    返回：存储文件路径的字符串流
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def getChunkInfoAndAllocatedDataServer(self, request, context):
    """事务：文件上传
    服务：客户获取文件分块信息并申请Data Server以供文件上传
    请求：预上传文件大小和在DFS中存放路径
    返回：状态码、分配的上传服务器（Data Server）信息、文件分块信息
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def createFolder(self, request, context):
    """服务：创建文件夹
    请求：文件夹路径
    返回：状态🏇
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def requestDownloadFromMaster(self, request, context):
    """事物：文件下载
    服务：客户获取文件信息并申请Data Server以供文件下载
    请求：预下载文件在DFS中存放路径
    返回：状态码、分配的下载服务器（Data Server）信息、文件分块信息
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def deleteFile(self, request, context):
    """事物：文件删除
    服务：客户删除指定路径下的某个文件
    请求：文件路径
    返回：状态码，返回信息
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')


def add_MFCServicer_to_server(servicer, server):
  rpc_method_handlers = {
      'getFiletree': grpc.unary_stream_rpc_method_handler(
          servicer.getFiletree,
          request_deserializer=MasterForClient__pb2.EmptyArg.FromString,
          response_serializer=MasterForClient__pb2.Str.SerializeToString,
      ),
      'getChunkInfoAndAllocatedDataServer': grpc.unary_stream_rpc_method_handler(
          servicer.getChunkInfoAndAllocatedDataServer,
          request_deserializer=MasterForClient__pb2.getChunkInfoAndAllocatedDataServerRequest.FromString,
          response_serializer=MasterForClient__pb2.ChunkStructor.SerializeToString,
      ),
      'createFolder': grpc.unary_unary_rpc_method_handler(
          servicer.createFolder,
          request_deserializer=MasterForClient__pb2.createFolderRequest.FromString,
          response_serializer=MasterForClient__pb2.ACK.SerializeToString,
      ),
      'requestDownloadFromMaster': grpc.unary_stream_rpc_method_handler(
          servicer.requestDownloadFromMaster,
          request_deserializer=MasterForClient__pb2.downloadRequestInfo.FromString,
          response_serializer=MasterForClient__pb2.targetInfo.SerializeToString,
      ),
      'deleteFile': grpc.unary_unary_rpc_method_handler(
          servicer.deleteFile,
          request_deserializer=MasterForClient__pb2.FilePath.FromString,
          response_serializer=MasterForClient__pb2.ACK.SerializeToString,
      ),
  }
  generic_handler = grpc.method_handlers_generic_handler(
      'MFC', rpc_method_handlers)
  server.add_generic_rpc_handlers((generic_handler,))
