Search in sources :

Example 11 with CairoEngine

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").$();
}
Also used : PropServerConfiguration(io.questdb.PropServerConfiguration) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) Properties(java.util.Properties) CairoEngine(io.questdb.cairo.CairoEngine) File(java.io.File) IOException(java.io.IOException)

Example 12 with CairoEngine

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();
}
Also used : SqlExecutionContextImpl(io.questdb.griffin.SqlExecutionContextImpl) SqlCompiler(io.questdb.griffin.SqlCompiler) CairoEngine(io.questdb.cairo.CairoEngine) BeforeClass(org.junit.BeforeClass)

Example 13 with CairoEngine

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);
}
Also used : CairoSecurityContextImpl(io.questdb.cairo.security.CairoSecurityContextImpl) DefaultCairoConfiguration(io.questdb.cairo.DefaultCairoConfiguration) CairoEngine(io.questdb.cairo.CairoEngine) CairoConfiguration(io.questdb.cairo.CairoConfiguration) DefaultCairoConfiguration(io.questdb.cairo.DefaultCairoConfiguration) BeforeClass(org.junit.BeforeClass)

Example 14 with CairoEngine

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);
        }
    });
}
Also used : Path(io.questdb.std.str.Path) CairoEngine(io.questdb.cairo.CairoEngine) Test(org.junit.Test) AbstractCairoTest(io.questdb.cairo.AbstractCairoTest)

Example 15 with CairoEngine

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");
            }
        }
    });
}
Also used : SqlExecutionContextImpl(io.questdb.griffin.SqlExecutionContextImpl) SqlCompiler(io.questdb.griffin.SqlCompiler) SqlExecutionContext(io.questdb.griffin.SqlExecutionContext) SqlException(io.questdb.griffin.SqlException) DefaultCairoConfiguration(io.questdb.cairo.DefaultCairoConfiguration) CairoEngine(io.questdb.cairo.CairoEngine) DefaultCairoConfiguration(io.questdb.cairo.DefaultCairoConfiguration) CairoConfiguration(io.questdb.cairo.CairoConfiguration) Test(org.junit.Test) AbstractCairoTest(io.questdb.cairo.AbstractCairoTest)

Aggregations

CairoEngine (io.questdb.cairo.CairoEngine)15 DefaultCairoConfiguration (io.questdb.cairo.DefaultCairoConfiguration)9 CairoConfiguration (io.questdb.cairo.CairoConfiguration)7 SqlCompiler (io.questdb.griffin.SqlCompiler)7 SqlExecutionContextImpl (io.questdb.griffin.SqlExecutionContextImpl)7 Test (org.junit.Test)7 AbstractCairoTest (io.questdb.cairo.AbstractCairoTest)5 TableWriter (io.questdb.cairo.TableWriter)3 SqlExecutionContext (io.questdb.griffin.SqlExecutionContext)3 WorkerPool (io.questdb.mp.WorkerPool)3 WorkerPoolConfiguration (io.questdb.mp.WorkerPoolConfiguration)3 Record (io.questdb.cairo.sql.Record)2 RecordCursor (io.questdb.cairo.sql.RecordCursor)2 RecordCursorFactory (io.questdb.cairo.sql.RecordCursorFactory)2 File (java.io.File)2 IOException (java.io.IOException)2 BeforeClass (org.junit.BeforeClass)2 LoopInterruptedCheck (de.invesdwin.util.concurrent.loop.LoopInterruptedCheck)1 Instant (de.invesdwin.util.time.Instant)1 FDate (de.invesdwin.util.time.date.FDate)1