diff --git a/common/config/environment.go b/common/config/environment.go index 998f0beefdb7c898c1a15fde4804a53a5ff133fa..8709d69a78263ab99501c4f6db78e78c47d2955b 100644 --- a/common/config/environment.go +++ b/common/config/environment.go @@ -63,32 +63,40 @@ func (env *Environment) UpdateExternalConfigMap(externalMap map[string]string) { func (env *Environment) Configuration() *list.List { list := list.New() memConf := newInmemoryConfiguration() - memConf.setProperties(env.externalConfigMap) + memConf.setProperties(&(env.externalConfigMap)) list.PushBack(memConf) return list } type InmemoryConfiguration struct { - store sync.Map + store *sync.Map } func newInmemoryConfiguration() *InmemoryConfiguration { return &InmemoryConfiguration{} } -func (conf *InmemoryConfiguration) setProperties(p sync.Map) { +func (conf *InmemoryConfiguration) setProperties(p *sync.Map) { conf.store = p } func (conf *InmemoryConfiguration) GetProperty(key string) (bool, string) { + if conf.store == nil { + return false, "" + } + v, ok := conf.store.Load(key) if ok { return true, v.(string) } - return false, "" + return false, "" } func (conf *InmemoryConfiguration) GetSubProperty(subKey string) map[string]struct{} { + if conf.store == nil { + return nil + } + properties := make(map[string]struct{}) conf.store.Range(func(key, value interface{}) bool { if idx := strings.Index(key.(string), subKey); idx >= 0 { @@ -100,5 +108,6 @@ func (conf *InmemoryConfiguration) GetSubProperty(subKey string) map[string]stru } return true }) + return properties } diff --git a/config/registry_config.go b/config/registry_config.go index 0c6b326a8077de571b4c6254c13f129eb5190b74..1a926b459e598ff313e141a39956dc88cb3daad3 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -37,8 +37,8 @@ type RegistryConfig struct { Group string `yaml:"group" json:"group,omitempty" property:"group"` //for registry Address string `yaml:"address" json:"address,omitempty" property:"address"` - Username string `yaml:"username" json:"address,omitempty" property:"username"` - Password string `yaml:"password" json:"address,omitempty" property:"password"` + Username string `yaml:"username" json:"username,omitempty" property:"username"` + Password string `yaml:"password" json:"password,omitempty" property:"password"` } func (*RegistryConfig) Prefix() string { diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go index af668a1aaf18702b0d7674afda38516d9ab2e3a3..5b9e0a8f824598fd5030bd76eec04adf3e639ed9 100644 --- a/remoting/zookeeper/listener.go +++ b/remoting/zookeeper/listener.go @@ -129,14 +129,14 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath string, children []string, li continue } // listen l service node - go func(node string) { + go func(node, childNode string) { logger.Infof("delete zkNode{%s}", node) if l.ListenServiceNodeEvent(node, listener) { - logger.Infof("delete content{%s}", n) + logger.Infof("delete content{%s}", childNode) listener.DataChange(remoting.Event{Path: zkPath, Action: remoting.EventTypeDel}) } logger.Warnf("listenSelf(zk path{%s}) goroutine exit now", zkPath) - }(newNode) + }(newNode, n) } // old node was deleted