use of org.exist.storage.dom.DOMFile in project exist by eXist-db.
the class XMLStatistics method genBufferStatus.
private void genBufferStatus(BrokerPool instance) throws SAXException {
final AttributesImpl atts = new AttributesImpl();
this.contentHandler.startElement(NAMESPACE, "buffers", PREFIX + ":buffers", atts);
final Configuration conf = instance.getConfiguration();
BFile db;
db = (BFile) conf.getProperty(CollectionStore.FILE_KEY_IN_CONFIG);
genBufferDetails(db.getIndexBufferStats(), db.getDataBufferStats(), "Collections storage (" + FileUtils.fileName(db.getFile()) + ")");
final DOMFile dom = (DOMFile) conf.getProperty(DOMFile.CONFIG_KEY_FOR_FILE);
genBufferDetails(dom.getIndexBufferStats(), dom.getDataBufferStats(), "Resource storage (" + FileUtils.fileName(dom.getFile()) + ")");
db = (BFile) conf.getProperty(NativeValueIndex.FILE_KEY_IN_CONFIG);
if (db != null) {
genBufferDetails(db.getIndexBufferStats(), db.getDataBufferStats(), "Values index (" + FileUtils.fileName(db.getFile()) + ")");
}
this.contentHandler.endElement(NAMESPACE, "buffers", PREFIX + ":buffers");
}
use of org.exist.storage.dom.DOMFile in project exist by eXist-db.
the class DOMFileRecoverTest method get.
@Test
public void get() throws EXistException, IOException, BTreeException {
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) {
// Recover and read the data
assertNotNull(broker);
TransactionManager mgr = pool.getTransactionManager();
assertNotNull(mgr);
DOMFile domDb = ((NativeBroker) broker).getDOMFile();
assertNotNull(domDb);
domDb.setOwnerObject(this);
IndexQuery query = new IndexQuery(IndexQuery.GT, new NativeBroker.NodeRef(500));
assertNotNull(query);
List<?> keys = domDb.findKeys(query);
assertNotNull(keys);
int count = 0;
for (Iterator<?> i = keys.iterator(); i.hasNext(); count++) {
Value key = (Value) i.next();
assertNotNull(key);
Value value = domDb.get(key);
assertNotNull(value);
}
Writer writer = new StringWriter();
domDb.dump(writer);
}
}
use of org.exist.storage.dom.DOMFile in project exist by eXist-db.
the class BTreeRecoverTest method add.
private void add(final BrokerPool pool) throws EXistException, IOException, BTreeException, TerminatedException {
// Add some random data and force db corruption
final TransactionManager mgr = pool.getTransactionManager();
final NodeIdFactory idFact = pool.getNodeFactory();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) {
broker.flush();
final DOMFile domDb = ((NativeBroker) broker).getDOMFile();
domDb.setOwnerObject(this);
try (final Txn txn = mgr.beginTransaction()) {
// put 1000 values into the btree
for (int i = 1; i < 1001; i++) {
final NodeId id = idFact.createInstance(i);
domDb.addValue(txn, new NativeBroker.NodeRef(500, id), i);
}
final IndexQuery idx = new IndexQuery(IndexQuery.GT, new NativeBroker.NodeRef(500, idFact.createInstance(800)));
domDb.remove(txn, idx, null);
mgr.commit(txn);
}
// start a dirty, uncommitted transaction. This will be rolled back by the recovery.
final Txn txn = mgr.beginTransaction();
for (int i = 801; i < 2001; i++) {
domDb.addValue(txn, new NativeBroker.NodeRef(500, idFact.createInstance(i)), i);
}
for (int i = 101; i < 301; i++) {
domDb.addValue(txn, new NativeBroker.NodeRef(500, idFact.createInstance(i)), i * 3);
}
final IndexQuery idx = new IndexQuery(IndexQuery.GT, new NativeBroker.NodeRef(500, idFact.createInstance(600)));
domDb.remove(txn, idx, null);
// DO NOT COMMIT THE TRANSACTION!
pool.getJournalManager().get().flush(true, false);
}
}
use of org.exist.storage.dom.DOMFile in project exist by eXist-db.
the class BTreeRecoverTest method get.
private void get(final BrokerPool pool) throws EXistException, TerminatedException, IOException, BTreeException {
final NodeIdFactory idFact = pool.getNodeFactory();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) {
final DOMFile domDb = ((NativeBroker) broker).getDOMFile();
domDb.setOwnerObject(this);
final IndexQuery query = new IndexQuery(IndexQuery.GEQ, new NativeBroker.NodeRef(500, idFact.createInstance(1)));
domDb.query(query, new IndexCallback());
assertEquals(count, 800);
}
}
Aggregations