Hi,

I will remove the if condition as in Azeez's solution, as there is no
performance gain having if condition in production environment.

Thanks,
Nipuni


On Thu, Jul 17, 2014 at 12:25 PM, Prasad Tissera <[email protected]> wrote:

> If you need to keep the if condition, something like following will do the
> job.
>
> if (log.isWarnEnabled()) {
>             String msg = sm.getString(
>                 "stuckThreadDetectionValve.notifyStuckThreadDetected",
>                 monitoredThread.getThread().getName(), activeTime,
>                 monitoredThread.getStartTime(), numStuckThreads,
>                 monitoredThread.getRequestUri(), threshold);
>             msg += ", tenantDomain=" + monitoredThread.getTenantDomain();
>             // msg += "\n" + getStackTraceAsString(trace);
>             Throwable th = new Throwable();
>             th.setStackTrace(monitoredThread.getThread().getStackTrace());
>             log.warn(msg, th);
>
>         }
>
> monitoredThread.getThread().interrupt();
> monitoredThread.getThread().stop();  // TODO: Not a good practice, but we
> are using this as a last resort to kill rogue tenant threads
> activeThreads.remove(monitoredThread.getThread().getId());
>
> But as Azeez said, because at logging level always set at least to WARN
> that does not have any performance gain.
>
> Regards,
> Prasad.
>
>
> On Thu, Jul 17, 2014 at 12:09 PM, Afkham Azeez <[email protected]> wrote:
>
>>
>>
>>
>> On Thu, Jul 17, 2014 at 12:01 PM, Nipuni Perera <[email protected]> wrote:
>>
>>> Hi,
>>>
>>> Regarding the issue[1], handleStuckThread() method in class
>>> CarbonStuckThreadDetectionValve [2] interrupt threads only when warn logs
>>> are enabled.
>>>
>>
>> Generally. we set log level to INFO so this has been working fine. In
>> production, you will set the log level to at least WARN. However, it is
>> fine to remove that condition check.
>>
>>
>>> If the thread handling operations are handled outside the if block,
>>> stuck threads can be interrupted without user being informed. Is it
>>> preferred to kill threads without giving any warning?.
>>>
>>> [1] https://wso2.org/jira/browse/CARBON-14603
>>> [2]
>>> https://github.com/wso2-dev/carbon4-kernel/blob/master/core/org.wso2.carbon.tomcat.ext/src/main/java/org/wso2/carbon/tomcat/ext/valves/CarbonStuckThreadDetectionValve.java
>>>
>>> Thanks,
>>> Nipuni
>>>
>>> --
>>> Nipuni Perera
>>> Software Engineer; WSO2 Inc.; http://wso2.com
>>> Email: [email protected]
>>> Git hub profile: https://github.com/nipuni
>>> Mobile: +94 (71) 5626680
>>> <http://wso2.com>
>>>
>>>
>>
>>
>> --
>> *Afkham Azeez*
>> Director of Architecture; WSO2, Inc.; http://wso2.com
>> Member; Apache Software Foundation; http://www.apache.org/
>> * <http://www.apache.org/>*
>> *email: **[email protected]* <[email protected]>
>> * cell: +94 77 3320919 <%2B94%2077%203320919> blog: *
>> *http://blog.afkham.org* <http://blog.afkham.org>
>> *twitter: **http://twitter.com/afkham_azeez*
>> <http://twitter.com/afkham_azeez>
>> * linked-in: **http://lk.linkedin.com/in/afkhamazeez
>> <http://lk.linkedin.com/in/afkhamazeez>*
>>
>> *Lean . Enterprise . Middleware*
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Prasad Tissera
> Software Engineer.
> Mobile : +94777223444
>



-- 
Nipuni Perera
Software Engineer; WSO2 Inc.; http://wso2.com
Email: [email protected]
Git hub profile: https://github.com/nipuni
Mobile: +94 (71) 5626680
<http://wso2.com>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to