Committed by
Gerrit Code Review
Fixed stack overflow bug when using BMv2 table entry service
Similarly to ONOS-4206, due to a bug in kryo, a non-registered class (Date in this case) was causing such a problem. Change-Id: I993f4b41d4deaa617065b29086a49d834832eca8
Showing
2 changed files
with
17 additions
and
18 deletions
| ... | @@ -47,7 +47,6 @@ import org.slf4j.LoggerFactory; | ... | @@ -47,7 +47,6 @@ import org.slf4j.LoggerFactory; |
| 47 | 47 | ||
| 48 | import java.util.Collection; | 48 | import java.util.Collection; |
| 49 | import java.util.Collections; | 49 | import java.util.Collections; |
| 50 | -import java.util.Date; | ||
| 51 | import java.util.List; | 50 | import java.util.List; |
| 52 | import java.util.concurrent.ConcurrentMap; | 51 | import java.util.concurrent.ConcurrentMap; |
| 53 | import java.util.concurrent.locks.Lock; | 52 | import java.util.concurrent.locks.Lock; |
| ... | @@ -152,7 +151,7 @@ public class Bmv2FlowRuleProgrammable extends AbstractHandlerBehaviour implement | ... | @@ -152,7 +151,7 @@ public class Bmv2FlowRuleProgrammable extends AbstractHandlerBehaviour implement |
| 152 | log.debug("getFlowEntries(): inconsistent entry id! BUG? Updating it... remote={}, local={}", | 151 | log.debug("getFlowEntries(): inconsistent entry id! BUG? Updating it... remote={}, local={}", |
| 153 | remoteEntryId, localEntryId); | 152 | remoteEntryId, localEntryId); |
| 154 | frWrapper = new Bmv2FlowRuleWrapper(frWrapper.rule(), remoteEntryId, | 153 | frWrapper = new Bmv2FlowRuleWrapper(frWrapper.rule(), remoteEntryId, |
| 155 | - frWrapper.creationDate()); | 154 | + frWrapper.installedOnMillis()); |
| 156 | tableEntryService.bind(entryRef, frWrapper); | 155 | tableEntryService.bind(entryRef, frWrapper); |
| 157 | } | 156 | } |
| 158 | 157 | ||
| ... | @@ -255,7 +254,7 @@ public class Bmv2FlowRuleProgrammable extends AbstractHandlerBehaviour implement | ... | @@ -255,7 +254,7 @@ public class Bmv2FlowRuleProgrammable extends AbstractHandlerBehaviour implement |
| 255 | } | 254 | } |
| 256 | // Add entry. | 255 | // Add entry. |
| 257 | entryId = doAddEntry(deviceAgent, bmv2Entry); | 256 | entryId = doAddEntry(deviceAgent, bmv2Entry); |
| 258 | - frWrapper = new Bmv2FlowRuleWrapper(rule, entryId, new Date()); | 257 | + frWrapper = new Bmv2FlowRuleWrapper(rule, entryId, System.currentTimeMillis()); |
| 259 | } else { | 258 | } else { |
| 260 | // Remove entry | 259 | // Remove entry |
| 261 | if (frWrapper == null) { | 260 | if (frWrapper == null) { | ... | ... |
| ... | @@ -20,8 +20,6 @@ import com.google.common.annotations.Beta; | ... | @@ -20,8 +20,6 @@ import com.google.common.annotations.Beta; |
| 20 | import com.google.common.base.Objects; | 20 | import com.google.common.base.Objects; |
| 21 | import org.onosproject.net.flow.FlowRule; | 21 | import org.onosproject.net.flow.FlowRule; |
| 22 | 22 | ||
| 23 | -import java.util.Date; | ||
| 24 | - | ||
| 25 | /** | 23 | /** |
| 26 | * A wrapper for a ONOS flow rule installed on a BMv2 device. | 24 | * A wrapper for a ONOS flow rule installed on a BMv2 device. |
| 27 | */ | 25 | */ |
| ... | @@ -30,19 +28,20 @@ public final class Bmv2FlowRuleWrapper { | ... | @@ -30,19 +28,20 @@ public final class Bmv2FlowRuleWrapper { |
| 30 | 28 | ||
| 31 | private final FlowRule rule; | 29 | private final FlowRule rule; |
| 32 | private final long entryId; | 30 | private final long entryId; |
| 33 | - private final Date creationDate; | 31 | + private final long installedOnMillis; |
| 34 | 32 | ||
| 35 | /** | 33 | /** |
| 36 | * Creates a new flow rule wrapper. | 34 | * Creates a new flow rule wrapper. |
| 37 | * | 35 | * |
| 38 | * @param rule a flow rule | 36 | * @param rule a flow rule |
| 39 | * @param entryId a BMv2 table entry ID | 37 | * @param entryId a BMv2 table entry ID |
| 40 | - * @param creationDate the creation date of the flow rule | 38 | + * @param installedOnMillis the time (in milliseconds, since January 1, 1970 UTC) when the flow rule was installed |
| 39 | + * on the device | ||
| 41 | */ | 40 | */ |
| 42 | - public Bmv2FlowRuleWrapper(FlowRule rule, long entryId, Date creationDate) { | 41 | + public Bmv2FlowRuleWrapper(FlowRule rule, long entryId, long installedOnMillis) { |
| 43 | this.rule = rule; | 42 | this.rule = rule; |
| 44 | this.entryId = entryId; | 43 | this.entryId = entryId; |
| 45 | - this.creationDate = new Date(); | 44 | + this.installedOnMillis = installedOnMillis; |
| 46 | } | 45 | } |
| 47 | 46 | ||
| 48 | /** | 47 | /** |
| ... | @@ -55,21 +54,22 @@ public final class Bmv2FlowRuleWrapper { | ... | @@ -55,21 +54,22 @@ public final class Bmv2FlowRuleWrapper { |
| 55 | } | 54 | } |
| 56 | 55 | ||
| 57 | /** | 56 | /** |
| 58 | - * Return the seconds since when this flow rule was installed on the device. | 57 | + * Return the number of seconds since when this flow rule was installed on the device. |
| 59 | * | 58 | * |
| 60 | * @return an integer value | 59 | * @return an integer value |
| 61 | */ | 60 | */ |
| 62 | public long lifeInSeconds() { | 61 | public long lifeInSeconds() { |
| 63 | - return (new Date().getTime() - creationDate.getTime()) / 1000; | 62 | + return (System.currentTimeMillis() - installedOnMillis) / 1000; |
| 64 | } | 63 | } |
| 65 | 64 | ||
| 66 | /** | 65 | /** |
| 67 | - * Returns the creation date of this flow rule. | 66 | + * Returns the the time (in milliseconds, since January 1, 1970 UTC) when the flow rule was installed on |
| 67 | + * the device. | ||
| 68 | * | 68 | * |
| 69 | - * @return a date | 69 | + * @return a long value |
| 70 | */ | 70 | */ |
| 71 | - public Date creationDate() { | 71 | + public long installedOnMillis() { |
| 72 | - return creationDate; | 72 | + return installedOnMillis; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | /** | 75 | /** |
| ... | @@ -83,7 +83,7 @@ public final class Bmv2FlowRuleWrapper { | ... | @@ -83,7 +83,7 @@ public final class Bmv2FlowRuleWrapper { |
| 83 | 83 | ||
| 84 | @Override | 84 | @Override |
| 85 | public int hashCode() { | 85 | public int hashCode() { |
| 86 | - return Objects.hashCode(rule, entryId, creationDate); | 86 | + return Objects.hashCode(rule, entryId, installedOnMillis); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | @Override | 89 | @Override |
| ... | @@ -97,11 +97,11 @@ public final class Bmv2FlowRuleWrapper { | ... | @@ -97,11 +97,11 @@ public final class Bmv2FlowRuleWrapper { |
| 97 | final Bmv2FlowRuleWrapper other = (Bmv2FlowRuleWrapper) obj; | 97 | final Bmv2FlowRuleWrapper other = (Bmv2FlowRuleWrapper) obj; |
| 98 | return Objects.equal(this.rule, other.rule) | 98 | return Objects.equal(this.rule, other.rule) |
| 99 | && Objects.equal(this.entryId, other.entryId) | 99 | && Objects.equal(this.entryId, other.entryId) |
| 100 | - && Objects.equal(this.creationDate, other.creationDate); | 100 | + && Objects.equal(this.installedOnMillis, other.installedOnMillis); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | @Override | 103 | @Override |
| 104 | public String toString() { | 104 | public String toString() { |
| 105 | - return creationDate + "-" + rule.hashCode(); | 105 | + return installedOnMillis + "-" + rule.hashCode(); |
| 106 | } | 106 | } |
| 107 | } | 107 | } | ... | ... |
-
Please register or login to post a comment