Is there any mechanism/api by which I can control TPS hits from http client?
From HTTP client, I need to control numbers of hits to rest services (my HTTP client will hit to server in controlled manner).
you can close it immediately by adding a Netty's IpFilterHandler to server pipeline as the first handler. It will also stop propagating the upstream channel state events for filtered connection too.
@ChannelHandler.Sharable
public class FilterIPHandler extends IpFilteringHandlerImpl {
private final Set<InetSocketAddress> deniedIP;
public filter(Set<InetSocketAddress> deniedIP) {
this.deniedIP = deniedIP;
}
@Override
protected boolean isAnAccpetedIP(ChannelHandlerContext ctx, ChannelEvent e, InetSocketAddress inetSocketAddress) throws Exception {
return !deniedIP.contains(inetSocketAddress);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.