Java Code Examples for com.alibaba.csp.sentinel.cluster.server.config.ClusterServerConfigManager#loadServerNamespaceSet()
The following examples show how to use
com.alibaba.csp.sentinel.cluster.server.config.ClusterServerConfigManager#loadServerNamespaceSet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModifyServerNamespaceSetHandler.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 6 votes |
@Override public CommandResponse<String> handle(CommandRequest request) { String data = request.getParam("data"); if (StringUtil.isBlank(data)) { return CommandResponse.ofFailure(new IllegalArgumentException("empty data")); } try { data = URLDecoder.decode(data, "utf-8"); RecordLog.info("[ModifyServerNamespaceSetHandler] Receiving cluster server namespace set: " + data); Set<String> set = JSON.parseObject(data, new TypeReference<Set<String>>() {}); ClusterServerConfigManager.loadServerNamespaceSet(set); return CommandResponse.ofSuccess("success"); } catch (Exception e) { RecordLog.warn("[ModifyServerNamespaceSetHandler] Decode cluster server namespace set error", e); return CommandResponse.ofFailure(e, "decode client cluster config error"); } }
Example 2
Source File: ModifyServerNamespaceSetHandler.java From Sentinel with Apache License 2.0 | 6 votes |
@Override public CommandResponse<String> handle(CommandRequest request) { String data = request.getParam("data"); if (StringUtil.isBlank(data)) { return CommandResponse.ofFailure(new IllegalArgumentException("empty data")); } try { data = URLDecoder.decode(data, "utf-8"); RecordLog.info("[ModifyServerNamespaceSetHandler] Receiving cluster server namespace set: " + data); Set<String> set = JSON.parseObject(data, new TypeReference<Set<String>>() {}); ClusterServerConfigManager.loadServerNamespaceSet(set); return CommandResponse.ofSuccess("success"); } catch (Exception e) { RecordLog.warn("[ModifyServerNamespaceSetHandler] Decode cluster server namespace set error", e); return CommandResponse.ofFailure(e, "decode client cluster config error"); } }
Example 3
Source File: ClusterServerDemo.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { // Not embedded mode by default (alone mode). ClusterTokenServer tokenServer = new SentinelDefaultTokenServer(); // A sample for manually load config for cluster server. // It's recommended to use dynamic data source to cluster manage config and rules. // See the sample in DemoClusterServerInitFunc for detail. ClusterServerConfigManager.loadGlobalTransportConfig(new ServerTransportConfig() .setIdleSeconds(600) .setPort(11111)); ClusterServerConfigManager.loadServerNamespaceSet(Collections.singleton(DemoConstants.APP_NAME)); // Start the server. tokenServer.start(); }
Example 4
Source File: SentinelDefaultTokenServer.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 5 votes |
private void handleEmbeddedStart() { String namespace = ConfigSupplierRegistry.getNamespaceSupplier().get(); if (StringUtil.isNotEmpty(namespace)) { // Mark server global mode as embedded. ClusterServerConfigManager.setEmbedded(true); if (!ClusterServerConfigManager.getNamespaceSet().contains(namespace)) { Set<String> namespaceSet = new HashSet<>(ClusterServerConfigManager.getNamespaceSet()); namespaceSet.add(namespace); ClusterServerConfigManager.loadServerNamespaceSet(namespaceSet); } // Register self to connection group. ConnectionManager.addConnection(namespace, HostNameUtil.getIp()); } }
Example 5
Source File: ClusterServer.java From sentinel-tutorial with Apache License 2.0 | 5 votes |
/** * 加载namespace的集合以及ServerTransportConfig * 最好还要再为他们每个都注册一个SentinelProperty,这样的话可以动态的修改这些配置项 */ private void loadServerConfig(){ // 加载namespace ClusterServerConfigManager.loadServerNamespaceSet(Collections.singleton(APP_NAME)); // 加载ServerTransportConfig ClusterServerConfigManager.loadGlobalTransportConfig(new ServerTransportConfig() .setIdleSeconds(600) .setPort(CLUSTER_SERVER_PORT)); }
Example 6
Source File: ClusterServerDemo.java From Sentinel with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { // Not embedded mode by default (alone mode). ClusterTokenServer tokenServer = new SentinelDefaultTokenServer(); // A sample for manually load config for cluster server. // It's recommended to use dynamic data source to cluster manage config and rules. // See the sample in DemoClusterServerInitFunc for detail. ClusterServerConfigManager.loadGlobalTransportConfig(new ServerTransportConfig() .setIdleSeconds(600) .setPort(11111)); ClusterServerConfigManager.loadServerNamespaceSet(Collections.singleton(DemoConstants.APP_NAME)); // Start the server. tokenServer.start(); }
Example 7
Source File: SentinelDefaultTokenServer.java From Sentinel with Apache License 2.0 | 5 votes |
private void handleEmbeddedStart() { String namespace = ConfigSupplierRegistry.getNamespaceSupplier().get(); if (StringUtil.isNotEmpty(namespace)) { // Mark server global mode as embedded. ClusterServerConfigManager.setEmbedded(true); if (!ClusterServerConfigManager.getNamespaceSet().contains(namespace)) { Set<String> namespaceSet = new HashSet<>(ClusterServerConfigManager.getNamespaceSet()); namespaceSet.add(namespace); ClusterServerConfigManager.loadServerNamespaceSet(namespaceSet); } // Register self to connection group. ConnectionManager.addConnection(namespace, HostNameUtil.getIp()); } }