use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class BufferManagerFactory method getStandaloneBufferManager.
/**
* Helper to get a buffer manager all set up for unmanaged standalone use. This is
* typically used for testing or when memory is not an issue.
* @return BufferManager ready for use
*/
public static BufferManager getStandaloneBufferManager() {
if (INSTANCE == null) {
BufferManagerImpl bufferMgr = createBufferManager();
INSTANCE = bufferMgr;
}
return INSTANCE;
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class BufferManagerFactory method getTestBufferManager.
public static BufferManagerImpl getTestBufferManager(long bytesAvailable, int procBatchSize) {
BufferManagerImpl bufferManager = new BufferManagerImpl();
bufferManager.setProcessorBatchSize(procBatchSize);
bufferManager.setMaxProcessingKB((int) (bytesAvailable / 1024));
bufferManager.setMaxReserveKB((int) (bytesAvailable / 1024));
return initBufferManager(bufferManager);
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestSTree method testStorageWrites.
@Test
public void testStorageWrites() throws TeiidComponentException {
BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
bm.setProcessorBatchSize(32);
// force all to disk
bm.setMaxReserveKB(0);
BufferFrontedFileStoreCache fsc = (BufferFrontedFileStoreCache) bm.getCache();
fsc.setMaxStorageObjectSize(1 << 19);
fsc.setMemoryBufferSpace(1 << 19);
fsc.initialize();
bm.initialize();
ElementSymbol e1 = new ElementSymbol("x");
e1.setType(String.class);
List<ElementSymbol> elements = Arrays.asList(e1);
STree map = bm.createSTree(elements, "1", 1);
int size = 1000;
for (int i = 0; i < size; i++) {
assertNull(map.insert(Arrays.asList(new String(new byte[1000])), InsertMode.ORDERED, size));
assertEquals(i + 1, map.getRowCount());
}
for (int i = 0; i < size; i++) {
assertNotNull(map.remove(Arrays.asList(new String(new byte[1000]))));
}
assertEquals(0, map.getRowCount());
assertEquals(0, bm.getActiveBatchBytes());
map.remove();
assertEquals(0, bm.getActiveBatchBytes());
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestSTree method testTupleBrowserRemove.
@Test
public void testTupleBrowserRemove() throws Exception {
BufferManagerImpl bm = BufferManagerFactory.getTestBufferManager(1, 1);
ElementSymbol e1 = new ElementSymbol("x");
e1.setType(Integer.class);
ElementSymbol e2 = new ElementSymbol("x");
e2.setType(Integer.class);
List<ElementSymbol> elements = Arrays.asList(e1, e2);
STree map = bm.createSTree(elements, "1", 2);
map.insert(Arrays.asList(1, 1), InsertMode.NEW, -1);
TupleBrowser tb = new TupleBrowser(map, new CollectionTupleSource(Collections.singletonList(Arrays.asList(1)).iterator()), true, false);
assertNotNull(tb.nextTuple());
tb.removed();
assertEquals(Integer.valueOf(0), tb.getValueCount());
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestDQPCore method setUp.
@Before
public void setUp() throws Exception {
agds = new AutoGenDataService();
DQPWorkContext context = RealMetadataFactory.buildWorkContext(RealMetadataFactory.createTransformationMetadata(RealMetadataFactory.exampleBQTCached().getMetadataStore(), "bqt"));
// $NON-NLS-1$
context.getVDB().getModel("BQT3").setVisible(false);
// $NON-NLS-1$
context.getVDB().getModel("VQT").setVisible(false);
HashMap<String, DataPolicy> policies = new HashMap<String, DataPolicy>();
policies.put("foo", new DataPolicyMetadata());
context.setPolicies(policies);
ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
context.getVDB().addAttchment(ConnectorManagerRepository.class, repo);
Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(agds);
BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
bm.setInlineLobs(false);
FakeBufferService bs = new FakeBufferService(bm, bm);
core = new DQPCore();
core.setBufferManager(bs.getBufferManager());
core.setResultsetCache(new SessionAwareCache<CachedResults>("resultset", new DefaultCacheFactory(new CacheConfiguration()), SessionAwareCache.Type.RESULTSET, 0));
core.setPreparedPlanCache(new SessionAwareCache<PreparedPlan>("preparedplan", new DefaultCacheFactory(new CacheConfiguration()), SessionAwareCache.Type.PREPAREDPLAN, 0));
core.setTransactionService(new FakeTransactionService());
config = new DQPConfiguration();
config.setMaxActivePlans(1);
config.setUserRequestSourceConcurrency(2);
DefaultAuthorizationValidator daa = new DefaultAuthorizationValidator();
daa.setPolicyDecider(new DataRolePolicyDecider());
config.setAuthorizationValidator(daa);
core.start(config);
core.getPrepPlanCache().setModTime(1);
core.getRsCache().setTupleBufferCache(bs.getBufferManager());
}
Aggregations