Basic HBase Java Classes and Methods – Part 8: Disable and Delete a Table

In order to delete a table in HBase it must be disabled first.  This forces any data in memory to be flushed to disk.  Because this is an admin operation, we must create an Admin object, similar to how we did when creating a table.  After the Admin object is created, we simply pass in the Table object to its disableTable method, followed by passing the Table object into its deleteTable method.   It’s very straight forward and simple.

Full code is below:


Posted in Data Analytics | Tagged , | Leave a comment

Basic HBase Java Classes and Methods – Part 7: Delete from a Table

Deleting data from an HBase table is very similar in overall structure to many of our previous operations.  First we have our general skeleton code.  As before we use static variable declarations to make the code look a lot nicer.

We will create a Delete object, with a parameter of 1, which means we are deleting from the row with row key 1.  We will then add the columns we wish to delete using the addColumn method, and finally call the delete method on our Table object and pass in our Delete object as its parameter.

Putting it all together the complete code is as so:

The last part of this series will show how to Disable and then Drop an HBase table using Java.

Posted in Data Analytics | Tagged , | Leave a comment

Basic HBase Java Classes and Methods – Part 6: Scan a Table

In HBase a Scan is similar to a Select in SQL.  Again we return to skeleton code which is very similar to what we have seen before.  I will put comments into the three areas we will be addressing:

So there are three areas we will cover that are new:

  • Define a ResultScanner
  • Code to Scan the table
  • Close scan resources

Define a ResultScanner

First just before our try clause, we define a ResultScanner.  We do this outside of the try clause for the same reason we do the table outside the try clause, because we need to check and close the resources in the finally clause and if we were to define this inside the try clause it would then be out of scope.

 Scan the table

We get a Table object from our Connection object, just as we have done before.  This time we run a getScanner method on the Table object using a Scan object that we instantiate.  The results come back as a list which we iterate though.  Each iteration we use the CellUtil utility class which allows us to access each part of the ResultScanner separately.  You can read more about CellUtil in the JavaDoc.

CellUtil.cloneRow() is used to access the key
CellUtil.cloneFamily() is used to access the column family name
CellUtil.cloneQualifier() is used to access the column name
CellUtil.cloneValue() is used to access the column value

 Close scan resources

Similar to how we close the connection and the table, we also need to close our ResultScanner.

The final code is as follows:

This produces the following output:

In our next part,  we will look at how to delete data from an HBase table.

Posted in Data Analytics | Tagged , | Leave a comment

Basic HBase Java Classes and Methods – Part 5: Getting Data from a Table

Now that we have seen how to Create a table and Put data into a table, we will explore how to read data out of a table. The main skeleton code is the the same as before, but this time we will construct a Get object and pass it in to the get method of the Table object.  The get method is overloaded, so it will accept a single get request or a list of get requests.

First lets look at what the skeleton code looks like, everything except our get requests:

First we will construct a basic Get object, add three columns to it using the addColumn method, pass that to the get method of the Table object and print out the results.  Remember everything in HBase is a byte array.

Now we will create two Get objects, add them to a list and then pass them in the same way.  The result given back to us is a list which we will walk through and print the results.

Complete program is below:

The results of our program are as follows:

Next part we will look at using the Scan command to accomplish similar to what the SELECT command does in SQL.

Posted in Data Analytics | Tagged , | Leave a comment

Summary of Cisco NX-OS security vulnerabilities I uncovered

I reported various vulnerabilities in NX-OS back in 2011, in various posts on my blog:

Hacking NX-OS Part 1

Hacking NX-OS Part 2

Hacking NX-OS Part 3

These were follow on’s to a series of posts I made about getting access to the OS by simply accessing the image:

Deconstructing Cisco NX-OS Part 1: Exploding Kickstart
Deconstructing Cisco NX-OS Part 2: Exploding the System Image

The exploits, which I formally reported to Cisco, were never made public, until over four years later.  These exploits were describe in the above posts years before their acknowledgement by Cisco.  Some of the exploits which I described  and were later made public by Cisco are:

GNU Bash Environment Variable Command Injection Vulnerability

Cisco Nexus Devices NX-OS Software Command-Line Interpreter Local Privilege Escalation Vulnerability

Cisco Nexus Operating System Devices Command Line Interface Local Privilege Escalation Vulnerability

Cisco NX-OS Software Arbitrary Code Execution Vulnerability

Cisco NX-OS Software Input Validation Vulnerability



Posted in Nexus, NX-OS | Tagged , | Leave a comment