Search in sources :

Example 16 with BufferManagerImpl

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;
}
Also used : BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl)

Example 17 with BufferManagerImpl

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);
}
Also used : BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl)

Example 18 with BufferManagerImpl

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());
}
Also used : BufferFrontedFileStoreCache(org.teiid.common.buffer.impl.BufferFrontedFileStoreCache) ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) Test(org.junit.Test)

Example 19 with BufferManagerImpl

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());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) CollectionTupleSource(org.teiid.query.processor.CollectionTupleSource) Test(org.junit.Test)

Example 20 with BufferManagerImpl

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());
}
Also used : BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) HashMap(java.util.HashMap) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) DefaultCacheFactory(org.teiid.cache.DefaultCacheFactory) FakeBufferService(org.teiid.dqp.service.FakeBufferService) DataPolicyMetadata(org.teiid.adminapi.impl.DataPolicyMetadata) DataPolicy(org.teiid.adminapi.DataPolicy) FakeTransactionService(org.teiid.dqp.internal.datamgr.FakeTransactionService) AutoGenDataService(org.teiid.dqp.service.AutoGenDataService) CacheConfiguration(org.teiid.cache.CacheConfiguration) Before(org.junit.Before)

Aggregations

BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)34 Test (org.junit.Test)24 CommandContext (org.teiid.query.util.CommandContext)13 List (java.util.List)11 ArrayList (java.util.ArrayList)8 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)8 RequestMessage (org.teiid.client.RequestMessage)6 ResultsMessage (org.teiid.client.ResultsMessage)5 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)5 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)4 TupleSource (org.teiid.common.buffer.TupleSource)3 BufferFrontedFileStoreCache (org.teiid.common.buffer.impl.BufferFrontedFileStoreCache)3 FileStorageManager (org.teiid.common.buffer.impl.FileStorageManager)3 RegisterRequestParameter (org.teiid.query.processor.RegisterRequestParameter)3 Command (org.teiid.query.sql.lang.Command)3 BufferServiceImpl (org.teiid.services.BufferServiceImpl)3 HashMap (java.util.HashMap)2 BlockedException (org.teiid.common.buffer.BlockedException)2 BufferManager (org.teiid.common.buffer.BufferManager)2 TupleBatch (org.teiid.common.buffer.TupleBatch)2