Search in sources :

Example 6 with EmptyNullException

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);
    }
}
Also used : EmptyNullException(com.duangframework.core.exceptions.EmptyNullException) IOException(java.io.IOException) EmptyNullException(com.duangframework.core.exceptions.EmptyNullException) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator)

Example 7 with EmptyNullException

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();
}
Also used : RuleInfoModel(com.duangframework.rule.entity.generate.RuleInfoModel) EmptyNullException(com.duangframework.core.exceptions.EmptyNullException)

Example 8 with EmptyNullException

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;
}
Also used : EmptyNullException(com.duangframework.core.exceptions.EmptyNullException)

Example 9 with EmptyNullException

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);
}
Also used : EmptyNullException(com.duangframework.core.exceptions.EmptyNullException) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) URL(java.net.URL)

Example 10 with EmptyNullException

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 出错啦...");
    }
}
Also used : HostAndPort(redis.clients.jedis.HostAndPort) GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) EmptyNullException(com.duangframework.core.exceptions.EmptyNullException) JedisCluster(redis.clients.jedis.JedisCluster) IOException(java.io.IOException) EmptyNullException(com.duangframework.core.exceptions.EmptyNullException) HashSet(java.util.HashSet)

Aggregations

EmptyNullException (com.duangframework.core.exceptions.EmptyNullException)16 IOException (java.io.IOException)2 Method (java.lang.reflect.Method)2 Document (org.bson.Document)2 Bson (org.bson.conversions.Bson)2 Mapping (com.duangframework.core.annotation.mvc.Mapping)1 Service (com.duangframework.core.annotation.mvc.Service)1 Rpc (com.duangframework.core.annotation.rpc.Rpc)1 AsyncContext (com.duangframework.core.common.dto.http.request.AsyncContext)1 HttpRequest (com.duangframework.core.common.dto.http.request.HttpRequest)1 HttpResponse (com.duangframework.core.common.dto.http.response.HttpResponse)1 RpcException (com.duangframework.core.exceptions.RpcException)1 ServiceException (com.duangframework.core.exceptions.ServiceException)1 Action (com.duangframework.mvc.core.Action)1 RpcAction (com.duangframework.rpc.common.RpcAction)1 ParamItem (com.duangframework.rule.entity.ParamItem)1 RuleParam (com.duangframework.rule.entity.RuleParam)1 RuleResult (com.duangframework.rule.entity.RuleResult)1 RuleInfoModel (com.duangframework.rule.entity.generate.RuleInfoModel)1 BasicDBObject (com.mongodb.BasicDBObject)1