当前位置: 首页>>代码示例>>Java>>正文


Java MixAll.DEFAULT_CHARSET属性代码示例

本文整理汇总了Java中org.apache.rocketmq.common.MixAll.DEFAULT_CHARSET属性的典型用法代码示例。如果您正苦于以下问题:Java MixAll.DEFAULT_CHARSET属性的具体用法?Java MixAll.DEFAULT_CHARSET怎么用?Java MixAll.DEFAULT_CHARSET使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.rocketmq.common.MixAll的用法示例。


在下文中一共展示了MixAll.DEFAULT_CHARSET属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fetchClassFromRemoteHost

private void fetchClassFromRemoteHost() {
    Iterator<Entry<String, FilterClassInfo>> it = this.filterClassTable.entrySet().iterator();
    while (it.hasNext()) {
        try {
            Entry<String, FilterClassInfo> next = it.next();
            FilterClassInfo filterClassInfo = next.getValue();
            String[] topicAndGroup = next.getKey().split("@");
            String responseStr =
                this.filterClassFetchMethod.fetch(topicAndGroup[0], topicAndGroup[1],
                    filterClassInfo.getClassName());
            byte[] filterSourceBinary = responseStr.getBytes("UTF-8");
            int classCRC = UtilAll.crc32(responseStr.getBytes("UTF-8"));
            if (classCRC != filterClassInfo.getClassCRC()) {
                String javaSource = new String(filterSourceBinary, MixAll.DEFAULT_CHARSET);
                Class<?> newClass =
                    DynaCode.compileAndLoadClass(filterClassInfo.getClassName(), javaSource);
                Object newInstance = newClass.newInstance();
                filterClassInfo.setMessageFilter((MessageFilter) newInstance);
                filterClassInfo.setClassCRC(classCRC);

                log.info("fetch Remote class File OK, {} {}", next.getKey(),
                    filterClassInfo.getClassName());
            }
        } catch (Exception e) {
            log.error("fetchClassFromRemoteHost Exception", e);
        }
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:28,代码来源:FilterClassManager.java

示例2: updateBrokerConfig

private RemotingCommand updateBrokerConfig(ChannelHandlerContext ctx, RemotingCommand request) {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);

    log.info("updateBrokerConfig called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));

    byte[] body = request.getBody();
    if (body != null) {
        try {
            String bodyStr = new String(body, MixAll.DEFAULT_CHARSET);
            Properties properties = MixAll.string2Properties(bodyStr);
            if (properties != null) {
                log.info("updateBrokerConfig, new config: [{}] client: {} ", properties, ctx.channel().remoteAddress());
                this.brokerController.getConfiguration().update(properties);
                if (properties.containsKey("brokerPermission")) {
                    this.brokerController.registerBrokerAll(false, false);
                    this.brokerController.getTopicConfigManager().getDataVersion().nextVersion();
                }
            } else {
                log.error("string2Properties error");
                response.setCode(ResponseCode.SYSTEM_ERROR);
                response.setRemark("string2Properties error");
                return response;
            }
        } catch (UnsupportedEncodingException e) {
            log.error("", e);
            response.setCode(ResponseCode.SYSTEM_ERROR);
            response.setRemark("UnsupportedEncodingException " + e);
            return response;
        }
    }

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:35,代码来源:AdminBrokerProcessor.java

示例3: updateConfig

private RemotingCommand updateConfig(ChannelHandlerContext ctx, RemotingCommand request) {
    log.info("updateConfig called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));

    final RemotingCommand response = RemotingCommand.createResponseCommand(null);

    byte[] body = request.getBody();
    if (body != null) {
        String bodyStr;
        try {
            bodyStr = new String(body, MixAll.DEFAULT_CHARSET);
        } catch (UnsupportedEncodingException e) {
            log.error("updateConfig byte array to string error: ", e);
            response.setCode(ResponseCode.SYSTEM_ERROR);
            response.setRemark("UnsupportedEncodingException " + e);
            return response;
        }

        if (bodyStr == null) {
            log.error("updateConfig get null body!");
            response.setCode(ResponseCode.SYSTEM_ERROR);
            response.setRemark("string2Properties error");
            return response;
        }

        Properties properties = MixAll.string2Properties(bodyStr);
        if (properties == null) {
            log.error("updateConfig MixAll.string2Properties error {}", bodyStr);
            response.setCode(ResponseCode.SYSTEM_ERROR);
            response.setRemark("string2Properties error");
            return response;
        }

        this.namesrvController.getConfiguration().update(properties);
    }

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:39,代码来源:DefaultRequestProcessor.java

示例4: registerFilterClass

public boolean registerFilterClass(final String consumerGroup, final String topic,
    final String className, final int classCRC, final byte[] filterSourceBinary) {
    final String key = buildKey(consumerGroup, topic);

    boolean registerNew = false;
    FilterClassInfo filterClassInfoPrev = this.filterClassTable.get(key);
    if (null == filterClassInfoPrev) {
        registerNew = true;
    } else {
        if (this.filtersrvController.getFiltersrvConfig().isClientUploadFilterClassEnable()) {
            if (filterClassInfoPrev.getClassCRC() != classCRC && classCRC != 0) {
                registerNew = true;
            }
        }
    }

    if (registerNew) {
        synchronized (this.compileLock) {
            filterClassInfoPrev = this.filterClassTable.get(key);
            if (null != filterClassInfoPrev && filterClassInfoPrev.getClassCRC() == classCRC) {
                return true;
            }

            try {

                FilterClassInfo filterClassInfoNew = new FilterClassInfo();
                filterClassInfoNew.setClassName(className);
                filterClassInfoNew.setClassCRC(0);
                filterClassInfoNew.setMessageFilter(null);

                if (this.filtersrvController.getFiltersrvConfig().isClientUploadFilterClassEnable()) {
                    String javaSource = new String(filterSourceBinary, MixAll.DEFAULT_CHARSET);
                    Class<?> newClass = DynaCode.compileAndLoadClass(className, javaSource);
                    Object newInstance = newClass.newInstance();
                    filterClassInfoNew.setMessageFilter((MessageFilter) newInstance);
                    filterClassInfoNew.setClassCRC(classCRC);
                }

                this.filterClassTable.put(key, filterClassInfoNew);
            } catch (Throwable e) {
                String info =
                    String
                        .format(
                            "FilterServer, registerFilterClass Exception, consumerGroup: %s topic: %s className: %s",
                            consumerGroup, topic, className);
                log.error(info, e);
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:53,代码来源:FilterClassManager.java


注:本文中的org.apache.rocketmq.common.MixAll.DEFAULT_CHARSET属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。