Skip to content
Snippets Groups Projects
Commit a5f005bd authored by Ming Deng's avatar Ming Deng
Browse files

Fix UT

parent 3a93341e
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,6 @@ services:
"UserProvider":
registry: "hangzhouzk,shanghaizk"
filter: ""
# the name of limiter
tps.limiter: "default"
# the time unit of interval is ms
......@@ -39,13 +38,11 @@ services:
tps.limit.strategy: "slidingWindow"
# the name of RejectedExecutionHandler
tps.limit.rejected.handler: "default"
# the concurrent request limitation of this service
# if the value < 0, it will not be limited.
execute.limit: "200"
# the name of RejectedExecutionHandler
execute.limit.rejected.handler: "default"
protocol : "dubbo"
# equivalent to interface of dubbo.xml
interface : "com.ikurento.user.UserProvider"
......@@ -58,11 +55,11 @@ services:
- name: "GetUser"
retries: 1
loadbalance: "random"
# the concurrent request limitation of this method
# if the value < 0, it will not be limited.
execute.limit: "200"
# the name of RejectedExecutionHandler
execute.limit.rejected.handler: "default"
# the concurrent request limitation of this method
# if the value < 0, it will not be limited.
execute.limit: "200"
# the name of RejectedExecutionHandler
execute.limit.rejected.handler: "default"
protocols:
"dubbo":
......
......@@ -90,7 +90,7 @@ func (ef *ExecuteLimitFilter) Invoke(invoker protocol.Invoker, invocation protoc
limitRate, err := strconv.ParseInt(limitRateConfig, 0, 0)
if err != nil {
logger.Error("The configuration of execute.limit is invalid: %s", limitRateConfig)
logger.Errorf("The configuration of execute.limit is invalid: %s", limitRateConfig)
return &protocol.RPCResult{}
}
......@@ -98,13 +98,12 @@ func (ef *ExecuteLimitFilter) Invoke(invoker protocol.Invoker, invocation protoc
return invoker.Invoke(invocation)
}
state, loaded := ef.executeState.LoadOrStore(limitTarget, &ExecuteState{
state, _ := ef.executeState.LoadOrStore(limitTarget, &ExecuteState{
concurrentCount: 0,
})
concurrentCount := state.(*ExecuteState).increase()
defer state.(*ExecuteState).decrease()
logger.Debugf("The execution count is %d, loaded: %t, target: %s", concurrentCount, loaded, limitTarget)
if concurrentCount > limitRate {
logger.Errorf("The invocation was rejected due to over the execute limitation, url: %s ", url.String())
rejectedHandlerConfig := url.GetParam(methodConfigPrefix+constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY,
......
......@@ -62,7 +62,7 @@ func TestExecuteLimitFilter_Invoke_Configure_Error(t *testing.T) {
result := limitFilter.Invoke(protocol.NewBaseInvoker(*invokeUrl), invoc)
assert.NotNil(t, result)
assert.NotNil(t, result.Error())
assert.Nil(t, result.Error())
}
func TestExecuteLimitFilter_Invoke(t *testing.T) {
......
......@@ -20,9 +20,6 @@ package impl
import (
"net/url"
"testing"
common2 "github.com/apache/dubbo-go/filter/common"
impl2 "github.com/apache/dubbo-go/filter/common/impl"
)
import (
......@@ -34,6 +31,8 @@ import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
common2 "github.com/apache/dubbo-go/filter/common"
impl2 "github.com/apache/dubbo-go/filter/common/impl"
"github.com/apache/dubbo-go/filter/impl/tps"
"github.com/apache/dubbo-go/filter/impl/tps/impl"
"github.com/apache/dubbo-go/protocol"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment