use of org.teiid.services.BufferServiceImpl in project teiid by teiid.
the class TestLocalBufferService method testCheckMemPropertyGotSet.
@Test
public void testCheckMemPropertyGotSet() throws Exception {
BufferServiceImpl svc = new BufferServiceImpl();
svc.setDiskDirectory(UnitTestUtil.getTestScratchPath() + "/teiid/1");
svc.setUseDisk(true);
svc.setInlineLobs(false);
svc.start();
// all the properties are set
// $NON-NLS-1$
assertTrue("Not Directory", svc.getBufferDirectory().isDirectory());
// $NON-NLS-1$
assertTrue("does not exist", svc.getBufferDirectory().exists());
// $NON-NLS-1$ //$NON-NLS-2$
assertTrue("does not end with one", svc.getBufferDirectory().getParent().endsWith("1"));
assertTrue(svc.isUseDisk());
assertFalse(svc.isInlineLobs());
BufferManagerImpl mgr = svc.getBufferManager();
SplittableStorageManager ssm = (SplittableStorageManager) ((BufferFrontedFileStoreCache) mgr.getCache()).getStorageManager();
assertTrue(((FileStorageManager) ssm.getStorageManager()).getDirectory().endsWith(svc.getBufferDirectory().getName()));
}
use of org.teiid.services.BufferServiceImpl 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);
}
use of org.teiid.services.BufferServiceImpl in project teiid by teiid.
the class TestLocalBufferService method testSchemaSize.
@Test
public void testSchemaSize() throws Exception {
// 82 strings of Total Length 2515 charcacters
// 11 Dates
// 1 Long
// 1 short
// 20 bigdecimal with 671 total integers in them.
List<Expression> schema = new ArrayList<Expression>();
for (int i = 0; i < 82; i++) {
schema.add(new Constant(null, DataTypeManager.DefaultDataClasses.STRING));
}
for (int i = 0; i < 11; i++) {
schema.add(new Constant(null, DataTypeManager.DefaultDataClasses.DATE));
}
schema.add(new Constant(null, DataTypeManager.DefaultDataClasses.LONG));
schema.add(new Constant(null, DataTypeManager.DefaultDataClasses.SHORT));
for (int i = 0; i < 20; i++) {
schema.add(new Constant(null, DataTypeManager.DefaultDataClasses.BIG_DECIMAL));
}
BufferServiceImpl svc = new BufferServiceImpl();
svc.setDiskDirectory(UnitTestUtil.getTestScratchPath() + "/teiid/1");
svc.setUseDisk(false);
svc.start();
BufferManager mgr = svc.getBufferManager();
assertEquals(3364096, mgr.getSchemaSize(schema));
assertEquals(128, mgr.getProcessorBatchSize(schema));
}
use of org.teiid.services.BufferServiceImpl in project teiid by teiid.
the class TestLocalBufferService method testStateTransfer.
@Test
public void testStateTransfer() throws Exception {
BufferServiceImpl svc = new BufferServiceImpl();
svc.setDiskDirectory(UnitTestUtil.getTestScratchPath() + "/teiid/1");
svc.setUseDisk(true);
svc.start();
BufferManager mgr = svc.getBufferManager();
List<ElementSymbol> schema = new ArrayList<ElementSymbol>(2);
// $NON-NLS-1$
ElementSymbol es = new ElementSymbol("x");
es.setType(DataTypeManager.getDataTypeClass(DefaultDataTypes.STRING));
schema.add(es);
// $NON-NLS-1$
ElementSymbol es2 = new ElementSymbol("y");
es2.setType(DataTypeManager.getDataTypeClass(DefaultDataTypes.INTEGER));
schema.add(es2);
// $NON-NLS-1$
TupleBuffer buffer = mgr.createTupleBuffer(schema, "cached", TupleSourceType.FINAL);
buffer.setBatchSize(50);
buffer.setId("state_id");
for (int batch = 0; batch < 3; batch++) {
for (int row = 0; row < 50; row++) {
int val = (batch * 50) + row;
buffer.addTuple(Arrays.asList(new Object[] { "String" + val, new Integer(val) }));
}
}
buffer.close();
mgr.distributeTupleBuffer(buffer.getId(), buffer);
FileOutputStream fo = new FileOutputStream(UnitTestUtil.getTestScratchPath() + "/teiid/statetest");
((BufferManagerImpl) mgr).getState(buffer.getId(), fo);
fo.close();
svc.stop();
// now read back
BufferServiceImpl svc2 = new BufferServiceImpl();
svc2.setDiskDirectory(UnitTestUtil.getTestScratchPath() + "/teiid/2");
svc2.setUseDisk(true);
svc2.start();
BufferManagerImpl mgr2 = svc2.getBufferManager();
FileInputStream fis = new FileInputStream(UnitTestUtil.getTestScratchPath() + "/teiid/statetest");
mgr2.setState(buffer.getId(), fis);
fis.close();
String id = "state_id";
buffer = mgr2.getTupleBuffer(id);
for (int batch = 0; batch < 3; batch++) {
TupleBatch tb = buffer.getBatch((batch * 50) + 1);
List[] rows = tb.getAllTuples();
for (int row = 0; row < 50; row++) {
int val = (batch * 50) + row;
assertEquals("String" + val, rows[row].get(0));
assertEquals(val, rows[row].get(1));
}
}
svc2.stop();
}
use of org.teiid.services.BufferServiceImpl in project teiid by teiid.
the class TestLocalBufferService method testCheckMemPropertyGotSet2.
@Test
public void testCheckMemPropertyGotSet2() throws Exception {
BufferServiceImpl svc = new BufferServiceImpl();
svc.setDiskDirectory(UnitTestUtil.getTestScratchPath() + "/teiid/1");
svc.setUseDisk(false);
svc.start();
// all the properties are set
assertFalse(svc.isUseDisk());
}
Aggregations