[GitHub] [servicecomb-java-chassis] yuzhouzhouba commented on issue #2072: 您好,在传递大文件的时候,遇到的网络延时问题
yuzhouzhouba commented on issue #2072: URL: https://github.com/apache/servicecomb-java-chassis/issues/2072#issuecomment-739731260 感谢@liubao68 支撑 经过测试,确实对于流的读取是一点一点的读的,目前认为这种方式`不适合传递大文件`,有如下三点问题: 1、在点击的时候有几秒的延迟 > 这个跟网络环境有关,可能第一个小包过来就产生了较大的延时。 2、在不同的环境下有几率性残缺 ---> 这个在需要通过网络传输复现,本地文件为复现。 3、浏览器不能显示进度 ---> 本地复现,确实浏览器不能显示进度,只能看到在传输。 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[servicecomb-docs] branch master updated: Fix maven settings notes (#211)
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-docs.git The following commit(s) were added to refs/heads/master by this push: new 281dc64 Fix maven settings notes (#211) 281dc64 is described below commit 281dc648a5dc683f26d5dbee2f0f1dbaf986eeed Author: bao liu AuthorDate: Mon Dec 7 15:24:13 2020 +0800 Fix maven settings notes (#211) --- .../en_US/docs/start/development-environment.md| 71 -- .../zh_CN/docs/references-handlers/ratelimit.md| 15 +++-- .../zh_CN/docs/start/development-environment.md| 69 - 3 files changed, 32 insertions(+), 123 deletions(-) diff --git a/java-chassis-reference/en_US/docs/start/development-environment.md b/java-chassis-reference/en_US/docs/start/development-environment.md index 216ac30..3546609 100644 --- a/java-chassis-reference/en_US/docs/start/development-environment.md +++ b/java-chassis-reference/en_US/docs/start/development-environment.md @@ -37,65 +37,18 @@ The JDK has been installed successfully. ### **installation steps** -a. Download the Maven installation package at the official address. - -b. (Optional) Download the Eclipse plugin m2eclipse at the official address. The latest Eclipse version comes with a Maven plugin, so you don't have to download this plugin. - -c. Unzip the Maven installation package to the native path. - -d. Set environment variables. - -* Set the M2\_HOME environment variable to point to the Maven installation directory. - -* Add %M2\_HOME%\bin to the system path path. - -e. (Optional) Set a local repository path to hold the plug-ins and dependent copies obtained from the remote repository. - -Here is the path D:\maven\repository. Find the settings.xml file in /conf and set localRepository to D:\maven\repository - -f. (Optional) In order to quickly download various dependencies, it is recommended to configure the maven repository settings. - -In `profiles` element, the content below should be added: -```xml - -MyProfile - - -SDK - https://repo.huaweicloud.com/repository/maven/huaweicloudsdk/ - -true - - -false - - - - -``` -In `mirrors` element, the content below should be added: -```xml - -RepoMirror -*,!SDK -https://repo.huaweicloud.com/repository/maven/ - -``` -Add `activeProfiles` element as below: -```xml - -MyProfile - -``` - -g. Verification - -Use the mvn -version command to verify that the installation is successful. The windows environment is echoed as follows: - -``` -C:\>mvn -version - Apache Maven 3.3.9 -``` +* Download the Maven installation package at the official address. +* Unzip the Maven installation package to the native path. +* Set environment variables: + * Set the M2\_HOME environment variable to point to the Maven installation directory. + * Add %M2\_HOME%\bin to the system path path. +* Verification + + Use the mvn -version command to verify that the installation is successful. The windows environment + is echoed as follows: + +C:\>mvn -version +Apache Maven 3.3.9 ## Eclipse installation diff --git a/java-chassis-reference/zh_CN/docs/references-handlers/ratelimit.md b/java-chassis-reference/zh_CN/docs/references-handlers/ratelimit.md index c80ddd8..5de7443 100644 --- a/java-chassis-reference/zh_CN/docs/references-handlers/ratelimit.md +++ b/java-chassis-reference/zh_CN/docs/references-handlers/ratelimit.md @@ -12,14 +12,17 @@ java-chassis 支持 Provider 限流和 Consumer 限流。 Provider 限流控制 ## 流控算法说明 2.1.3 版本之前,不提供流控策略的选择,默认流控实现算法是固定窗口算法。 + 2.1.3 版本以及之后,提供流控测流供选择,默认提供固定窗口算法、漏桶算法、令牌桶算法,且支持用户自定义流控策略实现。 -算法说明: - * 固定窗口算法:默认窗口大小为1s,最大可能产生2倍于指定流量设置大小的误差。 - * 令牌桶算法:令牌桶的主要思想是,设置一个固定大小的桶,以恒定速率向里面加入令牌,每次新请求到来时从里面取一个令牌出来,如果没有令牌可取,则请求直接失败(被限流)。 - * 漏桶算法:漏桶算法的主要思想是,设置一个固定大小的桶,请求不断加入桶中同时以固定大小从桶内部流出,如果达到桶的极限大小,则请求溢出(失败)。 - 在内部实现上漏桶算法与令牌桶算法的实现原理相同,根据设置的桶大小不同,能承载的突发流量不同。 - * 用户自定义流控算法:可以参考 [示例实现][customize-flow] ,以及该实现下的配置方法。 +* 算法说明: + * 固定窗口算法:默认窗口大小为1s,最大可能产生2倍于指定流量设置大小的误差。 + * 令牌桶算法:令牌桶的主要思想是,设置一个固定大小的桶,以恒定速率向里面加入令牌,每次新 +请求到来时从里面取一个令牌出来,如果没有令牌可取,则请求直接失败(被限流)。 + * 漏桶算法:漏桶算法的主要思想是,设置一个固定大小的桶,请求不断加入桶中同时以固定大小从桶 +内部流出,如果达到桶的极限大小,则请求溢出(失败)。在内部实现上漏桶算法与令牌桶算法的实现 +原理相同,根据设置的桶大小不同,能承载的突发流量不同。 + * 用户自定义流控算法:可以参考 [示例实现][customize-flow] ,以及该实现下的配置方法。 [customize-flow]: https://github.com/apache/servicecomb-java-chassis/blob/master/demo/demo-springmvc/springmvc-server/src/main/java/org/apache/servicecomb/demo/springmvc/server/MyStrategyFactory.java diff --git a/java-chassis-reference/zh_CN/docs/start/development-environment.md b/java-chassis-reference/zh_CN/docs/start/development-environment.md index 519df3b..454710d 100644 --- a/java-chassis-reference/zh_CN/docs/start/development-environment.md +++
[GitHub] [servicecomb-docs] liubao68 merged pull request #211: Fix maven settings notes
liubao68 merged pull request #211: URL: https://github.com/apache/servicecomb-docs/pull/211 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [servicecomb-service-center] lilai23 commented on a change in pull request #773: Syncer optimization: replace slice with channel in the implemention of queue
lilai23 commented on a change in pull request #773: URL: https://github.com/apache/servicecomb-service-center/pull/773#discussion_r537278067 ## File path: syncer/server/handler.go ## @@ -70,69 +71,16 @@ func (s *Server) tickHandler() { } } -func (s *Server) DataRemoveTickHandler() chan bool { - ticker := time.NewTicker(time.Second * 30) - stopChan := make(chan bool) - go func(trick *time.Ticker) { - //defer ticker.Stop() - for { - select { - case <-ticker.C: - s.eventQueueDataRemoveTickHandler() - log.Info(fmt.Sprintf("size of records map = %d, size of events slice = %d", len(s.revisionMap), len(s.eventQueue))) - case stop := <-stopChan: - if stop { - log.Info("data remove ticker stop") - return - } - case <-context.Background().Done(): - return - } - } - }(ticker) - return stopChan -} - -func (s *Server) eventQueueDataRemoveTickHandler() { - if len(s.revisionMap) == 0 || len(s.eventQueue) == 0 { - log.Info("RevisionMap or EventQueue is empty") - return - } - - log.Info(fmt.Sprintf("length of map : %d", len(s.revisionMap))) - var minRevision int64 = math.MaxInt64 - for _, value := range s.revisionMap { - var tempRevision = value.revision - if tempRevision < minRevision { - minRevision = tempRevision - } - } - - log.Info(fmt.Sprintf("revision of item will remove : %d", minRevision)) - - j := 0 - for _, value := range s.eventQueue { - var tempRevision = value.Revision - if tempRevision == minRevision { - break - } - j++ - } - s.eventQueue = s.eventQueue[j:] - log.Info(fmt.Sprintf("size of event queue : %d", len(s.eventQueue))) - if len(s.eventQueue) > 0 { - log.Info(fmt.Sprintf("revision of first element in event queue : %d", s.eventQueue[0].Revision)) - } -} - // Pull returns sync data of servicecenter -func (s *Server) Pull(context.Context, *pb.PullRequest) (*pb.SyncData, error) { +func (s *Server) Pull(ctx context.Context, req *pb.PullRequest) (*pb.SyncData, error) { + if _, ok := s.channelMap[req.GetAddr()]; !ok { + s.channelMap[req.GetAddr()] = make(chan *dump.WatchInstanceChangedEvent, BufferSize) + } Review comment: 这个是protobuf插件根据pb文件自动生成函数,应该是要保留的 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [servicecomb-service-center] lilai23 commented on a change in pull request #773: Syncer optimization: replace slice with channel in the implemention of queue
lilai23 commented on a change in pull request #773: URL: https://github.com/apache/servicecomb-service-center/pull/773#discussion_r537277101 ## File path: syncer/server/handler.go ## @@ -21,9 +21,9 @@ import ( "context" "crypto/tls" "fmt" - "math" "strconv" - "time" + + "github.com/apache/servicecomb-service-center/pkg/dump" Review comment: 已修改,很奇怪,你几天前的review 我现在才看到 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [servicecomb-java-chassis] wujimin opened a new pull request #2105: [SCB-2147] add RestClientCodecFilter
wujimin opened a new pull request #2105: URL: https://github.com/apache/servicecomb-java-chassis/pull/2105 Follow this checklist to help us incorporate your contribution quickly and easily: - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [ ] Each commit in the pull request should have a meaningful subject line and body. - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [ ] Run `mvn clean install -Pit` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [servicecomb-service-center] robotLJW commented on a change in pull request #773: Syncer optimization: replace slice with channel in the implemention of queue
robotLJW commented on a change in pull request #773: URL: https://github.com/apache/servicecomb-service-center/pull/773#discussion_r535767448 ## File path: syncer/server/handler.go ## @@ -21,9 +21,9 @@ import ( "context" "crypto/tls" "fmt" - "math" "strconv" - "time" + + "github.com/apache/servicecomb-service-center/pkg/dump" Review comment: 包导入顺序,建议顺序:标准库、系统库、第三方库、本项目的库,不同分组之间使用空行分割开 ## File path: syncer/server/handler.go ## @@ -70,69 +71,16 @@ func (s *Server) tickHandler() { } } -func (s *Server) DataRemoveTickHandler() chan bool { - ticker := time.NewTicker(time.Second * 30) - stopChan := make(chan bool) - go func(trick *time.Ticker) { - //defer ticker.Stop() - for { - select { - case <-ticker.C: - s.eventQueueDataRemoveTickHandler() - log.Info(fmt.Sprintf("size of records map = %d, size of events slice = %d", len(s.revisionMap), len(s.eventQueue))) - case stop := <-stopChan: - if stop { - log.Info("data remove ticker stop") - return - } - case <-context.Background().Done(): - return - } - } - }(ticker) - return stopChan -} - -func (s *Server) eventQueueDataRemoveTickHandler() { - if len(s.revisionMap) == 0 || len(s.eventQueue) == 0 { - log.Info("RevisionMap or EventQueue is empty") - return - } - - log.Info(fmt.Sprintf("length of map : %d", len(s.revisionMap))) - var minRevision int64 = math.MaxInt64 - for _, value := range s.revisionMap { - var tempRevision = value.revision - if tempRevision < minRevision { - minRevision = tempRevision - } - } - - log.Info(fmt.Sprintf("revision of item will remove : %d", minRevision)) - - j := 0 - for _, value := range s.eventQueue { - var tempRevision = value.Revision - if tempRevision == minRevision { - break - } - j++ - } - s.eventQueue = s.eventQueue[j:] - log.Info(fmt.Sprintf("size of event queue : %d", len(s.eventQueue))) - if len(s.eventQueue) > 0 { - log.Info(fmt.Sprintf("revision of first element in event queue : %d", s.eventQueue[0].Revision)) - } -} - // Pull returns sync data of servicecenter -func (s *Server) Pull(context.Context, *pb.PullRequest) (*pb.SyncData, error) { +func (s *Server) Pull(ctx context.Context, req *pb.PullRequest) (*pb.SyncData, error) { + if _, ok := s.channelMap[req.GetAddr()]; !ok { + s.channelMap[req.GetAddr()] = make(chan *dump.WatchInstanceChangedEvent, BufferSize) + } Review comment: 提一个疑问不一定是问题,我看这边返回error都是nil,是不是可以不要?还是其他场景下会返回其它错误 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [servicecomb-docs] liubao68 opened a new pull request #211: Fix maven settings notes
liubao68 opened a new pull request #211: URL: https://github.com/apache/servicecomb-docs/pull/211 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [servicecomb-samples] liubao68 opened a new pull request #61: Upgrade to latest version and add AK/SK example
liubao68 opened a new pull request #61: URL: https://github.com/apache/servicecomb-samples/pull/61 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [servicecomb-service-center] robotLJW closed pull request #778: [SCB-2094] Bug fixes: The heartbeat reporting interface needs to use …
robotLJW closed pull request #778: URL: https://github.com/apache/servicecomb-service-center/pull/778 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [servicecomb-service-center] tianxiaoliang merged pull request #775: SCB-2094 Bug fixes: Unavailable SSL
tianxiaoliang merged pull request #775: URL: https://github.com/apache/servicecomb-service-center/pull/775 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[servicecomb-service-center] branch master updated: SCB-2094 Bug fixes: Unavailable SSL (#775)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 9bdf36b SCB-2094 Bug fixes: Unavailable SSL (#775) 9bdf36b is described below commit 9bdf36b123ba915d929d8bfa7b18fbb13e172987 Author: little-cui AuthorDate: Mon Dec 7 10:56:46 2020 +0800 SCB-2094 Bug fixes: Unavailable SSL (#775) --- datasource/etcd/cache/common.go | 12 ++-- datasource/etcd/client/remote/etcd.go | 7 +-- datasource/etcd/engine.go | 28 ++-- datasource/etcd/etcd.go | 2 +- datasource/etcd/ms.go | 3 --- datasource/mongo/mongo.go | 2 +- pkg/util/context.go | 8 pkg/util/net.go | 4 +++- server/bootstrap/bootstrap.go | 2 +- server/config/config.go | 5 + server/config/server.go | 5 + server/core/microservice.go | 2 +- server/handler/context/context.go | 2 +- server/server.go | 1 + 14 files changed, 40 insertions(+), 43 deletions(-) diff --git a/datasource/etcd/cache/common.go b/datasource/etcd/cache/common.go index 69bd802..8e501f8 100644 --- a/datasource/etcd/cache/common.go +++ b/datasource/etcd/cache/common.go @@ -23,17 +23,17 @@ import ( "sync" "github.com/apache/servicecomb-service-center/datasource" + "github.com/apache/servicecomb-service-center/pkg/util" ) -type ContextKey string type ClustersIndex map[string]int const ( - CtxFindConsumer ContextKey = "_consumer" - CtxFindProvider ContextKey = "_provider" - CtxFindProviderInstance ContextKey = "_provider_instance" - CtxFindTags ContextKey = "_tags" - CtxFindRequestRev ContextKey = "_rev" + CtxFindConsumer util.CtxKey = "_consumer" + CtxFindProvider util.CtxKey = "_provider" + CtxFindProviderInstance util.CtxKey = "_provider_instance" + CtxFindTags util.CtxKey = "_tags" + CtxFindRequestRev util.CtxKey = "_rev" Find = "_find" Dep = "_dep" diff --git a/datasource/etcd/client/remote/etcd.go b/datasource/etcd/client/remote/etcd.go index 4f4d4a6..1dba232 100644 --- a/datasource/etcd/client/remote/etcd.go +++ b/datasource/etcd/client/remote/etcd.go @@ -73,6 +73,9 @@ func (c *Client) Initialize() (err error) { // parse the endpoints from config c.parseEndpoints() } + log.Info(fmt.Sprintf("parse %v -> endpoints: %v, ssl: %v", + etcd.Configuration().Clusters, c.Endpoints, etcd.Configuration().SslEnabled)) + if c.TLSConfig == nil && etcd.Configuration().SslEnabled { var err error // go client tls限制,提供身份证书、不认证服务端、不校验CN @@ -99,8 +102,8 @@ func (c *Client) Initialize() (err error) { close(c.ready) - log.Warnf("get etcd client %v completed, auto sync endpoints interval is %s.", - c.Endpoints, c.AutoSyncInterval) + log.Warn(fmt.Sprintf("get etcd client %v completed, ssl: %v, dial timeout: %s, auto sync endpoints interval is %s.", + c.Endpoints, c.TLSConfig != nil, c.DialTimeout, c.AutoSyncInterval)) return } diff --git a/datasource/etcd/engine.go b/datasource/etcd/engine.go index 5404a6f..62c934b 100644 --- a/datasource/etcd/engine.go +++ b/datasource/etcd/engine.go @@ -25,11 +25,11 @@ import ( "strings" "time" + "github.com/apache/servicecomb-service-center/datasource" "github.com/apache/servicecomb-service-center/datasource/etcd/path" + serviceUtil "github.com/apache/servicecomb-service-center/datasource/etcd/util" "github.com/apache/servicecomb-service-center/pkg/cluster" "github.com/apache/servicecomb-service-center/pkg/gopool" - - serviceUtil "github.com/apache/servicecomb-service-center/datasource/etcd/util" "github.com/apache/servicecomb-service-center/pkg/log" "github.com/apache/servicecomb-service-center/pkg/util" "github.com/apache/servicecomb-service-center/server/core" @@ -46,7 +46,8 @@ func (ds *DataSource) SelfRegister(ctx context.Context) error { return nil } -func (ds *DataSource) selfRegister(ctx context.Context) error { +func (ds *DataSource) selfRegister(pCtx context.Context) error { + ctx := core.AddDefaultContextValue(pCtx) err := ds.registerService(ctx) if err != nil { return err @@ -55,8 +56,7 @@ func (ds *DataSource) selfRegister(ctx context.Context) error { return ds.registerInstance(ctx) } -func (ds *DataSource) registerService(pCtx context.Context) error { - ctx := core.AddDefaultContextValue(pCtx) +func (ds
[GitHub] [servicecomb-service-center] lilai23 commented on a change in pull request #773: Syncer optimization: replace slice with channel in the implemention of queue
lilai23 commented on a change in pull request #773: URL: https://github.com/apache/servicecomb-service-center/pull/773#discussion_r537184134 ## File path: syncer/server/handler.go ## @@ -37,6 +37,7 @@ const ( EventDiscovered = "discovered" EventIncrementPulled = "incrementPulled" EventNotifyFullPulled = "notifyFullPulled" + BufferSize= 1000 Review comment: 已修改 ## File path: syncer/server/server.go ## @@ -313,96 +305,51 @@ func (s *Server) addToQueue(event *dump.WatchInstanceChangedEvent) { } } - s.queueLock.Lock() - s.eventQueue = append(s.eventQueue, event) - log.Debugf("success add instance event to queue:%s len:%s", event, len(s.eventQueue)) - s.queueLock.Unlock() -} - -func instFromOtherSC(instance *dump.Instance, m *pb.MappingEntry) bool { - if instance.Value.InstanceId == m.CurInstanceID && m.OrgInstanceID != "" { - return true - } - return false -} - -func (s *Server) getRevision(addr string) int64 { - s.mapLock.RLock() - value, ok := s.revisionMap[addr] - s.mapLock.RUnlock() - if ok { - return value.revision + for _, ch := range s.channelMap { + select { + case ch <- event: + log.Info("add event to queue") + default: + log.Info("channel buffer is full") + } } - return -1 } -func (s *Server) getAction(addr string) string { - s.mapLock.RLock() - value, ok := s.revisionMap[addr] - s.mapLock.RUnlock() +func (s *Server) getSyncDataLength(addr string) (response *pb.DeclareResponse) { + ch, ok := s.channelMap[addr] + var length int64 if ok { - return value.action + length = int64(len(ch)) + } else { + length = 0 + log.Error("fail to find the specific channel according to the addr", utils.ErrChannelSearch) } - return "" -} - -func (s *Server) getSyncDataLength(addr string) (response *pb.DeclareResponse) { response = { - SyncDataLength: int64(len(s.GetIncrementQueue(addr))), + SyncDataLength: length, } return response } -func (s *Server) updateRevisionMap(addr string, incrementQueue []*dump.WatchInstanceChangedEvent) { - if len(incrementQueue) == 0 { - log.Info("incrementQueue is empty, no need to update RevisionMap") - return - } - - log.Debug(fmt.Sprintf("update RevisionMap, addr = %s", addr)) - s.mapLock.Lock() - s.revisionMap[addr] = record{ - incrementQueue[len(incrementQueue)-1].Revision, - incrementQueue[len(incrementQueue)-1].Action, - } - s.mapLock.Unlock() -} - -func (s *Server) GetIncrementQueue(addr string) []*dump.WatchInstanceChangedEvent { - revision := s.getRevision(addr) - action := s.getAction(addr) - - s.queueLock.RLock() - defer s.queueLock.RUnlock() - - length := len(s.eventQueue) - if length == 0 { - log.Info("eventQueue is empty") +func (s *Server) GetIncrementQueue(addr string) (queue []*dump.WatchInstanceChangedEvent) { + ch, ok := s.channelMap[addr] + if !ok { + log.Debug("fail to find the queue according to the addr") return nil } - if revision == -1 { - return s.eventQueue - } - - index := 0 - for _, event := range s.eventQueue { - if event.Revision == revision && event.Action == action { - break + queue = make([]*dump.WatchInstanceChangedEvent, 0, len(ch)) + for { + select { + case temp, ok := <-ch: + if !ok { + log.Debug("channel closed") + return + } + queue = append(queue, temp) Review comment: 已修改 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [servicecomb-service-center] robotLJW opened a new pull request #778: [SCB-2094] Bug fixes: The heartbeat reporting interface needs to use …
robotLJW opened a new pull request #778: URL: https://github.com/apache/servicecomb-service-center/pull/778 ## [SCB-2094] Bug fixes: The heartbeat reporting interface needs to use serviceid to query This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 merged pull request #2104: [SCB-2146] add RestClientDecoder
liubao68 merged pull request #2104: URL: https://github.com/apache/servicecomb-java-chassis/pull/2104 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[servicecomb-java-chassis] branch master updated: [SCB-2146] add RestClientDecoder (#2104)
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git The following commit(s) were added to refs/heads/master by this push: new 013ad6d [SCB-2146] add RestClientDecoder (#2104) 013ad6d is described below commit 013ad6db0c5b7c60d91b021031a480065c6bf334 Author: wujimin AuthorDate: Mon Dec 7 09:53:32 2020 +0800 [SCB-2146] add RestClientDecoder (#2104) --- .../transport/rest/client/RestClientDecoder.java | 119 + .../rest/client/RestClientExceptionCodes.java | 5 + .../rest/client/RestClientDecoderTest.java | 110 +++ .../transport/rest/client/RestClientTestBase.java | 3 +- 4 files changed, 235 insertions(+), 2 deletions(-) diff --git a/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/RestClientDecoder.java b/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/RestClientDecoder.java new file mode 100644 index 000..3428a45 --- /dev/null +++ b/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/RestClientDecoder.java @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.servicecomb.transport.rest.client; + +import static org.apache.servicecomb.transport.rest.client.RestClientExceptionCodes.FAILED_TO_DECODE_REST_FAIL_RESPONSE; +import static org.apache.servicecomb.transport.rest.client.RestClientExceptionCodes.FAILED_TO_DECODE_REST_SUCCESS_RESPONSE; + +import javax.ws.rs.core.HttpHeaders; + +import org.apache.servicecomb.common.rest.codec.produce.ProduceProcessor; +import org.apache.servicecomb.common.rest.codec.produce.ProduceProcessorManager; +import org.apache.servicecomb.core.Invocation; +import org.apache.servicecomb.core.exception.Exceptions; +import org.apache.servicecomb.swagger.invocation.Response; +import org.apache.servicecomb.swagger.invocation.exception.InvocationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.JavaType; + +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpClientRequest; + +@Component +public class RestClientDecoder { + private static final Logger LOGGER = LoggerFactory.getLogger(RestClientDecoder.class); + + public Response decode(Invocation invocation, Response response) { +if (response.getResult() instanceof Buffer) { + Object result = extractBody(invocation, response); + response.entity(result); + + if (response.isFailed()) { +throw Exceptions.create(response.getStatus(), response.getResult()); + } +} + +return response; + } + + protected Object extractBody(Invocation invocation, Response response) { +ProduceProcessor produceProcessor = safeFindProduceProcessor(invocation, response); +JavaType responseType = invocation.findResponseType(response.getStatusCode()); + +try { + return produceProcessor.decodeResponse((Buffer) response.getResult(), responseType); +} catch (Exception e) { + throw createDecodeException(invocation, response, e); +} + } + + private ProduceProcessor safeFindProduceProcessor(Invocation invocation, Response response) { +RestClientTransportContext transportContext = invocation.getTransportContext(); + +String contentType = extractContentType(response); +ProduceProcessor produceProcessor = transportContext.getRestOperationMeta().findProduceProcessor(contentType); +if (produceProcessor != null) { + return produceProcessor; +} + +HttpClientRequest httpClientRequest = transportContext.getHttpClientRequest(); +LOGGER.warn( +"method {}, endpoint {}, uri {}, statusCode {}, reasonPhrase {}, response content-type {} is not supported in operation.", +httpClientRequest.method(), +invocation.getEndpoint().getEndpoint(), +httpClientRequest.absoluteURI(), +response.getStatusCode(), +response.getReasonPhrase(), +
[GitHub] [servicecomb-service-center] robotLJW closed pull request #777: Revert "[SCB-2094] Heartbeat interface optimization (#772)"
robotLJW closed pull request #777: URL: https://github.com/apache/servicecomb-service-center/pull/777 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [servicecomb-service-center] robotLJW opened a new pull request #777: Revert "[SCB-2094] Heartbeat interface optimization (#772)"
robotLJW opened a new pull request #777: URL: https://github.com/apache/servicecomb-service-center/pull/777 再调试mongo的ms_test测试用例时发现,发送心跳时,需要利用serviceID以及instanceID当做查询条件,不能单独使用instanceID当查询条件,所以原先的逻辑是正确的,需要回退一下 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[servicecomb-java-chassis] 02/02: [SCB-2145]fix review comments
This is an automated email from the ASF dual-hosted git repository. wujimin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git commit ba4fb37b6ab8bd3a6c3d0693f295d99a94879838 Author: liubao AuthorDate: Sat Dec 5 11:10:58 2020 +0800 [SCB-2145]fix review comments --- .../localregistry/LocalRegistryStore.java | 12 +--- .../client/LocalServiceRegistryClientImpl.java | 34 +- .../client/LocalServiceRegistryClientImplTest.java | 7 +++-- 3 files changed, 19 insertions(+), 34 deletions(-) diff --git a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistryStore.java b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistryStore.java index 98c43f4..4e6cba5 100644 --- a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistryStore.java +++ b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistryStore.java @@ -118,20 +118,10 @@ public class LocalRegistryStore { while (urls.hasMoreElements()) { URL url = urls.nextElement(); -InputStream is = null; -try { - is = url.openStream(); +try (InputStream is = url.openStream()) { if (is != null) { beans.addAll(initFromData(is)); } -} finally { - if (is != null) { -try { - is.close(); -} catch (IOException e) { - // nothing to do -} - } } } } catch (IOException e) { diff --git a/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImpl.java b/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImpl.java index 202e301..f2827b1 100644 --- a/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImpl.java +++ b/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImpl.java @@ -51,6 +51,7 @@ import org.apache.servicecomb.serviceregistry.client.http.Holder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Charsets; import com.google.common.hash.Hashing; @@ -78,33 +79,26 @@ public class LocalServiceRegistryClientImpl implements ServiceRegistryClient { return; } -InputStream is = this.getClass().getClassLoader().getResourceAsStream(localFile); -if (is == null) { - return; +try { + try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(localFile)) { +if (is == null) { + return; +} +initFromData(is); + } +} catch (IOException e) { + LOGGER.error("", e); } - -initFromData(is); } - public LocalServiceRegistryClientImpl(InputStream is) { + @VisibleForTesting + LocalServiceRegistryClientImpl(InputStream is) { initFromData(is); } - public LocalServiceRegistryClientImpl(Map data) { -initFromData(data); - } - private void initFromData(InputStream is) { -try { - Map data = YAMLUtil.yaml2Properties(is); - initFromData(data); -} finally { - try { -is.close(); - } catch (IOException e) { -LOGGER.error("", e); - } -} +Map data = YAMLUtil.yaml2Properties(is); +initFromData(data); } private void initFromData(Map data) { diff --git a/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImplTest.java b/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImplTest.java index bcebe82..b50344b 100644 --- a/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImplTest.java +++ b/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImplTest.java @@ -49,10 +49,11 @@ public class LocalServiceRegistryClientImplTest { public ExpectedException expectedException = ExpectedException.none(); @Before - public void loadRegistryFile() { + public void loadRegistryFile() throws Exception { ClassLoader loader = Thread.currentThread().getContextClassLoader(); -InputStream is = loader.getResourceAsStream("registry.yaml"); -registryClient = new LocalServiceRegistryClientImpl(is); +try (InputStream is = loader.getResourceAsStream("registry.yaml")) { + registryClient = new LocalServiceRegistryClientImpl(is); +} }
[GitHub] [servicecomb-java-chassis] wujimin merged pull request #2103: [SCB-2145]fix local yaml unsafe parse problem
wujimin merged pull request #2103: URL: https://github.com/apache/servicecomb-java-chassis/pull/2103 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org