use of org.bboxdb.storage.memtable.Memtable in project bboxdb by jnidzwetzki.
the class TestMemtable method before.
@Before
public void before() {
memtable = new Memtable(MEMTABLE_TABLE_NAME, MEMTABLE_MAX_ENTRIES, MEMTABLE_MAX_SIZE);
memtable.init();
memtable.acquire();
}
use of org.bboxdb.storage.memtable.Memtable in project bboxdb by jnidzwetzki.
the class TestMemtable method testAquire2.
/**
* Test the aquire
* @throws StorageManagerException
*/
@Test(timeout = 60000)
public void testAquire2() throws StorageManagerException {
final Memtable memtable = new Memtable(MEMTABLE_TABLE_NAME, MEMTABLE_MAX_ENTRIES, MEMTABLE_MAX_SIZE);
memtable.init();
Assert.assertTrue(memtable.acquire());
final Tuple createdTuple1 = new Tuple("1", null, "abc".getBytes(), 60);
memtable.put(createdTuple1);
memtable.release();
Assert.assertEquals(3, memtable.getSize());
memtable.deleteOnClose();
Assert.assertEquals(0, memtable.getSize());
}
use of org.bboxdb.storage.memtable.Memtable in project bboxdb by jnidzwetzki.
the class TestMemtable method testAquire1.
/**
* Test the aquire
* @throws StorageManagerException
*/
@Test(timeout = 60000)
public void testAquire1() throws StorageManagerException {
final Memtable memtable = new Memtable(MEMTABLE_TABLE_NAME, MEMTABLE_MAX_ENTRIES, MEMTABLE_MAX_SIZE);
memtable.init();
Assert.assertTrue(memtable.acquire());
final Tuple createdTuple1 = new Tuple("1", null, "abc".getBytes(), 60);
memtable.put(createdTuple1);
memtable.deleteOnClose();
Assert.assertFalse(memtable.acquire());
Assert.assertEquals(1, memtable.get("1").size());
memtable.release();
Assert.assertEquals(0, memtable.getSize());
}
use of org.bboxdb.storage.memtable.Memtable in project bboxdb by jnidzwetzki.
the class TupleStoreManager method flush.
/**
* Flush all in memory data, if the memtable flush thread is running
* @return
*/
public boolean flush() {
final Memtable activeMemtable = tupleStoreInstances.getMemtable();
if (activeMemtable == null) {
return true;
}
// Flush in memory data
initNewMemtable();
try {
tupleStoreInstances.waitForMemtableFlush(activeMemtable);
} catch (InterruptedException e) {
logger.info("Got interrupted exception while waiting for memtable flush");
Thread.currentThread().interrupt();
return false;
} catch (StorageManagerException e) {
logger.info("Got exception while waiting for memtable flush", e);
return false;
}
return true;
}
use of org.bboxdb.storage.memtable.Memtable in project bboxdb by jnidzwetzki.
the class TupleStoreManager method initNewMemtable.
/**
* Open a new memtable and schedule the old memtable for flushing
* @throws StorageManagerException
*/
public synchronized void initNewMemtable() {
final Memtable memtable = new Memtable(tupleStoreName, configuration.getMemtableEntriesMax(), configuration.getMemtableSizeMax());
memtable.acquire();
memtable.init();
final Memtable oldMemtable = tupleStoreInstances.activateNewMemtable(memtable);
if (oldMemtable != null) {
final MemtableAndTupleStoreManagerPair memtableTask = new MemtableAndTupleStoreManagerPair(oldMemtable, this);
storage.scheduleMemtableFlush(memtableTask);
}
logger.debug("Activated a new memtable: {}", memtable.getInternalName());
}
Aggregations