|
22 | 22 | import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId; |
23 | 23 | import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot; |
24 | 24 | import org.apache.iotdb.common.rpc.thrift.TTimePartitionSlot; |
| 25 | +import org.apache.iotdb.commons.conf.CommonDescriptor; |
| 26 | +import org.apache.iotdb.commons.utils.CommonDateTimeUtils; |
25 | 27 | import org.apache.iotdb.commons.utils.ThriftCommonsSerDeUtils; |
| 28 | +import org.apache.iotdb.commons.utils.TimePartitionUtils; |
26 | 29 | import org.apache.iotdb.confignode.rpc.thrift.TTimeSlotList; |
27 | 30 |
|
28 | 31 | import org.apache.thrift.TException; |
29 | 32 | import org.apache.thrift.protocol.TProtocol; |
30 | 33 | import org.apache.tsfile.utils.ReadWriteIOUtils; |
31 | | -import org.slf4j.Logger; |
32 | | -import org.slf4j.LoggerFactory; |
33 | 34 |
|
34 | 35 | import java.io.IOException; |
35 | 36 | import java.io.InputStream; |
|
49 | 50 |
|
50 | 51 | public class SeriesPartitionTable { |
51 | 52 |
|
52 | | - private static final Logger LOGGER = LoggerFactory.getLogger(SeriesPartitionTable.class); |
| 53 | + // should only be used in CN scope, in DN scope should directly use |
| 54 | + // TimePartitionUtils.getTimePartitionInterval() |
| 55 | + private static final long TIME_PARTITION_INTERVAL = |
| 56 | + CommonDateTimeUtils.convertMilliTimeWithPrecision( |
| 57 | + TimePartitionUtils.getTimePartitionInterval(), |
| 58 | + CommonDescriptor.getInstance().getConfig().getTimestampPrecision()); |
53 | 59 |
|
54 | 60 | private final ConcurrentSkipListMap<TTimePartitionSlot, List<TConsensusGroupId>> |
55 | 61 | seriesPartitionMap; |
@@ -255,7 +261,8 @@ public List<TTimePartitionSlot> autoCleanPartitionTable( |
255 | 261 | while (iterator.hasNext()) { |
256 | 262 | Map.Entry<TTimePartitionSlot, List<TConsensusGroupId>> entry = iterator.next(); |
257 | 263 | TTimePartitionSlot timePartitionSlot = entry.getKey(); |
258 | | - if (timePartitionSlot.getStartTime() + TTL < currentTimeSlot.getStartTime()) { |
| 264 | + if (timePartitionSlot.getStartTime() + TIME_PARTITION_INTERVAL + TTL |
| 265 | + <= currentTimeSlot.getStartTime()) { |
259 | 266 | removedTimePartitions.add(timePartitionSlot); |
260 | 267 | iterator.remove(); |
261 | 268 | } |
|
0 commit comments