Simplify IgniteSpiOperationTimeoutHelper
@@ -30,18 +30,12 @@ import org.apache.ignite.internal.util.typedef.internal.U;
*
*/
public class IgniteSpiOperationTimeoutHelper {
- // https://issues.apache.org/jira/browse/IGNITE-11221
- // We need to reuse new logic ExponentialBackoffTimeout logic in TcpDiscovery instead of this class.
-
/** Flag whether to use timeout. */
private final boolean timeoutEnabled;
/** Time in nanos which cannot be reached for current operation. */
private final long timeoutThreshold;
- /** Keeps {@code true} if last call to {@link #nextTimeoutChunk(long)} has timeouted. {@code False} otherwise. */
- private boolean lastOperationTimeouted;
-
/**
* Constructor.
*
@@ -104,26 +98,19 @@ public class IgniteSpiOperationTimeoutHelper {
left = timeoutThreshold - now;
}
- if (left <= 0) {
- lastOperationTimeouted = true;
-
+ if (left <= 0)
throw new IgniteSpiOperationTimeoutException("Network operation timed out.");
- }
return U.nanosToMillis(left);
}
/**
- * Checks whether the given {@link Exception} is a timeout-exception or the has been reached in last call to
- * {@code nextTimeoutChunk(long)}.
+ * Checks whether the given {@link Exception} is a timeout.
*
- * @param e Exception to check if is a timeout.
- * @return {@code True} if the excaption is a timeout or failure timeout was reached. {@code False} otherwise.
+ * @param e Exception to check.
+ * @return {@code True} if given exception is a timeout. {@code False} otherwise.
*/
public boolean checkFailureTimeoutReached(Exception e) {
- if (X.hasCause(e, IgniteSpiOperationTimeoutException.class, SocketTimeoutException.class, SocketException.class))
- return true;
-
- return lastOperationTimeouted;
+ return X.hasCause(e, IgniteSpiOperationTimeoutException.class, SocketTimeoutException.class, SocketException.class);
}
}
