示例#1
0
 public void testHandleToFileAndFileToHandle() {
   final PersistentEntityStoreImpl store = getEntityStore();
   final PersistentStoreTransaction txn = getStoreTransaction();
   store.getConfig().setMaxInPlaceBlobSize(0); // no in-lace blobs
   final int count = 1000;
   for (int i = 0; i < count; ++i) {
     txn.newEntity("E").setBlob("b", new ByteArrayInputStream("content".getBytes()));
   }
   Assert.assertTrue(txn.flush());
   final FileSystemBlobVault blobVault = (FileSystemBlobVault) store.getBlobVault();
   final NavigableMap<Long, File> handlesToFiles = new TreeMap<>();
   for (final BackupStrategy.FileDescriptor fd : blobVault.getBackupStrategy().listFiles()) {
     final File file = fd.getFile();
     if (file.isFile() && !file.getName().equals(FileSystemBlobVaultOld.VERSION_FILE)) {
       final long handle = blobVault.getBlobHandleByFile(file);
       Assert.assertFalse(handlesToFiles.containsKey(handle));
       handlesToFiles.put(handle, file);
       Assert.assertEquals(file, blobVault.getBlobLocation(handle));
     }
   }
   final long min = handlesToFiles.navigableKeySet().iterator().next();
   Assert.assertEquals(0L, min);
   final long max = handlesToFiles.descendingKeySet().iterator().next();
   Assert.assertEquals((long) (count - 1), max);
 }
 public EntitiesOfTypeRangeIterable(
     @NotNull final PersistentStoreTransaction txn,
     @NotNull final PersistentEntityStoreImpl store,
     final int entityTypeId,
     final long min,
     final long max) {
   super(store);
   this.entityTypeId = entityTypeId;
   if (!txn.isCurrent()) {
     txnGetter = txn;
   }
   this.min = min;
   this.max = max;
 }
示例#3
0
 public void testNewVaultFilesLocality() {
   final PersistentEntityStoreImpl store = getEntityStore();
   final PersistentStoreTransaction txn = getStoreTransaction();
   store.getConfig().setMaxInPlaceBlobSize(0); // no in-lace blobs
   for (int i = 0; i < 256; ++i) {
     txn.newEntity("E").setBlob("b", new ByteArrayInputStream("content".getBytes()));
   }
   Assert.assertTrue(txn.flush());
   final FileSystemBlobVaultOld blobVault = (FileSystemBlobVaultOld) store.getBlobVault();
   final File vaultLocation = blobVault.getVaultLocation();
   Assert.assertEquals(257, vaultLocation.listFiles().length); // + "version" file
   Assert.assertEquals(
       256,
       vaultLocation.listFiles(
               new FilenameFilter() {
                 @Override
                 public boolean accept(File dir, String name) {
                   return name.endsWith(PersistentEntityStoreImpl.BLOBS_EXTENSION);
                 }
               })
           .length);
   for (int i = 0; i < 256; ++i) {
     txn.newEntity("E").setBlob("b", new ByteArrayInputStream("content".getBytes()));
   }
   Assert.assertTrue(txn.flush());
   Assert.assertEquals(258, vaultLocation.listFiles().length);
   Assert.assertEquals(
       256,
       vaultLocation.listFiles(
               new FilenameFilter() {
                 @Override
                 public boolean accept(File dir, String name) {
                   return name.endsWith(PersistentEntityStoreImpl.BLOBS_EXTENSION);
                 }
               })
           .length);
 }