Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DUBBO-3137]: step4 - remove ClusterConstants #4065

Merged
merged 1 commit into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Map;
import java.util.Optional;

import static org.apache.dubbo.common.constants.ClusterConstants.PRIORITY_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.PRIORITY_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_KEY;
import static org.apache.dubbo.common.constants.RegistryConstants.EMPTY_PROTOCOL;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster;

package org.apache.dubbo.common.constants;

public interface ClusterConstants {
/**
* key for router type, for e.g., "script"/"file", corresponding to ScriptRouterFactory.NAME, FileRouterFactory.NAME
*/
String ROUTER_KEY = "router";

public interface Constants {
String LOADBALANCE_KEY = "loadbalance";

String DEFAULT_LOADBALANCE = "random";
Expand Down Expand Up @@ -95,8 +89,6 @@ public interface ClusterConstants {

String RUNTIME_KEY = "runtime";

String TAG_KEY = "dubbo.tag";

String REMOTE_TIMESTAMP_KEY = "remote.timestamp";

String WARMUP_KEY = "warmup";
Expand All @@ -106,4 +98,6 @@ public interface ClusterConstants {
String CONFIG_VERSION_KEY = "configVersion";

String OVERRIDE_PROVIDERS_KEY = "providerAddresses";

String TAG_KEY = "dubbo.tag";
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import java.util.Map;
import java.util.Set;

import static org.apache.dubbo.common.constants.ClusterConstants.CONFIG_VERSION_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.OVERRIDE_PROVIDERS_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.CONFIG_VERSION_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.OVERRIDE_PROVIDERS_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_VALUE;
import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE;
import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.List;
import java.util.Map;

import static org.apache.dubbo.common.constants.ClusterConstants.OVERRIDE_PROVIDERS_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.OVERRIDE_PROVIDERS_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_VALUE;
import static org.apache.dubbo.common.constants.RegistryConstants.APP_DYNAMIC_CONFIGURATORS_CATEGORY;
import static org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_CONFIGURATORS_CATEGORY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

import java.util.List;

import static org.apache.dubbo.common.constants.ClusterConstants.DEFAULT_WARMUP;
import static org.apache.dubbo.common.constants.ClusterConstants.DEFAULT_WEIGHT;
import static org.apache.dubbo.common.constants.ClusterConstants.REMOTE_TIMESTAMP_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.WARMUP_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.WEIGHT_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.DEFAULT_WARMUP;
import static org.apache.dubbo.rpc.cluster.Constants.DEFAULT_WEIGHT;
import static org.apache.dubbo.rpc.cluster.Constants.REMOTE_TIMESTAMP_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.WARMUP_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.WEIGHT_KEY;

/**
* AbstractLoadBalance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.apache.dubbo.common.constants.ClusterConstants.ADDRESS_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.FORCE_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.PRIORITY_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.RULE_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.RUNTIME_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.ADDRESS_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.FORCE_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.PRIORITY_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.RULE_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.RUNTIME_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_KEY_PREFIX;
import static org.apache.dubbo.common.constants.CommonConstants.ENABLED_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import java.io.FileReader;
import java.io.IOException;

import static org.apache.dubbo.common.constants.ClusterConstants.ROUTER_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.RULE_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.RUNTIME_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.TYPE_KEY;
import static org.apache.dubbo.common.constants.RegistryConstants.ROUTER_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.RULE_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.RUNTIME_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.TYPE_KEY;

public class FileRouterFactory implements RouterFactory {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import java.util.ArrayList;
import java.util.List;

import static org.apache.dubbo.common.constants.ClusterConstants.INVOCATION_NEED_MOCK;
import static org.apache.dubbo.common.constants.ClusterConstants.MOCK_PROTOCOL;
import static org.apache.dubbo.rpc.cluster.Constants.INVOCATION_NEED_MOCK;
import static org.apache.dubbo.rpc.cluster.Constants.MOCK_PROTOCOL;

/**
* A specific Router designed to realize mock feature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

import static org.apache.dubbo.common.constants.ClusterConstants.DEFAULT_SCRIPT_TYPE_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.FORCE_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.PRIORITY_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.RULE_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.RUNTIME_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.TYPE_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.DEFAULT_SCRIPT_TYPE_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.FORCE_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.PRIORITY_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.RULE_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.RUNTIME_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.TYPE_KEY;

/**
* ScriptRouter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.apache.dubbo.rpc.cluster.router.tag;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.ClusterConstants;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
Expand All @@ -31,6 +30,7 @@
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcException;
import org.apache.dubbo.rpc.cluster.Constants;
import org.apache.dubbo.rpc.cluster.router.AbstractRouter;
import org.apache.dubbo.rpc.cluster.router.tag.model.TagRouterRule;
import org.apache.dubbo.rpc.cluster.router.tag.model.TagRuleParser;
Expand All @@ -40,7 +40,7 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;

import static org.apache.dubbo.common.constants.ClusterConstants.TAG_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.TAG_KEY;
import static org.apache.dubbo.common.constants.RpcConstants.FORCE_USE_TAG;

/**
Expand Down Expand Up @@ -97,8 +97,8 @@ public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation
}

List<Invoker<T>> result = invokers;
String tag = StringUtils.isEmpty(invocation.getAttachment(ClusterConstants.TAG_KEY)) ? url.getParameter(ClusterConstants.TAG_KEY) :
invocation.getAttachment(ClusterConstants.TAG_KEY);
String tag = StringUtils.isEmpty(invocation.getAttachment(Constants.TAG_KEY)) ? url.getParameter(Constants.TAG_KEY) :
invocation.getAttachment(Constants.TAG_KEY);

// if we are requesting for a Provider with a specific tag
if (StringUtils.isNotEmpty(tag)) {
Expand All @@ -113,7 +113,7 @@ public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation
} else {
// dynamic tag group doesn't have any item about the requested app OR it's null after filtered by
// dynamic tag group but force=false. check static tag
result = filterInvoker(invokers, invoker -> tag.equals(invoker.getUrl().getParameter(ClusterConstants.TAG_KEY)));
result = filterInvoker(invokers, invoker -> tag.equals(invoker.getUrl().getParameter(Constants.TAG_KEY)));
}
// If there's no tagged providers that can match the current tagged request. force.tag is set by default
// to false, which means it will invoke any providers without a tag unless it's explicitly disallowed.
Expand All @@ -124,7 +124,7 @@ public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation
else {
List<Invoker<T>> tmp = filterInvoker(invokers, invoker -> addressNotMatches(invoker.getUrl(),
tagRouterRuleCopy.getAddresses()));
return filterInvoker(tmp, invoker -> StringUtils.isEmpty(invoker.getUrl().getParameter(ClusterConstants.TAG_KEY)));
return filterInvoker(tmp, invoker -> StringUtils.isEmpty(invoker.getUrl().getParameter(Constants.TAG_KEY)));
}
} else {
// List<String> addresses = tagRouterRule.filter(providerApp);
Expand All @@ -140,7 +140,7 @@ public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation
// static tag group.
}
return filterInvoker(result, invoker -> {
String localTag = invoker.getUrl().getParameter(ClusterConstants.TAG_KEY);
String localTag = invoker.getUrl().getParameter(Constants.TAG_KEY);
return StringUtils.isEmpty(localTag) || !tagRouterRuleCopy.getTagNames().contains(localTag);
});
}
Expand All @@ -163,8 +163,8 @@ public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation
private <T> List<Invoker<T>> filterUsingStaticTag(List<Invoker<T>> invokers, URL url, Invocation invocation) {
List<Invoker<T>> result = invokers;
// Dynamic param
String tag = StringUtils.isEmpty(invocation.getAttachment(ClusterConstants.TAG_KEY)) ? url.getParameter(ClusterConstants.TAG_KEY) :
invocation.getAttachment(ClusterConstants.TAG_KEY);
String tag = StringUtils.isEmpty(invocation.getAttachment(Constants.TAG_KEY)) ? url.getParameter(Constants.TAG_KEY) :
invocation.getAttachment(Constants.TAG_KEY);
// Tag request
if (!StringUtils.isEmpty(tag)) {
result = filterInvoker(invokers, invoker -> tag.equals(invoker.getUrl().getParameter(TAG_KEY)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.apache.dubbo.common.constants.ClusterConstants.CLUSTER_AVAILABLE_CHECK_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.CLUSTER_STICKY_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.DEFAULT_CLUSTER_AVAILABLE_CHECK;
import static org.apache.dubbo.common.constants.ClusterConstants.DEFAULT_CLUSTER_STICKY;
import static org.apache.dubbo.common.constants.ClusterConstants.DEFAULT_LOADBALANCE;
import static org.apache.dubbo.common.constants.ClusterConstants.LOADBALANCE_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.CLUSTER_AVAILABLE_CHECK_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.CLUSTER_STICKY_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.DEFAULT_CLUSTER_AVAILABLE_CHECK;
import static org.apache.dubbo.rpc.cluster.Constants.DEFAULT_CLUSTER_STICKY;
import static org.apache.dubbo.rpc.cluster.Constants.DEFAULT_LOADBALANCE;
import static org.apache.dubbo.rpc.cluster.Constants.LOADBALANCE_KEY;

/**
* AbstractClusterInvoker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.HashMap;
import java.util.Map;

import static org.apache.dubbo.common.constants.ClusterConstants.TAG_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.TAG_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.ALIVE_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.CORE_THREADS_KEY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
import java.util.List;
import java.util.concurrent.TimeUnit;

import static org.apache.dubbo.common.constants.ClusterConstants.DEFAULT_FAILBACK_TIMES;
import static org.apache.dubbo.common.constants.ClusterConstants.RETRIES_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.DEFAULT_FAILBACK_TASKS;
import static org.apache.dubbo.common.constants.ClusterConstants.FAIL_BACK_TASKS_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.DEFAULT_FAILBACK_TIMES;
import static org.apache.dubbo.rpc.cluster.Constants.RETRIES_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.DEFAULT_FAILBACK_TASKS;
import static org.apache.dubbo.rpc.cluster.Constants.FAIL_BACK_TASKS_KEY;

/**
* When fails, record failure requests and schedule for retry on a regular interval.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
import java.util.List;
import java.util.Set;

import static org.apache.dubbo.common.constants.ClusterConstants.DEFAULT_RETRIES;
import static org.apache.dubbo.common.constants.ClusterConstants.RETRIES_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.DEFAULT_RETRIES;
import static org.apache.dubbo.rpc.cluster.Constants.RETRIES_KEY;

/**
* When invoke fails, log the initial error and retry other invokers (retry n times, which means at most n different invokers will be invoked)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

import static org.apache.dubbo.common.constants.ClusterConstants.DEFAULT_FORKS;
import static org.apache.dubbo.common.constants.ClusterConstants.FORKS_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.DEFAULT_FORKS;
import static org.apache.dubbo.rpc.cluster.Constants.FORKS_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT;
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import java.util.List;

import static org.apache.dubbo.common.constants.ClusterConstants.INVOCATION_NEED_MOCK;
import static org.apache.dubbo.rpc.cluster.Constants.INVOCATION_NEED_MOCK;
import static org.apache.dubbo.common.constants.RpcConstants.MOCK_KEY;

public class MockClusterInvoker<T> implements Invoker<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.ArrayList;
import java.util.List;

import static org.apache.dubbo.common.constants.ClusterConstants.CLUSTER_STICKY_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.CLUSTER_STICKY_KEY;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import java.io.InputStream;
import java.util.List;

import static org.apache.dubbo.common.constants.ClusterConstants.LOADBALANCE_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.OVERRIDE_PROVIDERS_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.WEIGHT_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.LOADBALANCE_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.OVERRIDE_PROVIDERS_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.WEIGHT_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.ArrayList;
import java.util.List;

import static org.apache.dubbo.common.constants.ClusterConstants.RULE_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.RULE_KEY;

/**
* StaticDirectory Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

import static org.apache.dubbo.common.constants.ClusterConstants.DEFAULT_WARMUP;
import static org.apache.dubbo.common.constants.ClusterConstants.DEFAULT_WEIGHT;
import static org.apache.dubbo.rpc.cluster.Constants.DEFAULT_WARMUP;
import static org.apache.dubbo.rpc.cluster.Constants.DEFAULT_WEIGHT;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import java.util.ArrayList;
import java.util.List;

import static org.apache.dubbo.common.constants.ClusterConstants.FORCE_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.RULE_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.FORCE_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.RULE_KEY;

public class ConditionRouterTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import java.util.Arrays;
import java.util.List;

import static org.apache.dubbo.common.constants.ClusterConstants.RUNTIME_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.RUNTIME_KEY;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.ArrayList;
import java.util.List;

import static org.apache.dubbo.common.constants.ClusterConstants.RULE_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.RULE_KEY;

public class ScriptRouterTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

import static org.apache.dubbo.common.constants.ClusterConstants.CLUSTER_AVAILABLE_CHECK_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.INVOCATION_NEED_MOCK;
import static org.apache.dubbo.rpc.cluster.Constants.CLUSTER_AVAILABLE_CHECK_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.INVOCATION_NEED_MOCK;
import static org.apache.dubbo.common.constants.ConfigConstants.REFER_KEY;
import static org.apache.dubbo.common.constants.MonitorConstants.MONITOR_KEY;
import static org.mockito.BDDMockito.given;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,8 @@ public interface RegistryConstants {
String SESSION_TIMEOUT_KEY = "session";

int DEFAULT_SESSION_TIMEOUT = 60 * 1000;
/**
* key for router type, for e.g., "script"/"file", corresponding to ScriptRouterFactory.NAME, FileRouterFactory.NAME
*/
String ROUTER_KEY = "router";
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package com.alibaba.dubbo.common;

import org.apache.dubbo.common.constants.ClusterConstants;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.constants.ConfigConstants;
import org.apache.dubbo.common.constants.FilterConstants;
Expand All @@ -27,6 +26,6 @@
import org.apache.dubbo.common.constants.RpcConstants;

@Deprecated
public class Constants implements ClusterConstants, CommonConstants, ConfigConstants, FilterConstants,
MonitorConstants, RegistryConstants, RemotingConstants, RpcConstants {
public class Constants implements CommonConstants, ConfigConstants, FilterConstants,
MonitorConstants, RegistryConstants, RemotingConstants, RpcConstants, org.apache.dubbo.rpc.cluster.Constants {
}
Loading