Skip to content

Commit

Permalink
Merge branch '1.5' of https://github.com/apache/dubbo-go into 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexStocks committed Apr 22, 2021
2 parents 20b6349 + bad61dc commit c4b00af
Show file tree
Hide file tree
Showing 7 changed files with 1,784 additions and 22 deletions.
10 changes: 10 additions & 0 deletions common/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,16 @@ func (c *URL) Key() string {
return buildString
}

//GetCacheInvokerMapKey get directory cacheInvokerMap key
func (c *URL) GetCacheInvokerMapKey() string {
urlNew, _ := NewURL(c.PrimitiveURL)

buildString := fmt.Sprintf("%s://%s:%s@%s:%s/?interface=%s&group=%s&version=%s&timestamp=%s",
c.Protocol, c.Username, c.Password, c.Ip, c.Port, c.Service(), c.GetParam(constant.GROUP_KEY, ""),
c.GetParam(constant.VERSION_KEY, ""), urlNew.GetParam(constant.TIMESTAMP_KEY, ""))
return buildString
}

// ServiceKey gets a unique key of a service.
func (c *URL) ServiceKey() string {
return ServiceKey(c.GetParam(constant.INTERFACE_KEY, strings.TrimPrefix(c.Path, "/")),
Expand Down
15 changes: 0 additions & 15 deletions metadata/service/inmemory/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,11 @@ func (mts *MetadataService) getSpecifiedService(services *sync.Map, serviceKey s

// ExportURL can store the in memory
func (mts *MetadataService) ExportURL(url *common.URL) (bool, error) {
if constant.METADATA_SERVICE_NAME == url.GetParam(constant.INTERFACE_KEY, "") {
mts.metadataServiceURL = url
return true, nil
}
mts.mOnce.Do(func() {
mts.metadataInfo = common.NewMetadataInfWithApp(config.GetApplicationConfig().Name)
})
mts.metadataInfo.AddService(common.NewServiceInfoWithURL(url))
return mts.addURL(mts.exportedServiceURLs, url), nil
}

// UnexportURL can remove the url store in memory
func (mts *MetadataService) UnexportURL(url *common.URL) error {
if constant.METADATA_SERVICE_NAME == url.GetParam(constant.INTERFACE_KEY, "") {
mts.metadataServiceURL = nil
return nil
}
if mts.metadataInfo != nil {
mts.metadataInfo.RemoveService(common.NewServiceInfoWithURL(url))
}
mts.removeURL(mts.exportedServiceURLs, url)
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions registry/directory/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (dir *RegistryDirectory) invokerCacheKey(event *registry.ServiceEvent) stri
referenceUrl := dir.GetDirectoryUrl().SubURL
newUrl := common.MergeUrl(event.Service, referenceUrl)
event.Update(newUrl)
return newUrl.Key()
return newUrl.GetCacheInvokerMapKey()
}

// setNewInvokers groups the invokers from the cache first, then set the result to both directory and router chain.
Expand Down Expand Up @@ -325,7 +325,7 @@ func (dir *RegistryDirectory) toGroupInvokers() []protocol.Invoker {

// uncacheInvoker will return abandoned Invoker, if no Invoker to be abandoned, return nil
func (dir *RegistryDirectory) uncacheInvoker(url *common.URL) protocol.Invoker {
return dir.uncacheInvokerWithKey(url.Key())
return dir.uncacheInvokerWithKey(url.GetCacheInvokerMapKey())
}

func (dir *RegistryDirectory) uncacheInvokerWithKey(key string) protocol.Invoker {
Expand Down Expand Up @@ -364,7 +364,7 @@ func (dir *RegistryDirectory) cacheInvoker(url *common.URL) protocol.Invoker {
}

func (dir *RegistryDirectory) doCacheInvoker(newUrl *common.URL) (protocol.Invoker, bool) {
key := newUrl.Key()
key := newUrl.GetCacheInvokerMapKey()
if cacheInvoker, ok := dir.cacheInvokersMap.Load(key); !ok {
logger.Debugf("service will be added in cache invokers: invokers url is %s!", newUrl)
newInvoker := extension.GetProtocol(protocolwrapper.FILTER).Refer(newUrl)
Expand Down
2 changes: 1 addition & 1 deletion registry/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (e *ServiceEvent) Key() string {
if len(e.key) > 0 {
return e.key
}
e.key = e.Service.Key()
e.key = e.Service.GetCacheInvokerMapKey()
return e.key
}

Expand Down
3 changes: 0 additions & 3 deletions remoting/zookeeper/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath string, children []string, li
if l.listenServiceNodeEvent(node, listener) {
logger.Warnf("delete zkNode{%s}", node)
listener.DataChange(remoting.Event{Path: node, Action: remoting.EventTypeDel})
l.pathMapLock.Lock()
delete(l.pathMap, zkPath)
l.pathMapLock.Unlock()
}
logger.Warnf("handleZkNodeEvent->listenSelf(zk path{%s}) goroutine exit now", node)
}(newNode, listener)
Expand Down
Loading

0 comments on commit c4b00af

Please sign in to comment.