|
16 | 16 | */
|
17 | 17 | package org.apache.rocketmq.store.dledger;
|
18 | 18 |
|
| 19 | +import io.openmessaging.storage.dledger.AppendFuture; |
| 20 | +import io.openmessaging.storage.dledger.BatchAppendFuture; |
| 21 | +import io.openmessaging.storage.dledger.DLedgerConfig; |
| 22 | +import io.openmessaging.storage.dledger.DLedgerServer; |
| 23 | +import io.openmessaging.storage.dledger.entry.DLedgerEntry; |
| 24 | +import io.openmessaging.storage.dledger.protocol.AppendEntryRequest; |
| 25 | +import io.openmessaging.storage.dledger.protocol.AppendEntryResponse; |
| 26 | +import io.openmessaging.storage.dledger.protocol.BatchAppendEntryRequest; |
| 27 | +import io.openmessaging.storage.dledger.protocol.DLedgerResponseCode; |
| 28 | +import io.openmessaging.storage.dledger.store.file.DLedgerMmapFileStore; |
| 29 | +import io.openmessaging.storage.dledger.store.file.MmapFile; |
| 30 | +import io.openmessaging.storage.dledger.store.file.MmapFileList; |
| 31 | +import io.openmessaging.storage.dledger.store.file.SelectMmapBufferResult; |
| 32 | +import io.openmessaging.storage.dledger.utils.DLedgerUtils; |
19 | 33 | import java.net.Inet6Address;
|
20 | 34 | import java.net.InetSocketAddress;
|
21 | 35 | import java.nio.ByteBuffer;
|
22 | 36 | import java.util.LinkedList;
|
23 | 37 | import java.util.List;
|
24 | 38 | import java.util.concurrent.CompletableFuture;
|
25 |
| - |
26 | 39 | import org.apache.rocketmq.common.UtilAll;
|
27 | 40 | import org.apache.rocketmq.common.message.MessageDecoder;
|
28 | 41 | import org.apache.rocketmq.common.message.MessageExtBatch;
|
|
43 | 56 | import org.apache.rocketmq.store.logfile.MappedFile;
|
44 | 57 | import org.rocksdb.RocksDBException;
|
45 | 58 |
|
46 |
| -import io.openmessaging.storage.dledger.AppendFuture; |
47 |
| -import io.openmessaging.storage.dledger.BatchAppendFuture; |
48 |
| -import io.openmessaging.storage.dledger.DLedgerConfig; |
49 |
| -import io.openmessaging.storage.dledger.DLedgerServer; |
50 |
| -import io.openmessaging.storage.dledger.entry.DLedgerEntry; |
51 |
| -import io.openmessaging.storage.dledger.protocol.AppendEntryRequest; |
52 |
| -import io.openmessaging.storage.dledger.protocol.AppendEntryResponse; |
53 |
| -import io.openmessaging.storage.dledger.protocol.BatchAppendEntryRequest; |
54 |
| -import io.openmessaging.storage.dledger.protocol.DLedgerResponseCode; |
55 |
| -import io.openmessaging.storage.dledger.store.file.DLedgerMmapFileStore; |
56 |
| -import io.openmessaging.storage.dledger.store.file.MmapFile; |
57 |
| -import io.openmessaging.storage.dledger.store.file.MmapFileList; |
58 |
| -import io.openmessaging.storage.dledger.store.file.SelectMmapBufferResult; |
59 |
| -import io.openmessaging.storage.dledger.utils.DLedgerUtils; |
60 |
| - |
61 | 59 | /**
|
62 | 60 | * Store all metadata downtime for recovery, data protection reliability
|
63 | 61 | */
|
@@ -428,47 +426,54 @@ private void setRecoverPosition() {
|
428 | 426 | log.info("Will set the initial commitlog offset={} for dledger", dividedCommitlogOffset);
|
429 | 427 | }
|
430 | 428 |
|
431 |
| - private boolean isMmapFileMatchedRecover(final MmapFile mmapFile) { |
| 429 | + private boolean isMmapFileMatchedRecover(final MmapFile mmapFile) throws RocksDBException { |
432 | 430 | ByteBuffer byteBuffer = mmapFile.sliceByteBuffer();
|
433 | 431 |
|
434 | 432 | int magicCode = byteBuffer.getInt(DLedgerEntry.BODY_OFFSET + MessageDecoder.MESSAGE_MAGIC_CODE_POSITION);
|
435 | 433 | if (magicCode != MESSAGE_MAGIC_CODE) {
|
436 | 434 | return false;
|
437 | 435 | }
|
438 | 436 |
|
439 |
| - int storeTimestampPosition; |
440 |
| - int sysFlag = byteBuffer.getInt(DLedgerEntry.BODY_OFFSET + MessageDecoder.SYSFLAG_POSITION); |
441 |
| - if ((sysFlag & MessageSysFlag.BORNHOST_V6_FLAG) == 0) { |
442 |
| - storeTimestampPosition = MessageDecoder.MESSAGE_STORE_TIMESTAMP_POSITION; |
| 437 | + if (this.defaultMessageStore.getMessageStoreConfig().isEnableRocksDBStore()) { |
| 438 | + final long maxPhyOffsetInConsumeQueue = this.defaultMessageStore.getQueueStore().getMaxPhyOffsetInConsumeQueue(); |
| 439 | + long phyOffset = byteBuffer.getLong(DLedgerEntry.BODY_OFFSET + MessageDecoder.MESSAGE_PHYSIC_OFFSET_POSITION); |
| 440 | + if (phyOffset <= maxPhyOffsetInConsumeQueue) { |
| 441 | + log.info("find check. beginPhyOffset: {}, maxPhyOffsetInConsumeQueue: {}", phyOffset, maxPhyOffsetInConsumeQueue); |
| 442 | + return true; |
| 443 | + } |
443 | 444 | } else {
|
444 |
| - // v6 address is 12 byte larger than v4 |
445 |
| - storeTimestampPosition = MessageDecoder.MESSAGE_STORE_TIMESTAMP_POSITION + 12; |
446 |
| - } |
| 445 | + int storeTimestampPosition; |
| 446 | + int sysFlag = byteBuffer.getInt(DLedgerEntry.BODY_OFFSET + MessageDecoder.SYSFLAG_POSITION); |
| 447 | + if ((sysFlag & MessageSysFlag.BORNHOST_V6_FLAG) == 0) { |
| 448 | + storeTimestampPosition = MessageDecoder.MESSAGE_STORE_TIMESTAMP_POSITION; |
| 449 | + } else { |
| 450 | + // v6 address is 12 byte larger than v4 |
| 451 | + storeTimestampPosition = MessageDecoder.MESSAGE_STORE_TIMESTAMP_POSITION + 12; |
| 452 | + } |
447 | 453 |
|
448 |
| - long storeTimestamp = byteBuffer.getLong(DLedgerEntry.BODY_OFFSET + storeTimestampPosition); |
449 |
| - if (storeTimestamp == 0) { |
450 |
| - return false; |
451 |
| - } |
| 454 | + long storeTimestamp = byteBuffer.getLong(DLedgerEntry.BODY_OFFSET + storeTimestampPosition); |
| 455 | + if (storeTimestamp == 0) { |
| 456 | + return false; |
| 457 | + } |
452 | 458 |
|
453 |
| - if (this.defaultMessageStore.getMessageStoreConfig().isMessageIndexEnable() |
| 459 | + if (this.defaultMessageStore.getMessageStoreConfig().isMessageIndexEnable() |
454 | 460 | && this.defaultMessageStore.getMessageStoreConfig().isMessageIndexSafe()) {
|
455 |
| - if (storeTimestamp <= this.defaultMessageStore.getStoreCheckpoint().getMinTimestampIndex()) { |
456 |
| - log.info("dledger find check timestamp, {} {}", |
457 |
| - storeTimestamp, |
458 |
| - UtilAll.timeMillisToHumanString(storeTimestamp)); |
459 |
| - return true; |
460 |
| - } |
461 |
| - } else { |
462 |
| - if (storeTimestamp <= this.defaultMessageStore.getStoreCheckpoint().getMinTimestamp()) { |
463 |
| - log.info("dledger find check timestamp, {} {}", |
464 |
| - storeTimestamp, |
465 |
| - UtilAll.timeMillisToHumanString(storeTimestamp)); |
466 |
| - return true; |
| 461 | + if (storeTimestamp <= this.defaultMessageStore.getStoreCheckpoint().getMinTimestampIndex()) { |
| 462 | + log.info("dledger find check timestamp, {} {}", |
| 463 | + storeTimestamp, |
| 464 | + UtilAll.timeMillisToHumanString(storeTimestamp)); |
| 465 | + return true; |
| 466 | + } |
| 467 | + } else { |
| 468 | + if (storeTimestamp <= this.defaultMessageStore.getStoreCheckpoint().getMinTimestamp()) { |
| 469 | + log.info("dledger find check timestamp, {} {}", |
| 470 | + storeTimestamp, |
| 471 | + UtilAll.timeMillisToHumanString(storeTimestamp)); |
| 472 | + return true; |
| 473 | + } |
467 | 474 | }
|
468 | 475 | }
|
469 |
| - |
470 | 476 | return false;
|
471 |
| - |
472 | 477 | }
|
473 | 478 |
|
474 | 479 | @Override
|
|
0 commit comments