You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by Thomas Termin <tt...@blue-elephant-systems.com> on 2008/09/08 15:12:51 UTC

next question about implementation

Hi,

another question. Each EIPEndpoint has an TimerManager associated and it
is also startet and a thread is created even if it is not used. The only
class which I can see using the runing timer thread is the
AbstractAggregator. Would it be not better to create just a
TimerManagerImpl instance in each EIPComponent but start it the first
time it is really used? The AbstractAggregator could check if it runs
and when not could start it. We could save a lot of created threads (at
least in our cases), couldn't we?
It might be that I'm wrong so please correct me. What do you think?

Cheers
Thomas
-- 
Thomas Termin
_______________________________
blue elephant systems GmbH
Wollgrasweg 49
D-70599 Stuttgart

Tel    :  (+49) 0711 - 45 10 17 676
Fax    :  (+49) 0711 - 45 10 17 573
WWW    :  http://www.blue-elephant-systems.com
Email  :  Thomas.Termin@blue-elephant-systems.com

blue elephant systems GmbH
Firmensitz      : Wollgrasweg 49, D-70599 Stuttgart
Registergericht : Amtsgericht Stuttgart, HRB 24106
Geschäftsführer : Holger Dietrich, Thomas Gentsch, Joachim Hoernle


Re: next question about implementation

Posted by Thomas Termin <tt...@blue-elephant-systems.com>.
Guillaume Nodet wrote:
> Looks good.  We may want to add a synchronize keyword the two
> schedule() methods, empty the start one, and make sure to check if the
> timer has been created in the stop method (and set it back to null
> btw).  And I think the stop method should be synchronized too ...
> Feel free to go ahead and commit this modified class.
Yeah will do together with the poll-timeout problem.


> 
> On Mon, Sep 8, 2008 at 4:54 PM, Thomas Termin
> <tt...@blue-elephant-systems.com> wrote:
> 
>>Thanks! So cool that I'm not absolutly wrong here. :-D
>>
>>I did the following:
>>
>>public Timer schedule(TimerListener listener, long delay) {
>>       if (LOG.isDebugEnabled()) {
>>           LOG.debug("Schedule timer " + listener + " for " + delay);
>>       }
>>       TimerImpl tt = new TimerImpl(listener);
>>       if (timer == null) {
>>           timer = new java.util.Timer();
>>       }
>>       timer.schedule(tt, delay);
>>       return tt;
>>   }
>>
>>public Timer schedule(TimerListener listener, Date date) {
>>       if (LOG.isDebugEnabled()) {
>>           LOG.debug("Schedule timer " + listener + " at " + date);
>>       }
>>       TimerImpl tt = new TimerImpl(listener);
>>       if (timer == null) {
>>           timer = new java.util.Timer();
>>       }
>>       timer.schedule(tt, date);
>>       return tt;
>>   }
>>
>>That starts the timer if the schedule method id used. The advantage for
>>me was just to change the TimerManagerImpl class.
>>
>>But I think we can also use your way.
>>
>>Cheers,
>>Thomas
>>
>>Guillaume Nodet wrote:
>>
>>>Absolutely.
>>>Actually, I think it should be safe to create / start the timer in the
>>>getTimerManager() method.  We may need to add a boolean property to
>>>know if the timer manager has been started or not.  This would lead to
>>>only changing the EIPEndpoint class.
>>>
>>>On Mon, Sep 8, 2008 at 3:12 PM, Thomas Termin
>>><tt...@blue-elephant-systems.com> wrote:
>>>
>>>
>>>>Hi,
>>>>
>>>>another question. Each EIPEndpoint has an TimerManager associated and it
>>>>is also startet and a thread is created even if it is not used. The only
>>>>class which I can see using the runing timer thread is the
>>>>AbstractAggregator. Would it be not better to create just a
>>>>TimerManagerImpl instance in each EIPComponent but start it the first
>>>>time it is really used? The AbstractAggregator could check if it runs
>>>>and when not could start it. We could save a lot of created threads (at
>>>>least in our cases), couldn't we?
>>>>It might be that I'm wrong so please correct me. What do you think?
>>>>
>>>>Cheers
>>>>Thomas
>>>>--
>>>>Thomas Termin
>>>>_______________________________
>>>>blue elephant systems GmbH
>>>>Wollgrasweg 49
>>>>D-70599 Stuttgart
>>>>
>>>>Tel    :  (+49) 0711 - 45 10 17 676
>>>>Fax    :  (+49) 0711 - 45 10 17 573
>>>>WWW    :  http://www.blue-elephant-systems.com
>>>>Email  :  Thomas.Termin@blue-elephant-systems.com
>>>>
>>>>blue elephant systems GmbH
>>>>Firmensitz      : Wollgrasweg 49, D-70599 Stuttgart
>>>>Registergericht : Amtsgericht Stuttgart, HRB 24106
>>>>Geschäftsführer : Holger Dietrich, Thomas Gentsch, Joachim Hoernle
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>>--
>>Thomas Termin
>>_______________________________
>>blue elephant systems GmbH
>>Wollgrasweg 49
>>D-70599 Stuttgart
>>
>>Tel    :  (+49) 0711 - 45 10 17 676
>>Fax    :  (+49) 0711 - 45 10 17 573
>>WWW    :  http://www.blue-elephant-systems.com
>>Email  :  Thomas.Termin@blue-elephant-systems.com
>>
>>blue elephant systems GmbH
>>Firmensitz      : Wollgrasweg 49, D-70599 Stuttgart
>>Registergericht : Amtsgericht Stuttgart, HRB 24106
>>Geschäftsführer : Holger Dietrich, Thomas Gentsch, Joachim Hoernle
>>
>>
> 
> 
> 
> 


-- 
Thomas Termin
_______________________________
blue elephant systems GmbH
Wollgrasweg 49
D-70599 Stuttgart

Tel    :  (+49) 0711 - 45 10 17 676
Fax    :  (+49) 0711 - 45 10 17 573
WWW    :  http://www.blue-elephant-systems.com
Email  :  Thomas.Termin@blue-elephant-systems.com

blue elephant systems GmbH
Firmensitz      : Wollgrasweg 49, D-70599 Stuttgart
Registergericht : Amtsgericht Stuttgart, HRB 24106
Geschäftsführer : Holger Dietrich, Thomas Gentsch, Joachim Hoernle


Re: next question about implementation

Posted by Thomas Termin <tt...@blue-elephant-systems.com>.
Guillaume Nodet wrote:
> Looks good.  We may want to add a synchronize keyword the two
> schedule() methods, empty the start one, and make sure to check if the
> timer has been created in the stop method (and set it back to null
> btw).  And I think the stop method should be synchronized too ...
But actually each EIPEndpoint has its own timer so there should not be a
race condition. But I agree the TimerManager could be used for other
stuff as well.
> Feel free to go ahead and commit this modified class.
> 
> On Mon, Sep 8, 2008 at 4:54 PM, Thomas Termin
> <tt...@blue-elephant-systems.com> wrote:
> 
>>Thanks! So cool that I'm not absolutly wrong here. :-D
>>
>>I did the following:
>>
>>public Timer schedule(TimerListener listener, long delay) {
>>       if (LOG.isDebugEnabled()) {
>>           LOG.debug("Schedule timer " + listener + " for " + delay);
>>       }
>>       TimerImpl tt = new TimerImpl(listener);
>>       if (timer == null) {
>>           timer = new java.util.Timer();
>>       }
>>       timer.schedule(tt, delay);
>>       return tt;
>>   }
>>
>>public Timer schedule(TimerListener listener, Date date) {
>>       if (LOG.isDebugEnabled()) {
>>           LOG.debug("Schedule timer " + listener + " at " + date);
>>       }
>>       TimerImpl tt = new TimerImpl(listener);
>>       if (timer == null) {
>>           timer = new java.util.Timer();
>>       }
>>       timer.schedule(tt, date);
>>       return tt;
>>   }
>>
>>That starts the timer if the schedule method id used. The advantage for
>>me was just to change the TimerManagerImpl class.
>>
>>But I think we can also use your way.
>>
>>Cheers,
>>Thomas
>>
>>Guillaume Nodet wrote:
>>
>>>Absolutely.
>>>Actually, I think it should be safe to create / start the timer in the
>>>getTimerManager() method.  We may need to add a boolean property to
>>>know if the timer manager has been started or not.  This would lead to
>>>only changing the EIPEndpoint class.
>>>
>>>On Mon, Sep 8, 2008 at 3:12 PM, Thomas Termin
>>><tt...@blue-elephant-systems.com> wrote:
>>>
>>>
>>>>Hi,
>>>>
>>>>another question. Each EIPEndpoint has an TimerManager associated and it
>>>>is also startet and a thread is created even if it is not used. The only
>>>>class which I can see using the runing timer thread is the
>>>>AbstractAggregator. Would it be not better to create just a
>>>>TimerManagerImpl instance in each EIPComponent but start it the first
>>>>time it is really used? The AbstractAggregator could check if it runs
>>>>and when not could start it. We could save a lot of created threads (at
>>>>least in our cases), couldn't we?
>>>>It might be that I'm wrong so please correct me. What do you think?
>>>>
>>>>Cheers
>>>>Thomas
>>>>--
>>>>Thomas Termin
>>>>_______________________________
>>>>blue elephant systems GmbH
>>>>Wollgrasweg 49
>>>>D-70599 Stuttgart
>>>>
>>>>Tel    :  (+49) 0711 - 45 10 17 676
>>>>Fax    :  (+49) 0711 - 45 10 17 573
>>>>WWW    :  http://www.blue-elephant-systems.com
>>>>Email  :  Thomas.Termin@blue-elephant-systems.com
>>>>
>>>>blue elephant systems GmbH
>>>>Firmensitz      : Wollgrasweg 49, D-70599 Stuttgart
>>>>Registergericht : Amtsgericht Stuttgart, HRB 24106
>>>>Geschäftsführer : Holger Dietrich, Thomas Gentsch, Joachim Hoernle
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>>--
>>Thomas Termin
>>_______________________________
>>blue elephant systems GmbH
>>Wollgrasweg 49
>>D-70599 Stuttgart
>>
>>Tel    :  (+49) 0711 - 45 10 17 676
>>Fax    :  (+49) 0711 - 45 10 17 573
>>WWW    :  http://www.blue-elephant-systems.com
>>Email  :  Thomas.Termin@blue-elephant-systems.com
>>
>>blue elephant systems GmbH
>>Firmensitz      : Wollgrasweg 49, D-70599 Stuttgart
>>Registergericht : Amtsgericht Stuttgart, HRB 24106
>>Geschäftsführer : Holger Dietrich, Thomas Gentsch, Joachim Hoernle
>>
>>
> 
> 
> 
> 


-- 
Thomas Termin
_______________________________
blue elephant systems GmbH
Wollgrasweg 49
D-70599 Stuttgart

Tel    :  (+49) 0711 - 45 10 17 676
Fax    :  (+49) 0711 - 45 10 17 573
WWW    :  http://www.blue-elephant-systems.com
Email  :  Thomas.Termin@blue-elephant-systems.com

blue elephant systems GmbH
Firmensitz      : Wollgrasweg 49, D-70599 Stuttgart
Registergericht : Amtsgericht Stuttgart, HRB 24106
Geschäftsführer : Holger Dietrich, Thomas Gentsch, Joachim Hoernle


Re: next question about implementation

Posted by Guillaume Nodet <gn...@gmail.com>.
Looks good.  We may want to add a synchronize keyword the two
schedule() methods, empty the start one, and make sure to check if the
timer has been created in the stop method (and set it back to null
btw).  And I think the stop method should be synchronized too ...
Feel free to go ahead and commit this modified class.

On Mon, Sep 8, 2008 at 4:54 PM, Thomas Termin
<tt...@blue-elephant-systems.com> wrote:
> Thanks! So cool that I'm not absolutly wrong here. :-D
>
> I did the following:
>
> public Timer schedule(TimerListener listener, long delay) {
>        if (LOG.isDebugEnabled()) {
>            LOG.debug("Schedule timer " + listener + " for " + delay);
>        }
>        TimerImpl tt = new TimerImpl(listener);
>        if (timer == null) {
>            timer = new java.util.Timer();
>        }
>        timer.schedule(tt, delay);
>        return tt;
>    }
>
> public Timer schedule(TimerListener listener, Date date) {
>        if (LOG.isDebugEnabled()) {
>            LOG.debug("Schedule timer " + listener + " at " + date);
>        }
>        TimerImpl tt = new TimerImpl(listener);
>        if (timer == null) {
>            timer = new java.util.Timer();
>        }
>        timer.schedule(tt, date);
>        return tt;
>    }
>
> That starts the timer if the schedule method id used. The advantage for
> me was just to change the TimerManagerImpl class.
>
> But I think we can also use your way.
>
> Cheers,
> Thomas
>
> Guillaume Nodet wrote:
>> Absolutely.
>> Actually, I think it should be safe to create / start the timer in the
>> getTimerManager() method.  We may need to add a boolean property to
>> know if the timer manager has been started or not.  This would lead to
>> only changing the EIPEndpoint class.
>>
>> On Mon, Sep 8, 2008 at 3:12 PM, Thomas Termin
>> <tt...@blue-elephant-systems.com> wrote:
>>
>>>Hi,
>>>
>>>another question. Each EIPEndpoint has an TimerManager associated and it
>>>is also startet and a thread is created even if it is not used. The only
>>>class which I can see using the runing timer thread is the
>>>AbstractAggregator. Would it be not better to create just a
>>>TimerManagerImpl instance in each EIPComponent but start it the first
>>>time it is really used? The AbstractAggregator could check if it runs
>>>and when not could start it. We could save a lot of created threads (at
>>>least in our cases), couldn't we?
>>>It might be that I'm wrong so please correct me. What do you think?
>>>
>>>Cheers
>>>Thomas
>>>--
>>>Thomas Termin
>>>_______________________________
>>>blue elephant systems GmbH
>>>Wollgrasweg 49
>>>D-70599 Stuttgart
>>>
>>>Tel    :  (+49) 0711 - 45 10 17 676
>>>Fax    :  (+49) 0711 - 45 10 17 573
>>>WWW    :  http://www.blue-elephant-systems.com
>>>Email  :  Thomas.Termin@blue-elephant-systems.com
>>>
>>>blue elephant systems GmbH
>>>Firmensitz      : Wollgrasweg 49, D-70599 Stuttgart
>>>Registergericht : Amtsgericht Stuttgart, HRB 24106
>>>Geschäftsführer : Holger Dietrich, Thomas Gentsch, Joachim Hoernle
>>>
>>>
>>
>>
>>
>>
>
>
> --
> Thomas Termin
> _______________________________
> blue elephant systems GmbH
> Wollgrasweg 49
> D-70599 Stuttgart
>
> Tel    :  (+49) 0711 - 45 10 17 676
> Fax    :  (+49) 0711 - 45 10 17 573
> WWW    :  http://www.blue-elephant-systems.com
> Email  :  Thomas.Termin@blue-elephant-systems.com
>
> blue elephant systems GmbH
> Firmensitz      : Wollgrasweg 49, D-70599 Stuttgart
> Registergericht : Amtsgericht Stuttgart, HRB 24106
> Geschäftsführer : Holger Dietrich, Thomas Gentsch, Joachim Hoernle
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

Re: next question about implementation

Posted by Thomas Termin <tt...@blue-elephant-systems.com>.
Thanks! So cool that I'm not absolutly wrong here. :-D

I did the following:

public Timer schedule(TimerListener listener, long delay) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Schedule timer " + listener + " for " + delay);
        }
        TimerImpl tt = new TimerImpl(listener);
        if (timer == null) {
            timer = new java.util.Timer();
        }
        timer.schedule(tt, delay);
        return tt;
    }

public Timer schedule(TimerListener listener, Date date) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Schedule timer " + listener + " at " + date);
        }
        TimerImpl tt = new TimerImpl(listener);
        if (timer == null) {
            timer = new java.util.Timer();
        }
        timer.schedule(tt, date);
        return tt;
    }

That starts the timer if the schedule method id used. The advantage for
me was just to change the TimerManagerImpl class.

But I think we can also use your way.

Cheers,
Thomas

Guillaume Nodet wrote:
> Absolutely.
> Actually, I think it should be safe to create / start the timer in the
> getTimerManager() method.  We may need to add a boolean property to
> know if the timer manager has been started or not.  This would lead to
> only changing the EIPEndpoint class.
> 
> On Mon, Sep 8, 2008 at 3:12 PM, Thomas Termin
> <tt...@blue-elephant-systems.com> wrote:
> 
>>Hi,
>>
>>another question. Each EIPEndpoint has an TimerManager associated and it
>>is also startet and a thread is created even if it is not used. The only
>>class which I can see using the runing timer thread is the
>>AbstractAggregator. Would it be not better to create just a
>>TimerManagerImpl instance in each EIPComponent but start it the first
>>time it is really used? The AbstractAggregator could check if it runs
>>and when not could start it. We could save a lot of created threads (at
>>least in our cases), couldn't we?
>>It might be that I'm wrong so please correct me. What do you think?
>>
>>Cheers
>>Thomas
>>--
>>Thomas Termin
>>_______________________________
>>blue elephant systems GmbH
>>Wollgrasweg 49
>>D-70599 Stuttgart
>>
>>Tel    :  (+49) 0711 - 45 10 17 676
>>Fax    :  (+49) 0711 - 45 10 17 573
>>WWW    :  http://www.blue-elephant-systems.com
>>Email  :  Thomas.Termin@blue-elephant-systems.com
>>
>>blue elephant systems GmbH
>>Firmensitz      : Wollgrasweg 49, D-70599 Stuttgart
>>Registergericht : Amtsgericht Stuttgart, HRB 24106
>>Geschäftsführer : Holger Dietrich, Thomas Gentsch, Joachim Hoernle
>>
>>
> 
> 
> 
> 


-- 
Thomas Termin
_______________________________
blue elephant systems GmbH
Wollgrasweg 49
D-70599 Stuttgart

Tel    :  (+49) 0711 - 45 10 17 676
Fax    :  (+49) 0711 - 45 10 17 573
WWW    :  http://www.blue-elephant-systems.com
Email  :  Thomas.Termin@blue-elephant-systems.com

blue elephant systems GmbH
Firmensitz      : Wollgrasweg 49, D-70599 Stuttgart
Registergericht : Amtsgericht Stuttgart, HRB 24106
Geschäftsführer : Holger Dietrich, Thomas Gentsch, Joachim Hoernle


Re: next question about implementation

Posted by Guillaume Nodet <gn...@gmail.com>.
Absolutely.
Actually, I think it should be safe to create / start the timer in the
getTimerManager() method.  We may need to add a boolean property to
know if the timer manager has been started or not.  This would lead to
only changing the EIPEndpoint class.

On Mon, Sep 8, 2008 at 3:12 PM, Thomas Termin
<tt...@blue-elephant-systems.com> wrote:
> Hi,
>
> another question. Each EIPEndpoint has an TimerManager associated and it
> is also startet and a thread is created even if it is not used. The only
> class which I can see using the runing timer thread is the
> AbstractAggregator. Would it be not better to create just a
> TimerManagerImpl instance in each EIPComponent but start it the first
> time it is really used? The AbstractAggregator could check if it runs
> and when not could start it. We could save a lot of created threads (at
> least in our cases), couldn't we?
> It might be that I'm wrong so please correct me. What do you think?
>
> Cheers
> Thomas
> --
> Thomas Termin
> _______________________________
> blue elephant systems GmbH
> Wollgrasweg 49
> D-70599 Stuttgart
>
> Tel    :  (+49) 0711 - 45 10 17 676
> Fax    :  (+49) 0711 - 45 10 17 573
> WWW    :  http://www.blue-elephant-systems.com
> Email  :  Thomas.Termin@blue-elephant-systems.com
>
> blue elephant systems GmbH
> Firmensitz      : Wollgrasweg 49, D-70599 Stuttgart
> Registergericht : Amtsgericht Stuttgart, HRB 24106
> Geschäftsführer : Holger Dietrich, Thomas Gentsch, Joachim Hoernle
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/