Dubbo connection to zookeeper registry because of a broken network cause thread infinite wait problem "go"

Source: Internet
Author: User
Tags zookeeper

Recently maintained the system switched the network environment, from Unicom to the telecommunications network, because some filtering rules caused the system not connected to the Zookeeper server (application system machine in Shenzhen, Network for telecommunications lines, zookeeper server in Beijing, network for China Unicom Line), Because I am not a maintenance personnel also do not understand the operation and maintenance related technology, so the troubleshooting for a long time also do not know the reason, finally helpless under the Shenzhen side of the network cut back to the Unicom, the system back to normal.

But because this accident embodies a very serious problem, that is, when the zookeeper registry is not connected to the Dubbo thread will wait indefinitely, because the system has some scheduled tasks will be more frequent to open a new thread connection Dubbo, so the result is tomcat a while the thread pool is full, Other features that do not rely on Dubbo are also blocked from being used.

2, Zkclientzookeepertransporter is not the code I want to replace, I want to replace the Zkclientzookeepertransporter member variable zookeeperclient, only Dubbo added SPI annotations on Zookeepertransporter, so I had to do this, Zkclientzookeepertransporter code copied over.  
3, use your own zkclientzookeeperclient in Zkclientzookeepertransporter, the code is as follows:

Package com.gwall.zookeeper;import java.util.list;import org. I0itec.zkclient.izkchildlistener;import org. I0itec.zkclient.izkstatelistener;import org. I0itec.zkclient.zkclient;import org. I0itec.zkclient.exception.zknonodeexception;import org. i0itec.zkclient.exception.zknodeexistsexception;import org.apache.zookeeper.watcher.event.keeperstate; Import com.alibaba.dubbo.common.url;import com.alibaba.dubbo.remoting.zookeeper.childlistener;import  com.alibaba.dubbo.remoting.zookeeper.StateListener;import  com.alibaba.dubbo.remoting.zookeeper.support.abstractzookeeperclient;/** *  The main purpose of modifying the zkclientzookeeperclient *  provided by Dubbo is to increase the time-out of a connection zookeeper to avoid the zkclient default infinite wait  *  @author  long.zr * */public class ZkclientZookeeperClient extends  Abstractzookeeperclient<izkchildlistener> {    private final zkclient  client;    private volatile keeperstate state = keeperstate.syncconnected;     Public zkclientzookeeperclient (Url url)  {        super ( URL);         //set timeout of 5000 milliseconds          client = new zkclient (Url.getbackupaddress (),;      )   client.subscribestatechanges (New izkstatelistener ()  {             public void handlestatechanged (KeeperState state)  throws Exception {                 ZkclientZookeeperClient.this.state = state;                 if  (state ==  keeperstate.disconnected) &NBSP;{&NBSP;&NBSP;&NBsp;                  StateChanged (statelistener.disconnected);                 } else if  (state == keeperstate.syncconnected)  {                      statechanged (statelistener.connected);                 }            }             public void handlenewsession ()  throws Exception {                 statechanged (statelistener.reconnected);            &nbsP;}         });     }    public  void createpersistent (String path)  {        try  {            client.createpersistent (Path,  true);        } catch  (ZkNodeExistsException e)  {        }    }     Public void createephemeral (String path)  {         Try {            client.createephemeral (PATH) ;        } catch  (zknodeexistsexception e)  {         }    }    public void  delete (string p Ath)  {        try {             client.delete (path);         }  catch  (zknonodeexception e)  {        }     }    public list<string> getchildren (String path)  {        try {             return client.getchildren (PATH);         } catch  (zknonodeexception e)  {             return null;        }     }    public boolean isconnected ()  {         return state == keeperstate.syncconnected;    }    public void  Doclose ()  {        client.close ();    }     public izkchildlistener createtargetchildlistener (String path, final  childlistener listener)  {        return new  Izkchildlistener ()  {            public  Void handlechildchange (String parentpath, list<string> currentchilds)                       throws exception {                 listener.childchanged (Parentpath, currentchilds);             }        };    }     Public list<string> addtargetchildlistener (String path, final izkchildlistener  listener)  {        return client.subscribechildchanges (Path, listener);    }    public void  Removetargetchildlistener (String path, izkchildlistener listener)  {         client.unsubscribechildchanges (Path,  listener);     }}

Framework/Platform composition:

maven+ SPRINGMVC + Mybatis + Shiro (permissions) + Tiles (template) +activemq (Message Queuing) + Rest (service) + WebService (service) + EHcache (cache) + Quartz (scheduled) + HTML5 ( Support for PC, IOS, Android)

user rights system:
Organizational structure: Roles, users, user groups, organizations, permission points: Pages, methods, buttons, data permissions, Hierarchical authorization

New project management experience :
Rapid Prototyping, component tree, version control, module porting, collaborative development, Real-time monitoring, Release Management

Sustainable integration:
All components are portable, customizable, extensible, and build on development results , forming a virtuous circle of sustainable development

platform platform:  
Windows XP, Windows 7, Windows 10, Linux, Unix

server container:
Tomcat 5/6/7, Jetty, JBoss, WebSphere 8.5 

650) this.width=650; "alt=" Jeesz generic version Distributed modular development platform-Zookeeperflume-zookeeperflume blog "src=" http://img1.ph.126.net/ 4plhmet3ulpujqrsbtooyg==/4861635797847281602.png "style=" border:0px;height:auto;margin:0px 10px 0px 0px; "/>

650) this.width=650; "alt=" Jeesz generic version Distributed modular development platform-Zookeeperflume-zookeeperflume blog "src=" http://img2.ph.126.net/ Cg2njkrkmjfy75jfrlubwg==/6598205562228862577.png "style=" border:0px;height:auto;margin:0px 10px 0px 0px; "/>

650) this.width=650; "alt=" Jeesz generic version Distributed modular development platform-Zookeeperflume-zookeeperflume blog "src=" http://img2.ph.126.net/ Yhpexu5txhlnoxxhgelycw==/2871607712502861641.png "style=" border:0px;height:auto;margin:0px 10px 0px 0px; "/>

650) this.width=650; "alt=" Jeesz generic version Distributed modular development platform-Zookeeperflume-zookeeperflume blog "src=" http://img2.ph.126.net/F2j_ W3otqqcfcqzni0tjma==/3756846514257653360.png "style=" border:0px;height:auto;margin:0px 10px 0px 0px; "/>


Dubbo connection to zookeeper registry because of a broken network cause thread infinite wait problem "go"

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.