Contents
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 demonstrate how each HBase operator works, one at a time.
In StreamBase Studio, import this sample with the following steps:
-
From the top-level menu, select
> . -
Enter
hb
to narrow the list of options. -
Select Apache HBase operators from the Large Data Storage and Analysis category.
-
Click
.
StreamBase Studio creates a single project for the HBase operator samples in your current Studio workspace.
The Demo.sbapp
sample includes a number of HBase
adapters, which by default connect to the HBase server identified in the project's
HBase.conf configuration 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.
-
In the Project Explorer view, open the sample you just loaded.
If you see red marks on a project folder, wait a moment for the project to load its features.
If the red marks do not resolve themselves in a moment, select the project and right-click
> from the context menu. -
Open the
src/main/eventflow/
folder.packageName
-
Before running, you must configure the sample project with the your site's HBase server information. In the Project Explorer, locate the HBase.conf file in the
src/main/configurations
directory and open it. Be sure to edit the following settings:-
hbase.master
— Change the val attribute to point to the HBase server and port you want to use. -
hbase.zookeeper.quorum
— Change the val attribute to point to the ZooKeeper server you want to use. -
hbase.zookeeper.property.clientPort
— Change the val attribute to point to the ZooKeeper server's client port.
-
-
Open the
Demo.sbapp
file and click the Run button. This opens the SB Test/Debug perspective and starts the module. -
Observe the results in the output views.
-
When done, press F9 or click the Terminate EventFlow Fragment button.
The second sample, DemoSteps.sbapp
, shows how each HBase
operator is used individually.
The DemoSteps.sbapp
sample includes a number of HBase
operators, which by default connect to the HBase server defined in the project's
HBase.conf configuration 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.
-
Continuing with the same sample project folder, open the
DemoSteps.sbapp
file. -
Click the Run button. This opens the SB Test/Debug perspective and starts the module.
-
In the Manual Input view, select the
InAdminCreateTable
input stream.Click
. 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 theAdminCreateTableStatus
output stream receives a tuple with status information indicating the table was created. -
In the Manual Input view, select the
InGenerateRows
input stream.Click
. 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 thePutOut
output stream shows the values inserted. -
In the Manual Input view, select the
InUpdateRow
input stream.Click
. 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 theUpdateOut
output stream shows the values updated. -
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
. This triggers trigger the HBase Get operator to fetch the row updated in the previous step from HBase. Observe that theGetOut
output stream shows the values received. -
In the Manual Input view, select the
InScan
input stream.Click
. This causes an HBase Scan operator to fetch all rows from HBase. Observe in theScanOut
output stream that these row values are received. -
In the Manual Input view, select the
InScanWithFilter
input stream.Enter the following values:
-
In the family field enter:
Family1
-
In the column field, enter:
Column4
-
In the matchSubString field, enter:
1
Click
. This triggers the HBase Scan operator to fetch a filtered set of rows from HBase. Observe that theScanWithFilterOut
output stream shows a single row received. -
-
In the Manual Input view, select the
InDelete
input stream.Click
. 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 theDeleteOut
output stream shows the rows deleted. -
When done, press F9 or click the Terminate EventFlow Fragment button.
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 permission problems. The default workspace location for this sample is:
studio-workspace
/sample_adapter_embedded_hbase
See Default Installation
Directories for the default location of studio-workspace
on your system.