16 package org.openkilda.messaging.model;
18 import com.fasterxml.jackson.annotation.JsonCreator;
19 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
20 import com.fasterxml.jackson.annotation.JsonInclude;
21 import com.fasterxml.jackson.annotation.JsonProperty;
23 import lombok.ToString;
25 import java.io.Serializable;
26 import java.util.Objects;
28 @JsonIgnoreProperties(ignoreUnknown =
true)
29 @JsonInclude(JsonInclude.Include.NON_NULL)
39 @JsonProperty(
"source")
42 @JsonProperty("destination")
48 @JsonProperty("attempts")
54 @JsonProperty("ack_attempts")
55 private
int ackAttempts;
57 @JsonProperty("time_counter")
58 private
int timeCounter;
60 @JsonProperty("check_interval")
61 private
int checkInterval;
66 @JsonProperty("consecutive_failure")
67 private
int consecutiveFailure;
69 @JsonProperty("consecutive_success")
70 private
int consecutiveSuccess;
72 @JsonProperty("consecutive_failure_limit")
73 private
int consecutiveFailureLimit;
75 @JsonProperty("active")
76 private
boolean active;
83 this.destination = null;
85 this.checkInterval = checkInterval;
86 this.consecutiveFailureLimit = consecutiveFailureLimit;
87 this.consecutiveFailure = 0;
88 this.consecutiveSuccess = 0;
95 int checkInterval,
int consecutiveFailureLimit,
boolean active) {
99 this.checkInterval = checkInterval;
100 this.consecutiveFailureLimit = consecutiveFailureLimit;
101 this.consecutiveFailure = 0;
102 this.consecutiveSuccess = 0;
103 this.active = active;
112 @JsonProperty(
"attempts")
final int attempts,
113 @JsonProperty(
"ack_attempts")
final int ackAttempts,
114 @JsonProperty(
"time_counter")
final int timeCounter,
115 @JsonProperty(
"check_interval")
final int checkInterval,
116 @JsonProperty(
"consecutive_failure")
final int consecutiveFailure,
117 @JsonProperty(
"consecutive_success")
final int consecutiveSuccess,
118 @JsonProperty(
"consecutive_failure_limit")
final int consecutiveFailureLimit,
119 @JsonProperty(
"active")
final boolean active) {
120 this.source = source;
121 this.destination = destination;
122 this.attempts = attempts;
123 this.ackAttempts = ackAttempts;
124 this.timeCounter = timeCounter;
125 this.checkInterval = checkInterval;
126 this.consecutiveFailureLimit = consecutiveFailureLimit;
127 this.consecutiveFailure = consecutiveFailure;
128 this.consecutiveSuccess = consecutiveSuccess;
129 this.active = active;
136 this.destination = destination;
146 this.consecutiveFailure = 0;
147 this.consecutiveSuccess = 0;
169 return consecutiveFailure < consecutiveFailureLimit;
173 consecutiveFailure = 0;
177 consecutiveSuccess = 0;
181 consecutiveFailure++;
186 consecutiveSuccess++;
202 return attempts > attemptsLimit;
217 return ackAttempts > attemptsLimit;
228 return timeCounter >= checkInterval;
239 if (this.destination == null) {
243 return !Objects.equals(this.destination,
new NetworkEndpoint(dstSwitch, dstPort));
255 return Objects.
equals(getSource(), that.getSource())
256 && Objects.equals(getDestination(), that.getDestination());
261 return Objects.hash(getSource(), getDestination());
static final int ENDLESS_ATTEMPTS
DiscoveryLink(SwitchId srcSwitch, int srcPort, SwitchId dstSwitch, int dstPort, int checkInterval, int consecutiveFailureLimit, boolean active)
boolean isDestinationChanged(SwitchId dstSwitch, int dstPort)
boolean isAckAttemptsLimitExceeded(int attemptsLimit)
DiscoveryLink(SwitchId srcSwitch, int srcPort, int checkInterval, int consecutiveFailureLimit)
boolean isNewAttemptAllowed()
void activate(NetworkEndpoint destination)
boolean isAttemptsLimitExceeded(int attemptsLimit)
void incAcknowledgedAttempts()
void clearConsecutiveSuccess()
void clearConsecutiveFailure()
DiscoveryLink(@JsonProperty("source") final NetworkEndpoint source, @JsonProperty("destination") final NetworkEndpoint destination, @JsonProperty("attempts") final int attempts, @JsonProperty("ack_attempts") final int ackAttempts, @JsonProperty("time_counter") final int timeCounter, @JsonProperty("check_interval") final int checkInterval, @JsonProperty("consecutive_failure") final int consecutiveFailure, @JsonProperty("consecutive_success") final int consecutiveSuccess, @JsonProperty("consecutive_failure_limit") final int consecutiveFailureLimit, @JsonProperty("active") final boolean active)