HBase Operator Samples

Introduction

This topic describes how to run the HBase Operator sample applications, which illustrates how to use the HBase operators when connecting a StreamBase application to an HBase server. For more information on these operators, see Using Global Java Operators.

There are two samples included with the HBase sample package. The first sample, Demo.sbapp, demonstrates a complete process of creating a table, inserting data, updating data, getting data, and deleting rows all in a single flow. The second sample, DemoSteps.sbapp, breaks this process down to allow you to see how each HBase operator works, one at a time.

Step By Step Demo

This section describes the second sample, DemoSteps.sbapp, that shows how each HBase operator is used individually.

Step By Step Sample Overview

The DemoSteps.sbapp sample includes a number of HBase operators, which by default connect to the HBase server defined in the project's sbd.sbconf file when the application starts. Before running this demo, you must edit this file to provide the communication details to connect to your currently running HBase server.

Running The DemoSteps Sample in StreamBase Studio

The steps to run this sample in Studio are as follows:

  1. Before running, you must configure the sample project with the your site's HBase server information. In the Package Explorer, locate the sbd.sbconf file and open it for editing. Be sure to edit the following settings:

    1. hbase.master — Change the val attribute to point to the HBase server and port you want to use.

    2. hbase.zookeeper.quorum — Change the val attribute to point to the Zookeeper server you want to use.

    3. hbase.zookeeper.property.clientPort — Change the val attribute to point to the Zookeeper server's client port.

  2. In the Package Explorer view, double-click to open the DemoSteps.sbapp application.

  3. Make sure the application is the currently active tab in the EventFlow editor, then click the Run button. This opens the SB Test/Debug perspective and starts the application.

  4. In the Manual Input view, select the InAdminCreateTable input stream.

    Click Send Data. This causes a tuple to be sent to an HBase Admin operator that in turn causes a table to be created in the database. Now, observe that the AdminCreateTableStatus output stream receives a tuple with status information indicating the table was created.

  5. In the Manual Input view, select the InGenerateRows input stream.

    Click Send Data. This causes a list of generated tuples to be sent to an HBase Put operator, which causes data to the inserted into the HBase table. Observe that the PutOut output stream shows the values inserted.

  6. In the Manual Input view, select the InUpdateRow input stream.

    Click Send Data. This sends a tuple to an HBase Put operator, which causes the previously sent data's first row to be updated with new values. Observe that the UpdateOut output stream shows the values updated.

  7. In the Manual Input view, select the InGet input stream.

    Enter a rowId value of either 1, 2, 3, 4, or 5 into the rowId field.

    Click Send Data. This triggers trigger the HBase Get operator to fetch the row updated in the previous step from HBase. Observe that the GetOut output stream shows the values received.

  8. In the Manual Input view, select the InScan input stream.

    Click Send Data. This causes an HBase Scan operator to fetch all rows from HBase. Observe in the ScanOut output stream that these row values are received.

  9. In the Manual Input view, select the InScanWithFilter input stream.

    Enter the following values:

    1. In the family field enter: Family1

    2. In the column field, enter: Column4

    3. In the matchSubString field, enter: 1

    Click Send Data. This triggers the HBase Scan operator to fetch a filtered set of rows from HBase. Observe that the ScanWithFilterOut output stream shows a single row received.

  10. In the Manual Input view, select the InDelete input stream.

    Click Send Data. This causes the HBase Scan operator to fetch all rows, then feed the rowIds of those rows into the HBase Delete operator to delete those rows from HBase. Observe that the DeleteOut output stream shows the rows deleted.

  11. When done, press F9 or click the Stop Running Application button.

Running The DemoSteps Sample in Terminal Windows

This section describes how to run this sample in Windows command prompt or Unix terminal windows. Be sure to use the StreamBase Command Prompt from the Start menu as described in the Test/Debug Guide, not the default command prompt.

  1. Edit sbd.sbconf to configure the connection to your site's HBase server, as described in step 1 of the previous section.

  2. Open three terminal windows on UNIX, or three StreamBase Command Prompts on Windows.

  3. In window 1, navigate to the directory location where your project resides, then start StreamBase Server with the application file as its argument. Lines below are split onto two lines for clarity:

    cd /d "C:\Users\username\Documents\
        StreamBase Studio X.Y Workspace\sample_adapter_embedded_hbase" 
    sbd -f sbd.sbconf DemoSteps.sbapp
    
  4. In window 2, type:

    sbc dequeue

    This window will display tuples dequeued from all of the application's output streams.

  5. In window 3, type:

    sbc enq InAdminCreateTable

  6. In window 3, press Enter to send a single empty tuple to the stream.

    Still in window 3, type Ctrl+C to exit the sbc enqueue command.

    Observe in window 2 that a single tuple is emitted on the AdminCreateTableStatus stream with information about the action just performed.

  7. In window 3, type:

    sbc enq InGenerateRows

  8. In window 3, press Enter to send a single empty tuple to the stream.

    Still in window 3, type Ctrl+C.

    Observe in window 2 that a single tuple is emitted on the PutOut stream, which shows the rows just inserted into the HBase system.

  9. In window 3, type:

    sbc enq InGet

    This window is now ready to accept tuples send to the InGenerateRows stream, typed with CSV syntax.

  10. In window 3, type one of the following, followed by Enter:

    "1"

    "2"

    "3"

    "4"

    "5"

    Still in window 3, type Ctrl+C to exit the sbc enqueue command.

    Observe in window 2 that a single tuple is emitted on the GetOut stream, which shows the row value fetched from the HBase database.

  11. In window 3, type:

    sbc enq InUpdateRow

  12. In window 3, press Enter to send a single empty tuple to the stream.

    Still in window 3, type Ctrl+C.

    Observe in window 2 that a single tuple is emitted on the UpdateOut stream, which shows the update row sent to the HBase system.

  13. In window 3, type:

    sbc enq InScan

  14. In window 3, press Enter to send a single empty tuple to the stream.

    Still in window 3, type Ctrl+C.

    Observe in window 2 that multiple tuples are emitted on the ScanOut stream, which show the rows fetched from the HBase database.

  15. In window 3, type:

    sbc enq InDelete

  16. In window 3, press Enter to send a single empty tuple to the stream.

    Still in window 3, type Ctrl+C.

    Observe in window 2 that multiple tuples are emitted on the DeleteOut stream, which show the rows deleted from the HBase database.

  17. In window 3, type:

    sbc enq InAdminDeleteTable

  18. In window 3, press Enter to send a single empty tuple to the stream.

    Still in window 3, type Ctrl+C.

    Observe in window 2 that multiple tuples are emitted on the AdminDeleteTableStatus stream, which shows the status of the delete table command sent to the HBase database.

  19. In window 2, type Ctrl+C to terminate the dequeuing process. Then type the following command to shut down the server:

    sbadmin shutdown

Automated Sample

Automated Sample Overview

The Demo.sbapp sample includes a number of HBase adapters, which by default connect to the HBase server identified in the project's sbd.sbconf file. Before running this demo, you must edit this file with the configuration details to connect to your currently running HBase server. Once connected, the sample automatically creates a table and starts to send and receive data. When the sample finishes running, the table it created is deleted.

Running The Demo Sample in StreamBase Studio

The steps to run the Demo.sbapp sample in Studio are as follows:

  1. Before running, you must configure the sample project with the your site's HBase server information. In the Package Explorer, locate the sbd.sbconf file and open it for editing. Be sure to edit the following settings:

    1. hbase.master — Change the val attribute to point to the HBase server and port you want to use.

    2. hbase.zookeeper.quorum — Change the val attribute to point to the Zookeeper server you want to use.

    3. hbase.zookeeper.property.clientPort — Change the val attribute to point to the Zookeeper server's client port.

  2. In the Package Explorer view, double-click to open the Demo.sbapp application.

  3. Make sure the application is the currently active tab in the EventFlow editor, then click the Run button. This opens the SB Test/Debug perspective and starts the application.

  4. Observe the results in the output views.

  5. When done, press F9 or click the Stop Running Application button.

Importing This Sample into StreamBase Studio

In StreamBase Studio, import this sample with the following steps:

  • From the top-level menu, select FileLoad StreamBase Sample.

  • Type hbase to narrow the list of options.

  • Select Apache HBase operators from the Data Constructs and Operators category.

  • Click OK.

StreamBase Studio creates a single project for the HBase operator samples in your current Studio workspace.

Sample Location

When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.

Important

Load this sample in StreamBase Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.

Using the workspace copy of the sample avoids the permission problems that can occur when trying to work with the initially installed location of the sample. The default workspace location for this sample is:

studio-workspace/sample_adapter_embedded_hbase

See Default Installation Directories for the location of studio-workspace on your system.

In the default TIBCO StreamBase installation, this sample's files are initially installed in:

streambase-install-dir/sample/adapter/embedded/hbase

See Default Installation Directories for the location of streambase-install-dir on your system. This location may require administrator privileges for write access, depending on your platform.