Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-24890 The command regioninfo is not available #2263

Merged
merged 3 commits into from
Aug 22, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
HBASE-24890 The command regioninfo is not available
  • Loading branch information
bsglz committed Aug 16, 2020
commit f12184d0c989cfd93c34729ee754b807ce6b2354
25 changes: 20 additions & 5 deletions hbase-shell/src/main/ruby/shell/commands/regioninfo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
# limitations under the License.
#

include Java
java_import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil
java_import org.apache.hadoop.hbase.util.FutureUtils
java_import org.apache.hadoop.hbase.client.ConnectionFactory
java_import org.apache.hadoop.hbase.security.UserProvider
java_import org.apache.hadoop.hbase.client.ClusterConnectionFactory

module Shell
module Commands
class Regioninfo < Command
Expand All @@ -35,12 +42,20 @@ def help
EOF
end

def command(regionname)
connection = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection()
admin = connection.getAdmin()
def command(region_name)
admin = @shell.hbase.connection.getAdmin()
sn = admin.getMaster()
puts org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil.getRegionInfo(nil,
connection.getAdmin(sn), regionname.to_java_bytes)

conf = @shell.hbase.configuration
user = UserProvider.instantiate(conf).getCurrent()
clusterConnection = ClusterConnectionFactory.createAsyncClusterConnection(conf, nil, user)
regionInfo = ProtobufUtil.toRegionInfo(FutureUtils.get(
clusterConnection.getRegionServerAdmin(sn).getRegionInfo(
ProtobufUtil.getGetRegionInfoRequest(region_name.to_java_bytes))).getRegionInfo())
if clusterConnection != nil
clusterConnection.close()
end
puts regionInfo
end
end
end
Expand Down