Atitit. The stability of the upgrade software---persistent cyclic queue based on database implementation

Source: Internet
Author: User
Tags addall

Atitit. stability of the upgrade software --- implementing persistent cyclic queue ring queue based on database

1. Preface :: selection ( horse ) 1

2. Implementing the java.util.queue Interface 1

3. 2 implementations of the current pointer 1

1.1. With a cursor last to indicate (the pointer table field last ), troublesome , not recommended 1

1.2. ( simple , recommended ) Use the number of cycles to indicate that each loop adds 1 ( field Cirtimes), ORDER by Cirtimes 1

4. Table Design ID, cirtimes,createtime,handlerid,recid,delflag 1

5. Circular queue Loop Queue usage Flow 2

1.3. Increase the queue Addall,add 2

1.4. Grab the element to be processed peek (int fetchcount) Delflag=0,order by Cirtimes 2

1.5. Out of the squad and append to the end of the team Remove,removeall (list)::: cirtimes++; 2

1. Preface:: Selection (horse)

Pick a Li Yiwa , a implet for the horse

In order to use the Loop queue , the stability of the queue can be greatly improved . prevent push messages outdate do not send . .. and avoid the queue to stay stuck

2. Implement the Java.util.queue interface

3.2 implementations of the current pointer

1.1. With a cursor last to indicate (the Pointer table field last), troublesome, not recommended 1.2. (simple, recommended) use the number of cycles to indicate that each loop adds 1 (field cirtimes), and order by Cirtimes

Author :: Old Wow's paw attilax ayron,email:[email protected]

Reprint please indicate source: Http://blog.csdn.net/attilax

4. Table Design ID, Cirtimes,createtime,handlerid,recid,delflag

ID, Cirtimes,createtime,handlerid,recid,delflag

Handlerid:: be able to make a lot of processor use , each processor just get their own queue .

RecId:: associated Rec ID ...

5. Circular queue loop queue using flow 1.3. Increase Queue Addall,add

1.4. Fetching the elements to be processedPeek(int Fetchcount)  Delflag=0,order by Cirtimes

Public List Peek( int fetchcount) {

//  Attilax Old Wow's paw m_9_r o7s

Final List li = new ArrayList ();

Noticeflag is null

String hql="from Gvdownloadtask where 1=1 and downloadstatus are null ORDER by NOTICEFL AG ";

Query Q = getsession(). CreateQuery (hql) ;  

Q . Setfirstresult (0) ;  

Q . Setmaxresults (fetchcount) ;  

List l = q. List ();  

return l;

}

1.5. Out of the squad and append to the end of the team Remove,removeall (list)::: cirtimes++;

T . Setnoticeflag (t. Getnoticeflag ()+1);

C . Merge (t) ;

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

Atitit. The stability of the upgrade software---persistent cyclic queue based on database implementation

Related Article

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.