use of io.netty.util.concurrent.AbstractScheduledEventExecutor in project infinispan by infinispan.
the class ServerErrorTest method testErrorWhileDoingPut.
public void testErrorWhileDoingPut(Method m) {
cache.getAdvancedCache().withStorageMediaType().addListener(new ErrorInducingListener());
remoteCache = remoteCacheManager.getCache();
remoteCache.put(k(m), v(m));
assertEquals(v(m), remoteCache.get(k(m)));
// Obtain a reference to the single connection in the pool
ChannelFactory channelFactory = remoteCacheManager.getChannelFactory();
InetSocketAddress address = InetSocketAddress.createUnresolved(hotrodServer.getHost(), hotrodServer.getPort());
Channel channel = channelFactory.fetchChannelAndInvoke(address, new NoopChannelOperation()).join();
// Obtain a reference to the scheduled executor and its task queue
AbstractScheduledEventExecutor scheduledExecutor = ((AbstractScheduledEventExecutor) channel.eventLoop());
Queue<?> scheduledTaskQueue = TestingUtil.extractField(scheduledExecutor, "scheduledTaskQueue");
int scheduledTasksBaseline = scheduledTaskQueue.size();
// Release the channel back into the pool
channelFactory.releaseChannel(channel);
assertEquals(0, channelFactory.getNumActive(address));
assertEquals(1, channelFactory.getNumIdle(address));
log.debug("Sending failing operation to server");
expectException(HotRodClientException.class, () -> remoteCache.put("FailFailFail", "whatever..."));
assertEquals(0, channelFactory.getNumActive(address));
assertEquals(1, channelFactory.getNumIdle(address));
// Check that the operation was completed
HeaderDecoder headerDecoder = channel.pipeline().get(HeaderDecoder.class);
assertEquals(0, headerDecoder.registeredOperations());
// Check that the timeout task was cancelled
assertEquals(scheduledTasksBaseline, scheduledTaskQueue.size());
log.debug("Sending new request after server failure");
remoteCache.put(k(m, 2), v(m, 2));
assertEquals(v(m, 2), remoteCache.get(k(m, 2)));
}
Aggregations