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


Java RemotingCommand.readCustomHeader方法代码示例

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


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

示例1: getBrokerConfig

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand getBrokerConfig(ChannelHandlerContext ctx, RemotingCommand request) {

        final RemotingCommand response = RemotingCommand.createResponseCommand(GetBrokerConfigResponseHeader.class);
        final GetBrokerConfigResponseHeader responseHeader = (GetBrokerConfigResponseHeader) response.readCustomHeader();

        String content = this.brokerController.getConfiguration().getAllConfigsFormatString();
        if (content != null && content.length() > 0) {
            try {
                response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
            } catch (UnsupportedEncodingException e) {
                log.error("", e);

                response.setCode(ResponseCode.SYSTEM_ERROR);
                response.setRemark("UnsupportedEncodingException " + e);
                return response;
            }
        }

        responseHeader.setVersion(this.brokerController.getConfiguration().getDataVersionJson());

        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);
        return response;
    }
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:25,代码来源:AdminBrokerProcessor.java

示例2: getKVConfig

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public RemotingCommand getKVConfig(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(GetKVConfigResponseHeader.class);
    final GetKVConfigResponseHeader responseHeader = (GetKVConfigResponseHeader) response.readCustomHeader();
    final GetKVConfigRequestHeader requestHeader =
        (GetKVConfigRequestHeader) request.decodeCommandCustomHeader(GetKVConfigRequestHeader.class);

    String value = this.namesrvController.getKvConfigManager().getKVConfig(
        requestHeader.getNamespace(),
        requestHeader.getKey()
    );

    if (value != null) {
        responseHeader.setValue(value);
        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);
        return response;
    }

    response.setCode(ResponseCode.QUERY_NOT_FOUND);
    response.setRemark("No config item, Namespace: " + requestHeader.getNamespace() + " Key: " + requestHeader.getKey());
    return response;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:23,代码来源:DefaultRequestProcessor.java

示例3: executeSendMessageHookAfter

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public void executeSendMessageHookAfter(final RemotingCommand response, final SendMessageContext context) {
    if (hasSendMessageHook()) {
        for (SendMessageHook hook : this.sendMessageHookList) {
            try {
                if (response != null) {
                    final SendMessageResponseHeader responseHeader =
                        (SendMessageResponseHeader) response.readCustomHeader();
                    context.setMsgId(responseHeader.getMsgId());
                    context.setQueueId(responseHeader.getQueueId());
                    context.setQueueOffset(responseHeader.getQueueOffset());
                    context.setCode(response.getCode());
                    context.setErrorMsg(response.getRemark());
                }
                hook.sendMessageAfter(context);
            } catch (Throwable e) {
                // Ignore
            }
        }
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:21,代码来源:AbstractSendMessageProcessor.java

示例4: testProcessRequest_GetKVConfigReturnNull

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
@Test
public void testProcessRequest_GetKVConfigReturnNull() throws RemotingCommandException {
    GetKVConfigRequestHeader header = new GetKVConfigRequestHeader();
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_KV_CONFIG,
        header);
    request.addExtField("namespace", "namespace");
    request.addExtField("key", "key");

    RemotingCommand response = defaultRequestProcessor.processRequest(null, request);

    assertThat(response.getCode()).isEqualTo(ResponseCode.QUERY_NOT_FOUND);
    assertThat(response.getRemark()).isEqualTo("No config item, Namespace: namespace Key: key");

    GetKVConfigResponseHeader responseHeader = (GetKVConfigResponseHeader) response
        .readCustomHeader();

    assertThat(responseHeader.getValue()).isNull();
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:19,代码来源:DefaultRequestProcessorTest.java

示例5: wipeWritePermOfBroker

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand wipeWritePermOfBroker(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(WipeWritePermOfBrokerResponseHeader.class);
    final WipeWritePermOfBrokerResponseHeader responseHeader = (WipeWritePermOfBrokerResponseHeader) response.readCustomHeader();
    final WipeWritePermOfBrokerRequestHeader requestHeader =
        (WipeWritePermOfBrokerRequestHeader) request.decodeCommandCustomHeader(WipeWritePermOfBrokerRequestHeader.class);

    int wipeTopicCnt = this.namesrvController.getRouteInfoManager().wipeWritePermOfBrokerByLock(requestHeader.getBrokerName());

    log.info("wipe write perm of broker[{}], client: {}, {}",
        requestHeader.getBrokerName(),
        RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
        wipeTopicCnt);

    responseHeader.setWipeTopicCount(wipeTopicCnt);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:19,代码来源:DefaultRequestProcessor.java

示例6: testProcessRequest_GetKVConfigReturnNotNull

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
@Test
public void testProcessRequest_GetKVConfigReturnNotNull() throws RemotingCommandException {
    namesrvController.getKvConfigManager().putKVConfig("namespace", "key", "value");

    GetKVConfigRequestHeader header = new GetKVConfigRequestHeader();
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_KV_CONFIG,
        header);
    request.addExtField("namespace", "namespace");
    request.addExtField("key", "key");

    RemotingCommand response = defaultRequestProcessor.processRequest(null, request);

    assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS);
    assertThat(response.getRemark()).isNull();

    GetKVConfigResponseHeader responseHeader = (GetKVConfigResponseHeader) response
        .readCustomHeader();

    assertThat(responseHeader.getValue()).isEqualTo("value");
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:21,代码来源:DefaultRequestProcessorTest.java

示例7: createSuccessResponse

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand createSuccessResponse(RemotingCommand request) {
    RemotingCommand response = RemotingCommand.createResponseCommand(SendMessageResponseHeader.class);
    response.setCode(ResponseCode.SUCCESS);
    response.setOpaque(request.getOpaque());

    SendMessageResponseHeader responseHeader = (SendMessageResponseHeader) response.readCustomHeader();
    responseHeader.setMsgId("123");
    responseHeader.setQueueId(1);
    responseHeader.setQueueOffset(123L);

    response.addExtField(MessageConst.PROPERTY_MSG_REGION, "RegionHZ");
    response.addExtField(MessageConst.PROPERTY_TRACE_SWITCH, "true");
    response.addExtField("queueId", String.valueOf(responseHeader.getQueueId()));
    response.addExtField("msgId", responseHeader.getMsgId());
    response.addExtField("queueOffset", String.valueOf(responseHeader.getQueueOffset()));
    return response;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:18,代码来源:MQClientAPIImplTest.java

示例8: registerBrokerWithFilterServer

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public RemotingCommand registerBrokerWithFilterServer(ChannelHandlerContext ctx, RemotingCommand request)
    throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterBrokerResponseHeader.class);
    final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader) response.readCustomHeader();
    final RegisterBrokerRequestHeader requestHeader =
        (RegisterBrokerRequestHeader) request.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);

    RegisterBrokerBody registerBrokerBody = new RegisterBrokerBody();

    if (request.getBody() != null) {
        registerBrokerBody = RegisterBrokerBody.decode(request.getBody(), RegisterBrokerBody.class);
    } else {
        registerBrokerBody.getTopicConfigSerializeWrapper().getDataVersion().setCounter(new AtomicLong(0));
        registerBrokerBody.getTopicConfigSerializeWrapper().getDataVersion().setTimestamp(0);
    }

    RegisterBrokerResult result = this.namesrvController.getRouteInfoManager().registerBroker(
        requestHeader.getClusterName(),
        requestHeader.getBrokerAddr(),
        requestHeader.getBrokerName(),
        requestHeader.getBrokerId(),
        requestHeader.getHaServerAddr(),
        registerBrokerBody.getTopicConfigSerializeWrapper(),
        registerBrokerBody.getFilterServerList(),
        ctx.channel());

    responseHeader.setHaServerAddr(result.getHaServerAddr());
    responseHeader.setMasterAddr(result.getMasterAddr());

    byte[] jsonValue = this.namesrvController.getKvConfigManager().getKVListByNamespace(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG);
    response.setBody(jsonValue);

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:37,代码来源:DefaultRequestProcessor.java

示例9: searchOffsetByTimestamp

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand searchOffsetByTimestamp(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(SearchOffsetResponseHeader.class);
    final SearchOffsetResponseHeader responseHeader = (SearchOffsetResponseHeader) response.readCustomHeader();
    final SearchOffsetRequestHeader requestHeader =
        (SearchOffsetRequestHeader) request.decodeCommandCustomHeader(SearchOffsetRequestHeader.class);

    long offset = this.brokerController.getMessageStore().getOffsetInQueueByTime(requestHeader.getTopic(), requestHeader.getQueueId(),
        requestHeader.getTimestamp());

    responseHeader.setOffset(offset);

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:16,代码来源:AdminBrokerProcessor.java

示例10: getMaxOffset

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand getMaxOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(GetMaxOffsetResponseHeader.class);
    final GetMaxOffsetResponseHeader responseHeader = (GetMaxOffsetResponseHeader) response.readCustomHeader();
    final GetMaxOffsetRequestHeader requestHeader =
        (GetMaxOffsetRequestHeader) request.decodeCommandCustomHeader(GetMaxOffsetRequestHeader.class);

    long offset = this.brokerController.getMessageStore().getMaxOffsetInQueue(requestHeader.getTopic(), requestHeader.getQueueId());

    responseHeader.setOffset(offset);

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:15,代码来源:AdminBrokerProcessor.java

示例11: getMinOffset

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand getMinOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(GetMinOffsetResponseHeader.class);
    final GetMinOffsetResponseHeader responseHeader = (GetMinOffsetResponseHeader) response.readCustomHeader();
    final GetMinOffsetRequestHeader requestHeader =
        (GetMinOffsetRequestHeader) request.decodeCommandCustomHeader(GetMinOffsetRequestHeader.class);

    long offset = this.brokerController.getMessageStore().getMinOffsetInQueue(requestHeader.getTopic(), requestHeader.getQueueId());

    responseHeader.setOffset(offset);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:14,代码来源:AdminBrokerProcessor.java

示例12: registerFilterServer

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand registerFilterServer(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterFilterServerResponseHeader.class);
    final RegisterFilterServerResponseHeader responseHeader = (RegisterFilterServerResponseHeader) response.readCustomHeader();
    final RegisterFilterServerRequestHeader requestHeader =
        (RegisterFilterServerRequestHeader) request.decodeCommandCustomHeader(RegisterFilterServerRequestHeader.class);

    this.brokerController.getFilterServerManager().registerFilterServer(ctx.channel(), requestHeader.getFilterServerAddr());

    responseHeader.setBrokerId(this.brokerController.getBrokerConfig().getBrokerId());
    responseHeader.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:16,代码来源:AdminBrokerProcessor.java

示例13: getEarliestMsgStoretime

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand getEarliestMsgStoretime(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(GetEarliestMsgStoretimeResponseHeader.class);
    final GetEarliestMsgStoretimeResponseHeader responseHeader = (GetEarliestMsgStoretimeResponseHeader) response.readCustomHeader();
    final GetEarliestMsgStoretimeRequestHeader requestHeader =
        (GetEarliestMsgStoretimeRequestHeader) request.decodeCommandCustomHeader(GetEarliestMsgStoretimeRequestHeader.class);

    long timestamp =
        this.brokerController.getMessageStore().getEarliestMessageTime(requestHeader.getTopic(), requestHeader.getQueueId());

    responseHeader.setTimestamp(timestamp);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:15,代码来源:AdminBrokerProcessor.java

示例14: getMinOffset

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand getMinOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(GetMinOffsetResponseHeader.class);
    final GetMinOffsetResponseHeader responseHeader = (GetMinOffsetResponseHeader) response.readCustomHeader();
    final GetMinOffsetRequestHeader requestHeader =
        (GetMinOffsetRequestHeader) request.decodeCommandCustomHeader(GetMinOffsetRequestHeader.class);

    long offset = this.brokerController.getMessageStore().getMinOffsetInQuque(requestHeader.getTopic(), requestHeader.getQueueId());

    responseHeader.setOffset(offset);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:14,代码来源:AdminBrokerProcessor.java

示例15: queryConsumerOffset

import org.apache.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
private RemotingCommand queryConsumerOffset(ChannelHandlerContext ctx, RemotingCommand request)
    throws RemotingCommandException {
    final RemotingCommand response =
        RemotingCommand.createResponseCommand(QueryConsumerOffsetResponseHeader.class);
    final QueryConsumerOffsetResponseHeader responseHeader =
        (QueryConsumerOffsetResponseHeader) response.readCustomHeader();
    final QueryConsumerOffsetRequestHeader requestHeader =
        (QueryConsumerOffsetRequestHeader) request
            .decodeCommandCustomHeader(QueryConsumerOffsetRequestHeader.class);

    long offset =
        this.brokerController.getConsumerOffsetManager().queryOffset(
            requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId());

    if (offset >= 0) {
        responseHeader.setOffset(offset);
        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);
    } else {
        long minOffset =
            this.brokerController.getMessageStore().getMinOffsetInQuque(requestHeader.getTopic(),
                requestHeader.getQueueId());
        if (minOffset <= 0
            && !this.brokerController.getMessageStore().checkInDiskByConsumeOffset(
            requestHeader.getTopic(), requestHeader.getQueueId(), 0)) {
            responseHeader.setOffset(0L);
            response.setCode(ResponseCode.SUCCESS);
            response.setRemark(null);
        } else {
            response.setCode(ResponseCode.QUERY_NOT_FOUND);
            response.setRemark("Not found, V3_0_6_SNAPSHOT maybe this group consumer boot first");
        }
    }

    return response;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:37,代码来源:ConsumerManageProcessor.java


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