xcangCRM commented on a change in pull request #225: HBASE-22377 Provide API to 
check the existence of a namespace which does not require ADMIN permissions
URL: https://github.com/apache/hbase/pull/225#discussion_r283515213
 
 

 ##########
 File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
 ##########
 @@ -1921,6 +1922,34 @@ protected NamespaceDescriptor rpcCall() throws 
Exception {
     });
   }
 
+  /**
+   * List available namespaces
+   * @return List of namespace names
+   * @throws IOException if a remote or network exception occurs
+   */
+  @Override
+  public String[] listNamespaces() throws IOException {
+    return executeCallable(new MasterCallable<String[]>(getConnection(),
+        getRpcControllerFactory()) {
+      @Override
+      protected String[] rpcCall() throws Exception {
+        List<String> list =
+          master.listNamespaces(getRpcController(),
+            ListNamespacesRequest.newBuilder().build()).getNamespaceNameList();
+        String[] res = new String[list.size()];
+        for(int i = 0; i < list.size(); i++) {
+          res[i] = list.get(i);
+        }
 
 Review comment:
   Nit:
   should we just use toArray to convert a list to an array, removing the for 
loop?
   res = list.toArray(res); 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to