📄 abstractiosession.html
字号:
<a name="372" href="#372">372</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> Set<Object> getAttributeKeys() {<a name="373" href="#373">373</a> <strong class="jxr_keyword">return</strong> attributes.getAttributeKeys(<strong class="jxr_keyword">this</strong>);<a name="374" href="#374">374</a> }<a name="375" href="#375">375</a> <a name="376" href="#376">376</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../org/apache/mina/common/IoSessionAttributeMap.html">IoSessionAttributeMap</a> getAttributeMap() {<a name="377" href="#377">377</a> <strong class="jxr_keyword">return</strong> attributes;<a name="378" href="#378">378</a> }<a name="379" href="#379">379</a> <a name="380" href="#380">380</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> setAttributeMap(<a href="../../../../org/apache/mina/common/IoSessionAttributeMap.html">IoSessionAttributeMap</a> attributes) {<a name="381" href="#381">381</a> <strong class="jxr_keyword">this</strong>.attributes = attributes;<a name="382" href="#382">382</a> }<a name="383" href="#383">383</a> <a name="384" href="#384">384</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> setWriteRequestQueue(<a href="../../../../org/apache/mina/common/WriteRequestQueue.html">WriteRequestQueue</a> writeRequestQueue) {<a name="385" href="#385">385</a> <strong class="jxr_keyword">this</strong>.writeRequestQueue =<a name="386" href="#386">386</a> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/mina/common/AbstractIoSession.html">CloseRequestAwareWriteRequestQueue</a>(writeRequestQueue);<a name="387" href="#387">387</a> }<a name="388" href="#388">388</a> <a name="389" href="#389">389</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../org/apache/mina/common/TrafficMask.html">TrafficMask</a> getTrafficMask() {<a name="390" href="#390">390</a> <strong class="jxr_keyword">return</strong> trafficMask;<a name="391" href="#391">391</a> }<a name="392" href="#392">392</a> <a name="393" href="#393">393</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> setTrafficMask(<a href="../../../../org/apache/mina/common/TrafficMask.html">TrafficMask</a> trafficMask) {<a name="394" href="#394">394</a> <strong class="jxr_keyword">if</strong> (trafficMask == <strong class="jxr_keyword">null</strong>) {<a name="395" href="#395">395</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> NullPointerException(<span class="jxr_string">"trafficMask"</span>);<a name="396" href="#396">396</a> }<a name="397" href="#397">397</a> <a name="398" href="#398">398</a> <strong class="jxr_keyword">if</strong> (isClosing() || !isConnected()) {<a name="399" href="#399">399</a> <strong class="jxr_keyword">return</strong>;<a name="400" href="#400">400</a> }<a name="401" href="#401">401</a> <a name="402" href="#402">402</a> getFilterChain().fireFilterSetTrafficMask(trafficMask);<a name="403" href="#403">403</a> }<a name="404" href="#404">404</a> <a name="405" href="#405">405</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> setTrafficMaskNow(<a href="../../../../org/apache/mina/common/TrafficMask.html">TrafficMask</a> trafficMask) {<a name="406" href="#406">406</a> <strong class="jxr_keyword">this</strong>.trafficMask = trafficMask;<a name="407" href="#407">407</a> }<a name="408" href="#408">408</a> <a name="409" href="#409">409</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> suspendRead() {<a name="410" href="#410">410</a> setTrafficMask(getTrafficMask().and(TrafficMask.READ.not()));<a name="411" href="#411">411</a> }<a name="412" href="#412">412</a> <a name="413" href="#413">413</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> suspendWrite() {<a name="414" href="#414">414</a> setTrafficMask(getTrafficMask().and(TrafficMask.WRITE.not()));<a name="415" href="#415">415</a> }<a name="416" href="#416">416</a> <a name="417" href="#417">417</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> resumeRead() {<a name="418" href="#418">418</a> setTrafficMask(getTrafficMask().or(TrafficMask.READ));<a name="419" href="#419">419</a> }<a name="420" href="#420">420</a> <a name="421" href="#421">421</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> resumeWrite() {<a name="422" href="#422">422</a> setTrafficMask(getTrafficMask().or(TrafficMask.WRITE));<a name="423" href="#423">423</a> }<a name="424" href="#424">424</a> <a name="425" href="#425">425</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> getReadBytes() {<a name="426" href="#426">426</a> <strong class="jxr_keyword">return</strong> readBytes;<a name="427" href="#427">427</a> }<a name="428" href="#428">428</a> <a name="429" href="#429">429</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> getWrittenBytes() {<a name="430" href="#430">430</a> <strong class="jxr_keyword">return</strong> writtenBytes;<a name="431" href="#431">431</a> }<a name="432" href="#432">432</a> <a name="433" href="#433">433</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> getReadMessages() {<a name="434" href="#434">434</a> <strong class="jxr_keyword">return</strong> readMessages;<a name="435" href="#435">435</a> }<a name="436" href="#436">436</a> <a name="437" href="#437">437</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> getWrittenMessages() {<a name="438" href="#438">438</a> <strong class="jxr_keyword">return</strong> writtenMessages;<a name="439" href="#439">439</a> }<a name="440" href="#440">440</a> <a name="441" href="#441">441</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">double</strong> getReadBytesThroughput() {<a name="442" href="#442">442</a> <strong class="jxr_keyword">return</strong> readBytesThroughput;<a name="443" href="#443">443</a> }<a name="444" href="#444">444</a> <a name="445" href="#445">445</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">double</strong> getWrittenBytesThroughput() {<a name="446" href="#446">446</a> <strong class="jxr_keyword">return</strong> writtenBytesThroughput;<a name="447" href="#447">447</a> }<a name="448" href="#448">448</a> <a name="449" href="#449">449</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">double</strong> getReadMessagesThroughput() {<a name="450" href="#450">450</a> <strong class="jxr_keyword">return</strong> readMessagesThroughput;<a name="451" href="#451">451</a> }<a name="452" href="#452">452</a> <a name="453" href="#453">453</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">double</strong> getWrittenMessagesThroughput() {<a name="454" href="#454">454</a> <strong class="jxr_keyword">return</strong> writtenMessagesThroughput;<a name="455" href="#455">455</a> }<a name="456" href="#456">456</a> <a name="457" href="#457">457</a> <em class="jxr_javadoccomment">/**</em><a name="458" href="#458">458</a> <em class="jxr_javadoccomment"> * Update all statistical properties related with throughput assuming</em><a name="459" href="#459">459</a> <em class="jxr_javadoccomment"> * the specified time is the current time. By default this method returns</em><a name="460" href="#460">460</a> <em class="jxr_javadoccomment"> * silently without updating the throughput properties if they were </em><a name="461" href="#461">461</a> <em class="jxr_javadoccomment"> * calculated already within last </em><a name="462" href="#462">462</a> <em class="jxr_javadoccomment"> * {@link IoSessionConfig#getThroughputCalculationInterval() calculation interval}.</em><a name="463" href="#463">463</a> <em class="jxr_javadoccomment"> * If, however, <tt>force</tt> is specified as <tt>true</tt>, this method </em><a name="464" href="#464">464</a> <em class="jxr_javadoccomment"> * updates the throughput properties immediately.</em><a name="465" href="#465">465</a> <a name="466" href="#466">466</a> <em class="jxr_javadoccomment"> * @param currentTime the current time in milliseconds</em><a name="467" href="#467">467</a> <em class="jxr_javadoccomment"> */</em><a name="468" href="#468">468</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> updateThroughput(<strong class="jxr_keyword">long</strong> currentTime, <strong class="jxr_keyword">boolean</strong> force) {<a name="469" href="#469">469</a> <strong class="jxr_keyword">int</strong> interval = (<strong class="jxr_keyword">int</strong>) (currentTime - lastThroughputCalculationTime);<a name="470" href="#470">470</a> <a name="471" href="#471">471</a> <strong class="jxr_keyword">long</strong> minInterval = getConfig().getThroughputCalculationIntervalInMillis();<a name="472" href="#472">472</a> <strong class="jxr_keyword">if</strong> (minInterval == 0 || interval < minInterval) {<a name="473" href="#473">473</a> <strong class="jxr_keyword">if</strong> (!force) {<a name="474" href="#474">474</a> <strong class="jxr_keyword">return</strong>;<a name="475" href="#475">475</a> }<a name="476" href="#476">476</a> }<a name="477" href="#477">477</a> <a name="478" href="#478">478</a> readBytesThroughput = (readBytes - lastReadBytes) * 1000.0 / interval;<a name="479" href="#479">479</a> writtenBytesThroughput = (writtenBytes - lastWrittenBytes) * 1000.0 / interval;<a name="480" href="#480">480</a> readMessagesThroughput = (readMessages - lastReadMessages) * 1000.0 / interval;<a name="481" href="#481">481</a> writtenMessagesThroughput = (writtenMessages - lastWrittenMessages) * 1000.0 / interval;<a name="482" href="#482">482</a> <a name="483" href="#483">483</a> lastReadBytes = readBytes;<a name="484" href="#484">484</a> lastWrittenBytes = writtenBytes;<a name="485" href="#485">485</a> lastReadMessages = readMessages;<a name="486" href="#486">486</a> lastWrittenMessages = writtenMessages;<a name="487" href="#487">487</a> <a name="488" href="#488">488</a> lastThroughputCalculationTime = currentTime;<a name="489" href="#489">489</a> }<a name="490" href="#490">490</a> <a name="491" href="#491">491</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> getScheduledWriteBytes() {<a name="492" href="#492">492</a> <strong class="jxr_keyword">return</strong> scheduledWriteBytes.get();<a name="493" href="#493">493</a> }<a name="494" href="#494">494</a> <a name="495" href="#495">495</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> getScheduledWriteMessages() {<a name="496" href="#496">496</a> <strong class="jxr_keyword">return</strong> scheduledWriteMessages.get();<a name="497" href="#497">497</a> }<a name="498" href="#498">498</a>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -