Comments (4)
第四个文件应该是没写满,所以应该不删除掉,但是第二个��
�件不删掉,说不过去
Original comment by [email protected]
on 2 Dec 2011 at 1:57
from fqueue.
我应该找到原因了,2和4是通过FileRunner创建的,方法create(Stri
ng
path)创建的,但并未关闭,所以导致后来poll完,删除不了。��
�改如下,测试文件2成功删除了。
-------------------------------------------------------------
private boolean create(String path) throws IOException {
File file = new File(path);
if (file.exists() == false) {
if (file.createNewFile() == false) {
return false;
}
RandomAccessFile raFile = new RandomAccessFile(file, "rwd");
FileChannel fc = raFile.getChannel();
final MappedByteBuffer mappedByteBuffer = fc.map(MapMode.READ_WRITE, 0, this.fileLimitLength);
mappedByteBuffer.put(LogEntity.MAGIC.getBytes());
mappedByteBuffer.putInt(1);// 8 version
mappedByteBuffer.putInt(-1);// 12next fileindex
mappedByteBuffer.putInt(-2);// 16
mappedByteBuffer.force();
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
try {
Method getCleanerMethod = mappedByteBuffer.getClass()
.getMethod("cleaner", new Class[0]);
getCleanerMethod.setAccessible(true);
sun.misc.Cleaner cleaner = (sun.misc.Cleaner) getCleanerMethod
.invoke(mappedByteBuffer, new Object[0]);
cleaner.clean();
mappedByteBuffer.clear();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
});
fc.close();
raFile.close();
return true;
} else {
return false;
}
}
-------------------------------------------------------------
Original comment by [email protected]
on 2 Dec 2011 at 3:42
from fqueue.
可能会有这个bug,在写入的时候,做过类似的处理。
我现在转到linux平台在开发,所以这个问题我没有发现,谢谢
你的提出。
Original comment by [email protected]
on 5 Dec 2011 at 7:43
from fqueue.
Original comment by [email protected]
on 21 Mar 2012 at 2:19
- Changed state: Fixed
- Added labels: Priority-High
- Removed labels: Priority-Medium
from fqueue.
Related Issues (11)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fqueue.