StreamBase Monitor Adapter Sample

This sample contains two StreamBase applications that demonstrate the use of the TIBCO StreamBase® Monitor Adapter.

Importing This Sample into StreamBase Studio

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

  • From the top-level menu, select File>Import Samples and Community Content.

  • Enter monitor to narrow the list of options.

  • Select StreamBase Monitor Input Adapter From the StreamBase Standard Adapters category.

  • Click Import Now.

StreamBase Studio creates a project folder for this sample.

Running SBMonitorAdapter in StreamBase Studio

  1. 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 after a minute, select the project, right-click, and select Maven>Update Project from the context menu.

  2. Open the src/main/eventflow/packageName folder.

  3. Open the SBMonitorAdapter.sbapp file and click the Run button. This opens the SB Test/Debug perspective and starts the module.

  4. In the Output Streams view, select All Output Streams to view the adapter output. Observe a burst of output once per second, describing all performance information for the server instance hosting this application.

  5. Try selecting a single stream such as SystemInfo from the drop-down in the Output Streams view. For SystemInfo, notice that the timeRunning field increases by one every second, and that the memory statistics such as totalMemory and freeMemory change slightly as the application runs.

  6. When done, press F9 or click the Terminate EventFlow Fragment button.

Running SBMonitorServer in StreamBase Studio

  1. Continuing with the same sample project, open the SBMonitorServer.sbapp file and click the Run button. This opens the SB Test/Debug perspective and starts the module.

  2. In the Output Streams view, select All Output Streams to view the adapter output. Unlike the simple SBMonitorAdapter application, in this case, the output from the adapter is filtered to emit only events of interest. For example, the Thread information (port #4) is connected to filter IsThreadBusy, which drops everything except threads using high amounts of CPU.

  3. In the EventFlow Editor for SBMonitorServer.sbapp, select the Parameters tab. These parameters are used by the various filters to determine whether to pass an interesting event. Try changing ThreadCPUThresholdMS to 5 and restarting the server.

    In the Output Streams view, notice that the ThreadBusy output stream is now printing alerts for threads that use more than 5 milliseconds every sampling period.

  4. When done, press F9 or click the Terminate EventFlow Fragment button.

This Sample's Files

The sample includes the following EventFlow applications:

  • src/main/eventflow/com.sample.adapter.sbmonitor/SBMonitorAdapter.sbapp contains a single StreamBase Monitor adapter with all of its output ports enabled. Start this application to see the monitor data for the server instance running the application itself.

  • src/main/eventflow/com.sample.adapter.sbmonitor/SBMonitorServer.sbapp can run in its own StreamBase Server instance and connect remotely to another server, or can be added to a new container in a server with a running application. It will emit tuples only when certain performance thresholds are passed. For example, if any operator uses more than 0.3 seconds of CPU time in a one-second cycle sample, all information about that operator is emitted on the OperatorBusy output stream.

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 permission problems. The default workspace location for this sample is:

studio-workspace/sample_adapter_embedded_sbmonitor

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