Java Code Examples for org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader#getBodyCrc32()

The following examples show how to use org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader#getBodyCrc32() . 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: DefaultRequestProcessor.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
private boolean checksum(ChannelHandlerContext ctx, RemotingCommand request,
    RegisterBrokerRequestHeader requestHeader) {
    if (requestHeader.getBodyCrc32() != 0) {
        final int crc32 = UtilAll.crc32(request.getBody());
        if (crc32 != requestHeader.getBodyCrc32()) {
            log.warn(String.format("receive registerBroker request,crc32 not match,from %s",
                RemotingHelper.parseChannelRemoteAddr(ctx.channel())));
            return false;
        }
    }
    return true;
}
 
Example 2
Source File: DefaultRequestProcessor.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
/**
 * 进行crc32的校验,保证请求的完整性
 * @param ctx ctx
 * @param request  request
 * @param requestHeader request
 * @return ;
 */
private boolean checksum(ChannelHandlerContext ctx, RemotingCommand request,
    RegisterBrokerRequestHeader requestHeader) {
    if (requestHeader.getBodyCrc32() != 0) {
        final int crc32 = UtilAll.crc32(request.getBody());
        if (crc32 != requestHeader.getBodyCrc32()) {
            log.warn(String.format("receive registerBroker request,crc32 not match,from %s",
                RemotingHelper.parseChannelRemoteAddr(ctx.channel())));
            return false;
        }
    }
    return true;
}
 
Example 3
Source File: DefaultRequestProcessor.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private boolean checksum(ChannelHandlerContext ctx, RemotingCommand request,
    RegisterBrokerRequestHeader requestHeader) {
    if (requestHeader.getBodyCrc32() != 0) {
        final int crc32 = UtilAll.crc32(request.getBody());
        if (crc32 != requestHeader.getBodyCrc32()) {
            log.warn(String.format("receive registerBroker request,crc32 not match,from %s",
                RemotingHelper.parseChannelRemoteAddr(ctx.channel())));
            return false;
        }
    }
    return true;
}