[ 
https://issues.apache.org/jira/browse/ROCKETMQ-271?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16172689#comment-16172689
 ] 

ASF GitHub Bot commented on ROCKETMQ-271:
-----------------------------------------

Github user dongeforever commented on a diff in the pull request:

    https://github.com/apache/incubator-rocketmq/pull/156#discussion_r139868962
  
    --- Diff: 
broker/src/main/java/org/apache/rocketmq/broker/ServerTracerTimeUtil.java ---
    @@ -0,0 +1,108 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.rocketmq.broker;
    +
    +import com.google.common.cache.Cache;
    +import com.google.common.cache.CacheBuilder;
    +import java.util.concurrent.TimeUnit;
    +import org.apache.rocketmq.common.ClientTracerTimeUtil;
    +import org.apache.rocketmq.common.TracerTime;
    +
    +public class ServerTracerTimeUtil {
    +
    +    public static Cache<String, TracerTime> tracerTimeCache = 
CacheBuilder.newBuilder()
    +        .maximumSize(10000)
    +        .expireAfterWrite(15, TimeUnit.MINUTES)
    +        .build();
    +
    +    public static boolean isEnableTracerTime() {
    +        return ClientTracerTimeUtil.isEnableTracerTime();
    +    }
    +
    +    public static void addMessageCreateTime(String messageTracerTimeId, 
String messageCreateTime) {
    +        if (messageCreateTime == null || messageCreateTime.length() < 1) {
    +            return;
    +        }
    +
    +        TracerTime tracerTime = 
tracerTimeCache.getIfPresent(messageTracerTimeId);
    +        if (tracerTime == null) {
    +            tracerTime = new TracerTime();
    --- End diff --
    
    getIfPresent  may have concurrent problem
    
    Maybe getOrDefault is OK



> add diagnosis tools
> -------------------
>
>                 Key: ROCKETMQ-271
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-271
>             Project: Apache RocketMQ
>          Issue Type: New Feature
>          Components: rocketmq-broker, rocketmq-client, rocketmq-commons, 
> rocketmq-remoting
>            Reporter: yubaofu
>            Assignee: yukon
>            Priority: Minor
>   Original Estimate: 96h
>  Remaining Estimate: 96h
>
> when prodcurer send message timeout,how to find the root cause,it's difficult.
> so add the new diagnosis tools that record message lifetime ,eg message 
> create time,prodcurer send message to broker time,broker recive message 
> time,and send response to client time.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to