hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/storage/ContainerProtocolCalls.java
public static void writeSmallFile(XceiverClientSpi client,
      String containerName, String key, byte[] data, String traceID)
      throws IOException {

    KeyData containerKeyData =
        KeyData.newBuilder().setContainerName(containerName).setName(key)
            .build();
    PutKeyRequestProto.Builder createKeyRequest =
        PutKeyRequestProto.newBuilder()
            .setPipeline(client.getPipeline().getProtobufMessage())
            .setKeyData(containerKeyData);

    KeyValue keyValue =
        KeyValue.newBuilder().setKey("OverWriteRequested").setValue("true")
            .build();
    ChunkInfo chunk =
        ChunkInfo.newBuilder().setChunkName(key + "_chunk").setOffset(0)
            .setLen(data.length).addMetadata(keyValue).build();

    PutSmallFileRequestProto putSmallFileRequest =
        PutSmallFileRequestProto.newBuilder().setChunkInfo(chunk)
            .setKey(createKeyRequest).setData(ByteString.copyFrom(data))
            .build();

    String id = client.getPipeline().getLeader().getUuidString();
    ContainerCommandRequestProto request =
        ContainerCommandRequestProto.newBuilder()
            .setCmdType(Type.PutSmallFile)
            .setTraceID(traceID)
            .setDatanodeUuid(id)
            .setPutSmallFile(putSmallFileRequest)
            .build();
    ContainerCommandResponseProto response = client.sendCommand(request);
    validateContainerResponse(response);
  }
/**
   * Allows writing a small file using single RPC. This takes the container
   * name, key name and data to write sends all that data to the container using
   * a single RPC. This API is designed to be used for files which are smaller
   * than 1 MB.
   *
   * @param client - client that communicates with the container.
   * @param containerName - Name of the container
   * @param key - Name of the Key
   * @param data - Data to be written into the container.
   * @param traceID - Trace ID for logging purpose.
   * @throws IOException
   */
Allows writing a small file using single RPC. This takes the container
name, key name and data to write sends all that data to the container using
a single RPC. This API is designed to be used for files which are smaller
than 1 MB.

@param client - client that communicates with the container.
@param containerName - Name of the container
@param key - Name of the Key
@param data - Data to be written into the container.
@param traceID - Trace ID for logging purpose.
Allows writing a small file using single RPC . This takes the container name key name and data to write sends all that data to the container using a single RPC . This API is designed to be used for files which are smaller than 1 MB . @param client - client that communicates with the container . @param containerName - Name of the container @param key - Name of the Key @param data - Data to be written into the container . @param traceID - Trace ID for logging purpose .
public static void writeSmallFile(XceiverClientSpi client,
      String containerName, String key, byte[] data, String traceID)
      throws IOException {
    KeyData containerKeyData =
        KeyData.newBuilder().setContainerName(containerName).setName(key)
            .build();
    PutKeyRequestProto.Builder createKeyRequest =
        PutKeyRequestProto.newBuilder()
            .setPipeline(client.getPipeline().getProtobufMessage())
            .setKeyData(containerKeyData);
    KeyValue keyValue =
        KeyValue.newBuilder().setKey("OverWriteRequested").setValue("true")
            .build();
    ChunkInfo chunk =
        ChunkInfo.newBuilder().setChunkName(key + "_chunk").setOffset(0)
            .setLen(data.length).addMetadata(keyValue).build();
    PutSmallFileRequestProto putSmallFileRequest =
        PutSmallFileRequestProto.newBuilder().setChunkInfo(chunk)
            .setKey(createKeyRequest).setData(ByteString.copyFrom(data))
            .build();
    String id = client.getPipeline().getLeader().getUuidString();
    ContainerCommandRequestProto request =
        ContainerCommandRequestProto.newBuilder()
            .setCmdType(Type.PutSmallFile)
            .setTraceID(traceID)
            .setDatanodeUuid(id)
            .setPutSmallFile(putSmallFileRequest)
            .build();
    ContainerCommandResponseProto response = client.sendCommand(request);
    validateContainerResponse(response);
  }
public static void writeSmallFile ( XceiverClientSpi client , String containerName , String key , byte [ ] data , String traceID ) throws IOException { KeyData containerKeyData = KeyData . newBuilder ( ) . setContainerName ( containerName ) . setName ( key ) . build ( ) ; PutKeyRequestProto . Builder createKeyRequest = PutKeyRequestProto . newBuilder ( ) . setPipeline ( client . getPipeline ( ) . getProtobufMessage ( ) ) . setKeyData ( containerKeyData ) ; KeyValue keyValue = KeyValue . newBuilder ( ) . setKey ( "OverWriteRequested" ) . setValue ( "true" ) . build ( ) ; ChunkInfo chunk = ChunkInfo . newBuilder ( ) . setChunkName ( key + "_chunk" ) . setOffset ( 0 ) . setLen ( data . length ) . addMetadata ( keyValue ) . build ( ) ; PutSmallFileRequestProto putSmallFileRequest = PutSmallFileRequestProto . newBuilder ( ) . setChunkInfo ( chunk ) . setKey ( createKeyRequest ) . setData ( ByteString . copyFrom ( data ) ) . build ( ) ; String id = client . getPipeline ( ) . getLeader ( ) . getUuidString ( ) ; ContainerCommandRequestProto request = ContainerCommandRequestProto . newBuilder ( ) . setCmdType ( Type . PutSmallFile ) . setTraceID ( traceID ) . setDatanodeUuid ( id ) . setPutSmallFile ( putSmallFileRequest ) . build ( ) ; ContainerCommandResponseProto response = client . sendCommand ( request ) ; validateContainerResponse ( response ) ; }
Allows writing a small file using single RPC.
Allows writing a small file using single RPC .