I18N effort for dubbo-cluster, #1114
This commit is contained in:
parent
57c815eebe
commit
c6dcb72405
|
|
@ -1,12 +1,13 @@
|
|||
<!--
|
||||
- Copyright 1999-2011 Alibaba Group.
|
||||
-
|
||||
- Licensed 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
|
||||
-
|
||||
- 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.
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -27,7 +28,6 @@ import com.alibaba.dubbo.rpc.cluster.support.FailoverCluster;
|
|||
* <a href="http://en.wikipedia.org/wiki/Computer_cluster">Cluster</a>
|
||||
* <a href="http://en.wikipedia.org/wiki/Fault-tolerant_system">Fault-Tolerant</a>
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
@SPI(FailoverCluster.NAME)
|
||||
public interface Cluster {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -20,7 +21,6 @@ import com.alibaba.dubbo.common.URL;
|
|||
/**
|
||||
* Configurator. (SPI, Prototype, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public interface Configurator extends Comparable<Configurator> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -22,7 +23,6 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
/**
|
||||
* ConfiguratorFactory. (SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
@SPI
|
||||
public interface ConfiguratorFactory {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -27,7 +28,6 @@ import java.util.List;
|
|||
* <p>
|
||||
* <a href="http://en.wikipedia.org/wiki/Directory_service">Directory Service</a>
|
||||
*
|
||||
* @author william.liangf
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Cluster#join(Directory)
|
||||
*/
|
||||
public interface Directory<T> extends Node {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -30,8 +31,6 @@ import java.util.List;
|
|||
* <p>
|
||||
* <a href="http://en.wikipedia.org/wiki/Load_balancing_(computing)">Load-Balancing</a>
|
||||
*
|
||||
* @author qian.lei
|
||||
* @author william.liangf
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Cluster#join(Directory)
|
||||
*/
|
||||
@SPI(RandomLoadBalance.NAME)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -18,7 +19,6 @@ package com.alibaba.dubbo.rpc.cluster;
|
|||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*/
|
||||
@SPI
|
||||
public interface Merger<T> {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -27,7 +28,6 @@ import java.util.List;
|
|||
* <p>
|
||||
* <a href="http://en.wikipedia.org/wiki/Routing">Routing</a>
|
||||
*
|
||||
* @author chao.liuc
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Cluster#join(Directory)
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Directory#list(Invocation)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -25,7 +26,6 @@ import com.alibaba.dubbo.rpc.Invocation;
|
|||
* <p>
|
||||
* <a href="http://en.wikipedia.org/wiki/Routing">Routing</a>
|
||||
*
|
||||
* @author chao.liuc
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Cluster#join(Directory)
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Directory#list(Invocation)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
* 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
|
||||
*
|
||||
* Licensed 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
|
||||
* 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,
|
||||
|
|
@ -22,7 +23,6 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*/
|
||||
@SPI
|
||||
public interface RuleConverter {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -27,7 +28,6 @@ import java.util.Set;
|
|||
/**
|
||||
* AbstractOverrideConfigurator
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public abstract class AbstractConfigurator implements Configurator {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -21,7 +22,6 @@ import com.alibaba.dubbo.rpc.cluster.configurator.AbstractConfigurator;
|
|||
/**
|
||||
* AbsentConfigurator
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class AbsentConfigurator extends AbstractConfigurator {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -22,7 +23,6 @@ import com.alibaba.dubbo.rpc.cluster.ConfiguratorFactory;
|
|||
/**
|
||||
* AbsentConfiguratorFactory
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class AbsentConfiguratorFactory implements ConfiguratorFactory {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -21,7 +22,6 @@ import com.alibaba.dubbo.rpc.cluster.configurator.AbstractConfigurator;
|
|||
/**
|
||||
* AbsentConfigurator
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class OverrideConfigurator extends AbstractConfigurator {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -22,7 +23,6 @@ import com.alibaba.dubbo.rpc.cluster.ConfiguratorFactory;
|
|||
/**
|
||||
* AbsentConfiguratorFactory
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class OverrideConfiguratorFactory implements ConfiguratorFactory {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -33,13 +34,12 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 增加router的Directory
|
||||
* Abstract implementation of Directory: Invoker list returned from this Directory's list method have been filtered by Routers
|
||||
*
|
||||
* @author chao.liuc
|
||||
*/
|
||||
public abstract class AbstractDirectory<T> implements Directory<T> {
|
||||
|
||||
// 日志输出
|
||||
// logger
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractDirectory.class);
|
||||
|
||||
private final URL url;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -26,7 +27,6 @@ import java.util.List;
|
|||
/**
|
||||
* StaticDirectory
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class StaticDirectory<T> extends AbstractDirectory<T> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -26,7 +27,6 @@ import java.util.List;
|
|||
/**
|
||||
* AbstractLoadBalance
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public abstract class AbstractLoadBalance implements LoadBalance {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -32,7 +33,6 @@ import java.util.concurrent.ConcurrentMap;
|
|||
/**
|
||||
* ConsistentHashLoadBalance
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class ConsistentHashLoadBalance extends AbstractLoadBalance {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -27,7 +28,6 @@ import java.util.Random;
|
|||
/**
|
||||
* LeastActiveLoadBalance
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class LeastActiveLoadBalance extends AbstractLoadBalance {
|
||||
|
||||
|
|
@ -36,28 +36,28 @@ public class LeastActiveLoadBalance extends AbstractLoadBalance {
|
|||
private final Random random = new Random();
|
||||
|
||||
protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) {
|
||||
int length = invokers.size(); // 总个数
|
||||
int leastActive = -1; // 最小的活跃数
|
||||
int leastCount = 0; // 相同最小活跃数的个数
|
||||
int[] leastIndexs = new int[length]; // 相同最小活跃数的下标
|
||||
int totalWeight = 0; // 总权重
|
||||
int firstWeight = 0; // 第一个权重,用于于计算是否相同
|
||||
boolean sameWeight = true; // 是否所有权重相同
|
||||
int length = invokers.size(); // Number of invokers
|
||||
int leastActive = -1; // The least active value of all invokers
|
||||
int leastCount = 0; // The number of invokers having the same least active value (leastActive)
|
||||
int[] leastIndexs = new int[length]; // The index of invokers having the same least active value (leastActive)
|
||||
int totalWeight = 0; // The sum of weights
|
||||
int firstWeight = 0; // Initial value, used for comparision
|
||||
boolean sameWeight = true; // Every invoker has the same weight value?
|
||||
for (int i = 0; i < length; i++) {
|
||||
Invoker<T> invoker = invokers.get(i);
|
||||
int active = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()).getActive(); // 活跃数
|
||||
int weight = invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.WEIGHT_KEY, Constants.DEFAULT_WEIGHT); // 权重
|
||||
if (leastActive == -1 || active < leastActive) { // 发现更小的活跃数,重新开始
|
||||
leastActive = active; // 记录最小活跃数
|
||||
leastCount = 1; // 重新统计相同最小活跃数的个数
|
||||
leastIndexs[0] = i; // 重新记录最小活跃数下标
|
||||
totalWeight = weight; // 重新累计总权重
|
||||
firstWeight = weight; // 记录第一个权重
|
||||
sameWeight = true; // 还原权重相同标识
|
||||
} else if (active == leastActive) { // 累计相同最小的活跃数
|
||||
leastIndexs[leastCount++] = i; // 累计相同最小活跃数下标
|
||||
totalWeight += weight; // 累计总权重
|
||||
// 判断所有权重是否一样
|
||||
int active = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()).getActive(); // Active number
|
||||
int weight = invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.WEIGHT_KEY, Constants.DEFAULT_WEIGHT); // Weight
|
||||
if (leastActive == -1 || active < leastActive) { // Restart, when find a invoker having smaller least active value.
|
||||
leastActive = active; // Record the current least active value
|
||||
leastCount = 1; // Reset leastCount, count again based on current leastCount
|
||||
leastIndexs[0] = i; // Reset
|
||||
totalWeight = weight; // Reset
|
||||
firstWeight = weight; // Record the weight the first invoker
|
||||
sameWeight = true; // Reset, every invoker has the same weight value?
|
||||
} else if (active == leastActive) { // If current invoker's active value equals with leaseActive, then accumulating.
|
||||
leastIndexs[leastCount++] = i; // Record index number of this invoker
|
||||
totalWeight += weight; // Add this invoker's weight to totalWeight.
|
||||
// If every invoker has the same weight?
|
||||
if (sameWeight && i > 0
|
||||
&& weight != firstWeight) {
|
||||
sameWeight = false;
|
||||
|
|
@ -66,13 +66,13 @@ public class LeastActiveLoadBalance extends AbstractLoadBalance {
|
|||
}
|
||||
// assert(leastCount > 0)
|
||||
if (leastCount == 1) {
|
||||
// 如果只有一个最小则直接返回
|
||||
// If we got exactly one invoker having the least active value, return this invoker directly.
|
||||
return invokers.get(leastIndexs[0]);
|
||||
}
|
||||
if (!sameWeight && totalWeight > 0) {
|
||||
// 如果权重不相同且权重大于0则按总权重数随机
|
||||
// If (not every invoker has the same weight & at least one invoker's weight>0), select randomly based on totalWeight.
|
||||
int offsetWeight = random.nextInt(totalWeight);
|
||||
// 并确定随机值落在哪个片断上
|
||||
// Return a invoker based on the random value.
|
||||
for (int i = 0; i < leastCount; i++) {
|
||||
int leastIndex = leastIndexs[i];
|
||||
offsetWeight -= getWeight(invokers.get(leastIndex), invocation);
|
||||
|
|
@ -80,7 +80,7 @@ public class LeastActiveLoadBalance extends AbstractLoadBalance {
|
|||
return invokers.get(leastIndex);
|
||||
}
|
||||
}
|
||||
// 如果权重相同或权重为0则均等随机
|
||||
// If all invokers have the same weight value or totalWeight=0, return evenly.
|
||||
return invokers.get(leastIndexs[random.nextInt(leastCount)]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -25,8 +26,6 @@ import java.util.Random;
|
|||
/**
|
||||
* random load balance.
|
||||
*
|
||||
* @author qianlei
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class RandomLoadBalance extends AbstractLoadBalance {
|
||||
|
||||
|
|
@ -35,21 +34,21 @@ public class RandomLoadBalance extends AbstractLoadBalance {
|
|||
private final Random random = new Random();
|
||||
|
||||
protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) {
|
||||
int length = invokers.size(); // 总个数
|
||||
int totalWeight = 0; // 总权重
|
||||
boolean sameWeight = true; // 权重是否都一样
|
||||
int length = invokers.size(); // Number of invokers
|
||||
int totalWeight = 0; // The sum of weights
|
||||
boolean sameWeight = true; // Every invoker has the same weight?
|
||||
for (int i = 0; i < length; i++) {
|
||||
int weight = getWeight(invokers.get(i), invocation);
|
||||
totalWeight += weight; // 累计总权重
|
||||
totalWeight += weight; // Sum
|
||||
if (sameWeight && i > 0
|
||||
&& weight != getWeight(invokers.get(i - 1), invocation)) {
|
||||
sameWeight = false; // 计算所有权重是否一样
|
||||
sameWeight = false;
|
||||
}
|
||||
}
|
||||
if (totalWeight > 0 && !sameWeight) {
|
||||
// 如果权重不相同且权重大于0则按总权重数随机
|
||||
// If (not every invoker has the same weight & at least one invoker's weight>0), select randomly based on totalWeight.
|
||||
int offset = random.nextInt(totalWeight);
|
||||
// 并确定随机值落在哪个片断上
|
||||
// Return a invoker based on the random value.
|
||||
for (int i = 0; i < length; i++) {
|
||||
offset -= getWeight(invokers.get(i), invocation);
|
||||
if (offset < 0) {
|
||||
|
|
@ -57,7 +56,7 @@ public class RandomLoadBalance extends AbstractLoadBalance {
|
|||
}
|
||||
}
|
||||
}
|
||||
// 如果权重相同或权重为0则均等随机
|
||||
// If all invokers have the same weight value or totalWeight=0, return evenly.
|
||||
return invokers.get(random.nextInt(length));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -29,8 +30,6 @@ import java.util.concurrent.ConcurrentMap;
|
|||
/**
|
||||
* Round robin load balance.
|
||||
*
|
||||
* @author qian.lei
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class RoundRobinLoadBalance extends AbstractLoadBalance {
|
||||
|
||||
|
|
@ -40,15 +39,15 @@ public class RoundRobinLoadBalance extends AbstractLoadBalance {
|
|||
|
||||
protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) {
|
||||
String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName();
|
||||
int length = invokers.size(); // 总个数
|
||||
int maxWeight = 0; // 最大权重
|
||||
int minWeight = Integer.MAX_VALUE; // 最小权重
|
||||
int length = invokers.size(); // Number of invokers
|
||||
int maxWeight = 0; // The maximum weight
|
||||
int minWeight = Integer.MAX_VALUE; // The minimum weight
|
||||
final LinkedHashMap<Invoker<T>, IntegerWrapper> invokerToWeightMap = new LinkedHashMap<Invoker<T>, IntegerWrapper>();
|
||||
int weightSum = 0;
|
||||
for (int i = 0; i < length; i++) {
|
||||
int weight = getWeight(invokers.get(i), invocation);
|
||||
maxWeight = Math.max(maxWeight, weight); // 累计最大权重
|
||||
minWeight = Math.min(minWeight, weight); // 累计最小权重
|
||||
maxWeight = Math.max(maxWeight, weight); // Choose the maximum weight
|
||||
minWeight = Math.min(minWeight, weight); // Choose the minimum weight
|
||||
if (weight > 0) {
|
||||
invokerToWeightMap.put(invokers.get(i), new IntegerWrapper(weight));
|
||||
weightSum += weight;
|
||||
|
|
@ -60,7 +59,7 @@ public class RoundRobinLoadBalance extends AbstractLoadBalance {
|
|||
sequence = sequences.get(key);
|
||||
}
|
||||
int currentSequence = sequence.getAndIncrement();
|
||||
if (maxWeight > 0 && minWeight < maxWeight) { // 权重不一样
|
||||
if (maxWeight > 0 && minWeight < maxWeight) {
|
||||
int mod = currentSequence % weightSum;
|
||||
for (int i = 0; i < maxWeight; i++) {
|
||||
for (Map.Entry<Invoker<T>, IntegerWrapper> each : invokerToWeightMap.entrySet()) {
|
||||
|
|
@ -76,7 +75,7 @@ public class RoundRobinLoadBalance extends AbstractLoadBalance {
|
|||
}
|
||||
}
|
||||
}
|
||||
// 取模轮循
|
||||
// Round robin
|
||||
return invokers.get(currentSequence % length);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -20,7 +21,7 @@ import com.alibaba.dubbo.rpc.cluster.Merger;
|
|||
import java.lang.reflect.Array;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*
|
||||
*/
|
||||
public class ArrayMerger implements Merger<Object[]> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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.
|
||||
* 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 com.alibaba.dubbo.rpc.cluster.merger;
|
||||
|
|
@ -19,7 +20,6 @@ package com.alibaba.dubbo.rpc.cluster.merger;
|
|||
import com.alibaba.dubbo.rpc.cluster.Merger;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*/
|
||||
public class BooleanArrayMerger implements Merger<boolean[]> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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.
|
||||
* 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 com.alibaba.dubbo.rpc.cluster.merger;
|
||||
|
|
@ -19,7 +20,7 @@ package com.alibaba.dubbo.rpc.cluster.merger;
|
|||
import com.alibaba.dubbo.rpc.cluster.Merger;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*
|
||||
*/
|
||||
public class ByteArrayMerger implements Merger<byte[]> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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.
|
||||
* 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 com.alibaba.dubbo.rpc.cluster.merger;
|
||||
|
|
@ -19,7 +20,7 @@ package com.alibaba.dubbo.rpc.cluster.merger;
|
|||
import com.alibaba.dubbo.rpc.cluster.Merger;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*
|
||||
*/
|
||||
public class CharArrayMerger implements Merger<char[]> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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.
|
||||
* 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 com.alibaba.dubbo.rpc.cluster.merger;
|
||||
|
|
@ -19,7 +20,7 @@ package com.alibaba.dubbo.rpc.cluster.merger;
|
|||
import com.alibaba.dubbo.rpc.cluster.Merger;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*
|
||||
*/
|
||||
public class DoubleArrayMerger implements Merger<double[]> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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.
|
||||
* 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 com.alibaba.dubbo.rpc.cluster.merger;
|
||||
|
|
@ -19,7 +20,7 @@ package com.alibaba.dubbo.rpc.cluster.merger;
|
|||
import com.alibaba.dubbo.rpc.cluster.Merger;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*
|
||||
*/
|
||||
public class FloatArrayMerger implements Merger<float[]> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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.
|
||||
* 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 com.alibaba.dubbo.rpc.cluster.merger;
|
||||
|
|
@ -19,7 +20,7 @@ package com.alibaba.dubbo.rpc.cluster.merger;
|
|||
import com.alibaba.dubbo.rpc.cluster.Merger;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*
|
||||
*/
|
||||
public class IntArrayMerger implements Merger<int[]> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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.
|
||||
* 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 com.alibaba.dubbo.rpc.cluster.merger;
|
||||
|
|
@ -22,7 +23,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*
|
||||
*/
|
||||
public class ListMerger implements Merger<List<?>> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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.
|
||||
* 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 com.alibaba.dubbo.rpc.cluster.merger;
|
||||
|
|
@ -19,7 +20,7 @@ package com.alibaba.dubbo.rpc.cluster.merger;
|
|||
import com.alibaba.dubbo.rpc.cluster.Merger;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*
|
||||
*/
|
||||
public class LongArrayMerger implements Merger<long[]> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -21,7 +22,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*
|
||||
*/
|
||||
public class MapMerger implements Merger<Map<?, ?>> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
* 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
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
* 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 com.alibaba.dubbo.rpc.cluster.merger;
|
||||
|
|
@ -25,7 +26,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*
|
||||
*/
|
||||
public class MergerFactory {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,4 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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 com.alibaba.dubbo.rpc.cluster.merger;
|
||||
|
||||
|
|
@ -22,7 +8,7 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*
|
||||
*/
|
||||
public class SetMerger implements Merger<Set<?>> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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.
|
||||
* 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 com.alibaba.dubbo.rpc.cluster.merger;
|
||||
|
|
@ -19,7 +20,7 @@ package com.alibaba.dubbo.rpc.cluster.merger;
|
|||
import com.alibaba.dubbo.rpc.cluster.Merger;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*
|
||||
*/
|
||||
public class ShortArrayMerger implements Merger<short[]> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -26,9 +27,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* mock invoker选择器
|
||||
* A specific Router designed to realize mock feature.
|
||||
* If a request is configured to use mock, then this router guarantees that only the invokers with protocol MOCK appear in final the invoker list, all other invokers will be excluded.
|
||||
*
|
||||
* @author chao.liuc
|
||||
*/
|
||||
public class MockInvokersSelector implements Router {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -40,7 +41,6 @@ import java.util.regex.Pattern;
|
|||
/**
|
||||
* ConditionRouter
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class ConditionRouter implements Router, Comparable<Router> {
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ public class ConditionRouter implements Router, Comparable<Router> {
|
|||
String thenRule = i < 0 ? rule.trim() : rule.substring(i + 2).trim();
|
||||
Map<String, MatchPair> when = StringUtils.isBlank(whenRule) || "true".equals(whenRule) ? new HashMap<String, MatchPair>() : parseRule(whenRule);
|
||||
Map<String, MatchPair> then = StringUtils.isBlank(thenRule) || "false".equals(thenRule) ? null : parseRule(thenRule);
|
||||
// NOTE: When条件是允许为空的,外部业务来保证类似的约束条件
|
||||
// NOTE: It should be determined on the business level whether the `When condition` can be empty or not.
|
||||
this.whenCondition = when;
|
||||
this.thenCondition = then;
|
||||
} catch (ParseException e) {
|
||||
|
|
@ -81,20 +81,20 @@ public class ConditionRouter implements Router, Comparable<Router> {
|
|||
if (StringUtils.isBlank(rule)) {
|
||||
return condition;
|
||||
}
|
||||
// 匹配或不匹配Key-Value对
|
||||
// Key-Value pair, stores both match and mismatch conditions
|
||||
MatchPair pair = null;
|
||||
// 多个Value值
|
||||
// Multiple values
|
||||
Set<String> values = null;
|
||||
final Matcher matcher = ROUTE_PATTERN.matcher(rule);
|
||||
while (matcher.find()) { // 逐个匹配
|
||||
while (matcher.find()) { // Try to match one by one
|
||||
String separator = matcher.group(1);
|
||||
String content = matcher.group(2);
|
||||
// 表达式开始
|
||||
// Start part of the condition expression.
|
||||
if (separator == null || separator.length() == 0) {
|
||||
pair = new MatchPair();
|
||||
condition.put(content, pair);
|
||||
}
|
||||
// KV开始
|
||||
// The KV part of the condition expression
|
||||
else if ("&".equals(separator)) {
|
||||
if (condition.get(content) == null) {
|
||||
pair = new MatchPair();
|
||||
|
|
@ -103,7 +103,7 @@ public class ConditionRouter implements Router, Comparable<Router> {
|
|||
pair = condition.get(content);
|
||||
}
|
||||
}
|
||||
// KV的Value部分开始
|
||||
// The Value in the KV part.
|
||||
else if ("=".equals(separator)) {
|
||||
if (pair == null)
|
||||
throw new ParseException("Illegal route rule \""
|
||||
|
|
@ -114,7 +114,7 @@ public class ConditionRouter implements Router, Comparable<Router> {
|
|||
values = pair.matches;
|
||||
values.add(content);
|
||||
}
|
||||
// KV的Value部分开始
|
||||
// The Value in the KV part.
|
||||
else if ("!=".equals(separator)) {
|
||||
if (pair == null)
|
||||
throw new ParseException("Illegal route rule \""
|
||||
|
|
@ -125,8 +125,8 @@ public class ConditionRouter implements Router, Comparable<Router> {
|
|||
values = pair.mismatches;
|
||||
values.add(content);
|
||||
}
|
||||
// KV的Value部分的多个条目
|
||||
else if (",".equals(separator)) { // 如果为逗号表示
|
||||
// The Value in the KV part, if Value have more than one items.
|
||||
else if (",".equals(separator)) { // Should be seperateed by ','
|
||||
if (values == null || values.size() == 0)
|
||||
throw new ParseException("Illegal route rule \""
|
||||
+ rule + "\", The error char '" + separator
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -22,7 +23,6 @@ import com.alibaba.dubbo.rpc.cluster.RouterFactory;
|
|||
/**
|
||||
* ConditionRouterFactory
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class ConditionRouterFactory implements RouterFactory {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -38,10 +39,10 @@ public class FileRouterFactory implements RouterFactory {
|
|||
|
||||
public Router getRouter(URL url) {
|
||||
try {
|
||||
// File URL 转换成 其它Route URL,然后Load
|
||||
// Transform File URL into Script Route URL, and Load
|
||||
// file:///d:/path/to/route.js?router=script ==> script:///d:/path/to/route.js?type=js&rule=<file-content>
|
||||
String protocol = url.getParameter(Constants.ROUTER_KEY, ScriptRouterFactory.NAME); // 将原类型转为协议
|
||||
String type = null; // 使用文件后缀做为类型
|
||||
String protocol = url.getParameter(Constants.ROUTER_KEY, ScriptRouterFactory.NAME); // Replace original protocol (maybe 'file') with 'script'
|
||||
String type = null; // Use file suffix to config script type, e.g., js, groovy ...
|
||||
String path = url.getPath();
|
||||
if (path != null) {
|
||||
int i = path.lastIndexOf('.');
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -40,7 +41,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
/**
|
||||
* ScriptRouter
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class ScriptRouter implements Router {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -22,16 +23,15 @@ import com.alibaba.dubbo.rpc.cluster.RouterFactory;
|
|||
/**
|
||||
* ScriptRouterFactory
|
||||
* <p>
|
||||
* Script Router Factory用到的URL形如:
|
||||
* Example URLS used by Script Router Factory:
|
||||
* <ol>
|
||||
* <li> script://registyAddress?type=js&rule=xxxx
|
||||
* <li> script:///path/to/routerfile.js?type=js&rule=xxxx
|
||||
* <li> script://D:\path\to\routerfile.js?type=js&rule=xxxx
|
||||
* <li> script://C:/path/to/routerfile.js?type=js&rule=xxxx
|
||||
* </ol>
|
||||
* URL的Host一段包含的是Script Router内容的来源,Registry、File etc
|
||||
* The host value in URL points out the address of the source content of the Script Router,Registry、File etc
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class ScriptRouterFactory implements RouterFactory {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -37,8 +38,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
/**
|
||||
* AbstractClusterInvoker
|
||||
*
|
||||
* @author william.liangf
|
||||
* @author chao.liuc
|
||||
*/
|
||||
public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
||||
|
||||
|
|
@ -61,7 +60,7 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
throw new IllegalArgumentException("service directory == null");
|
||||
|
||||
this.directory = directory;
|
||||
//sticky 需要检测 avaliablecheck
|
||||
//sticky: invoker.isAvailable() should always be checked before using when availablecheck is true.
|
||||
this.availablecheck = url.getParameter(Constants.CLUSTER_AVAILABLE_CHECK_KEY, Constants.DEFAULT_CLUSTER_AVAILABLE_CHECK);
|
||||
}
|
||||
|
||||
|
|
@ -88,12 +87,20 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* 使用loadbalance选择invoker.</br>
|
||||
* a)先lb选择,如果在selected列表中 或者 不可用且做检验时,进入下一步(重选),否则直接返回</br>
|
||||
* b)重选验证规则:selected > available .保证重选出的结果尽量不在select中,并且是可用的
|
||||
* Select a invoker using loadbalance policy.</br>
|
||||
* a)Firstly, select an invoker using loadbalance. If this invoker is in previously selected list, or, if this invoker is unavailable, then continue step b (reselect), otherwise return the first selected invoker</br>
|
||||
* b)Reslection, the validation rule for reselection: selected > available. This rule guarantees that the selected invoker has the minimum chance to be one in the previously selected list, and also guarantees this invoker is available.
|
||||
*
|
||||
* @param availablecheck 如果设置true,在选择的时候先选invoker.available == true
|
||||
* @param selected 已选过的invoker.注意:输入保证不重复
|
||||
* @param loadbalance load balance policy
|
||||
* @param invocation
|
||||
* @param invokers invoker candidates
|
||||
* @param selected exclude selected invokers or not
|
||||
* @return
|
||||
* @throws RpcExceptione
|
||||
*/
|
||||
/**
|
||||
*
|
||||
|
||||
*/
|
||||
protected Invoker<T> select(LoadBalance loadbalance, Invocation invocation, List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
|
||||
if (invokers == null || invokers.size() == 0)
|
||||
|
|
@ -126,13 +133,13 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
return null;
|
||||
if (invokers.size() == 1)
|
||||
return invokers.get(0);
|
||||
// 如果只有两个invoker,退化成轮循
|
||||
// If we only have two invokers, use round-robin instead.
|
||||
if (invokers.size() == 2 && selected != null && selected.size() > 0) {
|
||||
return selected.get(0) == invokers.get(0) ? invokers.get(1) : invokers.get(0);
|
||||
}
|
||||
Invoker<T> invoker = loadbalance.select(invokers, getUrl(), invocation);
|
||||
|
||||
//如果 selected中包含(优先判断) 或者 不可用&&availablecheck=true 则重试.
|
||||
//If the `invoker` is in the `selected` or invoker is unavailable && availablecheck is true, reselect.
|
||||
if ((selected != null && selected.contains(invoker))
|
||||
|| (!invoker.isAvailable() && getUrl() != null && availablecheck)) {
|
||||
try {
|
||||
|
|
@ -140,10 +147,10 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
if (rinvoker != null) {
|
||||
invoker = rinvoker;
|
||||
} else {
|
||||
//看下第一次选的位置,如果不是最后,选+1位置.
|
||||
//Check the index of current selected invoker, if it's not the last one, choose the one at index+1.
|
||||
int index = invokers.indexOf(invoker);
|
||||
try {
|
||||
//最后在避免碰撞
|
||||
//Avoid collision
|
||||
invoker = index < invokers.size() - 1 ? invokers.get(index + 1) : invoker;
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage() + " may because invokers list dynamic change, ignore.", e);
|
||||
|
|
@ -157,7 +164,7 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* 重选,先从非selected的列表中选择,没有在从selected列表中选择.
|
||||
* Reselect, use invokers not in `selected` first, if all invokers are in `selected`, just pick an available one using loadbalance policy.
|
||||
*
|
||||
* @param loadbalance
|
||||
* @param invocation
|
||||
|
|
@ -170,11 +177,11 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
List<Invoker<T>> invokers, List<Invoker<T>> selected, boolean availablecheck)
|
||||
throws RpcException {
|
||||
|
||||
//预先分配一个,这个列表是一定会用到的.
|
||||
//Allocating one in advance, this list is certain to be used.
|
||||
List<Invoker<T>> reselectInvokers = new ArrayList<Invoker<T>>(invokers.size() > 1 ? (invokers.size() - 1) : invokers.size());
|
||||
|
||||
//先从非select中选
|
||||
if (availablecheck) { //选isAvailable 的非select
|
||||
//First, try picking a invoker not in `selected`.
|
||||
if (availablecheck) { // invoker.isAvailable() should be checked
|
||||
for (Invoker<T> invoker : invokers) {
|
||||
if (invoker.isAvailable()) {
|
||||
if (selected == null || !selected.contains(invoker)) {
|
||||
|
|
@ -185,7 +192,7 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
if (reselectInvokers.size() > 0) {
|
||||
return loadbalance.select(reselectInvokers, getUrl(), invocation);
|
||||
}
|
||||
} else { //选全部非select
|
||||
} else { // do not check invoker.isAvailable()
|
||||
for (Invoker<T> invoker : invokers) {
|
||||
if (selected == null || !selected.contains(invoker)) {
|
||||
reselectInvokers.add(invoker);
|
||||
|
|
@ -195,11 +202,11 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
return loadbalance.select(reselectInvokers, getUrl(), invocation);
|
||||
}
|
||||
}
|
||||
//最后从select中选可用的.
|
||||
// Just pick an available invoker using loadbalance policy
|
||||
{
|
||||
if (selected != null) {
|
||||
for (Invoker<T> invoker : selected) {
|
||||
if ((invoker.isAvailable()) //优先选available
|
||||
if ((invoker.isAvailable()) // available first
|
||||
&& !reselectInvokers.contains(invoker)) {
|
||||
reselectInvokers.add(invoker);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -28,7 +29,6 @@ import java.util.List;
|
|||
/**
|
||||
* AvailableCluster
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class AvailableCluster implements Cluster {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -27,7 +28,6 @@ import java.util.List;
|
|||
/**
|
||||
* AvailableCluster
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class AvailableClusterInvoker<T> extends AbstractClusterInvoker<T> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -23,7 +24,6 @@ import com.alibaba.dubbo.rpc.cluster.Directory;
|
|||
/**
|
||||
* BroadcastCluster
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class BroadcastCluster implements Cluster {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -30,7 +31,6 @@ import java.util.List;
|
|||
/**
|
||||
* BroadcastClusterInvoker
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class BroadcastClusterInvoker<T> extends AbstractClusterInvoker<T> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -24,7 +25,6 @@ import java.util.Map;
|
|||
/**
|
||||
* ClusterUtils
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class ClusterUtils {
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ public class ClusterUtils {
|
|||
if (remoteMap != null && remoteMap.size() > 0) {
|
||||
map.putAll(remoteMap);
|
||||
|
||||
//线程池配置不使用提供者的
|
||||
// Remove configurations from provider, some items should be affected by provider.
|
||||
map.remove(Constants.THREAD_NAME_KEY);
|
||||
map.remove(Constants.DEFAULT_KEY_PREFIX + Constants.THREAD_NAME_KEY);
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ public class ClusterUtils {
|
|||
map.putAll(localMap);
|
||||
}
|
||||
if (remoteMap != null && remoteMap.size() > 0) {
|
||||
// 版本号使用提供者的
|
||||
// Use version passed from provider side
|
||||
String dubbo = remoteMap.get(Constants.DUBBO_VERSION_KEY);
|
||||
if (dubbo != null && dubbo.length() > 0) {
|
||||
map.put(Constants.DUBBO_VERSION_KEY, dubbo);
|
||||
|
|
@ -83,12 +83,12 @@ public class ClusterUtils {
|
|||
if (methods != null && methods.length() > 0) {
|
||||
map.put(Constants.METHODS_KEY, methods);
|
||||
}
|
||||
// 保留provider的启动timestamp
|
||||
// Reserve timestamp of provider url.
|
||||
String remoteTimestamp = remoteMap.get(Constants.TIMESTAMP_KEY);
|
||||
if (remoteTimestamp != null && remoteTimestamp.length() > 0) {
|
||||
map.put(Constants.REMOTE_TIMESTAMP_KEY, remoteMap.get(Constants.TIMESTAMP_KEY));
|
||||
}
|
||||
// 合并filter和listener
|
||||
// Combine filters and listeners on Provider and Consumer
|
||||
String remoteFilter = remoteMap.get(Constants.REFERENCE_FILTER_KEY);
|
||||
String localFilter = localMap.get(Constants.REFERENCE_FILTER_KEY);
|
||||
if (remoteFilter != null && remoteFilter.length() > 0
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -21,11 +22,8 @@ import com.alibaba.dubbo.rpc.cluster.Cluster;
|
|||
import com.alibaba.dubbo.rpc.cluster.Directory;
|
||||
|
||||
/**
|
||||
* 失败自动恢复,后台记录失败请求,定时重发,通常用于消息通知操作。
|
||||
* <p>
|
||||
* <a href="http://en.wikipedia.org/wiki/Failback">Failback</a>
|
||||
* {@link FailbackClusterInvoker}
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class FailbackCluster implements Cluster {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -37,9 +38,11 @@ import java.util.concurrent.ScheduledFuture;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 失败自动恢复,后台记录失败请求,定时重发,通常用于消息通知操作。
|
||||
* When fails, record failure requests and schedule for retry on a regular interval.
|
||||
* Especially useful for services of notification.
|
||||
*
|
||||
* <a href="http://en.wikipedia.org/wiki/Failback">Failback</a>
|
||||
*
|
||||
* @author tony.chenl
|
||||
*/
|
||||
public class FailbackClusterInvoker<T> extends AbstractClusterInvoker<T> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -21,11 +22,8 @@ import com.alibaba.dubbo.rpc.cluster.Cluster;
|
|||
import com.alibaba.dubbo.rpc.cluster.Directory;
|
||||
|
||||
/**
|
||||
* 快速失败,只发起一次调用,失败立即报错,通常用于非幂等性的写操作。
|
||||
* <p>
|
||||
* <a href="http://en.wikipedia.org/wiki/Fail-fast">Fail-fast</a>
|
||||
* {@link FailfastClusterInvoker}
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class FailfastCluster implements Cluster {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -27,12 +28,11 @@ import com.alibaba.dubbo.rpc.cluster.LoadBalance;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 快速失败,只发起一次调用,失败立即报错,通常用于非幂等性的写操作。
|
||||
* <p>
|
||||
* Execute exactly once, which means this policy will throw an exception immediately in case of an invocation error.
|
||||
* Usually used for non-idempotent write operations
|
||||
*
|
||||
* <a href="http://en.wikipedia.org/wiki/Fail-fast">Fail-fast</a>
|
||||
*
|
||||
* @author william.liangf
|
||||
* @author chao.liuc
|
||||
*/
|
||||
public class FailfastClusterInvoker<T> extends AbstractClusterInvoker<T> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -21,11 +22,8 @@ import com.alibaba.dubbo.rpc.cluster.Cluster;
|
|||
import com.alibaba.dubbo.rpc.cluster.Directory;
|
||||
|
||||
/**
|
||||
* 失败转移,当出现失败,重试其它服务器,通常用于读操作,但重试会带来更长延迟。
|
||||
* <p>
|
||||
* <a href="http://en.wikipedia.org/wiki/Failover">Failover</a>
|
||||
* {@link FailoverClusterInvoker}
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class FailoverCluster implements Cluster {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -34,12 +35,11 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 失败转移,当出现失败,重试其它服务器,通常用于读操作,但重试会带来更长延迟。
|
||||
* When invoke fails, log the initial error and retry other invokers (retry n times, which means at most n different invokers will be invoked)
|
||||
* Note that retry causes latency.
|
||||
* <p>
|
||||
* <a href="http://en.wikipedia.org/wiki/Failover">Failover</a>
|
||||
*
|
||||
* @author william.liangf
|
||||
* @author chao.liuc
|
||||
*/
|
||||
public class FailoverClusterInvoker<T> extends AbstractClusterInvoker<T> {
|
||||
|
||||
|
|
@ -62,12 +62,12 @@ public class FailoverClusterInvoker<T> extends AbstractClusterInvoker<T> {
|
|||
List<Invoker<T>> invoked = new ArrayList<Invoker<T>>(copyinvokers.size()); // invoked invokers.
|
||||
Set<String> providers = new HashSet<String>(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
//重试时,进行重新选择,避免重试时invoker列表已发生变化.
|
||||
//注意:如果列表发生了变化,那么invoked判断会失效,因为invoker示例已经改变
|
||||
//Reselect before retry to avoid a change of candidate `invokers`.
|
||||
//NOTE: if `invokers` changed, then `invoked` also lose accuracy.
|
||||
if (i > 0) {
|
||||
checkWhetherDestroyed();
|
||||
copyinvokers = list(invocation);
|
||||
//重新检查一下
|
||||
// check again
|
||||
checkInvokers(copyinvokers, invocation);
|
||||
}
|
||||
Invoker<T> invoker = select(loadbalance, invocation, copyinvokers, invoked);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -21,11 +22,8 @@ import com.alibaba.dubbo.rpc.cluster.Cluster;
|
|||
import com.alibaba.dubbo.rpc.cluster.Directory;
|
||||
|
||||
/**
|
||||
* 失败安全,出现异常时,直接忽略,通常用于写入审计日志等操作。
|
||||
* <p>
|
||||
* <a href="http://en.wikipedia.org/wiki/Fail-safe">Fail-safe</a>
|
||||
* {@link FailsafeClusterInvoker}
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class FailsafeCluster implements Cluster {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -28,11 +29,11 @@ import com.alibaba.dubbo.rpc.cluster.LoadBalance;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 失败安全,出现异常时,直接忽略,通常用于写入审计日志等操作。
|
||||
* <p>
|
||||
* When invoke fails, log the error message and ignore this error by returning an empty RpcResult.
|
||||
* Usually used to write audit logs and other operations
|
||||
*
|
||||
* <a href="http://en.wikipedia.org/wiki/Fail-safe">Fail-safe</a>
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class FailsafeClusterInvoker<T> extends AbstractClusterInvoker<T> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FailsafeClusterInvoker.class);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -21,11 +22,8 @@ import com.alibaba.dubbo.rpc.cluster.Cluster;
|
|||
import com.alibaba.dubbo.rpc.cluster.Directory;
|
||||
|
||||
/**
|
||||
* 并行调用,只要一个成功即返回,通常用于实时性要求较高的操作,但需要浪费更多服务资源。
|
||||
* <p>
|
||||
* <a href="http://en.wikipedia.org/wiki/Fork_(topology)">Fork</a>
|
||||
* {@link ForkingClusterInvoker}
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class ForkingCluster implements Cluster {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -35,11 +36,10 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 并行调用,只要一个成功即返回,通常用于实时性要求较高的操作,但需要浪费更多服务资源。
|
||||
* <p>
|
||||
* Invoke a specific number of invokers concurrently, usually used for demanding real-time operations, but need to waste more service resources.
|
||||
*
|
||||
* <a href="http://en.wikipedia.org/wiki/Fork_(topology)">Fork</a>
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class ForkingClusterInvoker<T> extends AbstractClusterInvoker<T> {
|
||||
|
||||
|
|
@ -60,9 +60,9 @@ public class ForkingClusterInvoker<T> extends AbstractClusterInvoker<T> {
|
|||
} else {
|
||||
selected = new ArrayList<Invoker<T>>();
|
||||
for (int i = 0; i < forks; i++) {
|
||||
//在invoker列表(排除selected)后,如果没有选够,则存在重复循环问题.见select实现.
|
||||
// TODO. Add some comment here, refer chinese version for more details.
|
||||
Invoker<T> invoker = select(loadbalance, invocation, invokers, selected);
|
||||
if (!selected.contains(invoker)) {//防止重复添加invoker
|
||||
if (!selected.contains(invoker)) {//Avoid add the same invoker several times.
|
||||
selected.add(invoker);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -21,7 +22,6 @@ import com.alibaba.dubbo.rpc.cluster.Cluster;
|
|||
import com.alibaba.dubbo.rpc.cluster.Directory;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*/
|
||||
public class MergeableCluster implements Cluster {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -46,7 +47,6 @@ import java.util.concurrent.Future;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class MergeableClusterInvoker<T> implements Invoker<T> {
|
||||
|
|
@ -64,7 +64,7 @@ public class MergeableClusterInvoker<T> implements Invoker<T> {
|
|||
List<Invoker<T>> invokers = directory.list(invocation);
|
||||
|
||||
String merger = getUrl().getMethodParameter(invocation.getMethodName(), Constants.MERGER_KEY);
|
||||
if (ConfigUtils.isEmpty(merger)) { // 如果方法不需要Merge,退化为只调一个Group
|
||||
if (ConfigUtils.isEmpty(merger)) { // If a method doesn't have a merger, only invoke one Group
|
||||
for (final Invoker<T> invoker : invokers) {
|
||||
if (invoker.isAvailable()) {
|
||||
return invoker.invoke(invocation);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -32,7 +33,6 @@ import com.alibaba.dubbo.rpc.support.MockInvoker;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author chao.liuc
|
||||
*/
|
||||
public class MockClusterInvoker<T> implements Invoker<T> {
|
||||
|
||||
|
|
@ -129,10 +129,10 @@ public class MockClusterInvoker<T> implements Invoker<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* 返回MockInvoker
|
||||
* 契约:
|
||||
* directory根据invocation中是否有Constants.INVOCATION_NEED_MOCK,来判断获取的是一个normal invoker 还是一个 mock invoker
|
||||
* 如果directorylist 返回多个mock invoker,只使用第一个invoker.
|
||||
* Return MockInvoker
|
||||
* Contract:
|
||||
* directory.list() will return a list of normal invokers if Constants.INVOCATION_NEED_MOCK is present in invocation, otherwise, a list of mock invokers will return.
|
||||
* if directory.list() returns more than one mock invoker, only one of them will be used.
|
||||
*
|
||||
* @param invocation
|
||||
* @return
|
||||
|
|
@ -141,9 +141,9 @@ public class MockClusterInvoker<T> implements Invoker<T> {
|
|||
List<Invoker<T>> invokers = null;
|
||||
//TODO generic invoker?
|
||||
if (invocation instanceof RpcInvocation) {
|
||||
//存在隐含契约(虽然在接口声明中增加描述,但扩展性会存在问题.同时放在attachement中的做法需要改进
|
||||
//Note the implicit contract (although the description is added to the interface declaration, but extensibility is a problem. The practice placed in the attachement needs to be improved)
|
||||
((RpcInvocation) invocation).setAttachment(Constants.INVOCATION_NEED_MOCK, Boolean.TRUE.toString());
|
||||
//directory根据invocation中attachment是否有Constants.INVOCATION_NEED_MOCK,来判断获取的是normal invokers or mock invokers
|
||||
//directory will return a list of normal invokers if Constants.INVOCATION_NEED_MOCK is present in invocation, otherwise, a list of mock invokers will return.
|
||||
try {
|
||||
invokers = directory.list(invocation);
|
||||
} catch (RpcException e) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -23,7 +24,6 @@ import com.alibaba.dubbo.rpc.cluster.Directory;
|
|||
/**
|
||||
* mock impl
|
||||
*
|
||||
* @author chao.liuc
|
||||
*/
|
||||
public class MockClusterWrapper implements Cluster {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -101,7 +102,7 @@ public class StickyTest {
|
|||
|
||||
@Test
|
||||
public void testMethodsSticky() {
|
||||
for (int i = 0; i < 100; i++) {//多次调用看两个方法是否都选在同一个invoker
|
||||
for (int i = 0; i < 100; i++) {//Two different methods should always use the same invoker every time.
|
||||
int count1 = testSticky("method1", true);
|
||||
int count2 = testSticky("method2", true);
|
||||
Assert.assertTrue(count1 == count2);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -24,7 +25,6 @@ import org.junit.Test;
|
|||
/**
|
||||
* OverrideConfiguratorTest
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class AbsentConfiguratorTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -25,7 +26,6 @@ import org.junit.Test;
|
|||
/**
|
||||
* OverrideConfiguratorTest
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class OverrideConfiguratorTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -18,7 +19,6 @@ package com.alibaba.dubbo.rpc.cluster.filter;
|
|||
/**
|
||||
* MockService.java
|
||||
*
|
||||
* @author tony.chenl
|
||||
*/
|
||||
public class DemoServiceMock implements DemoService {
|
||||
public String sayHello(String name) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -18,7 +19,6 @@ package com.alibaba.dubbo.rpc.cluster.filter;
|
|||
/**
|
||||
* MockService.java
|
||||
*
|
||||
* @author tony.chenl
|
||||
*/
|
||||
public class MockService implements DemoService {
|
||||
public String sayHello(String name) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -38,7 +39,6 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||
/**
|
||||
* RoundRobinLoadBalanceTest
|
||||
*
|
||||
* @author liuchao
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public class LoadBalanceTest {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -25,7 +26,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*/
|
||||
public class ResultMergerTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -142,16 +143,16 @@ public class ConditionRouterTest {
|
|||
@Test
|
||||
public void testRoute_methodRoute() {
|
||||
Invocation invocation = new RpcInvocation("getFoo", new Class<?>[0], new Object[0]);
|
||||
// 有多个方法时,没法匹配
|
||||
// More than one methods, mismatch
|
||||
Router router = new ConditionRouterFactory().getRouter(getRouteUrl("methods=getFoo => host = 1.2.3.4"));
|
||||
boolean matchWhen = ((ConditionRouter) router).matchWhen(
|
||||
URL.valueOf("consumer://1.1.1.1/com.foo.BarService?methods=setFoo,getFoo,findFoo"), invocation);
|
||||
Assert.assertEquals(true, matchWhen);
|
||||
// 只有一个方法时,可以匹配
|
||||
// Exactly one method, match
|
||||
matchWhen = ((ConditionRouter) router).matchWhen(
|
||||
URL.valueOf("consumer://1.1.1.1/com.foo.BarService?methods=getFoo"), invocation);
|
||||
Assert.assertEquals(true, matchWhen);
|
||||
// 方法和其他参数一起,测试无影响
|
||||
// Method routing and Other condition routing can work together
|
||||
Router router2 = new ConditionRouterFactory()
|
||||
.getRouter(getRouteUrl("methods=getFoo & host!=1.1.1.1 => host = 1.2.3.4"));
|
||||
matchWhen = ((ConditionRouter) router2).matchWhen(
|
||||
|
|
@ -163,7 +164,7 @@ public class ConditionRouterTest {
|
|||
matchWhen = ((ConditionRouter) router3).matchWhen(
|
||||
URL.valueOf("consumer://1.1.1.1/com.foo.BarService?methods=getFoo"), invocation);
|
||||
Assert.assertEquals(true, matchWhen);
|
||||
// filter过滤条件测试
|
||||
// Test filter condition
|
||||
List<Invoker<String>> invokers = new ArrayList<Invoker<String>>();
|
||||
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
||||
Invoker<String> invoker2 = new MockInvoker<String>(URL.valueOf("dubbo://" + NetUtils.getLocalHost()
|
||||
|
|
@ -187,7 +188,7 @@ public class ConditionRouterTest {
|
|||
List<Invoker<String>> fileredInvokers2 = router5.route(invokers,
|
||||
URL.valueOf("consumer://" + NetUtils.getLocalHost() + "/com.foo.BarService"), invocation);
|
||||
Assert.assertEquals(3, fileredInvokers2.size());
|
||||
// 调用不存在的方法时
|
||||
// Request a non-exists method
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -42,7 +43,6 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author chao.liuc
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FileRouterEngineTest {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -47,7 +48,6 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||
/**
|
||||
* AbstractClusterInvokerTest
|
||||
*
|
||||
* @author chao.liuc
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class AbstractClusterInvokerTest {
|
||||
|
|
@ -198,7 +198,7 @@ public class AbstractClusterInvokerTest {
|
|||
LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME);
|
||||
initlistsize5();
|
||||
{
|
||||
//边界测试.
|
||||
//Boundary condition test .
|
||||
selectedInvokers.clear();
|
||||
selectedInvokers.add(invoker2);
|
||||
selectedInvokers.add(invoker3);
|
||||
|
|
@ -208,7 +208,7 @@ public class AbstractClusterInvokerTest {
|
|||
Assert.assertSame(invoker1, sinvoker);
|
||||
}
|
||||
{
|
||||
//边界测试.
|
||||
//Boundary condition test .
|
||||
selectedInvokers.clear();
|
||||
selectedInvokers.add(invoker1);
|
||||
selectedInvokers.add(invoker3);
|
||||
|
|
@ -218,7 +218,7 @@ public class AbstractClusterInvokerTest {
|
|||
Assert.assertSame(invoker2, sinvoker);
|
||||
}
|
||||
{
|
||||
//边界测试.
|
||||
//Boundary condition test .
|
||||
selectedInvokers.clear();
|
||||
selectedInvokers.add(invoker1);
|
||||
selectedInvokers.add(invoker2);
|
||||
|
|
@ -228,7 +228,7 @@ public class AbstractClusterInvokerTest {
|
|||
Assert.assertSame(invoker3, sinvoker);
|
||||
}
|
||||
{
|
||||
//边界测试.
|
||||
//Boundary condition test .
|
||||
selectedInvokers.clear();
|
||||
selectedInvokers.add(invoker1);
|
||||
selectedInvokers.add(invoker2);
|
||||
|
|
@ -238,7 +238,7 @@ public class AbstractClusterInvokerTest {
|
|||
Assert.assertSame(invoker5, sinvoker);
|
||||
}
|
||||
{
|
||||
//边界测试.
|
||||
//Boundary condition test .
|
||||
selectedInvokers.clear();
|
||||
selectedInvokers.add(invoker1);
|
||||
selectedInvokers.add(invoker2);
|
||||
|
|
@ -257,7 +257,7 @@ public class AbstractClusterInvokerTest {
|
|||
LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME);
|
||||
initlistsize5();
|
||||
{
|
||||
//边界测试.
|
||||
//Boundary condition test .
|
||||
selectedInvokers.clear();
|
||||
selectedInvokers.add(invoker1);
|
||||
selectedInvokers.add(invoker2);
|
||||
|
|
@ -267,7 +267,7 @@ public class AbstractClusterInvokerTest {
|
|||
Assert.assertTrue(sinvoker == invoker4);
|
||||
}
|
||||
{
|
||||
//边界测试.
|
||||
//Boundary condition test .
|
||||
selectedInvokers.clear();
|
||||
selectedInvokers.add(invoker2);
|
||||
selectedInvokers.add(invoker3);
|
||||
|
|
@ -277,7 +277,7 @@ public class AbstractClusterInvokerTest {
|
|||
Assert.assertTrue(sinvoker == invoker2 || sinvoker == invoker4);
|
||||
}
|
||||
{
|
||||
//边界测试.
|
||||
//Boundary condition test .
|
||||
for (int i = 0; i < 100; i++) {
|
||||
selectedInvokers.clear();
|
||||
Invoker sinvoker = cluster.select(lb, invocation, invokers, selectedInvokers);
|
||||
|
|
@ -285,7 +285,7 @@ public class AbstractClusterInvokerTest {
|
|||
}
|
||||
}
|
||||
{
|
||||
//边界测试.
|
||||
//Boundary condition test .
|
||||
for (int i = 0; i < 100; i++) {
|
||||
selectedInvokers.clear();
|
||||
selectedInvokers.add(invoker1);
|
||||
|
|
@ -296,7 +296,7 @@ public class AbstractClusterInvokerTest {
|
|||
}
|
||||
}
|
||||
{
|
||||
//边界测试.
|
||||
//Boundary condition test .
|
||||
for (int i = 0; i < 100; i++) {
|
||||
selectedInvokers.clear();
|
||||
selectedInvokers.add(invoker1);
|
||||
|
|
@ -361,7 +361,7 @@ public class AbstractClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试均衡.
|
||||
* Test balance.
|
||||
*/
|
||||
@Test
|
||||
public void testSelectBalance() {
|
||||
|
|
@ -394,7 +394,7 @@ public class AbstractClusterInvokerTest {
|
|||
|
||||
private void initlistsize5() {
|
||||
invokers.clear();
|
||||
selectedInvokers.clear();//需要清除,之前的测试中会主动将正确的invoker2放入其中.
|
||||
selectedInvokers.clear();//Clear first, previous test case will make sure that the right invoker2 will be used.
|
||||
invokers.add(invoker1);
|
||||
invokers.add(invoker2);
|
||||
invokers.add(invoker3);
|
||||
|
|
@ -451,7 +451,7 @@ public class AbstractClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试mock invoker选择是否正常
|
||||
* Test mock invoker selector works as expected
|
||||
*/
|
||||
@Test
|
||||
public void testMockedInvokerSelect() {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
/*
|
||||
* Copyright 1999-2012 Alibaba Group.
|
||||
* 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
|
||||
*
|
||||
* Licensed 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
|
||||
* 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,
|
||||
|
|
@ -22,7 +23,6 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*/
|
||||
public class ClusterUtilsTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -39,7 +40,6 @@ import static org.junit.Assert.assertTrue;
|
|||
/**
|
||||
* FailfastClusterInvokerTest
|
||||
*
|
||||
* @author tony.chenl
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FailSafeClusterInvokerTest {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -38,7 +39,6 @@ import static org.junit.Assert.assertEquals;
|
|||
/**
|
||||
* FailbackClusterInvokerTest
|
||||
*
|
||||
* @author tony.chenl
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FailbackClusterInvokerTest {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -39,7 +40,6 @@ import static org.junit.Assert.fail;
|
|||
/**
|
||||
* FailfastClusterInvokerTest
|
||||
*
|
||||
* @author liuchao
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FailfastClusterInvokerTest {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -43,7 +44,6 @@ import static org.junit.Assert.fail;
|
|||
/**
|
||||
* FailoverClusterInvokerTest
|
||||
*
|
||||
* @author liuchao
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FailoverClusterInvokerTest {
|
||||
|
|
@ -177,7 +177,8 @@ public class FailoverClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试在调用重试过程中,directory列表变更,invoke重试时重新进行list选择
|
||||
* When invokers in directory changes after a failed request but just before a retry effort,
|
||||
* then we should reselect from the latest invokers before retry.
|
||||
*/
|
||||
@Test
|
||||
public void testInvokerDestoryAndReList() {
|
||||
|
|
@ -195,7 +196,7 @@ public class FailoverClusterInvokerTest {
|
|||
|
||||
Callable<Object> callable = new Callable<Object>() {
|
||||
public Object call() throws Exception {
|
||||
//模拟invoker全部被destroy掉
|
||||
//Simulation: all invokers are destroyed
|
||||
for (Invoker<Demo> invoker : invokers) {
|
||||
invoker.destroy();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -37,7 +38,6 @@ import static org.junit.Assert.assertFalse;
|
|||
/**
|
||||
* ForkingClusterInvokerTest
|
||||
*
|
||||
* @author tony.chenl
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ForkingClusterInvokerTest {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -22,7 +23,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*/
|
||||
public class Menu {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -18,7 +19,6 @@ package com.alibaba.dubbo.rpc.cluster.support;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*/
|
||||
public interface MenuService {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
|
|
@ -40,7 +41,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
*/
|
||||
public class MergeableClusterInvokerTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* 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 com.alibaba.dubbo.rpc.cluster.support.wrapper;
|
||||
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
|
|
@ -34,7 +50,7 @@ public class MockClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试mock策略是否正常-fail-mock
|
||||
* Test if mock policy works fine: fail-mock
|
||||
*/
|
||||
@Test
|
||||
public void testMockInvokerInvoke_normal() {
|
||||
|
|
@ -48,13 +64,13 @@ public class MockClusterInvokerTest {
|
|||
Invoker<IHelloService> mInvoker1 = protocol.refer(IHelloService.class, mockUrl);
|
||||
invokers.add(mInvoker1);
|
||||
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("something", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("sayHello");
|
||||
ret = cluster.invoke(invocation);
|
||||
|
|
@ -62,7 +78,7 @@ public class MockClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试mock策略是否正常-fail-mock
|
||||
* Test if mock policy works fine: fail-mock
|
||||
*/
|
||||
@Test
|
||||
public void testMockInvokerInvoke_failmock() {
|
||||
|
|
@ -77,19 +93,19 @@ public class MockClusterInvokerTest {
|
|||
Invoker<IHelloService> mInvoker1 = protocol.refer(IHelloService.class, mockUrl);
|
||||
invokers.add(mInvoker1);
|
||||
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("aa", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething2");
|
||||
ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals(null, ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("sayHello");
|
||||
ret = cluster.invoke(invocation);
|
||||
|
|
@ -98,7 +114,7 @@ public class MockClusterInvokerTest {
|
|||
|
||||
|
||||
/**
|
||||
* 测试mock策略是否正常-force-mork
|
||||
* Test if mock policy works fine: force-mock
|
||||
*/
|
||||
@Test
|
||||
public void testMockInvokerInvoke_forcemock() {
|
||||
|
|
@ -113,19 +129,19 @@ public class MockClusterInvokerTest {
|
|||
Invoker<IHelloService> mInvoker1 = protocol.refer(IHelloService.class, mockUrl);
|
||||
invokers.add(mInvoker1);
|
||||
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("aa", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething2");
|
||||
ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals(null, ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("sayHello");
|
||||
ret = cluster.invoke(invocation);
|
||||
|
|
@ -152,7 +168,7 @@ public class MockClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试mock策略是否正常-fail-mock
|
||||
* Test if mock policy works fine: fail-mock
|
||||
*/
|
||||
@Test
|
||||
public void testMockInvokerFromOverride_Invoke_Fock_someMethods() {
|
||||
|
|
@ -160,25 +176,25 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getSomething.mock", "fail:return x")
|
||||
.addParameter("getSomething2.mock", "force:return y");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("something", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething2");
|
||||
ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("y", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething3");
|
||||
ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("something3", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("sayHello");
|
||||
ret = cluster.invoke(invocation);
|
||||
|
|
@ -186,7 +202,7 @@ public class MockClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试mock策略是否正常-fail-mock
|
||||
* Test if mock policy works fine: fail-mock
|
||||
*/
|
||||
@Test
|
||||
public void testMockInvokerFromOverride_Invoke_Fock_WithOutDefault() {
|
||||
|
|
@ -195,19 +211,19 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getSomething2.mock", "force:return y")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("x", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething2");
|
||||
ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("y", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething3");
|
||||
try {
|
||||
|
|
@ -219,7 +235,7 @@ public class MockClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试mock策略是否正常-fail-mock
|
||||
* Test if mock policy works fine: fail-mock
|
||||
*/
|
||||
@Test
|
||||
public void testMockInvokerFromOverride_Invoke_Fock_WithDefault() {
|
||||
|
|
@ -229,25 +245,25 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getSomething2.mock", "force:return y")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("x", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething2");
|
||||
ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("y", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething3");
|
||||
ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals(null, ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("sayHello");
|
||||
ret = cluster.invoke(invocation);
|
||||
|
|
@ -255,7 +271,7 @@ public class MockClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试mock策略是否正常-fail-mock
|
||||
* Test if mock policy works fine: fail-mock
|
||||
*/
|
||||
@Test
|
||||
public void testMockInvokerFromOverride_Invoke_Fock_WithFailDefault() {
|
||||
|
|
@ -265,25 +281,25 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getSomething2.mock", "force:return y")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("x", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething2");
|
||||
ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("y", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
// If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething3");
|
||||
ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("z", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
//If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("sayHello");
|
||||
ret = cluster.invoke(invocation);
|
||||
|
|
@ -291,7 +307,7 @@ public class MockClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试mock策略是否正常-fail-mock
|
||||
* Test if mock policy works fine: fail-mock
|
||||
*/
|
||||
@Test
|
||||
public void testMockInvokerFromOverride_Invoke_Fock_WithForceDefault() {
|
||||
|
|
@ -301,25 +317,25 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getSomething2.mock", "force:return y")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("x", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
//If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething2");
|
||||
ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("y", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
//If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething3");
|
||||
ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("z", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
//If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("sayHello");
|
||||
ret = cluster.invoke(invocation);
|
||||
|
|
@ -327,7 +343,7 @@ public class MockClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试mock策略是否正常-fail-mock
|
||||
* Test if mock policy works fine: fail-mock
|
||||
*/
|
||||
@Test
|
||||
public void testMockInvokerFromOverride_Invoke_Fock_Default() {
|
||||
|
|
@ -335,20 +351,20 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("mock", "fail:return x")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("x", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
//If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething2");
|
||||
ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("x", ret.getValue());
|
||||
|
||||
//如d
|
||||
//如果没有配置mock,则直接返回null
|
||||
//If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("sayHello");
|
||||
ret = cluster.invoke(invocation);
|
||||
|
|
@ -356,7 +372,7 @@ public class MockClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试mock策略是否正常-fail-mock
|
||||
* Test if mock policy works fine: fail-mock
|
||||
*/
|
||||
@Test
|
||||
public void testMockInvokerFromOverride_Invoke_checkCompatible_return() {
|
||||
|
|
@ -364,13 +380,13 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getSomething.mock", "return x")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
Assert.assertEquals("x", ret.getValue());
|
||||
|
||||
//如果没有配置mock,则直接返回null
|
||||
//If no mock was configured, return null directly
|
||||
invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething3");
|
||||
try {
|
||||
|
|
@ -382,7 +398,7 @@ public class MockClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试mock策略是否正常-fail-mock
|
||||
* Test if mock policy works fine: fail-mock
|
||||
*/
|
||||
@Test
|
||||
public void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock() {
|
||||
|
|
@ -390,7 +406,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("mock", "true")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
|
|
@ -398,7 +414,7 @@ public class MockClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试mock策略是否正常-fail-mock
|
||||
* Test if mock policy works fine: fail-mock
|
||||
*/
|
||||
@Test
|
||||
public void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock2() {
|
||||
|
|
@ -406,7 +422,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("mock", "fail")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
|
|
@ -414,14 +430,14 @@ public class MockClusterInvokerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 测试mock策略是否正常-fail-mock
|
||||
* Test if mock policy works fine: fail-mock
|
||||
*/
|
||||
@Test
|
||||
public void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock3() {
|
||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||
.addParameter("mock", "force");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
|
|
@ -434,7 +450,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getSomething.mock", "force:return 1688")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getSomething");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
|
|
@ -448,7 +464,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getInt1.mock", "force:return 1688")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getInt1");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
|
|
@ -462,7 +478,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getBoolean1.mock", "force:return true")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getBoolean1");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
|
|
@ -476,7 +492,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getBoolean2.mock", "force:return true")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getBoolean2");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
|
|
@ -490,7 +506,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getListString.mock", "force:return empty")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getListString");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
|
|
@ -504,7 +520,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getListString.mock", "force:return [\"hi\",\"hi2\"]")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getListString");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
|
|
@ -520,7 +536,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getUsers.mock", "force:return empty")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getUsers");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
|
|
@ -534,7 +550,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getUsers.mock", "force:return [{id:1, name:\"hi1\"}, {id:2, name:\"hi2\"}]")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getUsers");
|
||||
Result ret = cluster.invoke(invocation);
|
||||
|
|
@ -550,7 +566,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getUsers.mock", "force:return [{id:x, name:\"hi1\"}]")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getUsers");
|
||||
try {
|
||||
|
|
@ -565,7 +581,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getBoolean2.mock", "force:throw ")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getBoolean2");
|
||||
try {
|
||||
|
|
@ -582,7 +598,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getBoolean2.mock", "force:throw com.alibaba.dubbo.rpc.cluster.support.wrapper.MyMockException")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getBoolean2");
|
||||
try {
|
||||
|
|
@ -599,7 +615,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("getBoolean2.mock", "force:throw java.lang.RuntimeException2")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getBoolean2");
|
||||
try {
|
||||
|
|
@ -616,7 +632,7 @@ public class MockClusterInvokerTest {
|
|||
.addParameter("mock", "false")
|
||||
.addParameter("invoke_return_error", "true");
|
||||
Invoker<IHelloService> cluster = getClusterInvoker(url);
|
||||
//方法配置了mock
|
||||
//Configured with mock
|
||||
RpcInvocation invocation = new RpcInvocation();
|
||||
invocation.setMethodName("getBoolean2");
|
||||
try {
|
||||
|
|
@ -630,6 +646,7 @@ public class MockClusterInvokerTest {
|
|||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private Invoker<IHelloService> getClusterInvoker(URL url) {
|
||||
//javasssit方式对方法参数类型判断严格,如果invocation数据设置不全,调用会失败.
|
||||
// As `javassist` have a strict restriction of argument types, request will fail if Invocation do not contains complete parameter type information
|
||||
final URL durl = url.addParameter("proxy", "jdk");
|
||||
invokers.clear();
|
||||
ProxyFactory proxy = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getExtension("jdk");
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* 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 com.alibaba.dubbo.rpc.cluster.support.wrapper;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
- Copyright 1999-2011 Alibaba Group.
|
||||
-
|
||||
- Licensed 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
|
||||
-
|
||||
- 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.
|
||||
|
|
|
|||
Loading…
Reference in New Issue