Change netty reply timeout to 2s and run a periodic cleanup task to timeout outstanding requests
Change-Id: Ie0381b9371bfd8a3d680872bfc5dce54a19aaca2
diff --git a/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java b/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
index 76dc685..72ba2ea 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
@@ -84,6 +84,7 @@
@Service
public class NettyMessagingManager implements MessagingService {
+ private static final int REPLY_TIME_OUT_SEC = 2;
private static final short MIN_KS_LENGTH = 6;
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -96,7 +97,7 @@
private final Map<String, Consumer<InternalMessage>> handlers = new ConcurrentHashMap<>();
private final AtomicLong messageIdGenerator = new AtomicLong(0);
private final Cache<Long, Callback> callbacks = CacheBuilder.newBuilder()
- .expireAfterWrite(10, TimeUnit.SECONDS)
+ .expireAfterWrite(REPLY_TIME_OUT_SEC, TimeUnit.SECONDS)
.removalListener(new RemovalListener<Long, Callback>() {
@Override
public void onRemoval(RemovalNotification<Long, Callback> entry) {
@@ -145,6 +146,7 @@
initEventLoopGroup();
startAcceptingConnections();
started.set(true);
+ serverGroup.scheduleWithFixedDelay(callbacks::cleanUp, 0, REPLY_TIME_OUT_SEC, TimeUnit.SECONDS);
log.info("Started");
}