Skip to content

Commit 908f5ae

Browse files
author
guyinyou
committed
remove timerwheel mappedbytebuffer
Change-Id: If70c18789843d4fea3e6bd3348972e6896f080e5
1 parent bcd8268 commit 908f5ae

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

store/src/main/java/org/apache/rocketmq/store/timer/TimerWheel.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public class TimerWheel {
4545
private String fileName;
4646
private final RandomAccessFile randomAccessFile;
4747
private final FileChannel fileChannel;
48-
private MappedByteBuffer mappedByteBuffer;
4948
private final ByteBuffer byteBuffer;
5049
private final ThreadLocal<ByteBuffer> localBuffer = new ThreadLocal<ByteBuffer>() {
5150
@Override
@@ -80,10 +79,6 @@ public TimerWheel(String fileName, int slotsTotal, int precisionMs, long snapOff
8079
}
8180
randomAccessFile.setLength(wheelLength);
8281
fileChannel = randomAccessFile.getChannel();
83-
if (snapOffset < 0) {
84-
mappedByteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, wheelLength);
85-
assert wheelLength == mappedByteBuffer.remaining();
86-
}
8782
this.byteBuffer = ByteBuffer.allocateDirect(wheelLength);
8883
this.byteBuffer.put(Files.readAllBytes(file.toPath()));
8984
} catch (FileNotFoundException e) {
@@ -100,16 +95,6 @@ public void shutdown() {
10095
}
10196

10297
public void shutdown(boolean flush) {
103-
if (flush) {
104-
try {
105-
this.flush();
106-
} catch (Throwable e) {
107-
log.error("flush error when shutdown", e);
108-
}
109-
}
110-
111-
// unmap mappedByteBuffer
112-
UtilAll.cleanBuffer(this.mappedByteBuffer);
11398
UtilAll.cleanBuffer(this.byteBuffer);
11499
localBuffer.remove();
115100

@@ -120,20 +105,6 @@ public void shutdown(boolean flush) {
120105
}
121106
}
122107

123-
public void flush() {
124-
ByteBuffer bf = localBuffer.get();
125-
bf.position(0);
126-
bf.limit(wheelLength);
127-
mappedByteBuffer.position(0);
128-
mappedByteBuffer.limit(wheelLength);
129-
for (int i = 0; i < wheelLength; i++) {
130-
if (bf.get(i) != mappedByteBuffer.get(i)) {
131-
mappedByteBuffer.put(i, bf.get(i));
132-
}
133-
}
134-
this.mappedByteBuffer.force();
135-
}
136-
137108
/**
138109
* Perform backup operation.
139110
* <p>

0 commit comments

Comments
 (0)