Hi Ali,
I used ClusterAction for my case because I had to execute action on all
nodes. I used something like this
public class CustomAction extends
ClusterAction<CustomRequest, CustomResponse, CustomRequestBuilder>{
... implement all required methods (override newRequestBuilder and
newResponse) ...
public class CustomNodeResponse extends NodeOperationResponse {
}
public class CustomRequest extends NodesOperationRequest<CustomRequest> {
... overide writeTo and readFrom methods ...
... add custom data fields in this class ... (for example I used "id" which
was given in constructor and read/write in overridden methods ...
public class CustomRequestBuilder extends
NodesOperationRequestBuilder<CustomRequest,
CustomResponse, CustomRequestBuilder> {
... override doExecute method. I used something below ...
@Override
protected void doExecute(ActionListener<CustomResponse> listener) {
client.execute(CustomAction.INSTANCE, request, listener);
}
public class CustomResponse extends
NodesOperationResponse<NodeCustomResponse> {
... implement writeTo and readFrom methods ...
public class NodeCustomResponse extends NodeOperationResponse {
... implement writeTo and readFrom methods ...
And finally the most important part
public class TransportCustomAction extends
TransportNodesOperationAction<CustomRequest, CustomResponse,
TransportCustomAction.NodeCustomRequest, NodeCustomResponse> {
... the main part is in nodeOperation method. here is implementation of
your action ...
--
Paweł Róg
On Thursday, March 26, 2015 at 9:26:41 PM UTC+1, Ali Lotfdar wrote:
>
> Hi Pawel,
>
> I am new in creating action plugin, and I found you have already work on
> it. Could you please let me know if there is any sample and explanation
> which can help me to start.
> I already reviewed cookbook ES, but I could not understand its explanation!
>
> Thank you.
>
>
> Regards,
> Ali
>
> On Thursday, November 13, 2014 at 1:06:00 AM UTC-5, Paweł Róg wrote:
>>
>> Hi,
>> Thank you very much :-)
>>
>> Paweł
>>
>> On Wed, Nov 12, 2014 at 10:23 PM, Ivan Brusic <[email protected]> wrote:
>>
>>> There is also an ActionModule
>>>
>>> public void onModule(ActionModule module) {
>>> module.registerAction(MyAction.INSTANCE, TransportMyAction.class);
>>> }
>>>
>>> It is always easier to follow existing plugins.
>>>
>>> Cheers,
>>>
>>> Ivan
>>>
>>> On Wed, Nov 12, 2014 at 3:50 PM, Pawel <[email protected]> wrote:
>>>
>>>> Hi,
>>>> I'm thinking about building custom ClusterAction. I see that I can
>>>> build custom classes for Request, NodeResponse and NodesRespone but it is
>>>> not clear to me how I can register my custom action.
>>>>
>>>> In case of Rest action it was quite easy because in plugin i simply use
>>>>
>>>> public void onModule(RestModule module) {
>>>> module.addRestAction(RestCustomAction.class);
>>>> }
>>>>
>>>> but I cannot find any examples how I can do this in case of custom
>>>> ClusterAction.
>>>>
>>>> Does anybody have any example how I can achieve this? Thanks for your
>>>> help.
>>>>
>>>> --
>>>> Paweł Róg
>>>>
>>>> --
>>>> 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 [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbPoNd4yZLdow_sMJmpN8dr0krEipTX9SbMOp%2BugM0L8_w%40mail.gmail.com
>>>>
>>>> <https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbPoNd4yZLdow_sMJmpN8dr0krEipTX9SbMOp%2BugM0L8_w%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>>> 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 [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCTD3ZTreOTPXzd1ifwTqyFj3rzRd8KOsZxs8y6qg-M3Q%40mail.gmail.com
>>>
>>> <https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCTD3ZTreOTPXzd1ifwTqyFj3rzRd8KOsZxs8y6qg-M3Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/58822bc2-dfe0-429a-be6c-e372e700396c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.