Best practices for extending TransportBroadcastOperationAction

Hi Jörg thanks for your answer!

Am Mittwoch, 6. März 2013 20:22:30 UTC+1 schrieb Jörg Prante:

Just some first aid: ES is very picky and throws NPEs if you do not
transmit an "index" value. These NPEs are not critical since they are
expected to get fixed by the programmer - if you want to address all
indices or no indices, you can't just use null and expect that ES can
figure out what you want to do. Take care that you extend the action
request/response classes properly

and always use the constructors of the inherited classes so private

variables are filled with non-null values.

That last bit was the right hint: Although i was always calling super(...)
in my constructors, I missed to propagate parameters everywhere applicable.

E.g.:

public class ShardCustomRequest extends BroadcastShardOperationRequest {

protected ShardCustomRequest(CustomRequest request) {
//super(); <- wrong
super(request.index(), request.shard(), request); //<- correct
//...
}
}

What I found also confusing are the parameterless methods in
TransportBroadCastOperationAction for newRequest(), newShardRequest() and
newShardResponse(), since I don't see, what they are needed for...

You can look at//github.com/jprante/elasticsearch-index-termlist for an
example of a transport broadcast action,

Thanks, that was already one of the plugins I was drawing my insights from.

Node client and Transport Client work without any difference in respect

to action implementations, they are exchangeable.

Well, I figured they seem to slightly differ in the way a request is routed
and (re)constructed, since for me a

client.execute(MyCustomAction.INSTANCE, request).actionGet();

did yield the NPE in native mode, while working with transport.

I would like to give

more advise, but you have to show your code, for better insight of what
you intend to do.

For now this is also only self education and I don't have the guts yet to
show :wink: This might however change, once I cleaned up and tested properly.

The remaining question is, whether there exists documentation apart from
plugin code examples about the do's and don't's?

Regards,
Konrad

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.