本文整理汇总了Java中org.apache.rocketmq.remoting.protocol.RemotingSerializable类的典型用法代码示例。如果您正苦于以下问题:Java RemotingSerializable类的具体用法?Java RemotingSerializable怎么用?Java RemotingSerializable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemotingSerializable类属于org.apache.rocketmq.remoting.protocol包,在下文中一共展示了RemotingSerializable类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decode
import org.apache.rocketmq.remoting.protocol.RemotingSerializable; //导入依赖的package包/类
@Override
public void decode(String jsonString) {
if (jsonString != null) {
SubscriptionGroupManager obj = RemotingSerializable.fromJson(jsonString, SubscriptionGroupManager.class);
if (obj != null) {
this.subscriptionGroupTable.putAll(obj.subscriptionGroupTable);
this.dataVersion.assignNewOne(obj.dataVersion);
this.printLoadDataWhenFirstBoot(obj);
}
}
}
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:12,代码来源:SubscriptionGroupManager.java
示例2: decode
import org.apache.rocketmq.remoting.protocol.RemotingSerializable; //导入依赖的package包/类
@Override
public void decode(String jsonString) {
if (jsonString != null) {
ConsumerOffsetManager obj = RemotingSerializable.fromJson(jsonString, ConsumerOffsetManager.class);
if (obj != null) {
this.offsetTable = obj.offsetTable;
}
}
}
示例3: updateAndCreateSubscriptionGroup
import org.apache.rocketmq.remoting.protocol.RemotingSerializable; //导入依赖的package包/类
private RemotingCommand updateAndCreateSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request)
throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
log.info("updateAndCreateSubscriptionGroup called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
SubscriptionGroupConfig config = RemotingSerializable.decode(request.getBody(), SubscriptionGroupConfig.class);
if (config != null) {
this.brokerController.getSubscriptionGroupManager().updateSubscriptionGroupConfig(config);
}
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
return response;
}
示例4: encode
import org.apache.rocketmq.remoting.protocol.RemotingSerializable; //导入依赖的package包/类
@Override
public String encode(final boolean prettyFormat) {
// clean
{
clean();
}
return RemotingSerializable.toJson(this, prettyFormat);
}
示例5: execute
import org.apache.rocketmq.remoting.protocol.RemotingSerializable; //导入依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
adminExt.start();
String topic = commandLine.getOptionValue('t').trim();
String ips = commandLine.getOptionValue('i').trim();
final String[] split = ips.split(",");
final List<String> ipList = new LinkedList<String>();
for (String ip : split) {
ipList.add(ip);
}
final TopicRouteData topicRouteData = adminExt.examineTopicRouteInfo(topic);
final Set<MessageQueue> mqs = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData);
final AllocateMessageQueueAveragely averagely = new AllocateMessageQueueAveragely();
RebalanceResult rr = new RebalanceResult();
for (String i : ipList) {
final List<MessageQueue> mqResult = averagely.allocate("aa", i, new ArrayList<MessageQueue>(mqs), ipList);
rr.getResult().put(i, mqResult);
}
final String json = RemotingSerializable.toJson(rr, false);
System.out.printf("%s%n", json);
} catch (Exception e) {
throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
} finally {
adminExt.shutdown();
}
}
示例6: testFromJson
import org.apache.rocketmq.remoting.protocol.RemotingSerializable; //导入依赖的package包/类
@Test
public void testFromJson() throws Exception {
ConsumeStatus cs = new ConsumeStatus();
cs.setConsumeFailedTPS(10);
cs.setPullRT(100);
cs.setPullTPS(1000);
String json = RemotingSerializable.toJson(cs, true);
ConsumeStatus fromJson = RemotingSerializable.fromJson(json, ConsumeStatus.class);
assertThat(fromJson.getPullRT()).isCloseTo(cs.getPullRT(), within(0.0001));
assertThat(fromJson.getPullTPS()).isCloseTo(cs.getPullTPS(), within(0.0001));
assertThat(fromJson.getConsumeFailedTPS()).isCloseTo(cs.getConsumeFailedTPS(), within(0.0001));
}
示例7: execute
import org.apache.rocketmq.remoting.protocol.RemotingSerializable; //导入依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
adminExt.start();
String topic = commandLine.getOptionValue('t').trim();
String ips = commandLine.getOptionValue('i').trim();
final String[] split = ips.split(",");
final List<String> ipList = new LinkedList<String>();
for (String ip : split) {
ipList.add(ip);
}
final TopicRouteData topicRouteData = adminExt.examineTopicRouteInfo(topic);
final Set<MessageQueue> mqs = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData);
final AllocateMessageQueueAveragely averagely = new AllocateMessageQueueAveragely();
RebalanceResult rr = new RebalanceResult();
for (String i : ipList) {
final List<MessageQueue> mqResult = averagely.allocate("aa", i, new ArrayList<MessageQueue>(mqs), ipList);
rr.getResult().put(i, mqResult);
}
final String json = RemotingSerializable.toJson(rr, false);
System.out.printf("%s%n", json);
} catch (Exception e) {
e.printStackTrace();
} finally {
adminExt.shutdown();
}
}
示例8: encode
import org.apache.rocketmq.remoting.protocol.RemotingSerializable; //导入依赖的package包/类
public String encode(final boolean prettyFormat) {
return RemotingSerializable.toJson(this, prettyFormat);
}
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:4,代码来源:SubscriptionGroupManager.java
示例9: decode
import org.apache.rocketmq.remoting.protocol.RemotingSerializable; //导入依赖的package包/类
@Override
public void decode(final String jsonString) {
ConsumerFilterManager load = RemotingSerializable.fromJson(jsonString, ConsumerFilterManager.class);
if (load != null && load.filterDataByTopic != null) {
boolean bloomChanged = false;
for (String topic : load.filterDataByTopic.keySet()) {
FilterDataMapByTopic dataMapByTopic = load.filterDataByTopic.get(topic);
if (dataMapByTopic == null) {
continue;
}
for (String group : dataMapByTopic.getGroupFilterData().keySet()) {
ConsumerFilterData filterData = dataMapByTopic.getGroupFilterData().get(group);
if (filterData == null) {
continue;
}
try {
filterData.setCompiledExpression(
FilterFactory.INSTANCE.get(filterData.getExpressionType()).compile(filterData.getExpression())
);
} catch (Exception e) {
log.error("load filter data error, " + filterData, e);
}
// check whether bloom filter is changed
// if changed, ignore the bit map calculated before.
if (!this.bloomFilter.isValid(filterData.getBloomFilterData())) {
bloomChanged = true;
log.info("Bloom filter is changed!So ignore all filter data persisted! {}, {}", this.bloomFilter, filterData.getBloomFilterData());
break;
}
log.info("load exist consumer filter data: {}", filterData);
if (filterData.getDeadTime() == 0) {
// we think all consumers are dead when load
long deadTime = System.currentTimeMillis() - 30 * 1000;
filterData.setDeadTime(
deadTime <= filterData.getBornTime() ? filterData.getBornTime() : deadTime
);
}
}
}
if (!bloomChanged) {
this.filterDataByTopic = load.filterDataByTopic;
}
}
}