Jstorm multithreading issues when using Kafka as a spout

Source: Internet
Author: User

Jstorm when using Kafka as spout, there will be multi-threaded error problem in high concurrency situation
These two classes need to be appropriately modified to avoid the above problems:
Storm.kafka.PartitionManager
Storm.kafka.ExponentialBackoffMsgRetryManager
Modification of 1.storm.kafka.partitionmanager
//The variablePrivate Sortedmap<long, long> _pending =NewTreeMap ();//SwitchPrivate Sortedmap<long, long> _pending = Collections.synchronizedsortedmap (New Treemap<long, long>());/**----------------------------------------------------------------------------------------------------**///The methodPublicLongLastcompletedoffset () {return this._pending.isempty ()?  This._emittedtooffset.longvalue ():((Long) this._ Pending.firstkey ()). Longvalue ();} // change to: public long Lastcompletedoffset () { Synchronized (_pending) {if  (_pending.isempty ()) {return  _emittedtooffset;} else {return _pending.firstkey (); } }} 

Modification of 2.storm.kafka.exponentialbackoffmsgretrymanager
//will bePrivateQueue<exponentialbackoffmsgretrymanager.messageretryrecord> waiting =NewPriorityqueue (11,Newexponentialbackoffmsgretrymanager.retrytimecomparator ()); PrivateMap<long, exponentialbackoffmsgretrymanager.messageretryrecord> records =NewConcurrenthashmap ();//instead:PrivateQueue<messageretryrecord> waiting =NewPriorityblockingqueue<messageretryrecord> (11,Newretrytimecomparator ()); PrivateMap<long,messageretryrecord> records =NewConcurrenthashmap<long,messageretryrecord> ();

Jstorm multithreading issues when using Kafka as a spout

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.