use of com.duangframework.core.exceptions.EmptyNullException in project duangframework by tcrct.
the class BootStrap method init.
private void init() {
// loadLibrary();
try {
bossGroup = EventLoopGroupFactory.builderBossLoopGroup();
workerGroup = EventLoopGroupFactory.builderWorkerLoopGroup();
allocator = new PooledByteBufAllocator(PlatformDependent.directBufferPreferred());
} catch (Exception e) {
throw new EmptyNullException(e.getMessage(), e);
}
}
use of com.duangframework.core.exceptions.EmptyNullException in project duangframework by tcrct.
the class AutoCreateDrlFile method createRuleInfo.
private static String createRuleInfo(List<RuleInfoModel> ruleInfoModelList) {
if (ToolsKit.isEmpty(ruleInfoModelList)) {
throw new EmptyNullException("ruleInfoModelList is null");
}
StringBuilder ruleInfoString = new StringBuilder();
for (Iterator<RuleInfoModel> it = ruleInfoModelList.iterator(); it.hasNext(); ) {
RuleInfoModel ruleInfoModel = it.next();
ruleInfoString.append("// ").append(ruleInfoModel.getRuleDesc()).append(ENTER_FIELD);
ruleInfoString.append("rule \"").append(ruleInfoModel.getRuleName()).append("\"").append(ENTER_FIELD).append(TAB_FIELD).append("no-loop ").append(ruleInfoModel.isNoLoop()).append(ENTER_FIELD).append(TAB_FIELD).append("salience ").append(ruleInfoModel.getSalience()).append(ENTER_FIELD).append(TAB_FIELD).append("when").append(ENTER_FIELD).append(TAB_FIELD).append(TAB_FIELD).append(createRuleWhen(ruleInfoModel.getWhenList())).append(ENTER_FIELD).append(TAB_FIELD).append("then").append(ENTER_FIELD).append(TAB_FIELD).append(TAB_FIELD).append(createRuleThen(ruleInfoModel)).append(ENTER_FIELD).append("end").append(ENTER_FIELD).append(ENTER_FIELD);
}
return ruleInfoString.toString();
}
use of com.duangframework.core.exceptions.EmptyNullException in project duangframework by tcrct.
the class ToolsKit method isAliyunHost.
/**
* 如果是10开头的IP,统统默认为阿里云的机器
* @return
*/
public static boolean isAliyunHost() {
String clientIp = IpUtils.getLocalHostIP(false).trim();
if (isEmpty(clientIp))
throw new EmptyNullException("getLocalHostIP Fail: Ip is Empty!");
String preFixIp = ConfigKit.duang().key("ip.prefix").defaultValue("10").asString();
return clientIp.startsWith(preFixIp) ? true : false;
}
use of com.duangframework.core.exceptions.EmptyNullException in project duangframework by tcrct.
the class Properties method getConfigurationByUrl.
/**
* 根据配置文件名取网络上的配置文件并返回Configuration对象
* @param propertiesName
* @return
* @throws Exception
*/
private static Configuration getConfigurationByUrl(String urlStr, String propertiesName) throws Exception {
String urlString = urlStr + propertiesName;
URL url = new URL(urlString);
if (ToolsKit.isEmpty(url)) {
throw new EmptyNullException("get properties fail: " + urlString);
}
return new PropertiesConfiguration(url);
}
use of com.duangframework.core.exceptions.EmptyNullException in project duangframework by tcrct.
the class JedisClusterPoolUtils method createJedisPool.
/**
* 建立连接池 真实环境,一般把配置参数缺抽取出来。
*/
private static void createJedisPool() {
try {
String[] ipArray = getClusterIps();
if (ToolsKit.isEmpty(ipArray)) {
throw new EmptyNullException("ipArray is null");
}
// 只给集群里一个实例就可以
Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
for (int i = 0; i < ipArray.length; i++) {
String[] items = ipArray[i].split(":");
jedisClusterNodes.add(new HostAndPort(items[0], Integer.parseInt(items[1])));
}
// 配置信息
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(10000);
config.setMaxIdle(500);
config.setMinIdle(100);
config.setMaxWaitMillis(5000);
config.setTestOnBorrow(true);
config.setTestOnReturn(true);
jedisCluster = new JedisCluster(jedisClusterNodes, config);
if (null != jedisCluster) {
logger.warn("Connent Redis Cluster: " + ToolsKit.toJsonString(jedisClusterNodes) + " is Success...");
}
} catch (Exception e) {
e.printStackTrace();
logger.info("初始化 redis 出错啦...");
}
}
Aggregations