Connection failed connection interval variable

Source: Internet
Author: User
Tags jboss

Hash wheel Timer It is an algorithm that Netty for the heartbeat timeout check, the performance of the algorithm several co-owned: Ticks per wheel (around tick number), tick Duration (one tick duration) and timeunit (Time unit )。 Left and right tick duration I feel it should be explained for every tick interval.

Hashedwheeltimer the original English gaze expresses such a layer of meaning:

A timer for near real-time I/O network timeout scheduling.

*tick Duration: As described in "near real-time". Hashedwheeltimer will not dispatch on time (very few intervals). Each tick will check to see if TimerTask can be scheduled to run, and you can specify a long or short time tick duration in the constructor to control the accuracy of the dispatch time.

Ticks per Wheel:hashedwheeltimer maintains a data structure called a "time Wheel", where a time-wheel hash table is stored by the hash code of a task's death time.

The default size is 512 hash tables. Assuming you need to schedule a very large number of task timeouts, you can increase this value.


Connection failed reconnection. 500 milliseconds for the first time. Second 1000 milliseconds, ...., n-1 times 5 seconds. Nth Time 5 Seconds


Connection failure time interval maximum 5 seconds

Import Java.util.concurrent.timeunit;import Org.jboss.netty.util.hashedwheeltimer;import Org.jboss.netty.util.timeout;import Org.jboss.netty.util.timer;import Org.jboss.netty.util.timertask;public Class timeouttest {public static void main (string[] argv) {/*-* tick Duration (duration of a tick): * As described in "near real-time", Hashedwheeltimer will not be (very few intervals). * Every tick will check to see if TimerTask can be scheduled to run, * You can specify a long or short time tick duration in the constructor to control the accuracy of the dispatch time. * * Can be understood as: every tick interval *---------------------------------------------------------------------------------*ticks per Wheel (tick count): *hashedwheeltimer maintains a data structure called "Time Wheel", and a time-wheel hash table is stored by the hash code of a task's death time.

* The default size is 512 hash tables. Assuming you need to schedule a very large number of task timeouts, you can increase this value. * * Can be understood as: agree to the number of timeout, the default is 512. */final Timer timer = new Hashedwheeltimer (timeunit.microseconds); Timer.newtimeout (new TimerTask () {private int t = 0 ;p rivate int count = 1;private int step = 500;public void Run (timeout timeout) throws Exception {System.out.println ("This is a delay "+ t +" run after milliseconds "); if ((Count * Step) <= 5 * +) {t = count * step; System.out.println ("Next run will be delayed" + t + "milliseconds after" + Count + "Times"); count++;} Timeout.gettimer (). Newtimeout (Timeout.gettask (), T, timeunit.milliseconds);}}, and Timeunit.milliseconds);}}



Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

Connection failed connection interval variable

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.