0
votes

I am trying to get the currently allocated RUs for a DocumentDB collection using Java SDK. Anyone have any inputs?

2
Please share any code that you’ve written so far regarding this and the issues you’re running into with that code. - Gaurav Mantri

2 Answers

0
votes

What you are looking for is a way to query for the Offer or OfferV2 of the collection.

As you can see here OfferV2 has a set and get method of the collection throughput. Offer (v1) will also contain the property as it's a Resource at it's code

You can read the offer using the readOffer(string collectionSelfLink) method in AsyncDocumentClient in order to retrieve the Offer and then use offer.getContent().getInt("offerThroughput"); to get the RU/s of the collection.

Casting it to OfferV2 should work as well which gives you access to the getOfferThroughput() (which for the record internally will do what the line above does)

0
votes

You can use

  public int getRequstUnits(DocumentClient client, DocumentCollection coll) {
        return getOffer(client, coll).getContent().getInt("offerThroughput");
  }

Look at the complete code sample here