SOLR-14284 add expressible support to list, and add example of removing a component (#1292)

* add expressible support to list, and add example of removing a component

* document actions that can be passed to the /stream request handler

* responding to content feedback
This commit is contained in:
Eric Pugh 2020-03-25 14:53:51 -04:00 committed by GitHub
parent 8d937c1dc3
commit 4f03ce5899
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 250 additions and 2 deletions

View File

@ -369,6 +369,9 @@ These commands allow registering more advanced customizations to Solr:
* `add-runtimelib`
* `update-runtimelib`
* `delete-runtimelib`
* `add-expressible`
* `update-expressible`
* `delete-expressible`
==== Examples of Handler and Component Commands
@ -524,6 +527,35 @@ curl -X POST -H 'Content-type:application/json' -d '{
====
--
Finally we will go ahead and remove the request handler via the `delete-requesthandler` command:
[.dynamic-tabs]
--
[example.tab-pane#v1delete-handler]
====
[.tab-label]*V1 API*
[source,bash]
----
curl -X POST -H 'Content-type:application/json' -d '{
"delete-requesthandler": "/myterms"
}' http://localhost:8983/solr/techproducts/config
----
====
[example.tab-pane#v2delete-handler]
====
[.tab-label]*V2 API*
[source,bash]
----
curl -X POST -H 'Content-type:application/json' -d '{
"delete-requesthandler": "/myterms"
}' http://localhost:8983/api/collections/techproducts/config
----
====
--
=== Commands for User-Defined Properties
Solr lets users templatize the `solrconfig.xml` using the place holder format `${variable_name:default_val}`. You could set the values using system properties, for example, `-Dvariable_name= my_customvalue`. The same can be achieved during runtime using these commands:

View File

@ -0,0 +1,216 @@
= Stream Request Handler API
:page-toclevels: 1
:page-tocclass: right
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
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.
NOTE: This API doesn't follow the v2 API structure.
[[plugins]]
== 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*
[source,text]
----
http://localhost:8983/solr/gettingstarted/stream?action=PLUGINS
----
*Output*
[source,json]
----
{
"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: List Daemon processes
The <<stream-decorator-reference.adoc#daemon,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`
IMPORTANT: 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:
[source,text]
----
daemon(
id="12345",
runInterval="10000",
update(gettingstarted,
random(gettingstarted,
q="*:*",
rows="1"
)
)
)
----
*Input*
[source,text]
----
http://localhost:8983/solr/gettingstarted/stream?action=LIST
----
*Output*
[source,json]
----
{
"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 {java-javadocs}java/lang/Thread.html,
and the states are those of a Thread.
[[stop]]
== 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*
[source,text]
----
http://localhost:8983/solr/gettingstarted/stream?action=STOP&id=12345
----
*Output*
[source,json]
----
{
"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*
[source,text]
----
http://localhost:8983/solr/gettingstarted/stream?action=START&id=12345
----
*Output*
[source,json]
----
{
"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]]
== 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*
[source,text]
----
http://localhost:8983/solr/gettingstarted/stream?action=KILL&id=12345
----
*Output*
[source,json]
----
{
"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.

View File

@ -507,7 +507,7 @@ The effect of this is to push documents that match a specific query into another
Push streaming can also be used for continuous background aggregation scenarios where aggregates are rolled up in the background at intervals and pushed to other Solr collections. Another use case is continuous background machine learning model optimization, where the optimized model is pushed to another Solr collection where it can be integrated into queries.
The `/stream` handler supports a small set commands for listing and controlling daemon functions:
The `/stream` handler supports a small <<stream-api.adoc#plugins,set of commands>> for listing and controlling daemon functions:
[source,text]
----

View File

@ -1,5 +1,5 @@
= Streaming Expressions
:page-children: stream-source-reference, stream-decorator-reference, stream-evaluator-reference, math-expressions, graph-traversal
:page-children: stream-source-reference, stream-decorator-reference, stream-evaluator-reference, math-expressions, graph-traversal, stream-api
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information