You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2022/11/07 02:39:19 UTC
[servicecomb-service-center] branch nzx updated: 添加日志,用于双集群引擎同步debug (#1350)
This is an automated email from the ASF dual-hosted git repository.
littlecui pushed a commit to branch nzx
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/nzx by this push:
new db587cfb 添加日志,用于双集群引擎同步debug (#1350)
db587cfb is described below
commit db587cfb0aca47f30f15d2dd6daec7f2d6be6b4c
Author: kkf1 <46...@users.noreply.github.com>
AuthorDate: Mon Nov 7 10:39:13 2022 +0800
添加日志,用于双集群引擎同步debug (#1350)
---
syncer/service/replicator/replicator.go | 31 ++++++++++++++++++++++++++
syncer/service/replicator/resource/resource.go | 1 +
2 files changed, 32 insertions(+)
diff --git a/syncer/service/replicator/replicator.go b/syncer/service/replicator/replicator.go
index d7f1e3d4..5d2b775b 100644
--- a/syncer/service/replicator/replicator.go
+++ b/syncer/service/replicator/replicator.go
@@ -19,6 +19,7 @@ package replicator
import (
"context"
+ "encoding/json"
"fmt"
"github.com/apache/servicecomb-service-center/client"
@@ -169,6 +170,19 @@ func (r *replicatorManager) replicate(ctx context.Context, el *v1sync.EventList)
}
log.Info(fmt.Sprintf("replicate events success, count is %d", len(in.Events)))
+ for _, event := range in.Events {
+ s, err := json.Marshal(event)
+ if err != nil {
+ log.Error("failed to marshal event", err)
+ continue
+ }
+ log.Info(fmt.Sprintf("replicated event:%s", string(s)))
+ log.Info(fmt.Sprintf("event id: %v", event.Id))
+ log.Info(fmt.Sprintf("event action:%v", event.Action))
+ log.Info(fmt.Sprintf("event subject:%v", event.Subject))
+ log.Info(fmt.Sprintf("event value:%v", event.Value))
+ log.Info(fmt.Sprintf("event timestamp:%v\n\n", event.Timestamp))
+ }
for k, v := range res.Results {
log.Info(fmt.Sprintf("replicate event %s, %v", k, v))
@@ -189,6 +203,18 @@ func (r *replicatorManager) Persist(ctx context.Context, el *v1sync.EventList) [
for _, event := range el.Events {
log.Info(fmt.Sprintf("start handle event %s", event.Flag()))
+ s, err := json.Marshal(event)
+ if err != nil {
+ log.Error("failed to marshal event", err)
+ continue
+ }
+ log.Info(fmt.Sprintf("before persisting event:%v", string(s)))
+ log.Info(fmt.Sprintf("event id: %v", event.Id))
+ log.Info(fmt.Sprintf("event action:%v", event.Action))
+ log.Info(fmt.Sprintf("event subject:%v", event.Subject))
+ log.Info(fmt.Sprintf("event timestamp:%v", event.Timestamp))
+ log.Info(fmt.Sprintf("event value:%v\n\n", event.Value))
+
r, result := resource.New(event)
if result != nil {
results = append(results, result.WithEventID(event.Id))
@@ -200,12 +226,14 @@ func (r *replicatorManager) Persist(ctx context.Context, el *v1sync.EventList) [
result = r.LoadCurrentResource(ctx)
if result != nil {
+ log.Info(fmt.Sprintf("failed to load current resource: %s", event.Id))
results = append(results, result.WithEventID(event.Id))
continue
}
result = r.NeedOperate(ctx)
if result != nil {
+ log.Info(fmt.Sprintf("failed to need operate resource: %s", event.Id))
results = append(results, result.WithEventID(event.Id))
continue
}
@@ -214,6 +242,9 @@ func (r *replicatorManager) Persist(ctx context.Context, el *v1sync.EventList) [
results = append(results, result.WithEventID(event.Id))
log.Info(fmt.Sprintf("operate resource, event: %s, result: %s", event.Flag(), result.Flag()))
+
+ log.Info(fmt.Sprintf("after operating event: %s", string(s)))
+
}
for _, result := range results {
diff --git a/syncer/service/replicator/resource/resource.go b/syncer/service/replicator/resource/resource.go
index 37d09b9c..2829bc89 100644
--- a/syncer/service/replicator/resource/resource.go
+++ b/syncer/service/replicator/resource/resource.go
@@ -327,6 +327,7 @@ func (o *checker) needOperate(ctx context.Context) *Result {
return FailResult(err)
}
if updateTime >= o.event.Timestamp {
+ log.Info(fmt.Sprintf("skip operate event: %v, updatetime: %v, event timestamp: %v", o.event.Id, updateTime, o.event.Timestamp))
return SkipResult()
}