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


Java RemotingSerializable.fromJson方法代码示例

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


在下文中一共展示了RemotingSerializable.fromJson方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
        }
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:10,代码来源:ConsumerOffsetManager.java

示例3: 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));
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:13,代码来源:ConsumeStatusTest.java

示例4: 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;
        }
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:53,代码来源:ConsumerFilterManager.java


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