com.alibaba.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerResponseHeader Java Examples

The following examples show how to use com.alibaba.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerResponseHeader. 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: FilterServerOuterAPI.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
public RegisterFilterServerResponseHeader registerFilterServerToBroker(//
        final String brokerAddr,// 1
        final String filterServerAddr// 2
) throws RemotingCommandException, RemotingConnectException, RemotingSendRequestException,
        RemotingTimeoutException, InterruptedException, MQBrokerException {
    RegisterFilterServerRequestHeader requestHeader = new RegisterFilterServerRequestHeader();
    requestHeader.setFilterServerAddr(filterServerAddr);
    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.REGISTER_FILTER_SERVER, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(brokerAddr, request, 3000);
    assert response != null;
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        RegisterFilterServerResponseHeader responseHeader =
                (RegisterFilterServerResponseHeader) response
                    .decodeCommandCustomHeader(RegisterFilterServerResponseHeader.class);

        return responseHeader;
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #2
Source File: FiltersrvController.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
public void registerFilterServerToBroker() {
    try {
        RegisterFilterServerResponseHeader responseHeader =
                this.filterServerOuterAPI.registerFilterServerToBroker(
                    this.filtersrvConfig.getConnectWhichBroker(), this.localAddr());
        this.defaultMQPullConsumer.getDefaultMQPullConsumerImpl().getPullAPIWrapper()
            .setDefaultBrokerId(responseHeader.getBrokerId());

        if (null == this.brokerName) {
            this.brokerName = responseHeader.getBrokerName();
        }

        log.info("register filter server<{}> to broker<{}> OK, Return: {} {}", //
            this.localAddr(),//
            this.filtersrvConfig.getConnectWhichBroker(),//
            responseHeader.getBrokerName(),//
            responseHeader.getBrokerId()//
        );
    }
    catch (Exception e) {
        log.warn("register filter server Exception", e);
        log.warn("access broker failed, kill oneself");
        System.exit(-1);
    }
}
 
Example #3
Source File: FilterServerOuterAPI.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public RegisterFilterServerResponseHeader registerFilterServerToBroker(//
                                                                       final String brokerAddr,// 1
                                                                       final String filterServerAddr// 2
) throws RemotingCommandException, RemotingConnectException, RemotingSendRequestException,
        RemotingTimeoutException, InterruptedException, MQBrokerException {
    RegisterFilterServerRequestHeader requestHeader = new RegisterFilterServerRequestHeader();
    requestHeader.setFilterServerAddr(filterServerAddr);
    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.REGISTER_FILTER_SERVER, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(brokerAddr, request, 3000);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            RegisterFilterServerResponseHeader responseHeader =
                    (RegisterFilterServerResponseHeader) response
                            .decodeCommandCustomHeader(RegisterFilterServerResponseHeader.class);

            return responseHeader;
        }
        default:
            break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #4
Source File: FiltersrvController.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public void registerFilterServerToBroker() {
    try {
        RegisterFilterServerResponseHeader responseHeader =
                this.filterServerOuterAPI.registerFilterServerToBroker(
                        this.filtersrvConfig.getConnectWhichBroker(), this.localAddr());
        this.defaultMQPullConsumer.getDefaultMQPullConsumerImpl().getPullAPIWrapper()
                .setDefaultBrokerId(responseHeader.getBrokerId());

        if (null == this.brokerName) {
            this.brokerName = responseHeader.getBrokerName();
        }

        log.info("register filter server<{}> to broker<{}> OK, Return: {} {}", //
                this.localAddr(),//
                this.filtersrvConfig.getConnectWhichBroker(),//
                responseHeader.getBrokerName(),//
                responseHeader.getBrokerId()//
        );
    } catch (Exception e) {
        log.warn("register filter server Exception", e);

        log.warn("access broker failed, kill oneself");
        System.exit(-1);
    }
}
 
Example #5
Source File: FilterServerOuterAPI.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
public RegisterFilterServerResponseHeader registerFilterServerToBroker(//
        final String brokerAddr, // 1
        final String filterServerAddr// 2
) throws RemotingCommandException, RemotingConnectException, RemotingSendRequestException,
        RemotingTimeoutException, InterruptedException, MQBrokerException {
    RegisterFilterServerRequestHeader requestHeader = new RegisterFilterServerRequestHeader();
    requestHeader.setFilterServerAddr(filterServerAddr);
    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.REGISTER_FILTER_SERVER, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(brokerAddr, request, 3000);
    assert response != null;
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        RegisterFilterServerResponseHeader responseHeader = (RegisterFilterServerResponseHeader) response
            .decodeCommandCustomHeader(RegisterFilterServerResponseHeader.class);

        return responseHeader;
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #6
Source File: FiltersrvController.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
public void registerFilterServerToBroker() {
    try {
        RegisterFilterServerResponseHeader responseHeader = this.filterServerOuterAPI
            .registerFilterServerToBroker(this.filtersrvConfig.getConnectWhichBroker(), this.localAddr());
        this.defaultMQPullConsumer.getDefaultMQPullConsumerImpl().getPullAPIWrapper()
            .setDefaultBrokerId(responseHeader.getBrokerId());

        if (null == this.brokerName) {
            this.brokerName = responseHeader.getBrokerName();
        }

        log.info("register filter server<{}> to broker<{}> OK, Return: {} {}", //
            this.localAddr(), //
            this.filtersrvConfig.getConnectWhichBroker(), //
            responseHeader.getBrokerName(), //
            responseHeader.getBrokerId()//
        );
    }
    catch (Exception e) {
        log.warn("register filter server Exception", e);
        // 如果失败,尝试自杀
        log.warn("access broker failed, kill oneself");
        System.exit(-1);
    }
}
 
Example #7
Source File: AdminBrokerProcessor.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #8
Source File: AdminBrokerProcessor.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #9
Source File: AdminBrokerProcessor.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
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;
}