Search in sources :

Example 1 with WriterFactory

use of com.questdb.store.factory.WriterFactory in project questdb by bluestreak01.

the class HttpServerTest method testImportIntoBusyJournal2.

@Test
public void testImportIntoBusyJournal2() throws Exception {
    WriterFactory f = getFactory();
    try (JournalWriter w = f.writer(new JournalStructure("small.csv").$int("X").$int("Y").$())) {
        JournalEntryWriter ew = w.entryWriter();
        ew.putInt(0, 3);
        ew.putInt(1, 30);
        ew.append();
        w.commit();
        BootstrapEnv env = new BootstrapEnv();
        env.configuration = new ServerConfiguration();
        env.factory = getFactory();
        env.typeProbeCollection = TYPE_PROBE_COLLECTION;
        env.matcher = new SimpleUrlMatcher() {

            {
                put("/imp", new ImportHandler(env));
            }
        };
        HttpServer server = new HttpServer(env);
        server.start();
        StringBuilder response = new StringBuilder();
        try {
            Assert.assertEquals(200, HttpTestUtils.upload("/csv/small.csv", "http://localhost:9000/imp?fmt=json", null, response));
            Assert.assertTrue(Chars.startsWith(response, "{\"status\":\"com.questdb.ex.WriterBusyException\"}"));
        } catch (IOException e) {
            Assert.assertTrue(e.getMessage().contains("Connection reset"));
        } finally {
            server.halt();
        }
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) BootstrapEnv(com.questdb.BootstrapEnv) WriterFactory(com.questdb.store.factory.WriterFactory) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) ServerConfiguration(com.questdb.ServerConfiguration) ImportHandler(com.questdb.net.http.handlers.ImportHandler) JournalEntryWriter(com.questdb.store.JournalEntryWriter) AbstractJournalTest(com.questdb.net.ha.AbstractJournalTest) Test(org.junit.Test)

Aggregations

BootstrapEnv (com.questdb.BootstrapEnv)1 ServerConfiguration (com.questdb.ServerConfiguration)1 AbstractJournalTest (com.questdb.net.ha.AbstractJournalTest)1 ImportHandler (com.questdb.net.http.handlers.ImportHandler)1 JournalEntryWriter (com.questdb.store.JournalEntryWriter)1 JournalWriter (com.questdb.store.JournalWriter)1 WriterFactory (com.questdb.store.factory.WriterFactory)1 JournalStructure (com.questdb.store.factory.configuration.JournalStructure)1 Test (org.junit.Test)1