test_class.declarator: factory
test_class.modifier: private
test_class.original_string: private BloomFilterFactory factory;
test_class.type: BloomFilterFactory
test_class.var_name: factory
test_class.declarator: tempDirPath
test_class.modifier: private
test_class.original_string: private Path tempDirPath;
test_class.type: Path
test_class.var_name: tempDirPath
test_class.declarator: filterManager
test_class.modifier: private
test_class.original_string: private BloomFilterManager filterManager;
test_class.type: BloomFilterManager
test_class.var_name: filterManager
test_class.declarator: manager
test_class.modifier: private
test_class.original_string: private PersistentManager<BloomFilter> manager;
test_class.type: PersistentManager<BloomFilter>
test_class.var_name: manager
test_class.file: filter-service-core/src/test/java/cn/leancloud/filter/service/PersistentManagerTest.java
test_class.identifier: PersistentManagerTest
test_case.body: @Test
      public void freezeAllFilters() throws IOException {
          final List<FilterRecord<BloomFilter>> records = generateFilterRecords(10);
          when(filterManager.iterator()).thenReturn(records.iterator());
  
          manager.freezeAllFilters(filterManager);
  
          try (FilterRecordInputStream<GuavaBloomFilter> stream = new FilterRecordInputStream<>(
                  manager.persistentFilePath(),
                  new GuavaBloomFilterFactory())) {
              for (FilterRecord<BloomFilter> expectRecord : records) {
                  assertThat(stream.nextFilterRecord()).isEqualTo(expectRecord);
              }
  
              assertThat(stream.nextFilterRecord()).isNull();
          }
      }
test_case.class_method_signature: PersistentManagerTest.freezeAllFilters()
test_case.full_signature: @Test public void freezeAllFilters()
test_case.identifier: freezeAllFilters
test_case.invocations: generateFilterRecords thenReturn when iterator iterator freezeAllFilters persistentFilePath isEqualTo assertThat nextFilterRecord isNull assertThat nextFilterRecord
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void freezeAllFilters()
focal_class.declarator: logger = LoggerFactory.getLogger(PersistentManager.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(PersistentManager.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: LOCK_FILE_NAME = "lock"
focal_class.modifier: private static final
focal_class.original_string: private static final String LOCK_FILE_NAME = "lock";
focal_class.type: String
focal_class.var_name: LOCK_FILE_NAME
focal_class.declarator: TEMPORARY_PERSISTENT_FILE_SUFFIX = ".tmp"
focal_class.modifier: private static final
focal_class.original_string: private static final String TEMPORARY_PERSISTENT_FILE_SUFFIX = ".tmp";
focal_class.type: String
focal_class.var_name: TEMPORARY_PERSISTENT_FILE_SUFFIX
focal_class.declarator: PERSISTENT_FILE_SUFFIX = ".db"
focal_class.modifier: private static final
focal_class.original_string: private static final String PERSISTENT_FILE_SUFFIX = ".db";
focal_class.type: String
focal_class.var_name: PERSISTENT_FILE_SUFFIX
focal_class.declarator: PERSISTENT_FILE_NAME = "snapshot"
focal_class.modifier: private static final
focal_class.original_string: private static final String PERSISTENT_FILE_NAME = "snapshot";
focal_class.type: String
focal_class.var_name: PERSISTENT_FILE_NAME
focal_class.declarator: basePath
focal_class.modifier: private final
focal_class.original_string: private final Path basePath;
focal_class.type: Path
focal_class.var_name: basePath
focal_class.declarator: fileLock
focal_class.modifier: private final
focal_class.original_string: private final FileLock fileLock;
focal_class.type: FileLock
focal_class.var_name: fileLock
focal_class.file: filter-service-core/src/main/java/cn/leancloud/filter/service/PersistentManager.java
focal_class.identifier: PersistentManager
focal_class.interfaces: implements Closeable
focal_class.class_method_signature: PersistentManager.PersistentManager(Path persistentPath)
focal_class.full_signature:   PersistentManager(Path persistentPath)
focal_class.identifier: PersistentManager
focal_class.parameters: (Path persistentPath)
focal_class.signature:  PersistentManager(Path persistentPath)
focal_class.class_method_signature: PersistentManager.freezeAllFilters(Iterable<FilterRecord<F>> records)
focal_class.full_signature: synchronized void freezeAllFilters(Iterable<FilterRecord<F>> records)
focal_class.identifier: freezeAllFilters
focal_class.modifiers: synchronized
focal_class.parameters: (Iterable<FilterRecord<F>> records)
focal_class.return: void
focal_class.signature: void freezeAllFilters(Iterable<FilterRecord<F>> records)
focal_class.class_method_signature: PersistentManager.recoverFilters(BloomFilterFactory<? extends F, ?> factory,
                                                                  boolean allowRecoverFromCorruptedFile)
focal_class.full_signature: synchronized List<FilterRecord<? extends F>> recoverFilters(BloomFilterFactory<? extends F, ?> factory,
                                                                  boolean allowRecoverFromCorruptedFile)
focal_class.identifier: recoverFilters
focal_class.modifiers: synchronized
focal_class.parameters: (BloomFilterFactory<? extends F, ?> factory,
                                                                  boolean allowRecoverFromCorruptedFile)
focal_class.return: List<FilterRecord<? extends F>>
focal_class.signature: List<FilterRecord<? extends F>> recoverFilters(BloomFilterFactory<? extends F, ?> factory,
                                                                  boolean allowRecoverFromCorruptedFile)
focal_class.class_method_signature: PersistentManager.close()
focal_class.full_signature: @Override public synchronized void close()
focal_class.identifier: close
focal_class.modifiers: @Override public synchronized
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void close()
focal_class.class_method_signature: PersistentManager.temporaryPersistentFilePath()
focal_class.full_signature:  Path temporaryPersistentFilePath()
focal_class.identifier: temporaryPersistentFilePath
focal_class.parameters: ()
focal_class.return: Path
focal_class.signature: Path temporaryPersistentFilePath()
focal_class.class_method_signature: PersistentManager.persistentFilePath()
focal_class.full_signature:  Path persistentFilePath()
focal_class.identifier: persistentFilePath
focal_class.parameters: ()
focal_class.return: Path
focal_class.signature: Path persistentFilePath()
focal_class.class_method_signature: PersistentManager.recoverFiltersFromFile(BloomFilterFactory<? extends F, ?> factory,
                                                                     boolean allowRecoverFromCorruptedFile,
                                                                     Path filePath)
focal_class.full_signature: private List<FilterRecord<? extends F>> recoverFiltersFromFile(BloomFilterFactory<? extends F, ?> factory,
                                                                     boolean allowRecoverFromCorruptedFile,
                                                                     Path filePath)
focal_class.identifier: recoverFiltersFromFile
focal_class.modifiers: private
focal_class.parameters: (BloomFilterFactory<? extends F, ?> factory,
                                                                     boolean allowRecoverFromCorruptedFile,
                                                                     Path filePath)
focal_class.return: List<FilterRecord<? extends F>>
focal_class.signature: List<FilterRecord<? extends F>> recoverFiltersFromFile(BloomFilterFactory<? extends F, ?> factory,
                                                                     boolean allowRecoverFromCorruptedFile,
                                                                     Path filePath)
focal_class.class_method_signature: PersistentManager.readFiltersFromFile(FilterRecordInputStream<? extends F> filterStream)
focal_class.full_signature: private Iterable<FilterRecord<? extends F>> readFiltersFromFile(FilterRecordInputStream<? extends F> filterStream)
focal_class.identifier: readFiltersFromFile
focal_class.modifiers: private
focal_class.parameters: (FilterRecordInputStream<? extends F> filterStream)
focal_class.return: Iterable<FilterRecord<? extends F>>
focal_class.signature: Iterable<FilterRecord<? extends F>> readFiltersFromFile(FilterRecordInputStream<? extends F> filterStream)
focal_method.body: synchronized void freezeAllFilters(Iterable<FilterRecord<F>> records) throws IOException {
          final Path tempPath = temporaryPersistentFilePath();
          int counter = 0;
          try (FileChannel channel = FileChannel.open(tempPath, StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.READ)) {
              for (FilterRecord<F> record : records) {
                  record.writeFullyTo(channel);
                  counter++;
              }
  
              channel.force(true);
          }
  
          FilterServiceFileUtils.atomicMoveWithFallback(tempPath, persistentFilePath());
          logger.debug("Persistent " + counter + " filters.");
      }
focal_method.class_method_signature: PersistentManager.freezeAllFilters(Iterable<FilterRecord<F>> records)
focal_method.full_signature: synchronized void freezeAllFilters(Iterable<FilterRecord<F>> records)
focal_method.identifier: freezeAllFilters
focal_method.invocations: temporaryPersistentFilePath open writeFullyTo force atomicMoveWithFallback persistentFilePath debug
focal_method.modifiers: synchronized
focal_method.parameters: (Iterable<FilterRecord<F>> records)
focal_method.return: void
focal_method.signature: void freezeAllFilters(Iterable<FilterRecord<F>> records)