diff --git a/hbase-server/src/main/ruby/shell.rb b/hbase-server/src/main/ruby/shell.rb index ba72daa..8576dae 100644 --- a/hbase-server/src/main/ruby/shell.rb +++ b/hbase-server/src/main/ruby/shell.rb @@ -257,12 +257,12 @@ Shell.load_command_group( 'namespace', :full_name => 'NAMESPACE MANAGEMENT COMMANDS', :commands => %w[ - namespace_create - namespace_drop - namespace_alter - namespace_describe - namespace_list - namespace_list_tables + create_namespace + drop_namespace + alter_namespace + describe_namespace + list_namespace + list_namespace_tables ] ) diff --git a/hbase-server/src/main/ruby/shell/commands/alter_namespace.rb b/hbase-server/src/main/ruby/shell/commands/alter_namespace.rb new file mode 100644 index 0000000..760bbf7 --- /dev/null +++ b/hbase-server/src/main/ruby/shell/commands/alter_namespace.rb @@ -0,0 +1,44 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module Shell + module Commands + class AlterNamespace < Command + def help + return <<-EOF +Alter namespace properties. + +To add/modify a property: + + hbase> alter_namespace 'ns1', {METHOD => 'set', 'PROERTY_NAME' => 'PROPERTY_VALUE'} + +To delete a property: + + hbase> alter_namespace 'ns1', {METHOD => 'unset', NAME=>'PROERTY_NAME'} +EOF + end + + def command(namespace, *args) + format_simple_command do + admin.alter_namespace(namespace, *args) + end + end + end + end +end diff --git a/hbase-server/src/main/ruby/shell/commands/create_namespace.rb b/hbase-server/src/main/ruby/shell/commands/create_namespace.rb new file mode 100644 index 0000000..3259eb6 --- /dev/null +++ b/hbase-server/src/main/ruby/shell/commands/create_namespace.rb @@ -0,0 +1,41 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module Shell + module Commands + class CreateNamespace < Command + def help + return <<-EOF +Create namespace; pass namespace name, +and optionally a dictionary of namespace configuration. +Examples: + + hbase> create_namespace 'ns1' + hbase> create_namespace 'ns1', {'PROERTY_NAME'=>'PROPERTY_VALUE'} +EOF + end + + def command(namespace, *args) + format_simple_command do + admin.create_namespace(namespace, *args) + end + end + end + end +end diff --git a/hbase-server/src/main/ruby/shell/commands/describe_namespace.rb b/hbase-server/src/main/ruby/shell/commands/describe_namespace.rb new file mode 100644 index 0000000..cf135da --- /dev/null +++ b/hbase-server/src/main/ruby/shell/commands/describe_namespace.rb @@ -0,0 +1,41 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module Shell + module Commands + class DescribeNamespace < Command + def help + return <<-EOF +Describe the named namespace. For example: + hbase> describe_namespace 'ns1' +EOF + end + + def command(namespace) + now = Time.now + + desc = admin.describe_namespace(namespace) + + formatter.header([ "DESCRIPTION" ], [ 64 ]) + formatter.row([ desc ], true, [ 64 ]) + formatter.footer(now) + end + end + end +end diff --git a/hbase-server/src/main/ruby/shell/commands/drop_namespace.rb b/hbase-server/src/main/ruby/shell/commands/drop_namespace.rb new file mode 100644 index 0000000..b030d27 --- /dev/null +++ b/hbase-server/src/main/ruby/shell/commands/drop_namespace.rb @@ -0,0 +1,36 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module Shell + module Commands + class DropNamespace < Command + def help + return <<-EOF +Drop the named namespace. The namespace must be empty. +EOF + end + + def command(namespace) + format_simple_command do + admin.drop_namespace(namespace) + end + end + end + end +end diff --git a/hbase-server/src/main/ruby/shell/commands/list_namespace.rb b/hbase-server/src/main/ruby/shell/commands/list_namespace.rb new file mode 100644 index 0000000..0b577fe --- /dev/null +++ b/hbase-server/src/main/ruby/shell/commands/list_namespace.rb @@ -0,0 +1,47 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module Shell + module Commands + class ListNamespace < Command + def help + return <<-EOF +List all namespaces in hbase. Optional regular expression parameter could +be used to filter the output. Examples: + + hbase> list_namespace + hbase> list_namespace 'abc.*' +EOF + end + + def command(regex = ".*") + now = Time.now + formatter.header([ "NAMESPACE" ]) + + regex = /#{regex}/ unless regex.is_a?(Regexp) + list = admin.list_namespace.grep(regex) + list.each do |table| + formatter.row([ table ]) + end + + formatter.footer(now, list.size) + end + end + end +end diff --git a/hbase-server/src/main/ruby/shell/commands/list_namespace_tables.rb b/hbase-server/src/main/ruby/shell/commands/list_namespace_tables.rb new file mode 100644 index 0000000..29e1812 --- /dev/null +++ b/hbase-server/src/main/ruby/shell/commands/list_namespace_tables.rb @@ -0,0 +1,45 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module Shell + module Commands + class ListNamespaceTables < Command + def help + return <<-EOF +List all tables that are members of the namespace. +Examples: + + hbase> list_namespace_tables 'ns1' +EOF + end + + def command(namespace) + now = Time.now + formatter.header([ "TABLE" ]) + + list = admin.list_namespace_tables(namespace) + list.each do |table| + formatter.row([ table ]) + end + + formatter.footer(now, list.size) + end + end + end +end diff --git a/hbase-server/src/main/ruby/shell/commands/namespace_alter.rb b/hbase-server/src/main/ruby/shell/commands/namespace_alter.rb deleted file mode 100644 index a25c740..0000000 --- a/hbase-server/src/main/ruby/shell/commands/namespace_alter.rb +++ /dev/null @@ -1,44 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -module Shell - module Commands - class NamespaceAlter < Command - def help - return <<-EOF -Alter namespace properties. - -To add/modify a property: - - hbase> namespace_alter 'ns1', {METHOD => 'set', 'PROERTY_NAME' => 'PROPERTY_VALUE'} - -To delete a property: - - hbase> namespace_alter 'ns1', {METHOD => 'unset', NAME=>'PROERTY_NAME'} -EOF - end - - def command(namespace, *args) - format_simple_command do - admin.alter_namespace(namespace, *args) - end - end - end - end -end diff --git a/hbase-server/src/main/ruby/shell/commands/namespace_create.rb b/hbase-server/src/main/ruby/shell/commands/namespace_create.rb deleted file mode 100644 index 16e483d..0000000 --- a/hbase-server/src/main/ruby/shell/commands/namespace_create.rb +++ /dev/null @@ -1,41 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -module Shell - module Commands - class NamespaceCreate < Command - def help - return <<-EOF -Create namespace; pass namespace name, -and optionally a dictionary of namespace configuration. -Examples: - - hbase> namespace_create 'ns1' - hbase> namespace_create 'ns1', {'PROERTY_NAME'=>'PROPERTY_VALUE'} -EOF - end - - def command(namespace, *args) - format_simple_command do - admin.create_namespace(namespace, *args) - end - end - end - end -end diff --git a/hbase-server/src/main/ruby/shell/commands/namespace_describe.rb b/hbase-server/src/main/ruby/shell/commands/namespace_describe.rb deleted file mode 100644 index d19476d..0000000 --- a/hbase-server/src/main/ruby/shell/commands/namespace_describe.rb +++ /dev/null @@ -1,41 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -module Shell - module Commands - class NamespaceDescribe < Command - def help - return <<-EOF -Describe the named namespace. For example: - hbase> namespace_describe 'ns1' -EOF - end - - def command(namespace) - now = Time.now - - desc = admin.describe_namespace(namespace) - - formatter.header([ "DESCRIPTION" ], [ 64 ]) - formatter.row([ desc ], true, [ 64 ]) - formatter.footer(now) - end - end - end -end diff --git a/hbase-server/src/main/ruby/shell/commands/namespace_drop.rb b/hbase-server/src/main/ruby/shell/commands/namespace_drop.rb deleted file mode 100644 index 3c9af39..0000000 --- a/hbase-server/src/main/ruby/shell/commands/namespace_drop.rb +++ /dev/null @@ -1,36 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -module Shell - module Commands - class NamespaceDrop < Command - def help - return <<-EOF -Drop the named namespace. The namespace must be empty. -EOF - end - - def command(namespace) - format_simple_command do - admin.drop_namespace(namespace) - end - end - end - end -end diff --git a/hbase-server/src/main/ruby/shell/commands/namespace_list.rb b/hbase-server/src/main/ruby/shell/commands/namespace_list.rb deleted file mode 100644 index aa85e0c..0000000 --- a/hbase-server/src/main/ruby/shell/commands/namespace_list.rb +++ /dev/null @@ -1,47 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -module Shell - module Commands - class NamespaceList < Command - def help - return <<-EOF -List all namespaces in hbase. Optional regular expression parameter could -be used to filter the output. Examples: - - hbase> namespace_list - hbase> namespace_list 'abc.*' -EOF - end - - def command(regex = ".*") - now = Time.now - formatter.header([ "NAMESPACE" ]) - - regex = /#{regex}/ unless regex.is_a?(Regexp) - list = admin.list_namespace.grep(regex) - list.each do |table| - formatter.row([ table ]) - end - - formatter.footer(now, list.size) - end - end - end -end diff --git a/hbase-server/src/main/ruby/shell/commands/namespace_list_tables.rb b/hbase-server/src/main/ruby/shell/commands/namespace_list_tables.rb deleted file mode 100644 index 6c78255..0000000 --- a/hbase-server/src/main/ruby/shell/commands/namespace_list_tables.rb +++ /dev/null @@ -1,45 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -module Shell - module Commands - class NamespaceListTables < Command - def help - return <<-EOF -List all tables that are members of the namespace. -Examples: - - hbase> namespace_list_tables 'ns1' -EOF - end - - def command(namespace) - now = Time.now - formatter.header([ "TABLE" ]) - - list = admin.list_namespace_tables(namespace) - list.each do |table| - formatter.row([ table ]) - end - - formatter.footer(now, list.size) - end - end - end -end