/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// This file contains protocol buffers that are used throughout HDFS -- i.e.
// by the client, server, and data transfer protocols.

option java_package = "org.apache.hadoop.hdfs.protocol.proto";
option java_outer_classname = "ClientDatanodeProtocolProtos";
option java_generic_services = true;
option java_generate_equals_and_hash = true;

import "hdfs.proto";

/**
 * block - block for which visible length is requested
 */
message GetReplicaVisibleLengthRequestProto {
  required ExtendedBlockProto block = 1;
}

/**
 * length - visible length of the block
 */
message GetReplicaVisibleLengthResponseProto {
  required uint64 length = 1;
}

/**
 * void request
 */
message RefreshNamenodesRequestProto {
}

/**
 * void response
 */
message RefreshNamenodesResponseProto {
}

/**
 * blockPool - block pool to be deleted
 * force - if false, delete the block pool only if it is empty.
 *         if true, delete the block pool even if it has blocks.
 */
message DeleteBlockPoolRequestProto {
  required string blockPool = 1;
  required bool force = 2;
}

/**
 * void response
 */
message DeleteBlockPoolResponseProto {
}

/**
 * Gets the file information where block and its metadata is stored
 * block - block for which path information is being requested
 * token - block token
 */
message GetBlockLocalPathInfoRequestProto {
  required ExtendedBlockProto block = 1;
  required BlockTokenIdentifierProto token = 2;
}

/**
 * block - block for which file path information is being returned
 * localPath - file path where the block data is stored
 * localMetaPath - file path where the block meta data is stored
 */
message GetBlockLocalPathInfoResponseProto {
  required ExtendedBlockProto block = 1;
  required string localPath = 2;
  required string localMetaPath = 3;
}

/**
 * Protocol used from client to the Datanode.
 * See the request and response for details of rpc call.
 */
service ClientDatanodeProtocolService {
  /**
   * Returns the visible length of the replica
   */
  rpc getReplicaVisibleLength(GetReplicaVisibleLengthRequestProto)
      returns(GetReplicaVisibleLengthResponseProto);

  /**
   * Refresh the list of federated namenodes from updated configuration.
   * Adds new namenodes and stops the deleted namenodes.
   */
  rpc refreshNamenodes(RefreshNamenodesRequestProto)
      returns(RefreshNamenodesResponseProto);

  /**
   * Delete the block pool from the datanode.
   */
  rpc deleteBlockPool(DeleteBlockPoolRequestProto)
      returns(DeleteBlockPoolResponseProto);

  /**
   * Retrieves the path names of the block file and metadata file stored on the
   * local file system.
   */
  rpc getBlockLocalPathInfo(GetBlockLocalPathInfoRequestProto)
      returns(GetBlockLocalPathInfoResponseProto);
}
