Question about creating custom rivers


(IvanBrusic) #1

I found the concept of rivers interesting, so I decided to implement
my own out of curiosity. The goal is to index JSON documents returned
from an HTML 5 WebSocket. My issue is very likely a naming issue, I
am formatting my code around the existing river plugins.

Please forgive me, but the code is in Scala. It still should be very
readable (if not more so :slight_smile: ) https://gist.github.com/837883

My es-plugin.properties
plugin=plugin.SimpleWebsocketRiverPlugin

class SimpleWebsocketRiverPlugin @Inject() extends AbstractPlugin {
def name() = {
"river-simplewebsocket";
}

def description() = {
    "River Simple Websocket Plugin";
}

}

class SimpleWebsocketRiverModule extends AbstractModule {
override def configure() = {

bind(classOf[River]).to(classOf[SimpleWebsocketRiver]).asEagerSingleton()
}
}

The actual River declaration is:
class SimpleWebsocketRiver @Inject()(riverName: RiverName,
riverSettings: RiverSettings, client: Client) extends
AbstractRiverComponent(riverName, riverSettings) with River

I am able to bundle the code as a zip file and install as a plugin:
./bin/plugin url file:/// install simplewebsocket

ElasticSearch starts off fine:
...
[2011-02-21 18:03:04,210][INFO ][plugins ] [Gideon,
Gregory] loaded [river-simplewebsocket]
...

Attempting to create a new river results in an error:

curl -XPUT localhost:9200/_river/test_river/_meta -d '
{
"type" : "simplewebsocket"
}
'
ERROR:
[2011-02-21 18:05:51,509][WARN ][river ] [Gideon,
Gregory] failed to create river [simplewebsocket][test_river]
org.elasticsearch.common.settings.NoClassSettingsException: Failed to
load class with value [simplewebsocket]

I am assuming that I simply did not name something correctly. What am
I missing?

Thanks in advance,
Ivan


(IvanBrusic) #2

Found my own answer by digging through the source code. For those
that are interested, you must either declare the entire classname in
the "type" field of the _meta or your module must belong to the
org.elasticsearch.river package.

Works like a charm.


(Shay Banon) #3

Heya, gerat your found it!. Using the class name as the river is not that nice..., pushed an improvement to that: https://github.com/elasticsearch/elasticsearch/issues/712.
On Tuesday, February 22, 2011 at 6:04 AM, Ivan Brusic wrote:

Found my own answer by digging through the source code. For those
that are interested, you must either declare the entire classname in
the "type" field of the _meta or your module must belong to the
org.elasticsearch.river package.

Works like a charm.


(system) #4