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



---

Reply via email to