saintstack commented on a change in pull request #2268: URL: https://github.com/apache/hbase/pull/2268#discussion_r471914215
########## File path: hbase-shell/src/main/ruby/hbase/admin.rb ########## @@ -664,6 +668,40 @@ def alter_status(table_name) puts 'Done.' end + #---------------------------------------------------------------------------------------------- + # Use our internal logic to convert from "spec string" format to a coprocessor descriptor + # + # Provided for backwards shell compatibility + # + # @param [String] spec_str + # @return [ColumnDescriptor] + def coprocessor_descriptor_from_spec_str(spec_str) + method = TableDescriptorBuilder.java_class.declared_method_smart :toCoprocessorDescriptor + method.accessible = true + result = method.invoke(nil, spec_str).to_java + # unpack java's Optional to be more rubonic + return result.isPresent ? result.get : nil + end + + #---------------------------------------------------------------------------------------------- + # Use CoprocessorDescriptorBuilder to convert a Hash to CoprocessorDescriptor + # + # @param [Hash] spec column descriptor specification + # @return [ColumnDescriptor] + def coprocessor_descriptor_from_hash(spec) + classname = spec['CLASSNAME'] + jar_path = spec['JAR_PATH'] + priority = spec['PRIORITY'] + properties = spec['PROPERTIES'] + + builder = CoprocessorDescriptorBuilder.newBuilder classname Review comment: Its ok not checking for nil classname? ########## File path: hbase-shell/src/main/ruby/shell/commands/alter.rb ########## @@ -53,19 +53,19 @@ def help hbase> alter 't1', MAX_FILESIZE => '134217728' -You can add a table coprocessor by setting a table coprocessor attribute: +You can add a table coprocessor by setting a table coprocessor attribute. Only the CLASSNAME is +required in the coprocessor specification. - hbase> alter 't1', - 'coprocessor'=>'hdfs:///foo.jar|com.foo.FooRegionObserver|1001|arg1=1,arg2=2' + hbase> alter 't1', 'coprocessor' => { + 'CLASSNAME' => 'org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver', + 'JAR_PATH' => 'hdfs:///foo.jar' + 'PRIORITY' => 12, + 'PROPERTIES' => {'a' => '17' } Review comment: nice ########## File path: hbase-shell/src/main/ruby/hbase/admin.rb ########## @@ -587,7 +588,10 @@ def get_column_families(table_name) def get_table_attributes(table_name) tableExists(table_name) - @admin.getDescriptor(TableName.valueOf(table_name)).toStringTableAttributes + td = @admin.getDescriptor TableName.valueOf(table_name) + method = td.java_class.declared_method :toStringTableAttributes + method.accessible = true Review comment: Do you want to say in comment why you are doing this access setting? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org