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


Java RemotingSerializable.toJson方法代码示例

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


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

示例1: encode

import org.apache.rocketmq.remoting.protocol.RemotingSerializable; //导入方法依赖的package包/类
@Override
public String encode(final boolean prettyFormat) {
    // clean
    {
        clean();
    }
    return RemotingSerializable.toJson(this, prettyFormat);
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:9,代码来源:ConsumerFilterManager.java

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

示例5: 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


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