diff --git a/cluster/loadbalance/least_active.go b/cluster/loadbalance/least_active.go index 39c5620f02d607bb68430e17a206a1649ee31c54..aa69f3cc207ae7465bc6d5472bc075d0902c8978 100644 --- a/cluster/loadbalance/least_active.go +++ b/cluster/loadbalance/least_active.go @@ -15,7 +15,6 @@ * limitations under the License. */ -// @author yiji@apache.org package loadbalance import ( diff --git a/cluster/loadbalance/round_robin_test.go b/cluster/loadbalance/round_robin_test.go index e261884b55971d95ccfbfdc34e32a07dc256fcca..0b8e89c7349afb056309b5a70d91aa5cce309aa0 100644 --- a/cluster/loadbalance/round_robin_test.go +++ b/cluster/loadbalance/round_robin_test.go @@ -1,3 +1,20 @@ +/* + * 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 loadbalance import ( diff --git a/common/extension/router_factory.go b/common/extension/router_factory.go index f364292b07850d1ef48f008eeb12261bf4b274a5..6f27aafaebf87147116e74272cc229657f436201 100644 --- a/common/extension/router_factory.go +++ b/common/extension/router_factory.go @@ -1,3 +1,20 @@ +/* + * 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 extension import ( diff --git a/config_center/configuration_parser.go b/config_center/configuration_parser.go index ab02789c9267786c900b57c312b1346ee2653fde..95b122e1e790c5bd8e01988282eae517a431463a 100644 --- a/config_center/configuration_parser.go +++ b/config_center/configuration_parser.go @@ -1,8 +1,26 @@ +/* + * 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 config_center import ( "github.com/magiconair/properties" ) + import ( "github.com/apache/dubbo-go/common/logger" ) diff --git a/config_center/configuration_parser_test.go b/config_center/configuration_parser_test.go index 3c84fd70b03df06184365e132a174dfc640da1c2..4a67d423040c768475ab16f1d4a0c22bc64e4f0d 100644 --- a/config_center/configuration_parser_test.go +++ b/config_center/configuration_parser_test.go @@ -1,8 +1,26 @@ +/* + * 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 config_center import ( "testing" ) + import ( "github.com/stretchr/testify/assert" ) diff --git a/filter/impl/active_filter.go b/filter/impl/active_filter.go index d7dad74cf3f5ccadf39372335bc1efb22f497523..36a4e1a767ab7170ce8e5bebf2cfa4403f6ad4ff 100644 --- a/filter/impl/active_filter.go +++ b/filter/impl/active_filter.go @@ -15,7 +15,6 @@ * limitations under the License. */ -// @author yiji@apache.org package impl import ( diff --git a/protocol/dubbo/pool.go b/protocol/dubbo/pool.go index cdd2a10a471dd906fc77d165991752cc7d7e266b..d619a2f8fe78524b3d704cb9de280ebbf534eb12 100644 --- a/protocol/dubbo/pool.go +++ b/protocol/dubbo/pool.go @@ -39,7 +39,7 @@ type gettyRPCClient struct { once sync.Once protocol string addr string - created int64 // zero, not create or be destroyed + active int64 // zero, not create or be destroyed pool *gettyRPCClientPool @@ -85,11 +85,11 @@ func newGettyRPCClientConn(pool *gettyRPCClientPool, protocol, addr string) (*ge } func (c *gettyRPCClient) updateActive(active int64) { - atomic.StoreInt64(&c.created, active) + atomic.StoreInt64(&c.active, active) } func (c *gettyRPCClient) getActive() int64 { - return atomic.LoadInt64(&c.created) + return atomic.LoadInt64(&c.active) } func (c *gettyRPCClient) newSession(session getty.Session) error { @@ -154,6 +154,9 @@ func (c *gettyRPCClient) addSession(session getty.Session) { } c.lock.Lock() + if c.sessions == nil { + c.sessions = make([]*rpcSession, 0, 16) + } c.sessions = append(c.sessions, &rpcSession{session: session}) c.lock.Unlock() } @@ -271,7 +274,7 @@ func newGettyRPCClientConnPool(rpcClient *Client, size int, ttl time.Duration) * rpcClient: rpcClient, size: size, ttl: int64(ttl.Seconds()), - conns: []*gettyRPCClient{}, + conns: make([]*gettyRPCClient, 0, 16), } } @@ -300,12 +303,11 @@ func (p *gettyRPCClientPool) getGettyRpcClient(protocol, addr string) (*gettyRPC p.conns = p.conns[:len(p.conns)-1] if d := now - conn.getActive(); d > p.ttl { - if closeErr := conn.safeClose(); closeErr == nil { - p.remove(conn) - } + p.remove(conn) + conn.safeClose() continue } - conn.updateActive(now) //update created time + conn.updateActive(now) //update active time return conn, nil } @@ -331,10 +333,9 @@ func (p *gettyRPCClientPool) release(conn *gettyRPCClient, err error) { } if len(p.conns) >= p.size { - if closeErr := conn.safeClose(); closeErr == nil { - // delete @conn from client pool - p.remove(conn) - } + // delete @conn from client pool + p.remove(conn) + conn.safeClose() return } p.conns = append(p.conns, conn) diff --git a/registry/zookeeper/listener_test.go b/registry/zookeeper/listener_test.go index 7ebc32b8a50bcb38d5ac859e4216065559fbd4e5..9d9cebefcba0ab18e0e991a9cbd114af1aec6587 100644 --- a/registry/zookeeper/listener_test.go +++ b/registry/zookeeper/listener_test.go @@ -1,11 +1,31 @@ +/* + * 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 zookeeper import ( "context" + "testing" +) + +import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/remoting" "github.com/stretchr/testify/assert" - "testing" ) func Test_DataChange(t *testing.T) {