summaryrefslogtreecommitdiffstats
path: root/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/cache/DumpCacheManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/cache/DumpCacheManager.java')
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/cache/DumpCacheManager.java23
1 files changed, 11 insertions, 12 deletions
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/cache/DumpCacheManager.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/cache/DumpCacheManager.java
index 1acd9de4b..272aa8473 100644
--- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/cache/DumpCacheManager.java
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/cache/DumpCacheManager.java
@@ -19,12 +19,11 @@ package io.fd.honeycomb.translate.v3po.util.cache;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Optional;
+import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.DumpCheckFailedException;
import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException;
import io.fd.honeycomb.translate.v3po.util.cache.noop.NoopDumpPostProcessingFunction;
-import io.fd.honeycomb.translate.ModificationCache;
import javax.annotation.Nonnull;
-import org.openvpp.jvpp.dto.JVppReplyDump;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,7 +31,7 @@ import org.slf4j.LoggerFactory;
* Manager responsible for returning Data object dumps<br> either from cache or by invoking specified {@link
* EntityDumpExecutor}
*/
-public final class DumpCacheManager<T extends JVppReplyDump, U> {
+public final class DumpCacheManager<T, U> {
private static final Logger LOG = LoggerFactory.getLogger(DumpCacheManager.class);
@@ -49,21 +48,21 @@ public final class DumpCacheManager<T extends JVppReplyDump, U> {
/**
* Returns {@link Optional<T>} of dump
*/
- public Optional<T> getDump(@Nonnull String entityKey, @Nonnull ModificationCache cache)
+ public Optional<T> getDump(@Nonnull String entityKey, @Nonnull ModificationCache cache, final U dumpParams)
throws DumpExecutionFailedException {
- //this key binding to every log has its logic ,because every customizer have its own cache manager and if
- //there is need for debugging/fixing some complex call with a lot of data,you can get lost in those logs
+ // this key binding to every log has its logic ,because every customizer have its own cache manager and if
+ // there is need for debugging/fixing some complex call with a lot of data,you can get lost in those logs
LOG.debug("Loading dump for KEY[{}]", entityKey);
T dump = (T) cache.get(entityKey);
if (dump == null) {
LOG.debug("Dump for KEY[{}] not present in cache,invoking dump executor", entityKey);
+ // binds and execute dump to be thread-save
+ dump = dumpExecutor.executeDump(dumpParams);
- dump = dumpExecutor.executeDump();
-
- //this is not a critical exception, so its only logged here
+ // this is not a critical exception, so its only logged here
try {
dumpNonEmptyCheck.assertNotEmpty(dump);
} catch (DumpCheckFailedException e) {
@@ -71,7 +70,7 @@ public final class DumpCacheManager<T extends JVppReplyDump, U> {
return Optional.absent();
}
- //no need to check if post processor active,if wasnt set,default no-op will be used
+ // no need to check if post processor active,if wasn't set,default no-op will be used
LOG.debug("Post-processing dump for KEY[{}]", entityKey);
dump = postProcessor.apply(dump);
@@ -83,14 +82,14 @@ public final class DumpCacheManager<T extends JVppReplyDump, U> {
}
}
- public static final class DumpCacheManagerBuilder<T extends JVppReplyDump, U> {
+ public static final class DumpCacheManagerBuilder<T, U> {
private EntityDumpExecutor<T, U> dumpExecutor;
private EntityDumpNonEmptyCheck<T> dumpNonEmptyCheck;
private EntityDumpPostProcessingFunction<T> postProcessingFunction;
public DumpCacheManagerBuilder() {
- //for cases when user does not set specific post-processor
+ // for cases when user does not set specific post-processor
postProcessingFunction = new NoopDumpPostProcessingFunction<T>();
}
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592