use of io.questdb.cairo.CairoEngine in project questdb by bluestreak01.
the class LineTcpO3Test method setUp.
@Override
@Before
public void setUp() {
LOG.info().$("setup engine").$();
try {
root = temp.newFolder("dbRoot").getAbsolutePath();
} catch (IOException e) {
throw new ExceptionInInitializerError();
}
PropServerConfiguration serverConf;
Properties properties = new Properties();
try (InputStream is = LineTcpO3Test.class.getResourceAsStream(LineTcpO3Test.class.getSimpleName() + ".server.conf")) {
File mimeTypesFile = new File(new File(root.toString(), PropServerConfiguration.CONFIG_DIRECTORY), "mime.types");
if (!mimeTypesFile.exists()) {
mimeTypesFile.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(mimeTypesFile);
fos.write('\n');
fos.close();
}
properties.load(is);
serverConf = new PropServerConfiguration(root.toString(), properties, null, LOG, null);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
configuration = serverConf.getCairoConfiguration();
lineConfiguration = serverConf.getLineTcpReceiverConfiguration();
sharedWorkerPoolConfiguration = serverConf.getWorkerPoolConfiguration();
engine = new CairoEngine(configuration);
messageBus = engine.getMessageBus();
LOG.info().$("setup engine completed").$();
}
use of io.questdb.cairo.CairoEngine in project questdb by bluestreak01.
the class TimestampSequenceFunctionFactoryTest method setUp2.
@BeforeClass
public static void setUp2() {
engine = new CairoEngine(new StaticClockCairoConfiguration(root));
compiler = new SqlCompiler(engine);
sqlExecutionContext = new SqlExecutionContextImpl(engine, 1).with(AllowAllCairoSecurityContext.INSTANCE, bindVariableService, null, -1, null);
bindVariableService.clear();
}
use of io.questdb.cairo.CairoEngine in project questdb by bluestreak01.
the class SecurityTest method setUpReadOnlyExecutionContext.
@BeforeClass
public static void setUpReadOnlyExecutionContext() {
CairoConfiguration readOnlyConfiguration = new DefaultCairoConfiguration(root) {
@Override
public int getSqlMapPageSize() {
return 64;
}
@Override
public int getSqlMapMaxResizes() {
return 2;
}
@Override
public long getSqlSortKeyPageSize() {
return 64;
}
@Override
public int getSqlSortKeyMaxPages() {
return 2;
}
@Override
public int getSqlJoinMetadataPageSize() {
return 64;
}
@Override
public int getSqlJoinMetadataMaxResizes() {
return 10;
}
@Override
public long getSqlSortLightValuePageSize() {
return 1024;
}
@Override
public int getSqlSortLightValueMaxPages() {
return 11;
}
};
memoryRestrictedEngine = new CairoEngine(readOnlyConfiguration);
SqlExecutionInterruptor dummyInterruptor = () -> {
int nCalls = nCheckInterruptedCalls.incrementAndGet();
int max = maxNCheckInterruptedCalls;
if (nCalls > max) {
throw CairoException.instance(0).put("Interrupting SQL processing, max calls is ").put(max);
}
};
readOnlyExecutionContext = new SqlExecutionContextImpl(memoryRestrictedEngine, 1).with(new CairoSecurityContextImpl(false), bindVariableService, null, -1, dummyInterruptor);
memoryRestrictedCompiler = new SqlCompiler(memoryRestrictedEngine);
}
use of io.questdb.cairo.CairoEngine in project questdb by bluestreak01.
the class TelemetryTest method testTelemetryCreatesTablesWhenEnabled.
@Test
public void testTelemetryCreatesTablesWhenEnabled() throws Exception {
TestUtils.assertMemoryLeak(() -> {
try (CairoEngine engine = new CairoEngine(configuration)) {
final TelemetryJob telemetryJob = new TelemetryJob(engine, null);
try (Path path = new Path()) {
Assert.assertEquals(TableUtils.TABLE_EXISTS, TableUtils.exists(FF, path, root, "telemetry"));
Assert.assertEquals(TableUtils.TABLE_EXISTS, TableUtils.exists(FF, path, root, "telemetry_config"));
}
Misc.free(telemetryJob);
}
});
}
use of io.questdb.cairo.CairoEngine in project questdb by bluestreak01.
the class TelemetryTest method testTelemetryCanDeleteTableWhenDisabled.
@Test
public void testTelemetryCanDeleteTableWhenDisabled() throws Exception {
CairoConfiguration configuration = new DefaultCairoConfiguration(root) {
@Override
public TelemetryConfiguration getTelemetryConfiguration() {
return new DefaultTelemetryConfiguration() {
@Override
public boolean getEnabled() {
return false;
}
};
}
};
TestUtils.assertMemoryLeak(() -> {
try (CairoEngine engine = new CairoEngine(configuration);
SqlCompiler compiler = new SqlCompiler(engine, null);
TelemetryJob ignored = new TelemetryJob(engine);
SqlExecutionContext sqlExecutionContext = new SqlExecutionContextImpl(engine, 1)) {
try {
compiler.compile("drop table telemetry", sqlExecutionContext);
Assert.fail();
} catch (SqlException e) {
TestUtils.assertContains(e.getFlyweightMessage(), "table 'telemetry' does not exist");
}
}
});
}
Aggregations