use of org.apache.kafka.common.utils.LogContext in project apache-kafka-on-k8s by banzaicloud.
the class RocksDBStoreTest method setUp.
@Before
public void setUp() {
rocksDBStore = new RocksDBStore("test");
dir = TestUtils.tempDirectory();
context = new InternalMockProcessorContext(dir, Serdes.String(), Serdes.String(), new NoOpRecordCollector(), new ThreadCache(new LogContext("testCache "), 0, new MockStreamsMetrics(new Metrics())));
}
use of org.apache.kafka.common.utils.LogContext in project apache-kafka-on-k8s by banzaicloud.
the class SegmentsTest method createContext.
@Before
public void createContext() {
stateDirectory = TestUtils.tempDirectory();
context = new InternalMockProcessorContext(stateDirectory, Serdes.String(), Serdes.Long(), new NoOpRecordCollector(), new ThreadCache(new LogContext("testCache "), 0, new MockStreamsMetrics(new Metrics())));
segments = new Segments(storeName, retentionPeriod, NUM_SEGMENTS);
segmentInterval = Segments.segmentInterval(retentionPeriod, NUM_SEGMENTS);
}
use of org.apache.kafka.common.utils.LogContext in project apache-kafka-on-k8s by banzaicloud.
the class SslTransportLayerTest method testIOExceptionsDuringHandshake.
private void testIOExceptionsDuringHandshake(boolean failRead, boolean failWrite) throws Exception {
server = createEchoServer(SecurityProtocol.SSL);
TestSslChannelBuilder channelBuilder = new TestSslChannelBuilder(Mode.CLIENT);
boolean done = false;
for (int i = 1; i <= 100; i++) {
int readFailureIndex = failRead ? i : Integer.MAX_VALUE;
int flushFailureIndex = failWrite ? i : Integer.MAX_VALUE;
String node = String.valueOf(i);
channelBuilder.readFailureIndex = readFailureIndex;
channelBuilder.flushFailureIndex = flushFailureIndex;
channelBuilder.configure(sslClientConfigs);
this.selector = new Selector(5000, new Metrics(), new MockTime(), "MetricGroup", channelBuilder, new LogContext());
InetSocketAddress addr = new InetSocketAddress("localhost", server.port());
selector.connect(node, addr, BUFFER_SIZE, BUFFER_SIZE);
for (int j = 0; j < 30; j++) {
selector.poll(1000L);
KafkaChannel channel = selector.channel(node);
if (channel != null && channel.ready()) {
done = true;
break;
}
if (selector.disconnected().containsKey(node)) {
assertEquals(ChannelState.State.AUTHENTICATE, selector.disconnected().get(node).state());
break;
}
}
KafkaChannel channel = selector.channel(node);
if (channel != null)
assertTrue("Channel not ready or disconnected:" + channel.state().state(), channel.ready());
}
assertTrue("Too many invocations of read/write during SslTransportLayer.handshake()", done);
}
use of org.apache.kafka.common.utils.LogContext in project apache-kafka-on-k8s by banzaicloud.
the class SelectorTest method setUp.
@Before
public void setUp() throws Exception {
Map<String, Object> configs = new HashMap<>();
this.server = new EchoServer(SecurityProtocol.PLAINTEXT, configs);
this.server.start();
this.time = new MockTime();
this.channelBuilder = new PlaintextChannelBuilder();
this.channelBuilder.configure(configs);
this.metrics = new Metrics();
this.selector = new Selector(5000, this.metrics, time, "MetricGroup", channelBuilder, new LogContext());
}
use of org.apache.kafka.common.utils.LogContext in project apache-kafka-on-k8s by banzaicloud.
the class SelectorTest method registerFailure.
@Test
public void registerFailure() throws Exception {
ChannelBuilder channelBuilder = new PlaintextChannelBuilder() {
@Override
public KafkaChannel buildChannel(String id, SelectionKey key, int maxReceiveSize, MemoryPool memoryPool) throws KafkaException {
throw new RuntimeException("Test exception");
}
@Override
public void close() {
}
};
Selector selector = new Selector(5000, new Metrics(), new MockTime(), "MetricGroup", channelBuilder, new LogContext());
SocketChannel socketChannel = SocketChannel.open();
socketChannel.configureBlocking(false);
try {
selector.register("1", socketChannel);
fail("Register did not fail");
} catch (IOException e) {
assertTrue("Unexpected exception: " + e, e.getCause().getMessage().contains("Test exception"));
assertFalse("Socket not closed", socketChannel.isOpen());
}
selector.close();
}
Aggregations