Java Code Examples for org.apache.rocketmq.common.MixAll#DEFAULT_CHARSET
The following examples show how to use
org.apache.rocketmq.common.MixAll#DEFAULT_CHARSET .
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: FilterClassManager.java From rocketmq with Apache License 2.0 | 5 votes |
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); } } }
Example 2
Source File: DefaultRequestProcessor.java From rocketmq with Apache License 2.0 | 5 votes |
private RemotingCommand updateConfig(ChannelHandlerContext ctx, RemotingCommand request) { if (ctx != null) { 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; } 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; }
Example 3
Source File: FilterClassManager.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
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); } } }
Example 4
Source File: DefaultRequestProcessor.java From DDMQ with Apache License 2.0 | 5 votes |
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; }
Example 5
Source File: FilterClassManager.java From DDMQ with Apache License 2.0 | 5 votes |
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); } } }
Example 6
Source File: AdminBrokerProcessor.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
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; }
Example 7
Source File: AdminBrokerProcessor.java From rocketmq with Apache License 2.0 | 5 votes |
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; }
Example 8
Source File: FilterClassManager.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
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); } } }
Example 9
Source File: FilterClassManager.java From DDMQ with Apache License 2.0 | 5 votes |
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); } } }
Example 10
Source File: DefaultRequestProcessor.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
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; }
Example 11
Source File: AdminBrokerProcessor.java From rocketmq-read with Apache License 2.0 | 5 votes |
/** * 更新Broker的配置 * @param ctx ctx * @param request ; * @return ; */ private synchronized 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.getTopicConfigManager().getDataVersion().nextVersion(); this.brokerController.registerBrokerAll(false, false, true); } } 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; }
Example 12
Source File: DefaultRequestProcessor.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
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; }
Example 13
Source File: AdminBrokerProcessor.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
private synchronized 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.getTopicConfigManager().getDataVersion().nextVersion(); // 注册所有的broker =》 this.brokerController.registerBrokerAll(false, false, true); } } 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; }
Example 14
Source File: DefaultRequestProcessor.java From DDMQ with Apache License 2.0 | 5 votes |
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; }
Example 15
Source File: RegisterBrokerBody.java From rocketmq with Apache License 2.0 | 4 votes |
public static RegisterBrokerBody decode(byte[] data, boolean compressed) throws IOException { if (!compressed) { return RegisterBrokerBody.decode(data, RegisterBrokerBody.class); } long start = System.currentTimeMillis(); InflaterInputStream inflaterInputStream = new InflaterInputStream(new ByteArrayInputStream(data)); int dataVersionLength = readInt(inflaterInputStream); byte[] dataVersionBytes = readBytes(inflaterInputStream, dataVersionLength); DataVersion dataVersion = DataVersion.decode(dataVersionBytes, DataVersion.class); RegisterBrokerBody registerBrokerBody = new RegisterBrokerBody(); registerBrokerBody.getTopicConfigSerializeWrapper().setDataVersion(dataVersion); ConcurrentMap<String, TopicConfig> topicConfigTable = registerBrokerBody.getTopicConfigSerializeWrapper().getTopicConfigTable(); int topicConfigNumber = readInt(inflaterInputStream); LOGGER.debug("{} topic configs to extract", topicConfigNumber); for (int i = 0; i < topicConfigNumber; i++) { int topicConfigJsonLength = readInt(inflaterInputStream); byte[] buffer = readBytes(inflaterInputStream, topicConfigJsonLength); TopicConfig topicConfig = new TopicConfig(); String topicConfigJson = new String(buffer, MixAll.DEFAULT_CHARSET); topicConfig.decode(topicConfigJson); topicConfigTable.put(topicConfig.getTopicName(), topicConfig); } int filterServerListJsonLength = readInt(inflaterInputStream); byte[] filterServerListBuffer = readBytes(inflaterInputStream, filterServerListJsonLength); String filterServerListJson = new String(filterServerListBuffer, MixAll.DEFAULT_CHARSET); List<String> filterServerList = new ArrayList<String>(); try { filterServerList = JSON.parseArray(filterServerListJson, String.class); } catch (Exception e) { LOGGER.error("Decompressing occur Exception {}", filterServerListJson); } registerBrokerBody.setFilterServerList(filterServerList); long interval = System.currentTimeMillis() - start; if (interval > 50) { LOGGER.info("Decompressing takes {}ms", interval); } return registerBrokerBody; }
Example 16
Source File: RegisterBrokerBody.java From rocketmq-4.3.0 with Apache License 2.0 | 4 votes |
public static RegisterBrokerBody decode(byte[] data, boolean compressed) throws IOException { if (!compressed) { return RegisterBrokerBody.decode(data, RegisterBrokerBody.class); } long start = System.currentTimeMillis(); InflaterInputStream inflaterInputStream = new InflaterInputStream(new ByteArrayInputStream(data)); int dataVersionLength = readInt(inflaterInputStream); byte[] dataVersionBytes = readBytes(inflaterInputStream, dataVersionLength); DataVersion dataVersion = DataVersion.decode(dataVersionBytes, DataVersion.class); RegisterBrokerBody registerBrokerBody = new RegisterBrokerBody(); registerBrokerBody.getTopicConfigSerializeWrapper().setDataVersion(dataVersion); ConcurrentMap<String, TopicConfig> topicConfigTable = registerBrokerBody.getTopicConfigSerializeWrapper().getTopicConfigTable(); int topicConfigNumber = readInt(inflaterInputStream); LOGGER.debug("{} topic configs to extract", topicConfigNumber); for (int i = 0; i < topicConfigNumber; i++) { int topicConfigJsonLength = readInt(inflaterInputStream); byte[] buffer = readBytes(inflaterInputStream, topicConfigJsonLength); TopicConfig topicConfig = new TopicConfig(); String topicConfigJson = new String(buffer, MixAll.DEFAULT_CHARSET); topicConfig.decode(topicConfigJson); topicConfigTable.put(topicConfig.getTopicName(), topicConfig); } int filterServerListJsonLength = readInt(inflaterInputStream); byte[] filterServerListBuffer = readBytes(inflaterInputStream, filterServerListJsonLength); String filterServerListJson = new String(filterServerListBuffer, MixAll.DEFAULT_CHARSET); List<String> filterServerList = new ArrayList<String>(); try { filterServerList = JSON.parseArray(filterServerListJson, String.class); } catch (Exception e) { LOGGER.error("Decompressing occur Exception {}", filterServerListJson); } registerBrokerBody.setFilterServerList(filterServerList); long interval = System.currentTimeMillis() - start; if (interval > 50) { LOGGER.info("Decompressing takes {}ms", interval); } return registerBrokerBody; }
Example 17
Source File: FilterClassManager.java From DDMQ with Apache License 2.0 | 4 votes |
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; }
Example 18
Source File: AdminBrokerProcessor.java From DDMQ with Apache License 2.0 | 4 votes |
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) { //not for ASYNC_MASTER to SYNC_MASTER or SYNC_MASTER to ASYNC_MASTER if (properties.containsKey(ConfigName.BROKER_ROLE) && properties.containsKey(ConfigName.BROKER_ID)) { if (!brokerController.onRoleChangePre(properties)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("check status failed before change role"); return response; } } BrokerRole oldBrokerRole = brokerController.getMessageStoreConfig().getBrokerRole(); long oldBrokerId = brokerController.getBrokerConfig().getBrokerId(); log.info("updateBrokerConfig, new config: [{}] client: {} ", properties, ctx.channel().remoteAddress()); this.brokerController.getConfiguration().update(properties); if (properties.containsKey(ConfigName.BROKER_PERMISSION)) { this.brokerController.registerBrokerAll(false, false); this.brokerController.getTopicConfigManager().getDataVersion().nextVersion(); } if (properties.containsKey(ConfigName.BROKER_ROLE) && properties.containsKey(ConfigName.BROKER_ID)) { if (!brokerController.onRoleChange(oldBrokerRole, oldBrokerId)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("change role failed"); return response; } } } 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; }
Example 19
Source File: AdminBrokerProcessor.java From DDMQ with Apache License 2.0 | 4 votes |
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) { //not for ASYNC_MASTER to SYNC_MASTER or SYNC_MASTER to ASYNC_MASTER if (properties.containsKey(ConfigName.BROKER_ROLE) && properties.containsKey(ConfigName.BROKER_ID)) { if (!brokerController.onRoleChangePre(properties)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("check status failed before change role"); return response; } } BrokerRole oldBrokerRole = brokerController.getMessageStoreConfig().getBrokerRole(); long oldBrokerId = brokerController.getBrokerConfig().getBrokerId(); log.info("updateBrokerConfig, new config: [{}] client: {} ", properties, ctx.channel().remoteAddress()); this.brokerController.getConfiguration().update(properties); if (properties.containsKey(ConfigName.BROKER_PERMISSION)) { this.brokerController.registerBrokerAll(false, false); this.brokerController.getTopicConfigManager().getDataVersion().nextVersion(); } if (properties.containsKey(ConfigName.BROKER_ROLE) && properties.containsKey(ConfigName.BROKER_ID)) { if (!brokerController.onRoleChange(oldBrokerRole, oldBrokerId)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("change role failed"); return response; } } } 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; }
Example 20
Source File: FilterClassManager.java From DDMQ with Apache License 2.0 | 4 votes |
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; }