Class SelectorGuard
java.lang.Object
com.biglybt.core.networkmanager.impl.tcp.SelectorGuard
Temp class designed to help detect Selector anomalies and cleanly re-open if necessary.
NOTE:
As of JVM 1.4.2_03, after network connection disconnect/reconnect, usually-blocking
select() and select(long) calls no longer block, and will instead return immediately.
This can cause selector spinning and 100% cpu usage.
See:
http://forum.java.sun.com/thread.jsp?forum=4invalid input: '&thread'=293213
http://developer.java.sun.com/developer/bugParade/bugs/4850373.html
http://developer.java.sun.com/developer/bugParade/bugs/4881228.html
Fixed in JVM 1.4.2_05+ and 1.5b2+
The workaround applied for the above is Thread.sleep() to avoid CPU hogging.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long
private int
private int
private boolean
private static final int
private long
private static final int
private final String
-
Constructor Summary
ConstructorsConstructorDescriptionSelectorGuard
(String _type) Create a new SelectorGuard with the given failed count threshold. -
Method Summary
Modifier and TypeMethodDescriptiongetType()
void
Run this method right before the select() operation to mark the start time.void
verifySelectorIntegrity
(int num_keys_ready, long time_threshold) Checks whether selector is still OK, and not spinning.
-
Field Details
-
SELECTOR_SPIN_THRESHOLD
private static final int SELECTOR_SPIN_THRESHOLD- See Also:
-
MAX_IGNORES
private static final int MAX_IGNORES- See Also:
-
marked
private boolean marked -
consecutiveZeroSelects
private int consecutiveZeroSelects -
beforeSelectTime
private long beforeSelectTime -
select_op_time
private long select_op_time -
type
-
ignores
private int ignores
-
-
Constructor Details
-
SelectorGuard
Create a new SelectorGuard with the given failed count threshold.
-
-
Method Details
-
getType
-
markPreSelectTime
public void markPreSelectTime()Run this method right before the select() operation to mark the start time. -
verifySelectorIntegrity
public void verifySelectorIntegrity(int num_keys_ready, long time_threshold) Checks whether selector is still OK, and not spinning.
-