Skip to content

Commit 69c26d3

Browse files
authored
[ISSUE apache#7228] Converge the use of some important variables for some class
1 parent 9bb73b9 commit 69c26d3

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void recover() {
145145

146146
if (offset >= 0 && size > 0) {
147147
mappedFileOffset = i + CQ_STORE_UNIT_SIZE;
148-
this.maxPhysicOffset = offset + size;
148+
this.setMaxPhysicOffset(offset + size);
149149
if (isExtAddr(tagsCode)) {
150150
maxExtAddr = tagsCode;
151151
}
@@ -409,7 +409,7 @@ public void truncateDirtyLogicFiles(long phyOffset, boolean deleteFile) {
409409

410410
int logicFileSize = this.mappedFileSize;
411411

412-
this.maxPhysicOffset = phyOffset;
412+
this.setMaxPhysicOffset(phyOffset);
413413
long maxExtAddr = 1;
414414
boolean shouldDeleteFile = false;
415415
while (true) {
@@ -435,7 +435,7 @@ public void truncateDirtyLogicFiles(long phyOffset, boolean deleteFile) {
435435
mappedFile.setWrotePosition(pos);
436436
mappedFile.setCommittedPosition(pos);
437437
mappedFile.setFlushedPosition(pos);
438-
this.maxPhysicOffset = offset + size;
438+
this.setMaxPhysicOffset(offset + size);
439439
// This maybe not take effect, when not every consume queue has extend file.
440440
if (isExtAddr(tagsCode)) {
441441
maxExtAddr = tagsCode;
@@ -453,7 +453,7 @@ public void truncateDirtyLogicFiles(long phyOffset, boolean deleteFile) {
453453
mappedFile.setWrotePosition(pos);
454454
mappedFile.setCommittedPosition(pos);
455455
mappedFile.setFlushedPosition(pos);
456-
this.maxPhysicOffset = offset + size;
456+
this.setMaxPhysicOffset(offset + size);
457457
if (isExtAddr(tagsCode)) {
458458
maxExtAddr = tagsCode;
459459
}
@@ -881,8 +881,8 @@ private void removeWaitStorePropertyString(MessageExtBrokerInner msgInner) {
881881
private boolean putMessagePositionInfo(final long offset, final int size, final long tagsCode,
882882
final long cqOffset) {
883883

884-
if (offset + size <= this.maxPhysicOffset) {
885-
log.warn("Maybe try to build consume queue repeatedly maxPhysicOffset={} phyOffset={}", maxPhysicOffset, offset);
884+
if (offset + size <= this.getMaxPhysicOffset()) {
885+
log.warn("Maybe try to build consume queue repeatedly maxPhysicOffset={} phyOffset={}", this.getMaxPhysicOffset(), offset);
886886
return true;
887887
}
888888

@@ -926,7 +926,7 @@ private boolean putMessagePositionInfo(final long offset, final int size, final
926926
);
927927
}
928928
}
929-
this.maxPhysicOffset = offset + size;
929+
this.setMaxPhysicOffset(offset + size);
930930
return mappedFile.appendMessage(this.byteBufferIndex.array());
931931
}
932932
return false;
@@ -1130,7 +1130,7 @@ public void setMaxPhysicOffset(long maxPhysicOffset) {
11301130

11311131
@Override
11321132
public void destroy() {
1133-
this.maxPhysicOffset = -1;
1133+
this.setMaxPhysicOffset(-1);
11341134
this.minLogicOffset = 0;
11351135
this.mappedFileQueue.destroy();
11361136
if (isExtReadEnable()) {

store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java

+15-11
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public long howMuchFallBehind() {
285285
if (this.mappedFiles.isEmpty())
286286
return 0;
287287

288-
long committed = this.flushedWhere;
288+
long committed = this.getFlushedWhere();
289289
if (committed != 0) {
290290
MappedFile mappedFile = this.getLastMappedFile(0, false);
291291
if (mappedFile != null) {
@@ -442,11 +442,11 @@ public long getMaxWrotePosition() {
442442
}
443443

444444
public long remainHowManyDataToCommit() {
445-
return getMaxWrotePosition() - committedWhere;
445+
return getMaxWrotePosition() - getCommittedWhere();
446446
}
447447

448448
public long remainHowManyDataToFlush() {
449-
return getMaxOffset() - flushedWhere;
449+
return getMaxOffset() - this.getFlushedWhere();
450450
}
451451

452452
public void deleteLastMappedFile() {
@@ -616,15 +616,15 @@ public int deleteExpiredFileByOffsetForTimerLog(long offset, int checkOffset, in
616616

617617
public boolean flush(final int flushLeastPages) {
618618
boolean result = true;
619-
MappedFile mappedFile = this.findMappedFileByOffset(this.flushedWhere, this.flushedWhere == 0);
619+
MappedFile mappedFile = this.findMappedFileByOffset(this.getFlushedWhere(), this.getFlushedWhere() == 0);
620620
if (mappedFile != null) {
621621
long tmpTimeStamp = mappedFile.getStoreTimestamp();
622622
int offset = mappedFile.flush(flushLeastPages);
623623
long where = mappedFile.getFileFromOffset() + offset;
624-
result = where == this.flushedWhere;
625-
this.flushedWhere = where;
624+
result = where == this.getFlushedWhere();
625+
this.setFlushedWhere(where);
626626
if (0 == flushLeastPages) {
627-
this.storeTimestamp = tmpTimeStamp;
627+
this.setStoreTimestamp(tmpTimeStamp);
628628
}
629629
}
630630

@@ -633,12 +633,12 @@ public boolean flush(final int flushLeastPages) {
633633

634634
public synchronized boolean commit(final int commitLeastPages) {
635635
boolean result = true;
636-
MappedFile mappedFile = this.findMappedFileByOffset(this.committedWhere, this.committedWhere == 0);
636+
MappedFile mappedFile = this.findMappedFileByOffset(this.getCommittedWhere(), this.getCommittedWhere() == 0);
637637
if (mappedFile != null) {
638638
int offset = mappedFile.commit(commitLeastPages);
639639
long where = mappedFile.getFileFromOffset() + offset;
640-
result = where == this.committedWhere;
641-
this.committedWhere = where;
640+
result = where == this.getCommittedWhere();
641+
this.setCommittedWhere(where);
642642
}
643643

644644
return result;
@@ -763,7 +763,7 @@ public void destroy() {
763763
mf.destroy(1000 * 3);
764764
}
765765
this.mappedFiles.clear();
766-
this.flushedWhere = 0;
766+
this.setFlushedWhere(0);
767767

768768
// delete parent directory
769769
File file = new File(storePath);
@@ -848,6 +848,10 @@ public long getStoreTimestamp() {
848848
return storeTimestamp;
849849
}
850850

851+
public void setStoreTimestamp(long storeTimestamp) {
852+
this.storeTimestamp = storeTimestamp;
853+
}
854+
851855
public List<MappedFile> getMappedFiles() {
852856
return mappedFiles;
853857
}

store/src/main/java/org/apache/rocketmq/store/MultiPathMappedFileQueue.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717
package org.apache.rocketmq.store;
1818

19-
2019
import java.util.Arrays;
2120
import java.util.HashSet;
2221
import java.util.Set;
@@ -113,8 +112,7 @@ public void destroy() {
113112
mf.destroy(1000 * 3);
114113
}
115114
this.mappedFiles.clear();
116-
this.flushedWhere = 0;
117-
115+
this.setFlushedWhere(0);
118116

119117
Set<String> storePathSet = getPaths();
120118
storePathSet.addAll(getReadonlyPaths());

0 commit comments

Comments
 (0)