Search in sources :

Example 16 with FilesFacadeImpl

use of io.questdb.std.FilesFacadeImpl in project questdb by bluestreak01.

the class O3FailureTest method testColumnTopMidMergeBlankFailRetryOpenRw2Contended.

@Test
public void testColumnTopMidMergeBlankFailRetryOpenRw2Contended() throws Exception {
    counter.set(3);
    executeWithPool(0, O3FailureTest::testColumnTopMidMergeBlankColumnFailRetry0, new FilesFacadeImpl() {

        @Override
        public long openRW(LPSZ name) {
            if (Chars.endsWith(name, "1970-01-06" + Files.SEPARATOR + "b.d") && counter.decrementAndGet() == 0) {
                return -1;
            }
            return super.openRW(name);
        }
    });
}
Also used : LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 17 with FilesFacadeImpl

use of io.questdb.std.FilesFacadeImpl in project questdb by bluestreak01.

the class O3FailureTest method testOOOFollowedByAnotherOOO.

@Test
public void testOOOFollowedByAnotherOOO() throws Exception {
    counter.set(1);
    final AtomicBoolean restoreDiskSpace = new AtomicBoolean(false);
    executeWithPool(0, (engine, compiler, sqlExecutionContext) -> testOooFollowedByAnotherOOO0(engine, compiler, sqlExecutionContext, restoreDiskSpace), new FilesFacadeImpl() {

        long theFd = 0;

        boolean armageddon = false;

        @Override
        public boolean close(long fd) {
            if (fd == theFd) {
                theFd = 0;
            }
            return super.close(fd);
        }

        @Override
        public long openRW(LPSZ name) {
            long fd = super.openRW(name);
            if (Chars.endsWith(name, "x" + Files.SEPARATOR + "1970-01-01.1" + Files.SEPARATOR + "m.d")) {
                if (counter.decrementAndGet() == 0) {
                    theFd = fd;
                }
            }
            return fd;
        }

        @Override
        public boolean allocate(long fd, long size) {
            if (restoreDiskSpace.get()) {
                return super.allocate(fd, size);
            }
            if (armageddon) {
                return false;
            }
            if (fd == theFd) {
                theFd = 0;
                armageddon = true;
                return false;
            }
            return super.allocate(fd, size);
        }
    });
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 18 with FilesFacadeImpl

use of io.questdb.std.FilesFacadeImpl in project questdb by bluestreak01.

the class O3FailureTest method testColumnTopMidMergeBlankFailRetryMergeFixMapRWContended.

@Test
public void testColumnTopMidMergeBlankFailRetryMergeFixMapRWContended() throws Exception {
    counter.set(1);
    executeWithPool(0, O3FailureTest::testColumnTopMidMergeBlankColumnFailRetry0, new FilesFacadeImpl() {

        long theFd = 0;

        @Override
        public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
            if (fd != theFd) {
                return super.mmap(fd, len, offset, flags, memoryTag);
            }
            theFd = 0;
            return -1;
        }

        @Override
        public long openRW(LPSZ name) {
            long fd = super.openRW(name);
            if (Chars.endsWith(name, "1970-01-06.14" + Files.SEPARATOR + "v8.d") && counter.decrementAndGet() == 0) {
                theFd = fd;
            }
            return fd;
        }
    });
}
Also used : LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 19 with FilesFacadeImpl

use of io.questdb.std.FilesFacadeImpl in project questdb by bluestreak01.

the class O3FailureTest method testPartitionedDataAppendOOData.

@Test
public void testPartitionedDataAppendOOData() throws Exception {
    counter.set(4);
    executeWithoutPool(O3FailureTest::testPartitionedDataAppendOODataFailRetry0, new FilesFacadeImpl() {

        private final AtomicInteger mapCounter = new AtomicInteger(2);

        private long theFd = 0;

        @Override
        public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
            if (theFd == fd && mapCounter.decrementAndGet() == 0) {
                theFd = 0;
                return -1;
            }
            return super.mmap(fd, len, offset, flags, memoryTag);
        }

        @Override
        public long openRW(LPSZ name) {
            long fd = super.openRW(name);
            if (Chars.endsWith(name, "ts.d") && counter.decrementAndGet() == 0) {
                theFd = fd;
            }
            return fd;
        }
    });
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 20 with FilesFacadeImpl

use of io.questdb.std.FilesFacadeImpl in project questdb by bluestreak01.

the class LineTcpConnectionContextTest method testCairoExceptionOnAddColumn.

@Test
public void testCairoExceptionOnAddColumn() throws Exception {
    String table = "columnEx";
    runInContext(new FilesFacadeImpl() {

        @Override
        public long openRW(LPSZ name) {
            if (Chars.endsWith(name, "broken.d")) {
                return -1;
            }
            return super.openRW(name);
        }
    }, () -> {
        recvBuffer = table + ",location=us-midwest temperature=82 1465839830100400200\n" + table + ",location=us-midwest temperature=83 1465839830100500200\n" + table + ",location=us-eastcoast temperature=81,broken=23 1465839830101400200\n" + table + ",location=us-midwest temperature=85 1465839830102300200\n" + table + ",location=us-eastcoast temperature=89 1465839830102400200\n" + table + ",location=us-eastcoast temperature=80 1465839830102400200\n" + table + ",location=us-westcost temperature=82 1465839830102500200\n";
        do {
            handleContextIO();
            Assert.assertFalse(disconnected);
        } while (recvBuffer.length() > 0);
        closeContext();
        String expected = "location\ttemperature\ttimestamp\n" + "us-midwest\t82.0\t2016-06-13T17:43:50.100400Z\n" + "us-midwest\t83.0\t2016-06-13T17:43:50.100500Z\n" + "us-midwest\t85.0\t2016-06-13T17:43:50.102300Z\n" + "us-eastcoast\t89.0\t2016-06-13T17:43:50.102400Z\n" + "us-eastcoast\t80.0\t2016-06-13T17:43:50.102400Z\n" + "us-westcost\t82.0\t2016-06-13T17:43:50.102500Z\n";
        assertTable(expected, table);
    }, null, null);
}
Also used : LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Aggregations

FilesFacadeImpl (io.questdb.std.FilesFacadeImpl)48 Test (org.junit.Test)46 LPSZ (io.questdb.std.str.LPSZ)35 FilesFacade (io.questdb.std.FilesFacade)14 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 Path (io.questdb.std.str.Path)4 RecordCursorFactory (io.questdb.cairo.sql.RecordCursorFactory)3 AbstractGriffinTest (io.questdb.griffin.AbstractGriffinTest)3 SqlCompiler (io.questdb.griffin.SqlCompiler)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 MemoryMARW (io.questdb.cairo.vm.api.MemoryMARW)1 LineTcpSender (io.questdb.cutlass.line.LineTcpSender)1 SqlException (io.questdb.griffin.SqlException)1 BindVariableServiceImpl (io.questdb.griffin.engine.functions.bind.BindVariableServiceImpl)1 Rnd (io.questdb.std.Rnd)1 DateFormat (io.questdb.std.datetime.DateFormat)1 TimestampFormatCompiler (io.questdb.std.datetime.microtime.TimestampFormatCompiler)1 File (java.io.File)1