学习Note

Mina deadlock判断:

在DefaultIoFuture类中,checkDeadLock方法:

in DefaultIoFuture the deadlock detection algorithm, the strategy is in two steps, first is a simple and rapid method to detect, and then use a more accurate method to detect. The first method to obtain the current thread by getStackTrace the entire stack of array of elements, then iterate the array to see if there is a layer called the class is AbstractPollingIoProcessor, if any, is the existence of cycles is called deadlock. This is because to achieve IoProcessor AbstractPollingIoProcessor abstract class that contains an Executor, create a thread processing tasks,


在mina的官方API文档里,在介绍IoFilter时,有这么一句话:

Please NEVER implement your filters to wrapIoSessions.Users can cache the reference to the session, which might malfunction if any filters are added or removed later.

https://mina.apache.org/mina-project/apidocs/index.html

这个是什么意思呢?为何不建议定制filters to wrap IoSession?

The filter is removed from the chain if onPostAdd(IoFilterChain, String, org.apache.mina.core.filterchain.IoFilter.NextFilter)threw an exception. destroy()is also invoked by ReferenceCountingFilter if the filter is the last filter which was added to IoFilterChains. ???

如果是IoFilterChain上的最后一个filter,则调用destroy()方法。

IoService接口管理一个service下的所有session,使用Map用来存储session信息。

public interface IoService {

...

/**

*@returnthe map of all sessions which are currently managed by this

* service.  The key of map is the {@linkIoSession#getId() ID} of the

* session. An empty collection if there's no session.

*/

Map getManagedSessions();

...

}

IoAcceptor代表服务器端,接收客户端的connection,调用handler处理events。

IoConnector代表客户端,连接服务器端,调用handler处理events。

IoAcceptor和IoConnector都extends IoService。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容