Stream Request Handler API

The /stream request handler, beyond just running a streaming expression, also lets you find out what expressions are available to use and lets you control the behavior of any registered Daemon processes.

This API doesn’t follow the v2 API structure.

PLUGINS: List all expressions registered

Lists out all the streaming expressions that have been registered and are available for use. This includes both the default expressions registered by the StreamHandler and any that you have registered.

/stream?action=PLUGINS

PLUGINS Response

The response will list each expression registered and it’s implementing class.

Examples using PLUGINS

Input

http://localhost:8983/solr/gettingstarted/stream?action=PLUGINS

Output

{
  "plugins":{
    "enumeratedDistribution":"org.apache.solr.client.solrj.io.eval.EnumeratedDistributionEvaluator",
    "year":"org.apache.solr.client.solrj.io.eval.TemporalEvaluatorYear",
    "lteq":"org.apache.solr.client.solrj.io.eval.LessThanEqualToEvaluator",
    "upper":"org.apache.solr.client.solrj.io.eval.UpperEvaluator",
    "commit":"org.apache.solr.client.solrj.io.stream.CommitStream",
    "echo":"org.apache.solr.client.solrj.io.stream.EchoStream"
}}

LIST: List Daemon processes

The daemon function allows you to wrap a streaming expression and run it at intervals to provide both continuous push and pull streaming. This command lists out all the currently running daemon processes.

/stream?action=LIST

This command lists out all the daemon processed that are registered to a specific core that you are interacting with, not across the collection as a whole. If you have a collection that consists of multiple shards or multiple replicas of those shards, each LIST command will bounce between the cores, returning different lists of processes. It’s recommended that for managing daemon processes you create a collection with a single core and no replicas to host the daemon processes to ensure a single view.

LIST Response

The response will describe each daemon process on that specific core.

Examples using LIST

This assumes that you have registered a daemon process similar to the below simplistic example that reads a single random document from the gettingstarted collection and then writes it back to the same collection every 10 seconds:

daemon(
  id="12345",
  runInterval="10000",
  update(gettingstarted,
    random(gettingstarted,
         q="*:*",
         rows="1"
    )
  )
)

Input

http://localhost:8983/solr/gettingstarted/stream?action=LIST

Output

{
  "result-set":{
    "docs":[{
        "startTime":1582820357008,
        "stopTime":0,
        "id":"12345",
        "state":"TIMED_WAITING",
        "iterations":421}
      ,{
        "EOF":true}]}}

This shows a single daemon process running under the id of 12345, and that it has been run 421 times. Each process is a https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Thread.html, and the states are those of a Thread.

STOP: Stop a Daemon processes

/stream?action=STOP&id=12345

STOP Response

The response will either report back the stopping of daemon process, or report it wasn’t found on the specific core that the request was routed to.

Examples using STOP

Input

http://localhost:8983/solr/gettingstarted/stream?action=STOP&id=12345

Output

{
  "result-set":{
    "docs":[{
        "DaemonOp":"Deamon:12345 stopped on gettingstarted_shard2_replica_n4"}
      ,{
        "EOF":true}]}}

Calling LIST again will now have the stopTime of the process recorded.

START Response

The response will either report back the stopping of daemon process, or report it wasn’t found on the specific core that the request was routed to.

Examples using START

Input

http://localhost:8983/solr/gettingstarted/stream?action=START&id=12345

Output

{
  "result-set":{
    "docs":[{
        "DaemonOp":"Deamon:12345 started on gettingstarted_shard2_replica_n4"}
      ,{
        "EOF":true}]}}

The count of iterations is preserved through the STOP/START cycle.

KILL: Remove a Daemon process

/stream?action=KILL&id=12345

KILL Response

The response will either report back the stopping of daemon process, or report it wasn’t found on the specific core that the request was routed to.

Examples using KILL

Input

http://localhost:8983/solr/gettingstarted/stream?action=KILL&id=12345

Output

{
  "result-set":{
    "docs":[{
        "DaemonOp":"Deamon:12345 killed on gettingstarted_shard2_replica_n4"}
      ,{
        "EOF":true}]}}

The daemon process will no longer be listed in subsequent LIST commands.