Committed by
Gerrit Code Review
Cleaned up NewAdaptiveFlowStatsCollector logs to prevent excessive
object creation and string concatenation. Dropped per-flow-stats-request logs to TRACE level. Change-Id: I2dd55030bd1faa00d6fbfef74c7da1debb7f1d7d
Showing
2 changed files
with
193 additions
and
208 deletions
| ... | @@ -26,11 +26,27 @@ public final class FlowId extends Identifier<Long> { | ... | @@ -26,11 +26,27 @@ public final class FlowId extends Identifier<Long> { |
| 26 | super(id); | 26 | super(id); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | + /** | ||
| 30 | + * Creates a flow ID from a long value. | ||
| 31 | + * | ||
| 32 | + * @param id long value | ||
| 33 | + * @return flow ID | ||
| 34 | + */ | ||
| 29 | public static FlowId valueOf(long id) { | 35 | public static FlowId valueOf(long id) { |
| 30 | return new FlowId(id); | 36 | return new FlowId(id); |
| 31 | } | 37 | } |
| 32 | 38 | ||
| 39 | + /** | ||
| 40 | + * Gets the flow ID value. | ||
| 41 | + * | ||
| 42 | + * @return flow ID value as long | ||
| 43 | + */ | ||
| 33 | public long value() { | 44 | public long value() { |
| 34 | return this.identifier; | 45 | return this.identifier; |
| 35 | } | 46 | } |
| 47 | + | ||
| 48 | + @Override | ||
| 49 | + public String toString() { | ||
| 50 | + return Long.toHexString(identifier); | ||
| 51 | + } | ||
| 36 | } | 52 | } | ... | ... |
| ... | @@ -58,6 +58,22 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -58,6 +58,22 @@ import static org.slf4j.LoggerFactory.getLogger; |
| 58 | public class NewAdaptiveFlowStatsCollector { | 58 | public class NewAdaptiveFlowStatsCollector { |
| 59 | private final Logger log = getLogger(getClass()); | 59 | private final Logger log = getLogger(getClass()); |
| 60 | 60 | ||
| 61 | + private static final String CHECK_AND_MOVE_LOG = | ||
| 62 | + "checkAndMoveLiveFlowInternal: flowId={}, state={}, afterLiveType={}" | ||
| 63 | + + ", liveTime={}, life={}, bytes={}, packets={}, fromLastSeen={}" | ||
| 64 | + + ", priority={}, selector={}, treatment={} dpid={}"; | ||
| 65 | + | ||
| 66 | + private static final String CHECK_AND_MOVE_COUNT_LOG = | ||
| 67 | + "checkAndMoveLiveFlowAll: Total Flow_Count={}, add-remove_Count={}" | ||
| 68 | + + ", IMMEDIATE_FLOW_Count={}, SHORT_FLOW_Count={}" | ||
| 69 | + + ", MID_FLOW_Count={}, LONG_FLOW_Count={}, add_Count={}" | ||
| 70 | + + ", addWithSetFlowLiveType_Count={}, remove_Count={}, dpid={}"; | ||
| 71 | + | ||
| 72 | + private static final String ADD_INVALID_LOG = | ||
| 73 | + "addOrUpdateFlows: invalid flow update! The new life is SMALLER than the previous one" | ||
| 74 | + + ", new flowId={}, old flowId={}, new bytes={}, old bytes={}" | ||
| 75 | + + ", new life={}, old life={}, new lastSeen={}, old lastSeen={}"; | ||
| 76 | + | ||
| 61 | private final DriverService driverService; | 77 | private final DriverService driverService; |
| 62 | private final OpenFlowSwitch sw; | 78 | private final OpenFlowSwitch sw; |
| 63 | 79 | ||
| ... | @@ -178,7 +194,7 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -178,7 +194,7 @@ public class NewAdaptiveFlowStatsCollector { |
| 178 | longPollInterval, | 194 | longPollInterval, |
| 179 | TimeUnit.SECONDS); | 195 | TimeUnit.SECONDS); |
| 180 | 196 | ||
| 181 | - log.debug("calAndPollInterval=" + calAndPollInterval + "is adjusted"); | 197 | + log.debug("calAndPollInterval={} is adjusted", calAndPollInterval); |
| 182 | } | 198 | } |
| 183 | 199 | ||
| 184 | private class CalAndShortFlowsTask implements Runnable { | 200 | private class CalAndShortFlowsTask implements Runnable { |
| ... | @@ -224,7 +240,8 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -224,7 +240,8 @@ public class NewAdaptiveFlowStatsCollector { |
| 224 | // After processing the reply of this request message, | 240 | // After processing the reply of this request message, |
| 225 | // this must be set to NO_FLOW_MISSING_XID(-1) by provider | 241 | // this must be set to NO_FLOW_MISSING_XID(-1) by provider |
| 226 | setFlowMissingXid(request.getXid()); | 242 | setFlowMissingXid(request.getXid()); |
| 227 | - log.debug("ofFlowStatsRequestAllSend,Request={},for {}", request.toString(), sw.getStringId()); | 243 | + log.debug("ofFlowStatsRequestAllSend: request={}, dpid={}", |
| 244 | + request.toString(), sw.getStringId()); | ||
| 228 | 245 | ||
| 229 | sw.sendMsg(request); | 246 | sw.sendMsg(request); |
| 230 | } | 247 | } |
| ... | @@ -321,8 +338,7 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -321,8 +338,7 @@ public class NewAdaptiveFlowStatsCollector { |
| 321 | } | 338 | } |
| 322 | 339 | ||
| 323 | /** | 340 | /** |
| 324 | - * start adaptive flow statistic collection. | 341 | + * Starts adaptive flow statistic collection. |
| 325 | - * | ||
| 326 | */ | 342 | */ |
| 327 | public synchronized void start() { | 343 | public synchronized void start() { |
| 328 | log.debug("Starting AdaptiveStats collection thread for {}", sw.getStringId()); | 344 | log.debug("Starting AdaptiveStats collection thread for {}", sw.getStringId()); |
| ... | @@ -358,8 +374,7 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -358,8 +374,7 @@ public class NewAdaptiveFlowStatsCollector { |
| 358 | } | 374 | } |
| 359 | 375 | ||
| 360 | /** | 376 | /** |
| 361 | - * stop adaptive flow statistic collection. | 377 | + * Stops adaptive flow statistic collection. |
| 362 | - * | ||
| 363 | */ | 378 | */ |
| 364 | public synchronized void stop() { | 379 | public synchronized void stop() { |
| 365 | log.debug("Stopping AdaptiveStats collection thread for {}", sw.getStringId()); | 380 | log.debug("Stopping AdaptiveStats collection thread for {}", sw.getStringId()); |
| ... | @@ -381,10 +396,9 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -381,10 +396,9 @@ public class NewAdaptiveFlowStatsCollector { |
| 381 | } | 396 | } |
| 382 | 397 | ||
| 383 | /** | 398 | /** |
| 384 | - * add typed flow entry from flow rule into the internal flow table. | 399 | + * Adds typed flow entry from flow rule into the internal flow table. |
| 385 | * | 400 | * |
| 386 | * @param flowRules the flow rules | 401 | * @param flowRules the flow rules |
| 387 | - * | ||
| 388 | */ | 402 | */ |
| 389 | public synchronized void addWithFlowRule(FlowRule... flowRules) { | 403 | public synchronized void addWithFlowRule(FlowRule... flowRules) { |
| 390 | for (FlowRule fr : flowRules) { | 404 | for (FlowRule fr : flowRules) { |
| ... | @@ -399,70 +413,66 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -399,70 +413,66 @@ public class NewAdaptiveFlowStatsCollector { |
| 399 | } | 413 | } |
| 400 | 414 | ||
| 401 | /** | 415 | /** |
| 402 | - * add or update typed flow entry from flow entry into the internal flow table. | 416 | + * Adds or updates typed flow entry from flow entry into the internal flow table. |
| 403 | * | 417 | * |
| 404 | * @param flowEntries the flow entries | 418 | * @param flowEntries the flow entries |
| 405 | - * | ||
| 406 | */ | 419 | */ |
| 407 | public synchronized void addOrUpdateFlows(FlowEntry... flowEntries) { | 420 | public synchronized void addOrUpdateFlows(FlowEntry... flowEntries) { |
| 408 | - for (FlowEntry fe : flowEntries) { | 421 | + for (FlowEntry fe : flowEntries) { |
| 409 | - // check if this new rule is an update to an existing entry | 422 | + // check if this new rule is an update to an existing entry |
| 410 | - TypedStoredFlowEntry stored = deviceFlowTable.getFlowEntry(fe); | 423 | + TypedStoredFlowEntry stored = deviceFlowTable.getFlowEntry(fe); |
| 411 | - | 424 | + |
| 412 | - if (stored != null) { | 425 | + if (stored != null) { |
| 413 | - // duplicated flow entry is collected!, just skip | 426 | + // duplicated flow entry is collected!, just skip |
| 414 | - if (fe.bytes() == stored.bytes() && fe.packets() == stored.packets() | 427 | + if (fe.bytes() == stored.bytes() && fe.packets() == stored.packets() |
| 415 | - && fe.life() == stored.life()) { | 428 | + && fe.life() == stored.life()) { |
| 416 | - log.debug("addOrUpdateFlows:, FlowId=" + Long.toHexString(fe.id().value()) | 429 | + if (log.isTraceEnabled()) { |
| 417 | - + ",is DUPLICATED stats collection, just skip." | 430 | + log.trace("addOrUpdateFlows({}): flowId={},is DUPLICATED stats collection, just skip.", |
| 418 | - + " AdaptiveStats collection thread for {}", | 431 | + sw.getStringId(), fe.id()); |
| 419 | - sw.getStringId()); | 432 | + } |
| 420 | - | 433 | + |
| 421 | - //FIXME modification of "stored" flow entry outside of store | 434 | + //FIXME modification of "stored" flow entry outside of store |
| 422 | - stored.setLastSeen(); | 435 | + stored.setLastSeen(); |
| 423 | - continue; | 436 | + continue; |
| 424 | - } else if (fe.life() < stored.life()) { | 437 | + } else if (fe.life() < stored.life()) { |
| 425 | - // Invalid updates the stats values, i.e., bytes, packets, durations ... | 438 | + // Invalid updates the stats values, i.e., bytes, packets, durations ... |
| 426 | - log.debug("addOrUpdateFlows():" + | 439 | + if (log.isDebugEnabled()) { |
| 427 | - " Invalid Flow Update! The new life is SMALLER than the previous one, jus skip." + | 440 | + log.debug(ADD_INVALID_LOG, fe.id(), stored.id(), fe.bytes(), |
| 428 | - " new flowId=" + Long.toHexString(fe.id().value()) + | 441 | + stored.bytes(), fe.life(), stored.life(), |
| 429 | - ", old flowId=" + Long.toHexString(stored.id().value()) + | 442 | + fe.lastSeen(), stored.lastSeen()); |
| 430 | - ", new bytes=" + fe.bytes() + ", old bytes=" + stored.bytes() + | 443 | + } |
| 431 | - ", new life=" + fe.life() + ", old life=" + stored.life() + | 444 | + // go next |
| 432 | - ", new lastSeen=" + fe.lastSeen() + ", old lastSeen=" + stored.lastSeen()); | 445 | + //FIXME modification of "stored" flow entry outside of store |
| 433 | - // go next | 446 | + stored.setLastSeen(); |
| 434 | - //FIXME modification of "stored" flow entry outside of store | 447 | + continue; |
| 435 | - stored.setLastSeen(); | 448 | + } |
| 436 | - continue; | 449 | + |
| 437 | - } | 450 | + // update now |
| 438 | - | 451 | + //FIXME modification of "stored" flow entry outside of store |
| 439 | - // update now | 452 | + stored.setLife(fe.life()); |
| 440 | - //FIXME modification of "stored" flow entry outside of store | 453 | + stored.setPackets(fe.packets()); |
| 441 | - stored.setLife(fe.life()); | 454 | + stored.setBytes(fe.bytes()); |
| 442 | - stored.setPackets(fe.packets()); | 455 | + stored.setLastSeen(); |
| 443 | - stored.setBytes(fe.bytes()); | 456 | + if (stored.state() == FlowEntry.FlowEntryState.PENDING_ADD) { |
| 444 | - stored.setLastSeen(); | 457 | + // flow is really RULE_ADDED |
| 445 | - if (stored.state() == FlowEntry.FlowEntryState.PENDING_ADD) { | 458 | + stored.setState(FlowEntry.FlowEntryState.ADDED); |
| 446 | - // flow is really RULE_ADDED | 459 | + } |
| 447 | - stored.setState(FlowEntry.FlowEntryState.ADDED); | 460 | + // flow is RULE_UPDATED, skip adding and just updating flow live table |
| 448 | - } | 461 | + //deviceFlowTable.calAndSetFlowLiveType(stored); |
| 449 | - // flow is RULE_UPDATED, skip adding and just updating flow live table | 462 | + continue; |
| 450 | - //deviceFlowTable.calAndSetFlowLiveType(stored); | 463 | + } |
| 451 | - continue; | 464 | + |
| 452 | - } | 465 | + // add new flow entry, we suppose IMMEDIATE_FLOW |
| 453 | - | 466 | + TypedStoredFlowEntry newFlowEntry = new DefaultTypedFlowEntry(fe, |
| 454 | - // add new flow entry, we suppose IMMEDIATE_FLOW | ||
| 455 | - TypedStoredFlowEntry newFlowEntry = new DefaultTypedFlowEntry(fe, | ||
| 456 | FlowLiveType.IMMEDIATE_FLOW); | 467 | FlowLiveType.IMMEDIATE_FLOW); |
| 457 | - deviceFlowTable.addWithCalAndSetFlowLiveType(newFlowEntry); | 468 | + deviceFlowTable.addWithCalAndSetFlowLiveType(newFlowEntry); |
| 458 | } | 469 | } |
| 459 | } | 470 | } |
| 460 | 471 | ||
| 461 | /** | 472 | /** |
| 462 | - * remove typed flow entry from the internal flow table. | 473 | + * Removes typed flow entry from the internal flow table. |
| 463 | * | 474 | * |
| 464 | * @param flowRules the flow entries | 475 | * @param flowRules the flow entries |
| 465 | - * | ||
| 466 | */ | 476 | */ |
| 467 | public synchronized void removeFlows(FlowRule... flowRules) { | 477 | public synchronized void removeFlows(FlowRule... flowRules) { |
| 468 | for (FlowRule rule : flowRules) { | 478 | for (FlowRule rule : flowRules) { |
| ... | @@ -472,10 +482,9 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -472,10 +482,9 @@ public class NewAdaptiveFlowStatsCollector { |
| 472 | 482 | ||
| 473 | // same as removeFlows() function | 483 | // same as removeFlows() function |
| 474 | /** | 484 | /** |
| 475 | - * remove typed flow entry from the internal flow table. | 485 | + * Removes typed flow entry from the internal flow table. |
| 476 | * | 486 | * |
| 477 | * @param flowRules the flow entries | 487 | * @param flowRules the flow entries |
| 478 | - * | ||
| 479 | */ | 488 | */ |
| 480 | public void flowRemoved(FlowRule... flowRules) { | 489 | public void flowRemoved(FlowRule... flowRules) { |
| 481 | removeFlows(flowRules); | 490 | removeFlows(flowRules); |
| ... | @@ -483,19 +492,16 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -483,19 +492,16 @@ public class NewAdaptiveFlowStatsCollector { |
| 483 | 492 | ||
| 484 | // same as addOrUpdateFlows() function | 493 | // same as addOrUpdateFlows() function |
| 485 | /** | 494 | /** |
| 486 | - * add or update typed flow entry from flow entry into the internal flow table. | 495 | + * Adds or updates typed flow entry from flow entry into the internal flow table. |
| 487 | * | 496 | * |
| 488 | * @param flowEntries the flow entry list | 497 | * @param flowEntries the flow entry list |
| 489 | - * | ||
| 490 | */ | 498 | */ |
| 491 | public void pushFlowMetrics(List<FlowEntry> flowEntries) { | 499 | public void pushFlowMetrics(List<FlowEntry> flowEntries) { |
| 492 | - flowEntries.forEach(fe -> { | 500 | + flowEntries.forEach(this::addOrUpdateFlows); |
| 493 | - addOrUpdateFlows(fe); | ||
| 494 | - }); | ||
| 495 | } | 501 | } |
| 496 | 502 | ||
| 497 | /** | 503 | /** |
| 498 | - * returns flowMissingXid that indicates the execution of flowMissing process or not(NO_FLOW_MISSING_XID(-1)). | 504 | + * Returns flowMissingXid that indicates the execution of flowMissing process or not(NO_FLOW_MISSING_XID(-1)). |
| 499 | * | 505 | * |
| 500 | * @return xid of missing flow | 506 | * @return xid of missing flow |
| 501 | */ | 507 | */ |
| ... | @@ -504,10 +510,9 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -504,10 +510,9 @@ public class NewAdaptiveFlowStatsCollector { |
| 504 | } | 510 | } |
| 505 | 511 | ||
| 506 | /** | 512 | /** |
| 507 | - * set flowMissingXid, namely OFFlowStatsRequest match any ALL message Id. | 513 | + * Sets flowMissingXid, namely OFFlowStatsRequest match any ALL message Id. |
| 508 | * | 514 | * |
| 509 | * @param flowMissingXid the OFFlowStatsRequest message Id | 515 | * @param flowMissingXid the OFFlowStatsRequest message Id |
| 510 | - * | ||
| 511 | */ | 516 | */ |
| 512 | public void setFlowMissingXid(long flowMissingXid) { | 517 | public void setFlowMissingXid(long flowMissingXid) { |
| 513 | this.flowMissingXid = flowMissingXid; | 518 | this.flowMissingXid = flowMissingXid; |
| ... | @@ -531,8 +536,7 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -531,8 +536,7 @@ public class NewAdaptiveFlowStatsCollector { |
| 531 | private long removeCount = 0; | 536 | private long removeCount = 0; |
| 532 | 537 | ||
| 533 | /** | 538 | /** |
| 534 | - * Resets all count values with zero. | 539 | + * Resets all count values to zero. |
| 535 | - * | ||
| 536 | */ | 540 | */ |
| 537 | public void resetAllCount() { | 541 | public void resetAllCount() { |
| 538 | addCount = 0; | 542 | addCount = 0; |
| ... | @@ -565,8 +569,7 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -565,8 +569,7 @@ public class NewAdaptiveFlowStatsCollector { |
| 565 | /** | 569 | /** |
| 566 | * Gets the number of flow entry in flow table. | 570 | * Gets the number of flow entry in flow table. |
| 567 | * | 571 | * |
| 568 | - * @return the number of flow entry. | 572 | + * @return the number of flow entry |
| 569 | - * | ||
| 570 | */ | 573 | */ |
| 571 | public long getFlowCount() { | 574 | public long getFlowCount() { |
| 572 | return flowEntries.values().stream().mapToLong(Set::size).sum(); | 575 | return flowEntries.values().stream().mapToLong(Set::size).sum(); |
| ... | @@ -576,8 +579,7 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -576,8 +579,7 @@ public class NewAdaptiveFlowStatsCollector { |
| 576 | * Gets the number of flow entry in flow table. | 579 | * Gets the number of flow entry in flow table. |
| 577 | * | 580 | * |
| 578 | * @param rule the flow rule | 581 | * @param rule the flow rule |
| 579 | - * @return the typed flow entry. | 582 | + * @return the typed flow entry |
| 580 | - * | ||
| 581 | */ | 583 | */ |
| 582 | public TypedStoredFlowEntry getFlowEntry(FlowRule rule) { | 584 | public TypedStoredFlowEntry getFlowEntry(FlowRule rule) { |
| 583 | checkNotNull(rule); | 585 | checkNotNull(rule); |
| ... | @@ -588,8 +590,7 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -588,8 +590,7 @@ public class NewAdaptiveFlowStatsCollector { |
| 588 | /** | 590 | /** |
| 589 | * Gets the all typed flow entries in flow table. | 591 | * Gets the all typed flow entries in flow table. |
| 590 | * | 592 | * |
| 591 | - * @return the set of typed flow entry. | 593 | + * @return the set of typed flow entry |
| 592 | - * | ||
| 593 | */ | 594 | */ |
| 594 | public Set<TypedStoredFlowEntry> getFlowEntries() { | 595 | public Set<TypedStoredFlowEntry> getFlowEntries() { |
| 595 | return getFlowEntriesInternal(); | 596 | return getFlowEntriesInternal(); |
| ... | @@ -598,38 +599,34 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -598,38 +599,34 @@ public class NewAdaptiveFlowStatsCollector { |
| 598 | /** | 599 | /** |
| 599 | * Gets the short typed flow entries in flow table. | 600 | * Gets the short typed flow entries in flow table. |
| 600 | * | 601 | * |
| 601 | - * @return the set of typed flow entry. | 602 | + * @return the set of typed flow entry |
| 602 | - * | ||
| 603 | */ | 603 | */ |
| 604 | public Set<StoredFlowEntry> getShortFlows() { | 604 | public Set<StoredFlowEntry> getShortFlows() { |
| 605 | - return ImmutableSet.copyOf(shortFlows); //Sets.newHashSet(shortFlows); | 605 | + return ImmutableSet.copyOf(shortFlows); |
| 606 | } | 606 | } |
| 607 | 607 | ||
| 608 | /** | 608 | /** |
| 609 | * Gets the mid typed flow entries in flow table. | 609 | * Gets the mid typed flow entries in flow table. |
| 610 | * | 610 | * |
| 611 | - * @return the set of typed flow entry. | 611 | + * @return the set of typed flow entry |
| 612 | - * | ||
| 613 | */ | 612 | */ |
| 614 | public Set<StoredFlowEntry> getMidFlows() { | 613 | public Set<StoredFlowEntry> getMidFlows() { |
| 615 | - return ImmutableSet.copyOf(midFlows); //Sets.newHashSet(midFlows); | 614 | + return ImmutableSet.copyOf(midFlows); |
| 616 | } | 615 | } |
| 617 | 616 | ||
| 618 | /** | 617 | /** |
| 619 | * Gets the long typed flow entries in flow table. | 618 | * Gets the long typed flow entries in flow table. |
| 620 | * | 619 | * |
| 621 | - * @return the set of typed flow entry. | 620 | + * @return the set of typed flow entry |
| 622 | - * | ||
| 623 | */ | 621 | */ |
| 624 | public Set<StoredFlowEntry> getLongFlows() { | 622 | public Set<StoredFlowEntry> getLongFlows() { |
| 625 | - return ImmutableSet.copyOf(longFlows); //Sets.newHashSet(longFlows); | 623 | + return ImmutableSet.copyOf(longFlows); |
| 626 | } | 624 | } |
| 627 | 625 | ||
| 628 | /** | 626 | /** |
| 629 | * Add typed flow entry into table only. | 627 | * Add typed flow entry into table only. |
| 630 | * | 628 | * |
| 631 | * @param rule the flow rule | 629 | * @param rule the flow rule |
| 632 | - * | ||
| 633 | */ | 630 | */ |
| 634 | public synchronized void add(TypedStoredFlowEntry rule) { | 631 | public synchronized void add(TypedStoredFlowEntry rule) { |
| 635 | checkNotNull(rule); | 632 | checkNotNull(rule); |
| ... | @@ -643,11 +640,10 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -643,11 +640,10 @@ public class NewAdaptiveFlowStatsCollector { |
| 643 | } | 640 | } |
| 644 | 641 | ||
| 645 | /** | 642 | /** |
| 646 | - * Calculates and set the flow live type at the first time, | 643 | + * Calculates and sets the flow live type at the first time, |
| 647 | * and then add it into a corresponding typed flow table. | 644 | * and then add it into a corresponding typed flow table. |
| 648 | * | 645 | * |
| 649 | * @param rule the flow rule | 646 | * @param rule the flow rule |
| 650 | - * | ||
| 651 | */ | 647 | */ |
| 652 | public void calAndSetFlowLiveType(TypedStoredFlowEntry rule) { | 648 | public void calAndSetFlowLiveType(TypedStoredFlowEntry rule) { |
| 653 | checkNotNull(rule); | 649 | checkNotNull(rule); |
| ... | @@ -656,13 +652,12 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -656,13 +652,12 @@ public class NewAdaptiveFlowStatsCollector { |
| 656 | } | 652 | } |
| 657 | 653 | ||
| 658 | /** | 654 | /** |
| 659 | - * Add the typed flow entry into table, and calculates and set the flow live type, | 655 | + * Adds the typed flow entry into table, and calculates and set the flow live type, |
| 660 | * and then add it into a corresponding typed flow table. | 656 | * and then add it into a corresponding typed flow table. |
| 661 | * | 657 | * |
| 662 | * @param rule the flow rule | 658 | * @param rule the flow rule |
| 663 | - * | ||
| 664 | */ | 659 | */ |
| 665 | - public synchronized void addWithCalAndSetFlowLiveType(TypedStoredFlowEntry rule) { | 660 | + public synchronized void addWithCalAndSetFlowLiveType(TypedStoredFlowEntry rule) { |
| 666 | checkNotNull(rule); | 661 | checkNotNull(rule); |
| 667 | 662 | ||
| 668 | //rule have to be new DefaultTypedFlowEntry | 663 | //rule have to be new DefaultTypedFlowEntry |
| ... | @@ -671,10 +666,10 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -671,10 +666,10 @@ public class NewAdaptiveFlowStatsCollector { |
| 671 | calAndSetFlowLiveTypeInternal(rule); | 666 | calAndSetFlowLiveTypeInternal(rule); |
| 672 | addWithSetFlowLiveTypeCount++; | 667 | addWithSetFlowLiveTypeCount++; |
| 673 | } else { | 668 | } else { |
| 674 | - log.debug("addWithCalAndSetFlowLiveType, FlowId=" + Long.toHexString(rule.id().value()) | 669 | + if (log.isDebugEnabled()) { |
| 675 | - + " ADD Failed, cause it may already exists in table !!!," | 670 | + log.debug("FlowId {} ADD failed, it may already exist in table - {}", |
| 676 | - + " AdaptiveStats collection thread for {}", | 671 | + rule.id(), sw.getStringId()); |
| 677 | - sw.getStringId()); | 672 | + } |
| 678 | } | 673 | } |
| 679 | } | 674 | } |
| 680 | 675 | ||
| ... | @@ -701,18 +696,18 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -701,18 +696,18 @@ public class NewAdaptiveFlowStatsCollector { |
| 701 | 696 | ||
| 702 | if (rule.flowLiveType() != prevFlowLiveType) { | 697 | if (rule.flowLiveType() != prevFlowLiveType) { |
| 703 | switch (prevFlowLiveType) { | 698 | switch (prevFlowLiveType) { |
| 704 | - // delete it from previous flow table | 699 | + // delete it from previous flow table |
| 705 | - case SHORT_FLOW: | 700 | + case SHORT_FLOW: |
| 706 | - shortFlows.remove(rule); | 701 | + shortFlows.remove(rule); |
| 707 | - break; | 702 | + break; |
| 708 | - case MID_FLOW: | 703 | + case MID_FLOW: |
| 709 | - midFlows.remove(rule); | 704 | + midFlows.remove(rule); |
| 710 | - break; | 705 | + break; |
| 711 | - case LONG_FLOW: | 706 | + case LONG_FLOW: |
| 712 | - longFlows.remove(rule); | 707 | + longFlows.remove(rule); |
| 713 | - break; | 708 | + break; |
| 714 | - default: | 709 | + default: |
| 715 | - break; | 710 | + break; |
| 716 | } | 711 | } |
| 717 | } | 712 | } |
| 718 | } | 713 | } |
| ... | @@ -728,71 +723,60 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -728,71 +723,60 @@ public class NewAdaptiveFlowStatsCollector { |
| 728 | 723 | ||
| 729 | 724 | ||
| 730 | switch (fe.flowLiveType()) { | 725 | switch (fe.flowLiveType()) { |
| 731 | - case IMMEDIATE_FLOW: | 726 | + case IMMEDIATE_FLOW: |
| 732 | - if (liveTime >= longPollInterval) { | 727 | + if (liveTime >= longPollInterval) { |
| 733 | - fe.setFlowLiveType(FlowLiveType.LONG_FLOW); | 728 | + fe.setFlowLiveType(FlowLiveType.LONG_FLOW); |
| 734 | - longFlows.add(fe); | 729 | + longFlows.add(fe); |
| 735 | - } else if (liveTime >= midPollInterval) { | 730 | + } else if (liveTime >= midPollInterval) { |
| 736 | - fe.setFlowLiveType(FlowLiveType.MID_FLOW); | 731 | + fe.setFlowLiveType(FlowLiveType.MID_FLOW); |
| 737 | - midFlows.add(fe); | 732 | + midFlows.add(fe); |
| 738 | - } else if (liveTime >= calAndPollInterval) { | 733 | + } else if (liveTime >= calAndPollInterval) { |
| 739 | - fe.setFlowLiveType(FlowLiveType.SHORT_FLOW); | 734 | + fe.setFlowLiveType(FlowLiveType.SHORT_FLOW); |
| 740 | - shortFlows.add(fe); | 735 | + shortFlows.add(fe); |
| 741 | - } | 736 | + } |
| 742 | - break; | 737 | + break; |
| 743 | - case SHORT_FLOW: | 738 | + case SHORT_FLOW: |
| 744 | - if (liveTime >= longPollInterval) { | 739 | + if (liveTime >= longPollInterval) { |
| 745 | - fe.setFlowLiveType(FlowLiveType.LONG_FLOW); | 740 | + fe.setFlowLiveType(FlowLiveType.LONG_FLOW); |
| 746 | - shortFlows.remove(fe); | 741 | + shortFlows.remove(fe); |
| 747 | - longFlows.add(fe); | 742 | + longFlows.add(fe); |
| 748 | - } else if (liveTime >= midPollInterval) { | 743 | + } else if (liveTime >= midPollInterval) { |
| 749 | - fe.setFlowLiveType(FlowLiveType.MID_FLOW); | 744 | + fe.setFlowLiveType(FlowLiveType.MID_FLOW); |
| 750 | - shortFlows.remove(fe); | 745 | + shortFlows.remove(fe); |
| 751 | - midFlows.add(fe); | 746 | + midFlows.add(fe); |
| 752 | - } | 747 | + } |
| 753 | - break; | 748 | + break; |
| 754 | - case MID_FLOW: | 749 | + case MID_FLOW: |
| 755 | - if (liveTime >= longPollInterval) { | 750 | + if (liveTime >= longPollInterval) { |
| 756 | - fe.setFlowLiveType(FlowLiveType.LONG_FLOW); | 751 | + fe.setFlowLiveType(FlowLiveType.LONG_FLOW); |
| 757 | - midFlows.remove(fe); | 752 | + midFlows.remove(fe); |
| 758 | - longFlows.add(fe); | 753 | + longFlows.add(fe); |
| 759 | - } | 754 | + } |
| 760 | - break; | 755 | + break; |
| 761 | - case LONG_FLOW: | 756 | + case LONG_FLOW: |
| 762 | - if (fromLastSeen > entirePollInterval) { | 757 | + if (fromLastSeen > entirePollInterval) { |
| 763 | - log.trace("checkAndMoveLiveFlowInternal, flow is already removed at switch."); | 758 | + log.trace("checkAndMoveLiveFlowInternal: flow is already removed at switch."); |
| 764 | - return false; | ||
| 765 | - } | ||
| 766 | - break; | ||
| 767 | - case UNKNOWN_FLOW: // Unknown flow is an internal error flow type, just fall through | ||
| 768 | - default : | ||
| 769 | - // Error Unknown Live Type | ||
| 770 | - log.error("checkAndMoveLiveFlowInternal, Unknown Live Type error!" | ||
| 771 | - + "AdaptiveStats collection thread for {}", | ||
| 772 | - sw.getStringId()); | ||
| 773 | return false; | 759 | return false; |
| 760 | + } | ||
| 761 | + break; | ||
| 762 | + case UNKNOWN_FLOW: // Unknown flow is an internal error flow type, just fall through | ||
| 763 | + default: | ||
| 764 | + log.error("Unknown live type error for {}", sw.getStringId()); | ||
| 765 | + return false; | ||
| 774 | } | 766 | } |
| 775 | 767 | ||
| 776 | - log.debug("checkAndMoveLiveFlowInternal, FlowId=" + Long.toHexString(fe.id().value()) | 768 | + if (log.isTraceEnabled()) { |
| 777 | - + ", state=" + fe.state() | 769 | + log.trace(CHECK_AND_MOVE_LOG, fe.id(), fe.state(), fe.flowLiveType(), |
| 778 | - + ", After liveType=" + fe.flowLiveType() | 770 | + liveTime, fe.life(), fe.bytes(), fe.packets(), fromLastSeen, |
| 779 | - + ", liveTime=" + liveTime | 771 | + fe.priority(), fe.selector().criteria(), fe.treatment(), |
| 780 | - + ", life=" + fe.life() | 772 | + sw.getStringId()); |
| 781 | - + ", bytes=" + fe.bytes() | 773 | + } |
| 782 | - + ", packets=" + fe.packets() | ||
| 783 | - + ", fromLastSeen=" + fromLastSeen | ||
| 784 | - + ", priority=" + fe.priority() | ||
| 785 | - + ", selector=" + fe.selector().criteria() | ||
| 786 | - + ", treatment=" + fe.treatment() | ||
| 787 | - + " AdaptiveStats collection thread for {}", | ||
| 788 | - sw.getStringId()); | ||
| 789 | 774 | ||
| 790 | return true; | 775 | return true; |
| 791 | } | 776 | } |
| 792 | 777 | ||
| 793 | /** | 778 | /** |
| 794 | - * Check and move live type for all type flow entries in table at every calAndPollInterval time. | 779 | + * Checks and moves live type for all type flow entries in table at every calAndPollInterval time. |
| 795 | - * | ||
| 796 | */ | 780 | */ |
| 797 | public void checkAndMoveLiveFlowAll() { | 781 | public void checkAndMoveLiveFlowAll() { |
| 798 | Set<TypedStoredFlowEntry> typedFlowEntries = getFlowEntriesInternal(); | 782 | Set<TypedStoredFlowEntry> typedFlowEntries = getFlowEntriesInternal(); |
| ... | @@ -805,7 +789,7 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -805,7 +789,7 @@ public class NewAdaptiveFlowStatsCollector { |
| 805 | }); | 789 | }); |
| 806 | 790 | ||
| 807 | // print table counts for debug | 791 | // print table counts for debug |
| 808 | - if (log.isDebugEnabled()) { | 792 | + if (log.isTraceEnabled()) { |
| 809 | synchronized (this) { | 793 | synchronized (this) { |
| 810 | long totalFlowCount = getFlowCount(); | 794 | long totalFlowCount = getFlowCount(); |
| 811 | long shortFlowCount = shortFlows.size(); | 795 | long shortFlowCount = shortFlows.size(); |
| ... | @@ -814,73 +798,58 @@ public class NewAdaptiveFlowStatsCollector { | ... | @@ -814,73 +798,58 @@ public class NewAdaptiveFlowStatsCollector { |
| 814 | long immediateFlowCount = totalFlowCount - shortFlowCount - midFlowCount - longFlowCount; | 798 | long immediateFlowCount = totalFlowCount - shortFlowCount - midFlowCount - longFlowCount; |
| 815 | long calTotalCount = addCount + addWithSetFlowLiveTypeCount - removeCount; | 799 | long calTotalCount = addCount + addWithSetFlowLiveTypeCount - removeCount; |
| 816 | 800 | ||
| 817 | - log.debug("--------------------------------------------------------------------------- for {}", | 801 | + log.trace(CHECK_AND_MOVE_COUNT_LOG, totalFlowCount, calTotalCount, |
| 818 | - sw.getStringId()); | 802 | + immediateFlowCount, shortFlowCount, midFlowCount, longFlowCount, |
| 819 | - log.debug("checkAndMoveLiveFlowAll, Total Flow_Count=" + totalFlowCount | 803 | + addCount, addWithSetFlowLiveTypeCount, removeCount, sw.getStringId()); |
| 820 | - + ", add - remove_Count=" + calTotalCount | 804 | + |
| 821 | - + ", IMMEDIATE_FLOW_Count=" + immediateFlowCount | ||
| 822 | - + ", SHORT_FLOW_Count=" + shortFlowCount | ||
| 823 | - + ", MID_FLOW_Count=" + midFlowCount | ||
| 824 | - + ", LONG_FLOW_Count=" + longFlowCount | ||
| 825 | - + ", add_Count=" + addCount | ||
| 826 | - + ", addWithSetFlowLiveType_Count=" + addWithSetFlowLiveTypeCount | ||
| 827 | - + ", remove_Count=" + removeCount | ||
| 828 | - + " AdaptiveStats collection thread for {}", sw.getStringId()); | ||
| 829 | - log.debug("--------------------------------------------------------------------------- for {}", | ||
| 830 | - sw.getStringId()); | ||
| 831 | if (totalFlowCount != calTotalCount) { | 805 | if (totalFlowCount != calTotalCount) { |
| 832 | - log.error("checkAndMoveLiveFlowAll, Real total flow count and " | 806 | + log.error("Real total flow count and calculated total flow count do NOT match"); |
| 833 | - + "calculated total flow count do NOT match, something is wrong internally " | ||
| 834 | - + "or check counter value bound is over!"); | ||
| 835 | } | 807 | } |
| 836 | if (immediateFlowCount < 0) { | 808 | if (immediateFlowCount < 0) { |
| 837 | - log.error("checkAndMoveLiveFlowAll, IMMEDIATE_FLOW count is negative, " | 809 | + log.error("Immediate flow count is negative"); |
| 838 | - + "something is wrong internally " | ||
| 839 | - + "or check counter value bound is over!"); | ||
| 840 | } | 810 | } |
| 841 | } | 811 | } |
| 842 | } | 812 | } |
| 843 | - log.trace("checkAndMoveLiveFlowAll, AdaptiveStats for {}", sw.getStringId()); | 813 | + log.trace("checkAndMoveLiveFlowAll: adaptiveStats for {}", sw.getStringId()); |
| 844 | } | 814 | } |
| 845 | 815 | ||
| 846 | /** | 816 | /** |
| 847 | - * Remove the typed flow entry from table. | 817 | + * Removes the typed flow entry from table. |
| 848 | * | 818 | * |
| 849 | * @param rule the flow rule | 819 | * @param rule the flow rule |
| 850 | - * | ||
| 851 | */ | 820 | */ |
| 852 | public synchronized void remove(FlowRule rule) { | 821 | public synchronized void remove(FlowRule rule) { |
| 853 | checkNotNull(rule); | 822 | checkNotNull(rule); |
| 854 | 823 | ||
| 855 | TypedStoredFlowEntry removeStore = getFlowEntryInternal(rule); | 824 | TypedStoredFlowEntry removeStore = getFlowEntryInternal(rule); |
| 856 | if (removeStore != null) { | 825 | if (removeStore != null) { |
| 857 | - removeLiveFlowsInternal((TypedStoredFlowEntry) removeStore); | 826 | + removeLiveFlowsInternal(removeStore); |
| 858 | boolean result = getFlowEntriesInternal(rule.id()).remove(removeStore); | 827 | boolean result = getFlowEntriesInternal(rule.id()).remove(removeStore); |
| 859 | 828 | ||
| 860 | if (result) { | 829 | if (result) { |
| 861 | removeCount++; | 830 | removeCount++; |
| 862 | } | 831 | } |
| 863 | } | 832 | } |
| 864 | - } | 833 | + } |
| 865 | 834 | ||
| 866 | // Remove the typed flow entry from corresponding table | 835 | // Remove the typed flow entry from corresponding table |
| 867 | private void removeLiveFlowsInternal(TypedStoredFlowEntry fe) { | 836 | private void removeLiveFlowsInternal(TypedStoredFlowEntry fe) { |
| 868 | switch (fe.flowLiveType()) { | 837 | switch (fe.flowLiveType()) { |
| 869 | - case IMMEDIATE_FLOW: | 838 | + case IMMEDIATE_FLOW: |
| 870 | - // do nothing | 839 | + // do nothing |
| 871 | - break; | 840 | + break; |
| 872 | - case SHORT_FLOW: | 841 | + case SHORT_FLOW: |
| 873 | - shortFlows.remove(fe); | 842 | + shortFlows.remove(fe); |
| 874 | - break; | 843 | + break; |
| 875 | - case MID_FLOW: | 844 | + case MID_FLOW: |
| 876 | - midFlows.remove(fe); | 845 | + midFlows.remove(fe); |
| 877 | - break; | 846 | + break; |
| 878 | - case LONG_FLOW: | 847 | + case LONG_FLOW: |
| 879 | - longFlows.remove(fe); | 848 | + longFlows.remove(fe); |
| 880 | - break; | 849 | + break; |
| 881 | - default: // error in Flow Live Type | 850 | + default: // error in Flow Live Type |
| 882 | - log.error("removeLiveFlowsInternal, Unknown Live Type error!"); | 851 | + log.error("removeLiveFlowsInternal: unknown live type error"); |
| 883 | - break; | 852 | + break; |
| 884 | } | 853 | } |
| 885 | } | 854 | } |
| 886 | } | 855 | } | ... | ... |
-
Please register or login to post a comment