Skip to content

Commit

Permalink
ignore zk node already exist when store provider/consumer metadata (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Leospard committed Jun 3, 2023
1 parent 9d087ed commit 12f5211
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions metadata/report/zookeeper/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
gxset "github.com/dubbogo/gost/container/set"
gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
"github.com/dubbogo/gost/log/logger"
perrors "github.com/pkg/errors"
)

import (
Expand Down Expand Up @@ -79,7 +80,7 @@ func (m *zookeeperMetadataReport) PublishAppMetadata(metadataIdentifier *identif
return err
}
err = m.client.CreateWithValue(k, data)
if err == zk.ErrNodeExists {
if perrors.Is(err, zk.ErrNodeExists) {
logger.Debugf("Try to create the node data failed. In most cases, it's not a problem. ")
return nil
}
Expand All @@ -89,13 +90,23 @@ func (m *zookeeperMetadataReport) PublishAppMetadata(metadataIdentifier *identif
// StoreProviderMetadata stores the metadata.
func (m *zookeeperMetadataReport) StoreProviderMetadata(providerIdentifier *identifier.MetadataIdentifier, serviceDefinitions string) error {
k := m.rootDir + providerIdentifier.GetFilePathKey()
return m.client.CreateWithValue(k, []byte(serviceDefinitions))
err := m.client.CreateWithValue(k, []byte(serviceDefinitions))
if perrors.Is(err, zk.ErrNodeExists) {
logger.Debugf("Try to store provider metadata failed. In most cases, it's not a problem. ")
return nil
}
return err
}

// StoreConsumerMetadata stores the metadata.
func (m *zookeeperMetadataReport) StoreConsumerMetadata(consumerMetadataIdentifier *identifier.MetadataIdentifier, serviceParameterString string) error {
k := m.rootDir + consumerMetadataIdentifier.GetFilePathKey()
return m.client.CreateWithValue(k, []byte(serviceParameterString))
err := m.client.CreateWithValue(k, []byte(serviceParameterString))
if perrors.Is(err, zk.ErrNodeExists) {
logger.Debugf("Try to store consumer metadata failed. In most cases, it's not a problem. ")
return nil
}
return err
}

// SaveServiceMetadata saves the metadata.
Expand Down

0 comments on commit 12f5211

Please sign in to comment.