private boolean writeToAmbryReplica(BlobProperties blobProperties, ByteBuffer userMetaData, InputStream stream,
      BlobId blobId, ReplicaId replicaId, AtomicInteger correlationId, boolean enableVerboseLogging) throws Exception {
    ArrayList<BlobId> blobIds = new ArrayList<BlobId>();
    blobIds.add(blobId);
    ConnectedChannel blockingChannel = null;

    try {
      blockingChannel = connectionPool.checkOutConnection(replicaId.getDataNodeId().getHostname(),
          new Port(replicaId.getDataNodeId().getPort(), PortType.PLAINTEXT), 100000);
      int size = (int) blobProperties.getBlobSize();
      ByteBufferInputStream blobStream = new ByteBufferInputStream(stream, size);
      PutRequest putRequest =
          new PutRequest(correlationId.incrementAndGet(), "consumerThread", blobId, blobProperties, userMetaData,
              Unpooled.wrappedBuffer(blobStream.getByteBuffer()), size, BlobType.DataBlob, null);

      if (enableVerboseLogging) {
        System.out.println("Put Request to a replica : " + putRequest + " for blobId " + blobId);
      }
      PutResponse putResponse = getPutResponseFromStream(blockingChannel, putRequest, connectionPool);
      if (putResponse == null) {
        System.out.println("PutResponse to a replica " + replicaId + " failed with null Response for blobId " + blobId);
        blockingChannel = null;
        return false;
      } else {
        if (putResponse.getError() != ServerErrorCode.NoError
            && putResponse.getError() != ServerErrorCode.BlobAlreadyExists) {
          System.out.println(
              "PutResponse to a replica " + replicaId + " failed with Error code  " + putResponse.getError()
                  + " for blobId " + blobId);
          return false;
        }
        return true;
      }
    } finally {
      if (stream != null) {
        stream.close();
      }
      if (blockingChannel != null) {
        connectionPool.checkInConnection(blockingChannel);
      }
    }
  }
Adding a blob to a particular server.
@param stream stream containing the actual blob
@param blobId blob id generated by ambry
@param replicaId replica to which the blob has to be added
@param correlationId coorelation id to uniquely identify the call
@return true if write succeeds, else false
@throws Exception
ambry-tools/src/main/java/com/github/ambry/tools/admin/DirectoryUploader.java