hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/Dispatcher.java
private ContainerCommandResponseProto handlePutSmallFile(
      ContainerCommandRequestProto msg) throws StorageContainerException {

    if (!msg.hasPutSmallFile()) {
      LOG.debug("Malformed put small file request. trace ID: {}",
          msg.getTraceID());
      return ContainerUtils.malformedRequest(msg);
    }
    try {

      Pipeline pipeline =
          Pipeline.getFromProtoBuf(msg.getPutSmallFile()
              .getKey().getPipeline());

      Preconditions.checkNotNull(pipeline);
      if (!this.containerManager.isOpen(pipeline.getContainerName())) {
        throw new StorageContainerException("Write to closed container.",
            CLOSED_CONTAINER_IO);
      }
      KeyData keyData = KeyData.getFromProtoBuf(msg.getPutSmallFile().getKey()
          .getKeyData());
      ChunkInfo chunkInfo = ChunkInfo.getFromProtoBuf(msg.getPutSmallFile()
          .getChunkInfo());
      byte[] data = msg.getPutSmallFile().getData().toByteArray();

      metrics.incContainerBytesStats(Type.PutSmallFile, data.length);
      this.containerManager.getChunkManager().writeChunk(pipeline, keyData
          .getKeyName(), chunkInfo, data, ContainerProtos.Stage.COMBINED);
      List<ContainerProtos.ChunkInfo> chunks = new LinkedList<>();
      chunks.add(chunkInfo.getProtoBufMessage());
      keyData.setChunks(chunks);
      this.containerManager.getKeyManager().putKey(pipeline, keyData);
      return FileUtils.getPutFileResponse(msg);
    } catch (StorageContainerException e) {
      return ContainerUtils.logAndReturnError(LOG, e, msg);
    } catch (IOException e) {
      throw new StorageContainerException("Put Small File Failed.", e,
          PUT_SMALL_FILE_ERROR);
    }
  }
/**
   * Handles writing a chunk and associated key using single RPC.
   *
   * @param msg - Message.
   * @return ContainerCommandResponseProto
   * @throws StorageContainerException
   */
Handles writing a chunk and associated key using single RPC.
@param msg - Message.
Handles writing a chunk and associated key using single RPC . @param msg - Message .
private ContainerCommandResponseProto handlePutSmallFile(
      ContainerCommandRequestProto msg) throws StorageContainerException {
    if (!msg.hasPutSmallFile()) {
      LOG.debug("Malformed put small file request. trace ID: {}",
          msg.getTraceID());
      return ContainerUtils.malformedRequest(msg);
    }
    try {
      Pipeline pipeline =
          Pipeline.getFromProtoBuf(msg.getPutSmallFile()
              .getKey().getPipeline());
      Preconditions.checkNotNull(pipeline);
      if (!this.containerManager.isOpen(pipeline.getContainerName())) {
        throw new StorageContainerException("Write to closed container.",
            CLOSED_CONTAINER_IO);
      }
      KeyData keyData = KeyData.getFromProtoBuf(msg.getPutSmallFile().getKey()
          .getKeyData());
      ChunkInfo chunkInfo = ChunkInfo.getFromProtoBuf(msg.getPutSmallFile()
          .getChunkInfo());
      byte[] data = msg.getPutSmallFile().getData().toByteArray();
      metrics.incContainerBytesStats(Type.PutSmallFile, data.length);
      this.containerManager.getChunkManager().writeChunk(pipeline, keyData
          .getKeyName(), chunkInfo, data, ContainerProtos.Stage.COMBINED);
      List<ContainerProtos.ChunkInfo> chunks = new LinkedList<>();
      chunks.add(chunkInfo.getProtoBufMessage());
      keyData.setChunks(chunks);
      this.containerManager.getKeyManager().putKey(pipeline, keyData);
      return FileUtils.getPutFileResponse(msg);
    } catch (StorageContainerException e) {
      return ContainerUtils.logAndReturnError(LOG, e, msg);
    } catch (IOException e) {
      throw new StorageContainerException("Put Small File Failed.", e,
          PUT_SMALL_FILE_ERROR);
    }
  }
private ContainerCommandResponseProto handlePutSmallFile ( ContainerCommandRequestProto msg ) throws StorageContainerException { if ( ! msg . hasPutSmallFile ( ) ) { LOG . debug ( "Malformed put small file request. trace ID: {}" , msg . getTraceID ( ) ) ; return ContainerUtils . malformedRequest ( msg ) ; } try { Pipeline pipeline = Pipeline . getFromProtoBuf ( msg . getPutSmallFile ( ) . getKey ( ) . getPipeline ( ) ) ; Preconditions . checkNotNull ( pipeline ) ; if ( ! this . containerManager . isOpen ( pipeline . getContainerName ( ) ) ) { throw new StorageContainerException ( "Write to closed container." , CLOSED_CONTAINER_IO ) ; } KeyData keyData = KeyData . getFromProtoBuf ( msg . getPutSmallFile ( ) . getKey ( ) . getKeyData ( ) ) ; ChunkInfo chunkInfo = ChunkInfo . getFromProtoBuf ( msg . getPutSmallFile ( ) . getChunkInfo ( ) ) ; byte [ ] data = msg . getPutSmallFile ( ) . getData ( ) . toByteArray ( ) ; metrics . incContainerBytesStats ( Type . PutSmallFile , data . length ) ; this . containerManager . getChunkManager ( ) . writeChunk ( pipeline , keyData . getKeyName ( ) , chunkInfo , data , ContainerProtos . Stage . COMBINED ) ; List < ContainerProtos . ChunkInfo > chunks = new LinkedList < > ( ) ; chunks . add ( chunkInfo . getProtoBufMessage ( ) ) ; keyData . setChunks ( chunks ) ; this . containerManager . getKeyManager ( ) . putKey ( pipeline , keyData ) ; return FileUtils . getPutFileResponse ( msg ) ; } catch ( StorageContainerException e ) { return ContainerUtils . logAndReturnError ( LOG , e , msg ) ; } catch ( IOException e ) { throw new StorageContainerException ( "Put Small File Failed." , e , PUT_SMALL_FILE_ERROR ) ; } }
Handles writing a chunk and associated key using single RPC.
Handles writing a chunk and associated key using single RPC .