congbobo184 commented on a change in pull request #9229:
URL: https://github.com/apache/pulsar/pull/9229#discussion_r560702633



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/timeout/TransactionTimeoutTrackerImpl.java
##########
@@ -0,0 +1,120 @@
+/**
+ * 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.pulsar.broker.transaction.timeout;
+
+import io.netty.util.Timeout;
+import io.netty.util.Timer;
+import io.netty.util.TimerTask;
+import java.time.Clock;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.pulsar.broker.TransactionMetadataStoreService;
+import org.apache.pulsar.client.api.transaction.TxnID;
+import org.apache.pulsar.common.api.proto.TxnAction;
+import org.apache.pulsar.common.util.collections.TripleLongPriorityQueue;
+import org.apache.pulsar.transaction.coordinator.TransactionTimeoutTracker;
+
+/**
+ * An timer-task implementation of {@link TransactionTimeoutTracker}.
+ */
+@Slf4j
+public class TransactionTimeoutTrackerImpl implements 
TransactionTimeoutTracker, TimerTask {
+
+    private final Timer timer;
+    private final TripleLongPriorityQueue priorityQueue = new 
TripleLongPriorityQueue();
+    private final long tickTimeMillis;
+    private final Clock clock;
+    private final static long BASE_OF_MILLIS_TO_SECOND = 1000L;
+    private Timeout currentTimeout;
+    private final static long INITIAL_TIMEOUT = 1L;
+    private long nowTaskTimeoutTime = INITIAL_TIMEOUT;

Review comment:
       The timeout may wait time longer than the new transaction timeout time, 
so we should cancel the current timeout and create a timeout wait time is the 
new transaction timeout time.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to