hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/Dispatcher.java
private ContainerCommandResponseProto handleGetSmallFile(
      ContainerCommandRequestProto msg) throws StorageContainerException {
    ByteString dataBuf = ByteString.EMPTY;
    if (!msg.hasGetSmallFile()) {
      LOG.debug("Malformed get small file request. trace ID: {}",
          msg.getTraceID());
      return ContainerUtils.malformedRequest(msg);
    }
    try {
      Pipeline pipeline =
          Pipeline.getFromProtoBuf(msg.getGetSmallFile()
              .getKey().getPipeline());

      long bytes = 0;
      Preconditions.checkNotNull(pipeline);
      KeyData keyData = KeyData.getFromProtoBuf(msg.getGetSmallFile()
          .getKey().getKeyData());
      KeyData data = this.containerManager.getKeyManager().getKey(keyData);
      ContainerProtos.ChunkInfo c = null;
      for (ContainerProtos.ChunkInfo chunk : data.getChunks()) {
        bytes += chunk.getSerializedSize();
        ByteString current =
            ByteString.copyFrom(this.containerManager.getChunkManager()
                .readChunk(
                    pipeline, keyData.getKeyName(), ChunkInfo.getFromProtoBuf(
                        chunk)));
        dataBuf = dataBuf.concat(current);
        c = chunk;
      }
      metrics.incContainerBytesStats(Type.GetSmallFile, bytes);
      return FileUtils.getGetSmallFileResponse(msg, dataBuf.toByteArray(),
          ChunkInfo.getFromProtoBuf(c));
    } catch (StorageContainerException e) {
      return ContainerUtils.logAndReturnError(LOG, e, msg);
    } catch (IOException e) {
      throw new StorageContainerException("Get Small File Failed", e,
          GET_SMALL_FILE_ERROR);
    }
  }
/**
   * Handles getting a data stream using a key. This helps in reducing the RPC
   * overhead for small files.
   *
   * @param msg - ContainerCommandRequestProto
   * @return ContainerCommandResponseProto
   * @throws StorageContainerException
   */
Handles getting a data stream using a key. This helps in reducing the RPC
overhead for small files.


Handles getting a data stream using a key . This helps in reducing the RPC overhead for small files .
private ContainerCommandResponseProto handleGetSmallFile(
      ContainerCommandRequestProto msg) throws StorageContainerException {
    ByteString dataBuf = ByteString.EMPTY;
    if (!msg.hasGetSmallFile()) {
      LOG.debug("Malformed get small file request. trace ID: {}",
          msg.getTraceID());
      return ContainerUtils.malformedRequest(msg);
    }
    try {
      Pipeline pipeline =
          Pipeline.getFromProtoBuf(msg.getGetSmallFile()
              .getKey().getPipeline());
      long bytes = 0;
      Preconditions.checkNotNull(pipeline);
      KeyData keyData = KeyData.getFromProtoBuf(msg.getGetSmallFile()
          .getKey().getKeyData());
      KeyData data = this.containerManager.getKeyManager().getKey(keyData);
      ContainerProtos.ChunkInfo c = null;
      for (ContainerProtos.ChunkInfo chunk : data.getChunks()) {
        bytes += chunk.getSerializedSize();
        ByteString current =
            ByteString.copyFrom(this.containerManager.getChunkManager()
                .readChunk(
                    pipeline, keyData.getKeyName(), ChunkInfo.getFromProtoBuf(
                        chunk)));
        dataBuf = dataBuf.concat(current);
        c = chunk;
      }
      metrics.incContainerBytesStats(Type.GetSmallFile, bytes);
      return FileUtils.getGetSmallFileResponse(msg, dataBuf.toByteArray(),
          ChunkInfo.getFromProtoBuf(c));
    } catch (StorageContainerException e) {
      return ContainerUtils.logAndReturnError(LOG, e, msg);
    } catch (IOException e) {
      throw new StorageContainerException("Get Small File Failed", e,
          GET_SMALL_FILE_ERROR);
    }
  }
private ContainerCommandResponseProto handleGetSmallFile ( ContainerCommandRequestProto msg ) throws StorageContainerException { ByteString dataBuf = ByteString . EMPTY ; if ( ! msg . hasGetSmallFile ( ) ) { LOG . debug ( "Malformed get small file request. trace ID: {}" , msg . getTraceID ( ) ) ; return ContainerUtils . malformedRequest ( msg ) ; } try { Pipeline pipeline = Pipeline . getFromProtoBuf ( msg . getGetSmallFile ( ) . getKey ( ) . getPipeline ( ) ) ; long bytes = 0 ; Preconditions . checkNotNull ( pipeline ) ; KeyData keyData = KeyData . getFromProtoBuf ( msg . getGetSmallFile ( ) . getKey ( ) . getKeyData ( ) ) ; KeyData data = this . containerManager . getKeyManager ( ) . getKey ( keyData ) ; ContainerProtos . ChunkInfo c = null ; for ( ContainerProtos . ChunkInfo chunk : data . getChunks ( ) ) { bytes += chunk . getSerializedSize ( ) ; ByteString current = ByteString . copyFrom ( this . containerManager . getChunkManager ( ) . readChunk ( pipeline , keyData . getKeyName ( ) , ChunkInfo . getFromProtoBuf ( chunk ) ) ) ; dataBuf = dataBuf . concat ( current ) ; c = chunk ; } metrics . incContainerBytesStats ( Type . GetSmallFile , bytes ) ; return FileUtils . getGetSmallFileResponse ( msg , dataBuf . toByteArray ( ) , ChunkInfo . getFromProtoBuf ( c ) ) ; } catch ( StorageContainerException e ) { return ContainerUtils . logAndReturnError ( LOG , e , msg ) ; } catch ( IOException e ) { throw new StorageContainerException ( "Get Small File Failed" , e , GET_SMALL_FILE_ERROR ) ; } }
Handles getting a data stream using a key.
Handles getting a data stream using a key .