HeartbeatTimeout detectTimeout(long heartbeatTimeoutMillis) { if (pendingResponse != VOID) { // if there is a response, then we won't timeout return NO_TIMEOUT__RESPONSE_AVAILABLE; } long callTimeoutMillis = op.getCallTimeout(); if (callTimeoutMillis <= 0 || callTimeoutMillis == Long.MAX_VALUE) { return NO_TIMEOUT__CALL_TIMEOUT_DISABLED; } // a call is always allowed to execute as long as its own call timeout long deadlineMillis = op.getInvocationTime() + callTimeoutMillis; if (deadlineMillis > context.clusterClock.getClusterTime()) { return NO_TIMEOUT__CALL_TIMEOUT_NOT_EXPIRED; } // on top of its own call timeout, it is allowed to execute until there is a heartbeat timeout; // so if the callTimeout is five minutes, and the heartbeatTimeout is one minute, then the operation is allowed // to execute for at least six minutes before it is timing out long lastHeartbeatMillis = this.lastHeartbeatMillis; long heartbeatExpirationTimeMillis = lastHeartbeatMillis == 0 ? op.getInvocationTime() + callTimeoutMillis + heartbeatTimeoutMillis : lastHeartbeatMillis + heartbeatTimeoutMillis; if (heartbeatExpirationTimeMillis > Clock.currentTimeMillis()) { return NO_TIMEOUT__HEARTBEAT_TIMEOUT_NOT_EXPIRED; } return TIMEOUT; }
HeartbeatTimeout detectTimeout(long heartbeatTimeoutMillis) { if (pendingResponse != VOID) { // if there is a response, then we won't timeout return NO_TIMEOUT__RESPONSE_AVAILABLE; } long callTimeoutMillis = op.getCallTimeout(); if (callTimeoutMillis <= 0 || callTimeoutMillis == Long.MAX_VALUE) { return NO_TIMEOUT__CALL_TIMEOUT_DISABLED; } // a call is always allowed to execute as long as its own call timeout long deadlineMillis = op.getInvocationTime() + callTimeoutMillis; if (deadlineMillis > context.clusterClock.getClusterTime()) { return NO_TIMEOUT__CALL_TIMEOUT_NOT_EXPIRED; } // on top of its own call timeout, it is allowed to execute until there is a heartbeat timeout; // so if the callTimeout is five minutes, and the heartbeatTimeout is one minute, then the operation is allowed // to execute for at least six minutes before it is timing out long lastHeartbeatMillis = this.lastHeartbeatMillis; long heartbeatExpirationTimeMillis = lastHeartbeatMillis == 0 ? op.getInvocationTime() + callTimeoutMillis + heartbeatTimeoutMillis : lastHeartbeatMillis + heartbeatTimeoutMillis; if (heartbeatExpirationTimeMillis > Clock.currentTimeMillis()) { return NO_TIMEOUT__HEARTBEAT_TIMEOUT_NOT_EXPIRED; } return TIMEOUT; }
long elapsedTime = max(0, context.clusterClock.getClusterTime() - op.getInvocationTime());
long elapsedTime = max(0, context.clusterClock.getClusterTime() - op.getInvocationTime());
@Override public boolean isCallTimedOut(Operation op) { // Join operations should not be checked for timeout because caller is not member of this cluster // and can have a different clock. if (isJoinOperation(op)) { return false; } long callTimeout = op.getCallTimeout(); long invocationTime = op.getInvocationTime(); long expireTime = invocationTime + callTimeout; if (expireTime <= 0 || expireTime == Long.MAX_VALUE) { return false; } ClusterClock clusterClock = nodeEngine.getClusterService().getClusterClock(); long now = clusterClock.getClusterTime(); if (expireTime < now) { return true; } return false; }
@Override public boolean isCallTimedOut(Operation op) { // Join and WAN replication operations should not be checked for timeout // because caller is not member of this cluster and can have a different // clock. if (isJoinOperation(op) || isWanReplicationOperation(op)) { return false; } long callTimeout = op.getCallTimeout(); long invocationTime = op.getInvocationTime(); long expireTime = invocationTime + callTimeout; if (expireTime <= 0 || expireTime == Long.MAX_VALUE) { return false; } ClusterClock clusterClock = nodeEngine.getClusterService().getClusterClock(); long now = clusterClock.getClusterTime(); if (expireTime < now) { return true; } return false; }