From e5cc277f0accacf4084403ae4802906118788a28 Mon Sep 17 00:00:00 2001 From: leitao <1225214744@qq.com> Date: Mon, 17 Dec 2018 14:14:16 +0800 Subject: [PATCH] Remove duplicate class in sentinel-core (#309) ClusterTokenClient.java,TokenClientProvider.java in package `com.alibaba.csp.sentinel.cluster` --- .../sentinel/cluster/ClusterTokenClient.java | 32 ---------- .../sentinel/cluster/TokenClientProvider.java | 61 ------------------- 2 files changed, 93 deletions(-) delete mode 100644 sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/ClusterTokenClient.java delete mode 100644 sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/TokenClientProvider.java diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/ClusterTokenClient.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/ClusterTokenClient.java deleted file mode 100644 index 6a230c07..00000000 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/ClusterTokenClient.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 1999-2018 Alibaba Group Holding Ltd. - * - * 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.csp.sentinel.cluster; - -/** - * Token client interface for distributed flow control. - * - * @author Eric Zhao - * @since 1.4.0 - */ -public interface ClusterTokenClient extends TokenService { - - /** - * Get descriptor of current token server. - * - * @return current token server - */ - TokenServerDescriptor currentServer(); -} \ No newline at end of file diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/TokenClientProvider.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/TokenClientProvider.java deleted file mode 100644 index 592046c9..00000000 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/TokenClientProvider.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 1999-2018 Alibaba Group Holding Ltd. - * - * 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.csp.sentinel.cluster; - -import java.util.ArrayList; -import java.util.List; -import java.util.ServiceLoader; - -import com.alibaba.csp.sentinel.log.RecordLog; - -/** - * Provider for a universal {@link ClusterTokenClient} instance. - * - * @author Eric Zhao - * @since 1.4.0 - */ -public final class TokenClientProvider { - - private static ClusterTokenClient client = null; - - private static final ServiceLoader LOADER = ServiceLoader.load(ClusterTokenClient.class); - - static { - // Not strictly thread-safe, but it's OK since it will be resolved only once. - resolveTokenClientInstance(); - } - - public static ClusterTokenClient getClient() { - return client; - } - - private static void resolveTokenClientInstance() { - List clients = new ArrayList(); - for (ClusterTokenClient client : LOADER) { - clients.add(client); - } - - if (!clients.isEmpty()) { - // Get first. - client = clients.get(0); - RecordLog.info("[TokenClientProvider] Token client resolved: " + client.getClass().getCanonicalName()); - } else { - RecordLog.warn("[TokenClientProvider] No existing token client, resolve failed"); - } - } - - private TokenClientProvider() {} -}