Issue while extending out of the box classes

classic Classic list List threaded Threaded
3 messages Options
Saurabh Sharma Saurabh Sharma
Reply | Threaded
Open this post in threaded view
|

Issue while extending out of the box classes

Hi,

 

I am facing issue while trying to extend any out of the box Ignite classes. I am trying to extend DataStreamerImpl class and overriding addData(K,V) method to do extra processing before saving it to cache.

I did not find bean definitions defined in Bean configuration file except Ignite configuration in Ignite.

 

If I need to extend any bean which has parametrized constructor then I had to define that constructor of base class into my child class. I passed constructor argument through Bean configuration file.

 

public CustomStreamer(

               final GridKernalContext ctx,

               @Nullable final String cacheName,

               DelayQueue<DataStreamerImpl<K, V>> flushQ) {

              super(ctx, cacheName, flushQ);

       }

 

<bean id="igniteStreamer" class="org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl"/>

<bean id="kafkaStreamer" class="com.ignite.streamer.CustomStreamer " parent="igniteStreamer">

              <constructor-arg ref="ignite.ctx" index="0"/>

              <constructor-arg type="java.lang.String" value="igfs-data" index="1"/>

              <constructor-arg ref="delayQueue" index="2"/>

</bean>

 

But then it gave error for GridKernalContextImpl class like no default constructor defined which got resolved when I extended this class and defined parameterized constructor. But then again it contains many objects in constructor for which I again have to define beans and constructor arguments.

 

I wanted to confirm if this is the right approach or am I missing anything here.

 

Thanks,

Saurabh

Roman Shtykh Roman Shtykh
Reply | Threaded
Open this post in threaded view
|

Re: Issue while extending out of the box classes

Hi Saurabh,

This may be not an answer to your question, but from the bean id I guess you try to implement a Kafka streamer.
Please check if [1] will work for you.


-Roman

vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: Issue while extending out of the box classes

In reply to this post by Saurabh Sharma
Hi Saurabh,

DataStreamerImpl is an internal implementation class and it's not a good idea to extend it to provide your own implementation.

If you want to implement your own streamer to integrate with another product, refer to streamers implementation guideline [1]. Or you can use one of the implementations that are already provided in Ignite.

[1] https://cwiki.apache.org/confluence/display/IGNITE/Streamers+Implementation+Guidelines

-Val