Java Code Examples for org.apache.rocketmq.remoting.protocol.RemotingSerializable#decode()

The following examples show how to use org.apache.rocketmq.remoting.protocol.RemotingSerializable#decode() . 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: AdminBrokerProcessor.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
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;
    }
 
Example 2
Source File: AdminBrokerProcessor.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
/**
 * 更新获取创建 SubscriptionGroup
 * @param ctx ;
 * @param request ;
 * @return ;
 * @throws RemotingCommandException ;
 */
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;
}
 
Example 3
Source File: ClusterInfoTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testFormJson() throws Exception {
    ClusterInfo clusterInfo = buildClusterInfo();
    byte[] data = clusterInfo.encode();
    ClusterInfo json = RemotingSerializable.decode(data, ClusterInfo.class);

    assertNotNull(json);
    assertNotNull(json.getClusterAddrTable());
    assertTrue(json.getClusterAddrTable().containsKey("DEFAULT_CLUSTER"));
    assertTrue(json.getClusterAddrTable().get("DEFAULT_CLUSTER").contains("master"));
    assertNotNull(json.getBrokerAddrTable());
    assertTrue(json.getBrokerAddrTable().containsKey("master"));
    assertEquals(json.getBrokerAddrTable().get("master").getBrokerName(), "master");
    assertEquals(json.getBrokerAddrTable().get("master").getCluster(), "DEFAULT_CLUSTER");
    assertEquals(json.getBrokerAddrTable().get("master").getBrokerAddrs().get(MixAll.MASTER_ID), MixAll.getLocalhostByNetworkInterface());
}
 
Example 4
Source File: AdminBrokerProcessor.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: DeFiAdminBrokerProcessorTest.java    From DeFiBus with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_GET_CONSUME_STATS_V2() throws RemotingCommandException {
    RemotingCommand request = createCommand(DeFiBusRequestCode.GET_CONSUME_STATS_V2);
    deFiBrokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(topic, 1, 6, 0);
    RemotingCommand response = deFiAdminBrokerProcessor.processRequest(handlerContext, request);
    assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS);
    DeFiBusConsumeStats consumerStats = RemotingSerializable.decode(response.getBody(), DeFiBusConsumeStats.class);
    assertThat(consumerStats).isNotNull();
}
 
Example 6
Source File: DeFiClientManageProcessorTest.java    From DeFiBus with Apache License 2.0 5 votes vote down vote up
@Test
public void processRequest_GetConsumerListByGroupAndTopic() throws Exception {
    ConsumerGroupInfo consumerGroupInfo = deFiBrokerController.getConsumerManager().getConsumerGroupInfo(group);
    assertThat(consumerGroupInfo).isNotNull();

    RemotingCommand request = GetConsumerListCommand();
    RemotingCommand response = deFiClientManageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS);
    GetConsumerListByGroupResponseBody body = RemotingSerializable.decode(response.getBody(), GetConsumerListByGroupResponseBody.class);
    List<String> clientIdList = body.getConsumerIdList();
    assertThat(clientIdList).isNotNull();
    assertThat(clientIdList.get(0)).isEqualTo(clientId);
}
 
Example 7
Source File: DeFiClientManageProcessorTest.java    From DeFiBus with Apache License 2.0 5 votes vote down vote up
@Test
public void processRequest_GetConsumerListByGroupAndTopicIsNull() throws Exception {
    ConsumerGroupInfo consumerGroupInfo = deFiBrokerController.getConsumerManager().getConsumerGroupInfo(group);
    assertThat(consumerGroupInfo).isNotNull();

    RemotingCommand request = GetConsumerListCommandWithNoTopic();
    RemotingCommand response = response = deFiClientManageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS);
    GetConsumerListByGroupResponseBody body = RemotingSerializable.decode(response.getBody(), GetConsumerListByGroupResponseBody.class);
    List<String> clientIdList = body.getConsumerIdList();
    assertThat(clientIdList).isNotNull();
    assertThat(clientIdList.get(0)).isEqualTo(clientId);
}
 
Example 8
Source File: AdminBrokerProcessor.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 9
Source File: AdminBrokerProcessor.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 10
Source File: AdminBrokerProcessor.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 11
Source File: AdminBrokerProcessor.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 12
Source File: AdminBrokerProcessor.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 13
Source File: ClusterInfoTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testRetrieveAllClusterNames() throws Exception {
    ClusterInfo clusterInfo = buildClusterInfo();
    byte[] data = clusterInfo.encode();
    ClusterInfo json = RemotingSerializable.decode(data, ClusterInfo.class);

    assertArrayEquals(new String[]{"DEFAULT_CLUSTER"}, json.retrieveAllClusterNames());
}
 
Example 14
Source File: ClusterInfoTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testRetrieveAllAddrByCluster() throws Exception {
    ClusterInfo clusterInfo = buildClusterInfo();
    byte[] data = clusterInfo.encode();
    ClusterInfo json = RemotingSerializable.decode(data, ClusterInfo.class);

    assertArrayEquals(new String[]{MixAll.getLocalhostByNetworkInterface()}, json.retrieveAllAddrByCluster("DEFAULT_CLUSTER"));
}
 
Example 15
Source File: QueryConsumeTimeSpanBodyTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testEncode() throws Exception {
    QueryConsumeTimeSpanBody origin = new QueryConsumeTimeSpanBody();
    List<QueueTimeSpan> queueTimeSpans = newUniqueConsumeTimeSpanSet();
    origin.setConsumeTimeSpanSet(queueTimeSpans);
    byte[] data = origin.encode();
    QueryConsumeTimeSpanBody fromData = RemotingSerializable.decode(data, QueryConsumeTimeSpanBody.class);
    assertThat(fromData.getConsumeTimeSpanSet().get(0).getMinTimeStamp()).isEqualTo(origin.getConsumeTimeSpanSet().get(0).getMinTimeStamp());
    assertThat(fromData.getConsumeTimeSpanSet().get(0).getMaxTimeStamp()).isEqualTo(origin.getConsumeTimeSpanSet().get(0).getMaxTimeStamp());
    assertThat(fromData.getConsumeTimeSpanSet().get(0).getConsumeTimeStamp()).isEqualTo(origin.getConsumeTimeSpanSet().get(0).getConsumeTimeStamp());
    assertThat(fromData.getConsumeTimeSpanSet().get(0).getDelayTime()).isEqualTo(origin.getConsumeTimeSpanSet().get(0).getDelayTime());
    assertThat(fromData.getConsumeTimeSpanSet().get(0).getMessageQueue().getBrokerName()).isEqualTo(origin.getConsumeTimeSpanSet().get(0).getMessageQueue().getBrokerName());
    assertThat(fromData.getConsumeTimeSpanSet().get(0).getMessageQueue().getTopic()).isEqualTo(origin.getConsumeTimeSpanSet().get(0).getMessageQueue().getTopic());
    assertThat(fromData.getConsumeTimeSpanSet().get(0).getMessageQueue().getQueueId()).isEqualTo(origin.getConsumeTimeSpanSet().get(0).getMessageQueue().getQueueId());
}
 
Example 16
Source File: OffsetMovedEventTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testFromBytes() throws Exception {
  OffsetMovedEvent event = mockOffsetMovedEvent();

  byte[] encodeData = event.encode();
  OffsetMovedEvent decodeData = RemotingSerializable.decode(encodeData, OffsetMovedEvent.class);

  assertEquals(event, decodeData);
}