Java API

    The Ozone client factory creates the ozone client. To get a RPC client we can call

    If the user want to create a client based on the configuration, then they can call.

    and an appropriate client based on configuration will be returned.

    Writing data using Ozone Client

    Once we have a client, we need to get a reference to the ObjectStore. This is done via

    An object store represents an active cluster against which the client is working.

    1. // Let us create a volume to store our game assets.
    2. // This uses default arguments for creating that volume.
    3. objectStore.createVolume("assets");
    4. // Let us verify that the volume got created.
    5. OzoneVolume assets = objectStore.getVolume("assets");

    It is possible to pass an array of arguments to the createVolume by creating volume arguments.

    At this point we have a usable volume and a bucket. Our volume is called assets and bucket is called videos.

    Now we can create a Key.

    With a bucket object the users can now read and write keys. The following code reads a video called intro.mp4 from the local disk and stores in the video bucket that we just created.

    1. // read data from the file, this is a user provided function.
    2. // Create an output stream and write data.
    3. OzoneOutputStream videoStream = video.createKey("intro.mp4", 1048576);
    4. videoStream.write(videoData);
    5. videoStream.close();
    6. // We can use the same bucket to read the file that we just wrote, by creating an input Stream.
    7. // Let us allocate a byte array to hold the video first.
    8. byte[] data = new byte[(int)1048576];
    9. OzoneInputStream introStream = video.readKey("intro.mp4");
    10. // read intro.mp4 into the data buffer
    11. introStream.read(data);