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);
});
}
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;
}
};
}
Aggregations