[ 
https://issues.apache.org/jira/browse/HBASE-20119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17178013#comment-17178013
 ] 

Elliot Miller commented on HBASE-20119:
---------------------------------------

Hey [~chia7712],
{quote}TableDescriptorBuilder#addCoprocessorWithSpec should be removed since it 
exposes how we format the cp information.
{quote}
We still use coprocessor "spec strings" in the {{alter}} command of 
hbase-shell. I think that for compatibility, we will want to keep accepting 
this form of specification. I think the best way to do this will be to create a 
new static method on ColumnDescriptorBuilder called "fromSpecString" based on 
the currently private method TableDescriptorBuilder.toCoprocessorDescriptor. 
I'm happy to take care of this, but I'd love to get a second opinion first.

I bring this up now because the method addCoprocessorWithSpec is no longer 
accessible to the shell, which means that the shell cannot set coprocessors 
until we address this (See https://issues.apache.org/jira/browse/HBASE-24874).

> Introduce a pojo class to carry coprocessor information in order to make 
> TableDescriptorBuilder accept multiple cp at once
> --------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-20119
>                 URL: https://issues.apache.org/jira/browse/HBASE-20119
>             Project: HBase
>          Issue Type: Task
>            Reporter: Chia-Ping Tsai
>            Assignee: Chia-Ping Tsai
>            Priority: Minor
>             Fix For: 2.0.0
>
>         Attachments: HBASE-20119.branch-2.0.v0.addendum.patch, 
> HBASE-20119.branch-2.v0.patch, HBASE-20119.v0.patch.patch, 
> HBASE-20119.v1.patch.patch, HBASE-20119.v2.patch, HBASE-20119.v3.patch
>
>
> The way to add cp to TableDescriptorBuilder is shown below.
> {code:java}
> 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;
> }{code}
> When loading our config to create table with multiple cps, we have to write 
> the ugly for-loop.
> {code:java}
> val builder = TableDescriptorBuilder.newBuilde(tableName)
>   .setAAA()
>   .setBBB()
> cps.map(toHBaseCp).foreach(builder.addCoprocessor)
> cfs.map(toHBaseCf).foreach(builder.addColumnFamily)
> admin.createTable(builder.build())
> {code}
> 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.
> {code:java}
> admin.createTable(TableDescriptorBuilder.newBuilde(tableName)
> .addCoprocessor(cps.map(toHBaseCp).asJavaCollection)
> .addColumnFamily(cf.map(toHBaseCf).asJavaCollection)
> .setAAA()
> .setBBB()
> .build){code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to