Java Code Examples for com.alibaba.csp.sentinel.util.AssertUtil#assertState()
The following examples show how to use
com.alibaba.csp.sentinel.util.AssertUtil#assertState() .
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: EurekaDataSource.java From Sentinel with Apache License 2.0 | 6 votes |
public EurekaDataSource(String appId, String instanceId, List<String> serviceUrls, String ruleKey, Converter<String, T> configParser, long refreshMs, int connectTimeoutMills, int readTimeoutMills) { super(configParser, refreshMs); AssertUtil.notNull(appId, "appId can't be null"); AssertUtil.notNull(instanceId, "instanceId can't be null"); AssertUtil.assertNotEmpty(serviceUrls, "serviceUrls can't be empty"); AssertUtil.notNull(ruleKey, "ruleKey can't be null"); AssertUtil.assertState(connectTimeoutMills > 0, "connectTimeoutMills must be greater than 0"); AssertUtil.assertState(readTimeoutMills > 0, "readTimeoutMills must be greater than 0"); this.appId = appId; this.instanceId = instanceId; this.serviceUrls = ensureEndWithSlash(serviceUrls); AssertUtil.assertNotEmpty(this.serviceUrls, "No available service url"); this.ruleKey = ruleKey; this.connectTimeoutMills = connectTimeoutMills; this.readTimeoutMills = readTimeoutMills; }
Example 2
Source File: RedisConnectionConfig.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 5 votes |
/** * Add a withRedisSentinel host/port to the existing builder. * * @param host the host name * @param port the port * @return the builder */ public RedisConnectionConfig.Builder withRedisSentinel(String host, int port) { AssertUtil.assertState(this.host == null, "Cannot use with Redis mode."); AssertUtil.notEmpty(host, "Host must not be empty"); AssertUtil.isTrue(isValidPort(port), String.format("Port out of range: %s", port)); redisSentinels.add(RedisHostAndPort.of(host, port)); return this; }
Example 3
Source File: RedisConnectionConfig.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 5 votes |
/** * Adds host information to the builder. Does only affect Redis URI, cannot be used with Sentinel connections. * * @param host the port * @return the builder */ public RedisConnectionConfig.Builder withHost(String host) { AssertUtil.assertState(this.redisSentinels.isEmpty(), "Sentinels are non-empty. Cannot use in Sentinel mode."); AssertUtil.notEmpty(host, "Host must not be empty"); this.host = host; return this; }
Example 4
Source File: RedisConnectionConfig.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 5 votes |
/** * Adds port information to the builder. Does only affect Redis URI, cannot be used with Sentinel connections. * * @param port the port * @return the builder */ public RedisConnectionConfig.Builder withPort(int port) { AssertUtil.assertState(this.host != null, "Host is null. Cannot use in Sentinel mode."); AssertUtil.isTrue(isValidPort(port), String.format("Port out of range: %s", port)); this.port = port; return this; }
Example 5
Source File: RedisConnectionConfig.java From Sentinel with Apache License 2.0 | 5 votes |
/** * Add a withRedisSentinel host/port to the existing builder. * * @param host the host name * @param port the port * @return the builder */ public RedisConnectionConfig.Builder withRedisSentinel(String host, int port) { AssertUtil.assertState(this.host == null, "Cannot use with Redis mode."); AssertUtil.notEmpty(host, "Host must not be empty"); AssertUtil.isTrue(isValidPort(port), String.format("Port out of range: %s", port)); redisSentinels.add(RedisHostAndPort.of(host, port)); return this; }
Example 6
Source File: RedisConnectionConfig.java From Sentinel with Apache License 2.0 | 5 votes |
/** * Adds host information to the builder. Does only affect Redis URI, cannot be used with Sentinel connections. * * @param host the port * @return the builder */ public RedisConnectionConfig.Builder withHost(String host) { AssertUtil.assertState(this.redisSentinels.isEmpty(), "Sentinels are non-empty. Cannot use in Sentinel mode."); AssertUtil.notEmpty(host, "Host must not be empty"); this.host = host; return this; }
Example 7
Source File: RedisConnectionConfig.java From Sentinel with Apache License 2.0 | 5 votes |
/** * Adds port information to the builder. Does only affect Redis URI, cannot be used with Sentinel connections. * * @param port the port * @return the builder */ public RedisConnectionConfig.Builder withPort(int port) { AssertUtil.assertState(this.host != null, "Host is null. Cannot use in Sentinel mode."); AssertUtil.isTrue(isValidPort(port), String.format("Port out of range: %s", port)); this.port = port; return this; }