Skip to content
Snippets Groups Projects
Commit 52354fba authored by CodingSinger's avatar CodingSinger
Browse files

fix the zk HandleClientRestart issues

parent 319ca562
No related branches found
No related tags found
No related merge requests found
......@@ -178,7 +178,10 @@ func (r *BaseRegistry) RestartCallBack() bool {
}
logger.Infof("success to re-register service :%v", confIf.Key())
}
r.facadeBasedRegistry.InitListeners()
if flag {
r.facadeBasedRegistry.InitListeners()
}
return flag
}
......
......@@ -38,7 +38,6 @@ import (
// RegistryDataListener ...
type RegistryDataListener struct {
subscribed map[*common.URL]config_center.ConfigurationListener
listener config_center.ConfigurationListener
mutex sync.Mutex
closed bool
}
......
......@@ -120,8 +120,12 @@ func newMockZkRegistry(url *common.URL, opts ...zookeeper.Option) (*zk.TestClust
func (r *zkRegistry) InitListeners() {
r.listener = zookeeper.NewZkEventListener(r.client)
r.dataListener = NewRegistryDataListener()
recoverd := r.dataListener.subscribed
newDataListener := NewRegistryDataListener()
for url, _ := range recoverd {
newDataListener.SubscribeURL(url, NewRegistryConfigurationListener(r.client, r))
}
r.dataListener = newDataListener
}
func (r *zkRegistry) CreatePath(path string) error {
......@@ -174,8 +178,9 @@ func (r *zkRegistry) registerTempZookeeperNode(root string, node string) error {
}
zkPath, err = r.client.RegisterTemp(root, node)
if err != nil {
if err == zk.ErrNodeExists {
logger.Warnf("RegisterTempNode(root{%s}, node{%s}) = error{%v}", root, node, perrors.WithStack(err))
if perrors.Cause(err) == zk.ErrNodeExists {
logger.Warnf("RegisterTempNode(root{%s}, node{%s}) = error{%v}, ignore!", root, node, perrors.WithStack(err))
return nil
} else {
logger.Errorf("RegisterTempNode(root{%s}, node{%s}) = error{%v}", root, node, perrors.WithStack(err))
}
......@@ -222,6 +227,5 @@ func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListen
go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, url.QueryEscape(conf.Service())), r.dataListener)
return zkListener, nil
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment