1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.channel.epoll;
17
18 import io.netty.buffer.ByteBufAllocator;
19 import io.netty.channel.ChannelOption;
20 import io.netty.channel.MessageSizeEstimator;
21 import io.netty.channel.RecvByteBufAllocator;
22 import io.netty.channel.unix.DomainSocketChannelConfig;
23 import io.netty.channel.unix.DomainSocketReadMode;
24
25 import java.util.Map;
26
27 public final class EpollDomainSocketChannelConfig extends EpollChannelConfig
28 implements DomainSocketChannelConfig {
29 private volatile DomainSocketReadMode mode = DomainSocketReadMode.BYTES;
30
31 EpollDomainSocketChannelConfig(AbstractEpollChannel channel) {
32 super(channel);
33
34 setMaxMessagesPerRead(16);
35 }
36
37 @Override
38 public Map<ChannelOption<?>, Object> getOptions() {
39 return getOptions(super.getOptions(), EpollChannelOption.DOMAIN_SOCKET_READ_MODE);
40 }
41
42 @SuppressWarnings("unchecked")
43 @Override
44 public <T> T getOption(ChannelOption<T> option) {
45 if (option == EpollChannelOption.DOMAIN_SOCKET_READ_MODE) {
46 return (T) getReadMode();
47 }
48 return super.getOption(option);
49 }
50
51 @Override
52 public <T> boolean setOption(ChannelOption<T> option, T value) {
53 validate(option, value);
54
55 if (option == EpollChannelOption.DOMAIN_SOCKET_READ_MODE) {
56 setReadMode((DomainSocketReadMode) value);
57 } else {
58 return super.setOption(option, value);
59 }
60
61 return true;
62 }
63 @Override
64 public EpollDomainSocketChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead) {
65 super.setMaxMessagesPerRead(maxMessagesPerRead);
66 return this;
67 }
68
69 @Override
70 public EpollDomainSocketChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis) {
71 super.setConnectTimeoutMillis(connectTimeoutMillis);
72 return this;
73 }
74
75 @Override
76 public EpollDomainSocketChannelConfig setWriteSpinCount(int writeSpinCount) {
77 super.setWriteSpinCount(writeSpinCount);
78 return this;
79 }
80
81 @Override
82 public EpollDomainSocketChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator) {
83 super.setRecvByteBufAllocator(allocator);
84 return this;
85 }
86
87 @Override
88 public EpollDomainSocketChannelConfig setAllocator(ByteBufAllocator allocator) {
89 super.setAllocator(allocator);
90 return this;
91 }
92
93 @Override
94 public EpollDomainSocketChannelConfig setAutoClose(boolean autoClose) {
95 super.setAutoClose(autoClose);
96 return this;
97 }
98
99 @Override
100 public EpollDomainSocketChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator) {
101 super.setMessageSizeEstimator(estimator);
102 return this;
103 }
104
105 @Override
106 public EpollDomainSocketChannelConfig setWriteBufferLowWaterMark(int writeBufferLowWaterMark) {
107 super.setWriteBufferLowWaterMark(writeBufferLowWaterMark);
108 return this;
109 }
110
111 @Override
112 public EpollDomainSocketChannelConfig setWriteBufferHighWaterMark(int writeBufferHighWaterMark) {
113 super.setWriteBufferHighWaterMark(writeBufferHighWaterMark);
114 return this;
115 }
116
117 @Override
118 public EpollDomainSocketChannelConfig setAutoRead(boolean autoRead) {
119 super.setAutoRead(autoRead);
120 return this;
121 }
122
123 @Override
124 public EpollDomainSocketChannelConfig setEpollMode(EpollMode mode) {
125 super.setEpollMode(mode);
126 return this;
127 }
128
129 @Override
130 public EpollDomainSocketChannelConfig setReadMode(DomainSocketReadMode mode) {
131 if (mode == null) {
132 throw new NullPointerException("mode");
133 }
134 this.mode = mode;
135 return this;
136 }
137
138 @Override
139 public DomainSocketReadMode getReadMode() {
140 return mode;
141 }
142 }