/** * Apply new {@link ClusterClientConfig}, while the former config will be replaced. * * @param config new config to apply */ public static void applyNewConfig(ClusterClientConfig config) { clientConfigProperty.updateValue(config); }
public static void register2Property(SentinelProperty<Integer> property) { property.addListener(new SimplePropertyListener<Integer>() { @Override public void configUpdate(Integer value) { if (value != null) { updateSampleCount(value); } } }); }
@Override public SentinelProperty<List<ParamFlowRule>> apply(String namespace) { return new DynamicSentinelProperty<>(); } };
/** * Listen to the {@link SentinelProperty} for {@link SystemRule}s. The property is the source * of {@link SystemRule}s. System rules can also be set by {@link #loadRules(List)} directly. * * @param property the property to listen. */ public static void register2Property(SentinelProperty<List<SystemRule>> property) { synchronized (listener) { currentProperty.removeListener(listener); property.addListener(listener); currentProperty = property; } }
private static void removePropertyListener() { clientAssignProperty.removeListener(ASSIGN_PROPERTY_LISTENER); clientConfigProperty.removeListener(CONFIG_PROPERTY_LISTENER); }
@Override public boolean updateValue(T newValue) { if (isEqual(value, newValue)) { return false; } RecordLog.info("[DynamicSentinelProperty] Config will be updated to: " + newValue); value = newValue; for (PropertyListener<T> listener : listeners) { listener.configUpdate(newValue); } return true; }
@Override public void configLoad(T value) { configUpdate(value); } }
/** * Load provided server global statistic (flow) configuration to property in memory. * * @param config valid cluster server flow configuration for global */ public static void loadGlobalFlowConfig(ServerFlowConfig config) { globalFlowProperty.updateValue(config); }
public static void registerProperty(SentinelProperty<Integer> property) { synchronized (PROPERTY_LISTENER) { RecordLog.info("[ClusterStateManager] Registering new property to cluster state manager"); stateProperty.removeListener(PROPERTY_LISTENER); property.addListener(PROPERTY_LISTENER); stateProperty = property; } }
public static void register2Property(SentinelProperty<Integer> property) { property.addListener(new SimplePropertyListener<Integer>() { @Override public void configUpdate(Integer value) { if (value != null) { updateInterval(value); } } }); }
@Override public SentinelProperty<List<FlowRule>> apply(String namespace) { return new DynamicSentinelProperty<>(); } };
/** * Load {@link SystemRule}s, former rules will be replaced. * * @param rules new rules to load. */ public static void loadRules(List<SystemRule> rules) { currentProperty.updateValue(rules); }
/** * Apply given state to cluster mode. * * @param state valid state to apply */ public static void applyState(Integer state) { stateProperty.updateValue(state); }
/** * Load the authority rules to memory. * * @param rules list of authority rules */ public static void loadRules(List<AuthorityRule> rules) { currentProperty.updateValue(rules); }
/** * Load provided server namespace set to property in memory. * * @param namespaceSet valid namespace set */ public static void loadServerNamespaceSet(Set<String> namespaceSet) { namespaceSetProperty.updateValue(namespaceSet); }
/** * Load {@link FlowRule}s, former rules will be replaced. * * @param rules new rules to load. */ public static void loadRules(List<FlowRule> rules) { currentProperty.updateValue(rules); }
/** * Load provided server transport configuration to property in memory. * * @param config valid cluster server transport configuration */ public static void loadGlobalTransportConfig(ServerTransportConfig config) { transportConfigProperty.updateValue(config); }
public static void applyNewAssignConfig(ClusterClientAssignConfig clusterClientAssignConfig) { clientAssignProperty.updateValue(clusterClientAssignConfig); }
/** * Load parameter flow rules. Former rules will be replaced. * * @param rules new rules to load. */ public static void loadRules(List<ParamFlowRule> rules) { try { currentProperty.updateValue(rules); } catch (Throwable e) { RecordLog.info("[ParamFlowRuleManager] Failed to load rules", e); } }
/** * Load server flow config for a specific namespace. * * @param namespace a valid namespace * @param config valid flow config for the namespace */ public static void loadFlowConfig(String namespace, ServerFlowConfig config) { AssertUtil.notEmpty(namespace, "namespace cannot be empty"); // TODO: Support namespace-scope server flow config. globalFlowProperty.updateValue(config); }