[ 
https://issues.apache.org/jira/browse/TUBEMQ-73?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Guo Jiwei updated TUBEMQ-73:
----------------------------
    Description: 
1. remove duplicate block
{code:java}
catch (final Exception e) {
            logger.error("Put message failed ", e);
            strBuffer.delete(0, strBuffer.length());
            builder.setSuccess(false);
            builder.setErrCode(TErrCodeConstants.INTERNAL_SERVER_ERROR);
            builder.setErrMsg(strBuffer.append("Put message failed from ")
                    .append(tubeConfig.getHostName()).append(" ")
                    .append((e.getMessage() != null ? e.getMessage() : " 
")).toString());
            return builder.build();
        } catch (final Throwable ex) {
            logger.error("Put message failed ", ex);
            strBuffer.delete(0, strBuffer.length());
            builder.setSuccess(false);
            builder.setErrCode(TErrCodeConstants.INTERNAL_SERVER_ERROR);
            builder.setErrMsg(strBuffer.append("Put message failed from ")
                    .append(tubeConfig.getHostName()).append(" ")
                    .append((ex.getMessage() != null ? ex.getMessage() : " 
")).toString());
            return builder.build();
        }
{code}
2.  remove inner if
{code:java}
if (request.getCheckSum() != -1) {
     if (checkSum != request.getCheckSum()) {
          builder.setErrCode(TErrCodeConstants.FORBIDDEN);
          builder.setErrMsg(strBuffer.append("Checksum msg data failure: ")
                        .append(request.getCheckSum()).append(" of 
").append(reqTopic)
                        .append(" not equal to the data's checksum of ")
                        .append(checkSum).toString());
           return builder.build();
       }
}
{code}
3. fix some typos
     transferedMessageList -> transferMessageList
     cosnumer -> consumer

4. modify log print 
{code:java}
logger.info(strBuffer.append("[Consumer Register]").append(clientId)
                    .append(TokenConstants.SEGMENT_SEP).append(partStr)
                    .append(TokenConstants.SEGMENT_SEP).append(offsetInfo)
                    .append(", requestOffset=").append(reqOffset)
                    .append(", req has SSD 
storeId=").append(request.hasSsdStoreId())
                    .append(", req qryPriorityId=").append(reqQryPriorityId)
                    .append(", cur SSD storeId=").append(reqSsdStoreId)
                    .append(", isOverTLS=").append(overtls).toString());
{code}
     to below :
{code:java}
logger.info(strBuffer.append("[Consumer Register]").append(clientId)
                    .append(TokenConstants.SEGMENT_SEP).append(partStr)
                    .append(TokenConstants.SEGMENT_SEP).append(offsetInfo)
                    .append(", reqOffset=").append(reqOffset)
                    .append(", reqSsdStoreId=").append(reqSsdStoreId)
                    .append(", reqQryPriorityId=").append(reqQryPriorityId)
                    .append(", isOverTLS=").append(overtls).toString());
{code}





  was:
1. BrokerServiceServer is always doing crc32 checksum when producing message,  
we should only check it when producer enable it.

{code:java}
int checkSum = CheckSum.crc32(msgData);
if (request.getCheckSum() != -1) {
     if (checkSum != request.getCheckSum()) {
          builder.setErrCode(TErrCodeConstants.FORBIDDEN);
          builder.setErrMsg(strBuffer.append("Checksum msg data failure: ")
                        .append(request.getCheckSum()).append(" of 
").append(reqTopic)
                        .append(" not equal to the data's checksum of ")
                        .append(checkSum).toString());
           return builder.build();
       }
}
{code}
2. remove duplicate block

{code:java}
catch (final Exception e) {
            logger.error("Put message failed ", e);
            strBuffer.delete(0, strBuffer.length());
            builder.setSuccess(false);
            builder.setErrCode(TErrCodeConstants.INTERNAL_SERVER_ERROR);
            builder.setErrMsg(strBuffer.append("Put message failed from ")
                    .append(tubeConfig.getHostName()).append(" ")
                    .append((e.getMessage() != null ? e.getMessage() : " 
")).toString());
            return builder.build();
        } catch (final Throwable ex) {
            logger.error("Put message failed ", ex);
            strBuffer.delete(0, strBuffer.length());
            builder.setSuccess(false);
            builder.setErrCode(TErrCodeConstants.INTERNAL_SERVER_ERROR);
            builder.setErrMsg(strBuffer.append("Put message failed from ")
                    .append(tubeConfig.getHostName()).append(" ")
                    .append((ex.getMessage() != null ? ex.getMessage() : " 
")).toString());
            return builder.build();
        }
{code}



        Summary: remove duplicate codes & some minor updates  (was: fix crc32 
checksum in broker & remove duplicate codes)

> remove duplicate codes & some minor updates
> -------------------------------------------
>
>                 Key: TUBEMQ-73
>                 URL: https://issues.apache.org/jira/browse/TUBEMQ-73
>             Project: Apache TubeMQ
>          Issue Type: Improvement
>            Reporter: Guo Jiwei
>            Assignee: Guo Jiwei
>            Priority: Normal
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 1. remove duplicate block
> {code:java}
> catch (final Exception e) {
>             logger.error("Put message failed ", e);
>             strBuffer.delete(0, strBuffer.length());
>             builder.setSuccess(false);
>             builder.setErrCode(TErrCodeConstants.INTERNAL_SERVER_ERROR);
>             builder.setErrMsg(strBuffer.append("Put message failed from ")
>                     .append(tubeConfig.getHostName()).append(" ")
>                     .append((e.getMessage() != null ? e.getMessage() : " 
> ")).toString());
>             return builder.build();
>         } catch (final Throwable ex) {
>             logger.error("Put message failed ", ex);
>             strBuffer.delete(0, strBuffer.length());
>             builder.setSuccess(false);
>             builder.setErrCode(TErrCodeConstants.INTERNAL_SERVER_ERROR);
>             builder.setErrMsg(strBuffer.append("Put message failed from ")
>                     .append(tubeConfig.getHostName()).append(" ")
>                     .append((ex.getMessage() != null ? ex.getMessage() : " 
> ")).toString());
>             return builder.build();
>         }
> {code}
> 2.  remove inner if
> {code:java}
> if (request.getCheckSum() != -1) {
>      if (checkSum != request.getCheckSum()) {
>           builder.setErrCode(TErrCodeConstants.FORBIDDEN);
>           builder.setErrMsg(strBuffer.append("Checksum msg data failure: ")
>                         .append(request.getCheckSum()).append(" of 
> ").append(reqTopic)
>                         .append(" not equal to the data's checksum of ")
>                         .append(checkSum).toString());
>            return builder.build();
>        }
> }
> {code}
> 3. fix some typos
>      transferedMessageList -> transferMessageList
>      cosnumer -> consumer
> 4. modify log print 
> {code:java}
> logger.info(strBuffer.append("[Consumer Register]").append(clientId)
>                     .append(TokenConstants.SEGMENT_SEP).append(partStr)
>                     .append(TokenConstants.SEGMENT_SEP).append(offsetInfo)
>                     .append(", requestOffset=").append(reqOffset)
>                     .append(", req has SSD 
> storeId=").append(request.hasSsdStoreId())
>                     .append(", req qryPriorityId=").append(reqQryPriorityId)
>                     .append(", cur SSD storeId=").append(reqSsdStoreId)
>                     .append(", isOverTLS=").append(overtls).toString());
> {code}
>      to below :
> {code:java}
> logger.info(strBuffer.append("[Consumer Register]").append(clientId)
>                     .append(TokenConstants.SEGMENT_SEP).append(partStr)
>                     .append(TokenConstants.SEGMENT_SEP).append(offsetInfo)
>                     .append(", reqOffset=").append(reqOffset)
>                     .append(", reqSsdStoreId=").append(reqSsdStoreId)
>                     .append(", reqQryPriorityId=").append(reqQryPriorityId)
>                     .append(", isOverTLS=").append(overtls).toString());
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to