1616
1717package com .weibo .api .motan .config ;
1818
19- import java .util .ArrayList ;
20- import java .util .Collections ;
21- import java .util .HashMap ;
22- import java .util .List ;
23- import java .util .Map ;
24- import java .util .Map .Entry ;
25- import java .util .Set ;
26- import java .util .concurrent .atomic .AtomicBoolean ;
27-
28- import org .apache .commons .lang3 .StringUtils ;
29-
3019import com .weibo .api .motan .cluster .Cluster ;
3120import com .weibo .api .motan .cluster .group .ClusterGroup ;
3221import com .weibo .api .motan .cluster .group .DefaultClusterGroup ;
4332import com .weibo .api .motan .rpc .Caller ;
4433import com .weibo .api .motan .rpc .URL ;
4534import com .weibo .api .motan .runtime .GlobalRuntime ;
46- import com .weibo .api .motan .util .CollectionUtil ;
47- import com . weibo . api . motan . util . LoggerUtil ;
48- import com . weibo . api . motan . util . MotanGlobalConfigUtil ;
49- import com . weibo . api . motan . util .NetUtils ;
50- import com . weibo . api . motan . util .StringTools ;
51- import com . weibo . api . motan . util . UrlUtils ;
35+ import com .weibo .api .motan .util .* ;
36+ import org . apache . commons . lang3 . StringUtils ;
37+
38+ import java . util .* ;
39+ import java . util .Map . Entry ;
40+ import java . util . concurrent . atomic . AtomicBoolean ;
5241
5342/**
5443 * Referer config.
5847 */
5948
6049public class RefererConfig <T > extends AbstractRefererConfig {
50+ private static final ConcurrentHashSet <String > NONE_SANDBOX_PROTOCOL_SET = new ConcurrentHashSet <>(); // The set of protocols that do not support sandbox grouping.
51+
52+ static {
53+ NONE_SANDBOX_PROTOCOL_SET .add (MotanConstants .PROTOCOL_INJVM );
54+ NONE_SANDBOX_PROTOCOL_SET .add ("memcache" );
55+ NONE_SANDBOX_PROTOCOL_SET .add ("memcacheq" );
56+ NONE_SANDBOX_PROTOCOL_SET .add ("redis" );
57+ }
6158
6259 private static final long serialVersionUID = -2299754608229467887L ;
6360
@@ -195,7 +192,7 @@ private ClusterGroup<T> createClusterGroup(ConfigHandler configHandler, URL refU
195192 Cluster <T > masterCluster = createInnerCluster (configHandler , refUrl , MASTER_CLUSTER_KEY );
196193 DefaultClusterGroup <T > clusterGroup = new DefaultClusterGroup <T >(masterCluster );
197194 // try to create sandbox, backup clusters if not injvm protocol
198- if (!MotanConstants . PROTOCOL_INJVM . equals (refUrl .getProtocol ())) {
195+ if (!NONE_SANDBOX_PROTOCOL_SET . contains (refUrl .getProtocol ())) {
199196 try {
200197 String sandboxGroups = refUrl .getParameter (URLParamType .sandboxGroups .getName (), DEFAULT_SANDBOX_GROUPS );
201198 // set sandbox clusters
@@ -220,7 +217,7 @@ private ClusterGroup<T> createClusterGroup(ConfigHandler configHandler, URL refU
220217 }
221218
222219 private List <Cluster <T >> createMultiClusters (URL baseUrl , ConfigHandler configHandler , String groupString ,
223- String prefixKey , boolean lazyInit , boolean emptyNodeNotify ) {
220+ String prefixKey , boolean lazyInit , boolean emptyNodeNotify ) {
224221 String baseGroup = baseUrl .getGroup ();
225222 List <Cluster <T >> clusters = new ArrayList <>();
226223 Set <String > groupNames = StringTools .splitSet (groupString , MotanConstants .COMMA_SEPARATOR );
@@ -248,7 +245,7 @@ private List<Cluster<T>> createMultiClusters(URL baseUrl, ConfigHandler configHa
248245 return clusters ;
249246 }
250247
251- private Cluster <T > createInnerCluster (ConfigHandler configHandler , URL url , String prefixKey ){
248+ private Cluster <T > createInnerCluster (ConfigHandler configHandler , URL url , String prefixKey ) {
252249 ClusterSupport <T > clusterSupport = createClusterSupport (url , configHandler );
253250 Cluster <T > cluster = clusterSupport .getCluster ();
254251 String key = prefixKey + cluster .getUrl ().getIdentity ();
@@ -315,7 +312,7 @@ public synchronized void destroy() {
315312 clusterSupports .clear ();
316313 }
317314 if (clusterGroups != null ) {
318- for (Caller <T > clusterGroup : clusterGroups ) {
315+ for (Caller <T > clusterGroup : clusterGroups ) {
319316 try {
320317 clusterGroup .destroy ();
321318 } catch (Exception e ) {
0 commit comments