Parameter Configuration

  1. Before executing the sample code, you must change the values of the following parameters in the com.huawei.cloudtable.opentsdb.examples.OpenTsdbSample class in the sample code project.

      private final static String OPENTSDB_IP = "opentsdb-vdswm7gj45awlom.cloudtable.com";
      private final static int OPENTSDB_PORT = 4242;
    • OPENTSDB_IP: Change its value to the URL of OpenTSDB on the CloudTable cluster information page.
    • OPENTSDB_PORT: Change the port number to 4242.

  2. If IAM authentication is enabled for the CloudTable cluster, modify the following parameters in the com.huawei.cloudtable.opentsdb.examples.OpenTsdbSample class in the sample code project.

     private final static boolean securityMode = true;
     private final static String PROJECT_ID = "XXXXXX";
     private final static String USER = "XXXXXX";
     private final static String AK = "XXXXXX";
     private final static String TOKEN = "XXXXXX";
    • securityMode: Set it to true. If IAM authentication is disabled for the CloudTable cluster, this parameter must be set to false.

      The IAM authentication mode provides better security than the normal mode. Therefore, you are advised to enable IAM authentication for the CloudTable cluster and use IAM authentication in client or application code to connect to the cluster.

    • PROJECT_ID: Set it to the project ID. Move the cursor over your account in the upper right corner of the management console and click My Credential. On the Project List tab page, you can view the project ID.
    • USER: Set it to the IAM username. If the cluster is created by a user's sub-user, user must be set to Sub-user.End user when the sub-user accesses the cluster, and set to the user name when the end user accesses the cluster.
    • AK: indicates the ID of the access key. You can move your cursor over your account in the upper right corner of the management console and choose My Credential. Click Access Keys tab. On the Access Keys tab page, you can view the existing access keys or click Add Access Key to add an access key.
    • TOKEN: Generate a token using org.apache.hadoop.hbase.security.token.web.AKSKWebTokenCommonUtil#createPassword.

  3. (Optional) If the sample project is not used, the sample code needs to depend on the following third-party JAR files only.

    1. gson
      <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
      <dependency>
          <groupId>com.google.code.gson</groupId>
          <artifactId>gson</artifactId>
          <version>2.2.4</version>
      </dependency>
    2. httpcore
      <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
      <dependency>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpcore</artifactId>
          <version>4.4.4</version>
      </dependency>
    3. httpclient
      <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
      <dependency>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpclient</artifactId>
          <version>4.5.2</version>
      </dependency>

  4. A timeout interval must be set for each HTTP request using the following method:

    public static void addTimeout(HttpRequestBase req) {
      RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(5000)
          .setConnectionRequestTimeout(10000).setSocketTimeout(60000).build();
      req.setConfig(requestConfig);
    }