Meter operations

Updated at:

Perform Meter operations by using the DataHub Java SDK.

Get a meter

Parameters

Parameter

Type

Description

projectName

String

The name of the project.

topicName

String

The name of the topic.

shardId

String

The shard ID.

Exceptions

Exception class

Error code

Description

DatahubClientException

-

The base class for all exceptions.

InvalidParameterException

InvalidParameter

InvalidCursor

The request contains invalid parameters.

AuthorizationFailureException

Unauthorized

An authorization signature parsing error. Verify that the AccessKey pair is correctly configured.

ResourceNotFoundException

ResourceNotFound

NoSuchProject

NoSuchTopic

NoSuchShard

NoSuchSubscription

NoSuchConnector

NoSuchMeteringInfo

The requested resource does not exist.

Note

This exception may be thrown if other requests are sent immediately after a Split or Merge operation.

Example

public static void getMeter(String projectName,String topicName) {
  String shardId = "5";
  try {
      GetMeterInfoResult getMeterInfoResult = datahubClient.getMeterInfo(projectName, topicName, shardId);
      System.out.println("get meter successful");
      System.out.println(getMeterInfoResult.getActiveTime() + "\t" + getMeterInfoResult.getStorage());
  } catch (DatahubClientException e) {
        System.out.println(e.getErrorMessage());      
  }
}