Search in sources :

Example 21 with FileStore

use of org.teiid.common.buffer.FileStore in project teiid by teiid.

the class TestFileStorageManager method testGrowth.

@Test
public void testGrowth() throws Exception {
    FileStorageManager sm = getStorageManager(null, null);
    FileStore store = sm.createFileStore("0");
    FileStoreOutputStream fsos = store.createOutputStream(1 << 15);
    assertTrue(fsos.getBuffer().length < 1 << 15);
    fsos.write(1);
    fsos.write(new byte[1 << 14]);
    fsos.flush();
    assertEquals(1 + (1 << 14), fsos.getCount());
    assertEquals(1 << 15, fsos.getBuffer().length);
}
Also used : FileStore(org.teiid.common.buffer.FileStore) FileStoreOutputStream(org.teiid.common.buffer.FileStore.FileStoreOutputStream) Test(org.junit.Test)

Example 22 with FileStore

use of org.teiid.common.buffer.FileStore in project teiid by teiid.

the class TestFileStorageManager method testFlush.

@Test
public void testFlush() throws Exception {
    FileStorageManager sm = getStorageManager(null, null);
    FileStore store = sm.createFileStore("0");
    FileStoreOutputStream fsos = store.createOutputStream(2);
    fsos.write(new byte[3]);
    fsos.write(1);
    fsos.flush();
    assertEquals(0, fsos.getCount());
}
Also used : FileStore(org.teiid.common.buffer.FileStore) FileStoreOutputStream(org.teiid.common.buffer.FileStore.FileStoreOutputStream) Test(org.junit.Test)

Example 23 with FileStore

use of org.teiid.common.buffer.FileStore in project teiid by teiid.

the class TestSaveOnReadInputStream method getSaveOnReadInputStream.

private SaveOnReadInputStream getSaveOnReadInputStream() {
    FileStore fs = BufferManagerFactory.getStandaloneBufferManager().createFileStore("test");
    FileStoreInputStreamFactory factory = new FileStoreInputStreamFactory(fs, Streamable.ENCODING);
    InputStream is = new ByteArrayInputStream("hello world".getBytes(Streamable.CHARSET));
    SaveOnReadInputStream soris = new SaveOnReadInputStream(is, factory);
    return soris;
}
Also used : FileStore(org.teiid.common.buffer.FileStore) FileStoreInputStreamFactory(org.teiid.common.buffer.FileStoreInputStreamFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream)

Example 24 with FileStore

use of org.teiid.common.buffer.FileStore in project teiid by teiid.

the class TestLocalBufferService method testUseDiskFalse.

@Test
public void testUseDiskFalse() throws Exception {
    BufferServiceImpl svc = new BufferServiceImpl();
    svc.setDiskDirectory(UnitTestUtil.getTestScratchPath() + "/teiid/1");
    svc.setUseDisk(false);
    svc.start();
    // all the properties are set
    BufferManagerImpl mgr = svc.getBufferManager();
    FileStore f = mgr.getCache().createFileStore("x");
    f.write(new byte[1234], 0, 1234);
}
Also used : FileStore(org.teiid.common.buffer.FileStore) BufferServiceImpl(org.teiid.services.BufferServiceImpl) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) Test(org.junit.Test)

Aggregations

FileStore (org.teiid.common.buffer.FileStore)24 Test (org.junit.Test)14 FileStoreInputStreamFactory (org.teiid.common.buffer.FileStoreInputStreamFactory)7 InputStream (java.io.InputStream)5 IOException (java.io.IOException)4 FileStoreOutputStream (org.teiid.common.buffer.FileStore.FileStoreOutputStream)4 TeiidComponentException (org.teiid.core.TeiidComponentException)3 TeiidProcessingException (org.teiid.core.TeiidProcessingException)3 Reader (java.io.Reader)2 Writer (java.io.Writer)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FilterReader (java.io.FilterReader)1 ObjectInput (java.io.ObjectInput)1 ObjectInputStream (java.io.ObjectInputStream)1 OutputStream (java.io.OutputStream)1 SQLException (java.sql.SQLException)1 Lock (java.util.concurrent.locks.Lock)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 DataSource (javax.activation.DataSource)1