Search in sources :

Example 6 with NetworkFacadeImpl

use of io.questdb.network.NetworkFacadeImpl in project questdb by bluestreak01.

the class LinuxLineUdpProtoReceiverTest method assertCannotJoin.

private void assertCannotJoin(ReceiverFactory factory) throws Exception {
    TestUtils.assertMemoryLeak(() -> {
        NetworkFacade nf = new NetworkFacadeImpl() {

            @Override
            public boolean join(long fd, int bindIPv4Address, int groupIPv4Address) {
                return false;
            }
        };
        LineUdpReceiverConfiguration receiverCfg = new DefaultLineUdpReceiverConfiguration() {

            @Override
            public NetworkFacade getNetworkFacade() {
                return nf;
            }
        };
        assertConstructorFail(receiverCfg, factory);
    });
}
Also used : NetworkFacade(io.questdb.network.NetworkFacade) NetworkFacadeImpl(io.questdb.network.NetworkFacadeImpl)

Example 7 with NetworkFacadeImpl

use of io.questdb.network.NetworkFacadeImpl in project questdb by bluestreak01.

the class TestUtils method getSendDelayNetworkFacade.

@NotNull
public static NetworkFacade getSendDelayNetworkFacade(int startDelayDelayAfter) {
    return new NetworkFacadeImpl() {

        final AtomicInteger totalSent = new AtomicInteger();

        @Override
        public int send(long fd, long buffer, int bufferLen) {
            if (startDelayDelayAfter == 0) {
                return super.send(fd, buffer, bufferLen);
            }
            int sentNow = totalSent.get();
            if (bufferLen > 0) {
                if (sentNow >= startDelayDelayAfter) {
                    totalSent.set(0);
                    return 0;
                }
                int result = super.send(fd, buffer, Math.min(bufferLen, startDelayDelayAfter - sentNow));
                totalSent.addAndGet(result);
                return result;
            }
            return 0;
        }
    };
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NetworkFacadeImpl(io.questdb.network.NetworkFacadeImpl) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NetworkFacadeImpl (io.questdb.network.NetworkFacadeImpl)7 NetworkFacade (io.questdb.network.NetworkFacade)6 StaticContentProcessor (io.questdb.cutlass.http.processors.StaticContentProcessor)1 TextImportProcessor (io.questdb.cutlass.http.processors.TextImportProcessor)1 SOCountDownLatch (io.questdb.mp.SOCountDownLatch)1 WorkerPool (io.questdb.mp.WorkerPool)1 WorkerPoolConfiguration (io.questdb.mp.WorkerPoolConfiguration)1 DefaultIODispatcherConfiguration (io.questdb.network.DefaultIODispatcherConfiguration)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 NotNull (org.jetbrains.annotations.NotNull)1