use of com.swiftmq.tools.collection.IntRingBuffer in project swiftmq-ce by iitsoftware.
the class StableStore method init.
private void init() throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/init ...");
nFree = 0;
if (freePoolEnabled)
freePool = new IntRingBuffer[10];
filename = path + File.separatorChar + FILENAME;
emptyData = new byte[Page.PAGE_SIZE];
// emtpy
emptyData[0] = 1;
for (int i = 1; i < Page.PAGE_SIZE; i++) emptyData[i] = 0;
file = new RandomAccessFile(filename, "rw");
fileLength = file.length();
if (fileLength > 0) {
numberPages = (int) (fileLength / Page.PAGE_SIZE);
if (!offline)
shrinkFile();
} else
initialize(initialPages);
sync();
if (freePoolEnabled)
buildFreePageList();
if (!offline) {
Entity entity = ctx.filesList.createEntity();
entity.setName(FILENAME);
entity.createCommands();
ctx.filesList.addEntity(entity);
freeProp = entity.getProperty("free-pages");
usedProp = entity.getProperty("used-pages");
fileSizeProp = entity.getProperty("file-size");
sizeCollectProp = ctx.dbEntity.getProperty("size-collect-interval");
collectInterval = (long) (Long) sizeCollectProp.getValue();
startTimer();
PropertyChangeListener propChangeListener = new PropertyChangeListener() {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
stopTimer();
collectInterval = (Long) newValue;
startTimer();
}
};
sizeCollectProp.setPropertyChangeListener(propChangeListener);
swiftletManagerAdapter = new SwiftletManagerAdapter() {
public void swiftletStarted(SwiftletManagerEvent event) {
mgmtSwiftlet = (MgmtSwiftlet) SwiftletManager.getInstance().getSwiftlet("sys$mgmt");
mgmtSwiftlet.addMgmtListener(StableStore.this);
}
};
SwiftletManager.getInstance().addSwiftletManagerListener("sys$mgmt", swiftletManagerAdapter);
}
ctx.logSwiftlet.logInformation("sys$store", toString() + "/init done, size=" + numberPages + ", freePages=" + getNumberFreePages());
}
Aggregations