hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneBucket.java
public void putKey(String keyName, String data) throws OzoneException {
    if ((keyName == null) || keyName.isEmpty()) {
      throw new OzoneRestClientException("Invalid key Name.");
    }

    if (data == null) {
      throw new OzoneRestClientException("Invalid data.");
    }

    HttpPut putRequest = null;
    InputStream is = null;
    try (CloseableHttpClient httpClient = HddsClientUtils.newHttpClient()) {
      URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
      builder.setPath("/" + getVolume().getVolumeName() + "/" + getBucketName()
          + "/" + keyName).build();

      putRequest = getVolume().getClient().getHttpPut(builder.toString());

      is = new ByteArrayInputStream(data.getBytes(ENCODING));
      putRequest.setEntity(new InputStreamEntity(is, data.length()));
      is.mark(data.length());
      try {
        putRequest.setHeader(Header.CONTENT_MD5, DigestUtils.md5Hex(is));
      } finally {
        is.reset();
      }
      executePutKey(putRequest, httpClient);
    } catch (IOException | URISyntaxException ex) {
      throw new OzoneRestClientException(ex.getMessage(), ex);
    } finally {
      IOUtils.closeStream(is);
      releaseConnection(putRequest);
    }
  }
/**
   * Puts an Object in Ozone bucket.
   *
   * @param keyName - Name of the key
   * @param data    - Data that you want to put
   * @throws OzoneException
   */
Puts an Object in Ozone bucket.
@param keyName - Name of the key
@param data    - Data that you want to put
@throws OzoneException
Puts an Object in Ozone bucket . @param keyName - Name of the key @param data - Data that you want to put @throws OzoneException
public void putKey(String keyName, String data) throws OzoneException {
    if ((keyName == null) || keyName.isEmpty()) {
      throw new OzoneRestClientException("Invalid key Name.");
    }
    if (data == null) {
      throw new OzoneRestClientException("Invalid data.");
    }
    HttpPut putRequest = null;
    InputStream is = null;
    try (CloseableHttpClient httpClient = HddsClientUtils.newHttpClient()) {
      URIBuilder builder = new URIBuilder(volume.getClient().getEndPointURI());
      builder.setPath("/" + getVolume().getVolumeName() + "/" + getBucketName()
          + "/" + keyName).build();
      putRequest = getVolume().getClient().getHttpPut(builder.toString());
      is = new ByteArrayInputStream(data.getBytes(ENCODING));
      putRequest.setEntity(new InputStreamEntity(is, data.length()));
      is.mark(data.length());
      try {
        putRequest.setHeader(Header.CONTENT_MD5, DigestUtils.md5Hex(is));
      } finally {
        is.reset();
      }
      executePutKey(putRequest, httpClient);
    } catch (IOException | URISyntaxException ex) {
      throw new OzoneRestClientException(ex.getMessage(), ex);
    } finally {
      IOUtils.closeStream(is);
      releaseConnection(putRequest);
    }
  }
public void putKey ( String keyName , String data ) throws OzoneException { if ( ( keyName == null ) || keyName . isEmpty ( ) ) { throw new OzoneRestClientException ( "Invalid key Name." ) ; } if ( data == null ) { throw new OzoneRestClientException ( "Invalid data." ) ; } HttpPut putRequest = null ; InputStream is = null ; try ( CloseableHttpClient httpClient = HddsClientUtils . newHttpClient ( ) ) { URIBuilder builder = new URIBuilder ( volume . getClient ( ) . getEndPointURI ( ) ) ; builder . setPath ( "/" + getVolume ( ) . getVolumeName ( ) + "/" + getBucketName ( ) + "/" + keyName ) . build ( ) ; putRequest = getVolume ( ) . getClient ( ) . getHttpPut ( builder . toString ( ) ) ; is = new ByteArrayInputStream ( data . getBytes ( ENCODING ) ) ; putRequest . setEntity ( new InputStreamEntity ( is , data . length ( ) ) ) ; is . mark ( data . length ( ) ) ; try { putRequest . setHeader ( Header . CONTENT_MD5 , DigestUtils . md5Hex ( is ) ) ; } finally { is . reset ( ) ; } executePutKey ( putRequest , httpClient ) ; } catch ( IOException | URISyntaxException ex ) { throw new OzoneRestClientException ( ex . getMessage ( ) , ex ) ; } finally { IOUtils . closeStream ( is ) ; releaseConnection ( putRequest ) ; } }
Puts an Object in Ozone bucket.
Puts an Object in Ozone bucket .