Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-20119

Introduce a pojo class to carry coprocessor information in order to make TableDescriptorBuilder accept multiple cp at once

    XMLWordPrintableJSON

Details

    • Task
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 2.0.0
    • None
    • None
    • Incompatible change, Reviewed
    • Hide
      1) Make all methods in TableDescriptorBuilder be setter pattern.
      addCoprocessor -> setCoprocessor
      addColumnFamily -> setColumnFamily
      (addCoprocessor and addColumnFamily are still in branch-2 but they are marked as deprecated)
      2) add CoprocessorDescriptor to carry cp information
      3) add CoprocessorDescriptorBuilder to build CoprocessorDescriptor
      4) TD disallow user to set negative priority to coprocessor since parsing the negative value will cause a exception
      Show
      1) Make all methods in TableDescriptorBuilder be setter pattern. addCoprocessor -> setCoprocessor addColumnFamily -> setColumnFamily (addCoprocessor and addColumnFamily are still in branch-2 but they are marked as deprecated) 2) add CoprocessorDescriptor to carry cp information 3) add CoprocessorDescriptorBuilder to build CoprocessorDescriptor 4) TD disallow user to set negative priority to coprocessor since parsing the negative value will cause a exception

    Description

      The way to add cp to TableDescriptorBuilder is shown below.

      public TableDescriptorBuilder addCoprocessor(String className) throws IOException {
        return addCoprocessor(className, null, Coprocessor.PRIORITY_USER, null);
      }
      
      public TableDescriptorBuilder addCoprocessor(String className, Path jarFilePath,
              int priority, final Map<String, String> kvs) throws IOException {
        desc.addCoprocessor(className, jarFilePath, priority, kvs);
        return this;
      }
      
      public TableDescriptorBuilder addCoprocessorWithSpec(final String specStr) throws IOException {
        desc.addCoprocessorWithSpec(specStr);
        return this;
      }

      When loading our config to create table with multiple cps, we have to write the ugly for-loop.

      val builder = TableDescriptorBuilder.newBuilde(tableName)
        .setAAA()
        .setBBB()
      cps.map(toHBaseCp).foreach(builder.addCoprocessor)
      cfs.map(toHBaseCf).foreach(builder.addColumnFamily)
      admin.createTable(builder.build())
      
      

      If we introduce a pojo to carry the cp data and add the method accepting multiple cps and cfs, it is easier to exercise the fluent interface of TableDescriptorBuilder.

      admin.createTable(TableDescriptorBuilder.newBuilde(tableName)
      .addCoprocessor(cps.map(toHBaseCp).asJavaCollection)
      .addColumnFamily(cf.map(toHBaseCf).asJavaCollection)
      .setAAA()
      .setBBB()
      .build)

       

       

      Attachments

        1. HBASE-20119.v0.patch.patch
          145 kB
          Chia-Ping Tsai
        2. HBASE-20119.v1.patch.patch
          147 kB
          Chia-Ping Tsai
        3. HBASE-20119.v2.patch
          184 kB
          Chia-Ping Tsai
        4. HBASE-20119.v3.patch
          191 kB
          Chia-Ping Tsai
        5. HBASE-20119.branch-2.v0.patch
          175 kB
          Chia-Ping Tsai
        6. HBASE-20119.branch-2.0.v0.addendum.patch
          7 kB
          Chia-Ping Tsai

        Issue Links

          Activity

            People

              chia7712 Chia-Ping Tsai
              chia7712 Chia-Ping Tsai
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: