test_class.declarator: job
test_class.modifier: private
test_class.original_string: private PersistentFiltersJob job;
test_class.type: PersistentFiltersJob
test_class.var_name: job
test_class.declarator: bloomFilterManager
test_class.modifier: private
test_class.original_string: private BloomFilterManager<BloomFilter, ?> bloomFilterManager;
test_class.type: BloomFilterManager<BloomFilter, ?>
test_class.var_name: bloomFilterManager
test_class.declarator: persistentManager
test_class.modifier: private
test_class.original_string: private PersistentManager<BloomFilter> persistentManager;
test_class.type: PersistentManager<BloomFilter>
test_class.var_name: persistentManager
test_class.declarator: filterUpdateTimesCounter
test_class.modifier: private
test_class.original_string: private LongAdder filterUpdateTimesCounter;
test_class.type: LongAdder
test_class.var_name: filterUpdateTimesCounter
test_class.declarator: criteria = new TriggerPersistenceCriteria(Duration.ofSeconds(1), 10)
test_class.modifier: private
test_class.original_string: private TriggerPersistenceCriteria criteria = new TriggerPersistenceCriteria(Duration.ofSeconds(1), 10);
test_class.type: TriggerPersistenceCriteria
test_class.var_name: criteria
test_class.file: filter-service-core/src/test/java/cn/leancloud/filter/service/PersistentFiltersJobTest.java
test_class.identifier: PersistentFiltersJobTest
test_case.body: @Test
      public void testPersistentThrowsException() throws IOException {
          final Exception exception = new IOException("expected exception");
          doThrow(exception).when(persistentManager).freezeAllFilters(bloomFilterManager);
          filterUpdateTimesCounter.add(100);
          // eat exception
          job.run();
          assertThat(filterUpdateTimesCounter.sum()).isZero();
          verify(persistentManager, times(1)).freezeAllFilters(bloomFilterManager);
      }
test_case.class_method_signature: PersistentFiltersJobTest.testPersistentThrowsException()
test_case.full_signature: @Test public void testPersistentThrowsException()
test_case.identifier: testPersistentThrowsException
test_case.invocations: freezeAllFilters when doThrow add run isZero assertThat sum freezeAllFilters verify times
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPersistentThrowsException()
focal_class.declarator: logger = LoggerFactory.getLogger(PersistentFiltersJob.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(PersistentFiltersJob.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: bloomFilterManager
focal_class.modifier: private final
focal_class.original_string: private final BloomFilterManager<F, ?> bloomFilterManager;
focal_class.type: BloomFilterManager<F, ?>
focal_class.var_name: bloomFilterManager
focal_class.declarator: persistentManager
focal_class.modifier: private final
focal_class.original_string: private final PersistentManager<F> persistentManager;
focal_class.type: PersistentManager<F>
focal_class.var_name: persistentManager
focal_class.declarator: filterUpdateTimesCounter
focal_class.modifier: private final
focal_class.original_string: private final LongAdder filterUpdateTimesCounter;
focal_class.type: LongAdder
focal_class.var_name: filterUpdateTimesCounter
focal_class.declarator: criteria
focal_class.modifier: private final
focal_class.original_string: private final TriggerPersistenceCriteria criteria;
focal_class.type: TriggerPersistenceCriteria
focal_class.var_name: criteria
focal_class.file: filter-service-core/src/main/java/cn/leancloud/filter/service/PersistentFiltersJob.java
focal_class.identifier: PersistentFiltersJob
focal_class.interfaces: implements Runnable
focal_class.class_method_signature: PersistentFiltersJob.PersistentFiltersJob(BloomFilterManager<F, ?> bloomFilterManager,
                           PersistentManager<F> persistentManager,
                           LongAdder filterUpdateTimesCounter,
                           TriggerPersistenceCriteria criteria)
focal_class.full_signature:   PersistentFiltersJob(BloomFilterManager<F, ?> bloomFilterManager,
                           PersistentManager<F> persistentManager,
                           LongAdder filterUpdateTimesCounter,
                           TriggerPersistenceCriteria criteria)
focal_class.identifier: PersistentFiltersJob
focal_class.parameters: (BloomFilterManager<F, ?> bloomFilterManager,
                           PersistentManager<F> persistentManager,
                           LongAdder filterUpdateTimesCounter,
                           TriggerPersistenceCriteria criteria)
focal_class.signature:  PersistentFiltersJob(BloomFilterManager<F, ?> bloomFilterManager,
                           PersistentManager<F> persistentManager,
                           LongAdder filterUpdateTimesCounter,
                           TriggerPersistenceCriteria criteria)
focal_class.class_method_signature: PersistentFiltersJob.run()
focal_class.full_signature: @Override public void run()
focal_class.identifier: run
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void run()
focal_class.class_method_signature: PersistentFiltersJob.doPersistence()
focal_class.full_signature: private void doPersistence()
focal_class.identifier: doPersistence
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void doPersistence()
focal_method.body: @Override
      public void run() {
          // synchronized on an instance of a class only to prevent several PersistentFiltersJob to
          // access on the same filterUpdateTimesCounter. It's not mean to and can't prevent thread
          // not in PersistentFiltersJob to access this counter
          synchronized (filterUpdateTimesCounter) {
              final long sum = filterUpdateTimesCounter.sum();
              if (sum > criteria.updatesThreshold()) {
                  if (logger.isDebugEnabled()) {
                      logger.debug("Updated {} times in last {} seconds meets threshold {} to persistence filters",
                              sum, criteria.checkingPeriod().getSeconds(), criteria.updatesThreshold());
                  }
  
                  filterUpdateTimesCounter.reset();
                  doPersistence();
              }
          }
      }
focal_method.class_method_signature: PersistentFiltersJob.run()
focal_method.full_signature: @Override public void run()
focal_method.identifier: run
focal_method.invocations: sum updatesThreshold isDebugEnabled debug getSeconds checkingPeriod updatesThreshold reset doPersistence
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void run()