Skip to content
Snippets Groups Projects
Commit a7908eef authored by LaurenceLiZhixin's avatar LaurenceLiZhixin
Browse files

fix: add liscense

parent 570fd592
No related branches found
No related tags found
No related merge requests found
Showing
with 323 additions and 43 deletions
/*
* 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 uniform
import (
......@@ -31,7 +48,9 @@ func (drr *DubboRouterRule) route(invokers []protocol.Invoker, url *common.URL,
if resultInvokers = v.route(invokers, url, invocation); len(resultInvokers) == 0 {
continue
}
// once there is a uniformRule successfully get target invoker lists, return it
return resultInvokers
}
// return s empty invoker list
return resultInvokers
}
......@@ -23,7 +23,7 @@ import (
)
// nolint
func TestHealthCheckRouteFactory(t *testing.T) {
func TestUniformRouterFacotry(t *testing.T) {
factory := newUniformRouterFactory()
assert.NotNil(t, factory)
router, err := factory.NewPriorityRouter([]byte{}, []byte{}, make(chan struct{}))
......
/*
* 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 k8s_api
import (
......
/*
* 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 k8s_api
import (
"fmt"
dubboConfig "github.com/apache/dubbo-go/config"
"github.com/apache/dubbo-go/config_center"
"github.com/apache/dubbo-go/remoting"
"github.com/apache/dubbo-go/remoting/k8sCRD"
)
import (
metav "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
......@@ -13,6 +29,13 @@ import (
"k8s.io/client-go/rest"
)
import (
dubboConfig "github.com/apache/dubbo-go/config"
"github.com/apache/dubbo-go/config_center"
"github.com/apache/dubbo-go/remoting"
"github.com/apache/dubbo-go/remoting/k8sCRD"
)
const VirtualServiceEventKey = "virtualServiceEventKey"
const DestinationRuleEventKey = "destinationRuleEventKe3y"
......
/*
* 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 match_judger
import (
......
/*
* 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 match_judger
import "github.com/apache/dubbo-go/config"
......
/*
* 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 match_judger
import (
......
/*
* 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 match_judger
import (
......
/*
* 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 match_judger
import (
......
/*
* 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 match_judger
import (
......
/*
* 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 match_judger
import (
......
/*
* 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 match_judger
import (
"github.com/apache/dubbo-go/config"
"regexp"
"strings"
)
import (
"github.com/apache/dubbo-go/config"
)
type StringMatchJudger struct {
config.StringMatch
}
......
/*
* 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 match_judger
import "testing"
......
/*
* 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 match_judger
import (
......
/*
* 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 uniform
import (
......@@ -17,6 +34,8 @@ import (
"strings"
)
// RouterChain contains all uniform router logic
// it has UniformRouter list,
type RouterChain struct {
routers []*UniformRouter
virtualServiceConfigBytes []byte
......@@ -24,6 +43,7 @@ type RouterChain struct {
notify chan struct{}
}
// NewUniformRouterChain return
func NewUniformRouterChain(virtualServiceConfig, destinationRuleConfig []byte, notify chan struct{}) (router.PriorityRouter, error) {
uniformRouters := make([]*UniformRouter, 0)
var err error
......@@ -48,6 +68,7 @@ func NewUniformRouterChain(virtualServiceConfig, destinationRuleConfig []byte, n
return r, nil
}
// Route route invokers using RouterChain's routers one by one
func (r *RouterChain) Route(invokers []protocol.Invoker, url *common.URL, invocation protocol.Invocation) []protocol.Invoker {
for _, v := range r.routers {
invokers = v.Route(invokers, url, invocation)
......@@ -151,7 +172,7 @@ func (r *RouterChain) URL() *common.URL {
return nil
}
// parseFromConfigToRouters file -> routers
// parseFromConfigToRouters parse virtualService and destinationRule yaml file bytes to target router list
func parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig []byte, notify chan struct{}) ([]*UniformRouter, error) {
var virtualServiceConfigList []*config.VirtualServiceConfig
destRuleConfigsMap := make(map[string]map[string]map[string]string)
......@@ -220,3 +241,9 @@ func parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig []byte
logger.Debug("parsed successed! with router size = ", len(routers))
return routers, nil
}
func mapCombine(dist map[string]map[string]string, from map[string]map[string]string) {
for k, v := range from {
dist[k] = v
}
}
......@@ -22,7 +22,6 @@ import (
)
import (
"github.com/apache/dubbo-go/cluster/router"
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/protocol"
)
......@@ -31,18 +30,12 @@ const (
name = "uniform-router"
)
// UniformRouter provides a health-first routing mechanism through ConnChecker
// UniformRouter have
type UniformRouter struct {
dubboRouter *DubboRouterRule
notify chan struct{}
}
func mapCombine(dist map[string]map[string]string, from map[string]map[string]string) {
for k, v := range from {
dist[k] = v
}
}
// NewUniformRouter construct an NewConnCheckRouter via url
func NewUniformRouter(dubboRouter *DubboRouterRule, notify chan struct{}) (*UniformRouter, error) {
r := &UniformRouter{
......@@ -57,26 +50,8 @@ func (r *UniformRouter) Route(invokers []protocol.Invoker, url *common.URL, invo
return r.dubboRouter.route(invokers, url, invocation)
}
// Process there is no process needs for uniform Router, as it upper struct RouterChain has done it
func (r *UniformRouter) Process(event *config_center.ConfigChangeEvent) {
// todo deal with router change
}
// Pool separates healthy invokers from others.
func (r *UniformRouter) Pool(invokers []protocol.Invoker) (router.AddrPool, router.AddrMetadata) {
rb := make(router.AddrPool, 8)
//rb[uniformSelected] = roaring.NewBitmap()
//for i, invoker := range invokers {
// if r.checker.IsConnHealthy(invoker) {
// rb[connHealthy].Add(uint32(i))
// }
//}
return rb, nil
}
// ShouldPool will always return true to make sure healthy check constantly.
func (r *UniformRouter) ShouldPool() bool {
return true
}
// Name get name of ConnCheckerRouter
......
......@@ -19,12 +19,18 @@ package uniform
import (
"fmt"
)
import (
perrors "github.com/pkg/errors"
)
import (
"github.com/apache/dubbo-go/cluster/router/uniform/match_judger"
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/config"
"github.com/apache/dubbo-go/protocol"
perrors "github.com/pkg/errors"
)
// VirtualServiceRule is item of virtual service, it aims at judge if invocation context match it's condition, and
......@@ -146,7 +152,6 @@ func (vsr *VirtualServiceRule) getRuleTargetInvokers(invokers []protocol.Invoker
for _, v := range resultInvokersMap {
invokerList = append(invokerList, v)
}
// todo
return invokerList, nil
}
......@@ -180,17 +185,21 @@ func (u *UniformRule) route(invokers []protocol.Invoker, url *common.URL, invoca
resultInvokers := make([]protocol.Invoker, 0)
matchService := false
for _, v := range u.services {
// check if match service field
if match_judger.NewStringMatchJudger(v).Judge(url.ServiceKey()) {
matchService = true
break
}
}
if !matchService {
// if not match, jump this rule
return resultInvokers
}
// route Details level match
// match service field, route Details level(service level) match
// then, check all sub rule, if match, get destination rule target invokers, else do fail back logic
for _, rule := range u.virtualServiceRules {
if rule.match(url, invocation) {
// match this rule, do get target logic
resultInvokers, err := rule.getRuleTargetInvokers(invokers)
if err != nil {
logger.Error("getRuleTargetInvokers from rule err = ", err)
......
apiVersion: "apiextensions.k8sCRD.io/v1"
apiVersion: "apiextensions.k8s.io/v1"
kind: "CustomResourceDefinition"
metadata:
name: "virtualservices.service.dubbo.apache.org"
......@@ -18,4 +18,26 @@ spec:
names:
plural: "virtualservices"
singular: "virtualservice"
kind: "VirtualService"
\ No newline at end of file
kind: "VirtualService"
---
apiVersion: "apiextensions.k8s.io/v1"
kind: "CustomResourceDefinition"
metadata:
name: "destinationrules.service.dubbo.apache.org"
spec:
group: "service.dubbo.apache.org"
versions:
- name: "v1alpha1"
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
scope: "Namespaced"
names:
plural: "destinationrules"
singular: "destinationrule"
kind: "DestinationRule"
\ No newline at end of file
package k8sCRD
//const GroupName = "service.dubbo.apache.org"
//const GroupVersion = "v1alpha1"
//const Resource = "virtualservices"
//const Namespace = "dubbo-workplace"
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