Skip to content

Commit 55c2b2e

Browse files
committed
ignore
1 parent be61c75 commit 55c2b2e

2 files changed

Lines changed: 24 additions & 18 deletions

File tree

Netty/netty-channel-attr.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Constant
66
|-AbstractConstant
77
|-AttributeKey
8-
8+
ConstantPool
99
AttributeMap
1010
|-DefaultAttributeMap
1111
|-AbstractChannel
@@ -15,6 +15,24 @@
1515

1616
Attribute
1717

18+
# ConstantPool
19+
* 维护了一个 ConcurrentHashMap
20+
private final ConcurrentMap<String, T> constants = PlatformDependent.newConcurrentHashMap();
21+
22+
23+
# AttributeMap
24+
* 一个抽象的接口, Channel 实现了
25+
<T> Attribute<T> attr(AttributeKey<T> key);
26+
<T> boolean hasAttr(AttributeKey<T> key);
27+
28+
# Attribute
29+
* 表示Value的接口
30+
AttributeKey<T> key();
31+
T get();
32+
void set(T value);
33+
T getAndSet(T value);
34+
T setIfAbsent(T value);
35+
boolean compareAndSet(T oldValue, T newValue);
1836

1937
# ChannelHandlerContext Channel attr 没有区别
2038
Channel.attr() == ChannelHandlerContext.attr()
@@ -45,19 +63,3 @@ public static <T> AttributeKey<T> valueOf(Class<?> firstNameComponent, String se
4563
* 底层还是调用 valueOf(String name),
4664
* firstNameComponent secondNameComponent 之间添加了 '#' 字符串(命名空间的感觉)
4765

48-
-------------------------
49-
Attribute |
50-
-------------------------
51-
# 表示Value
52-
53-
AttributeKey<T> key();
54-
55-
T get();
56-
57-
void set(T value);
58-
59-
T getAndSet(T value);
60-
61-
T setIfAbsent(T value);
62-
63-
boolean compareAndSet(T oldValue, T newValue);

Netty/netty-超时.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@ public IdleStateHandler(long readerIdleTime, long writerIdleTime, long allIdleTi
3535
* 可以通过该对象判断是什么超时事件发生了
3636
* 该对象是一个枚举对象(非枚举类)
3737
IdleStateEvent.FIRST_READER_IDLE_STATE_EVENT
38-
* 第一次发生了读超时
38+
* 第一次发生了读超时, 就是很久没读取到客户的信息了
3939

4040
IdleStateEvent.READER_IDLE_STATE_EVENT
4141
* 不是第一次发生了读超时,如果出现该状态,就说明channle目前处于连续读超时(起码2次)
4242

4343
IdleStateEvent.FIRST_WRITER_IDLE_STATE_EVENT
44+
* 第一次发生了写超时, 就是很久没往客户端写数据了
45+
4446
IdleStateEvent.WRITER_IDLE_STATE_EVENT
4547
IdleStateEvent.FIRST_ALL_IDLE_STATE_EVENT
48+
* 第一次发生, 读写都超时了
49+
4650
IdleStateEvent.ALL_IDLE_STATE_EVENT
4751

4852
# 总结

0 commit comments

Comments
 (0)