@@ -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