Examples of FileMetadata


Examples of org.infinispan.lucene.FileMetadata

      final boolean trace = log.isTraceEnabled();
      final String indexName = readLockKey.getIndexName();
      final String filename = readLockKey.getFileName();
      FileCacheKey key = new FileCacheKey(indexName, filename);
      if (trace) log.tracef("deleting metadata: %s", key);
      FileMetadata file = (FileMetadata) metadataCache.withFlags(Flag.SKIP_LOCKING).remove(key);
      if (file != null) { //during optimization of index a same file could be deleted twice, so you could see a null here
         for (int i = 0; i < file.getNumberOfChunks(); i++) {
            ChunkCacheKey chunkKey = new ChunkCacheKey(indexName, filename, i);
            if (trace) log.tracef("deleting chunk: %s", chunkKey);
            chunksCache.withFlags(Flag.SKIP_REMOTE_LOOKUP, Flag.SKIP_CACHE_LOAD, Flag.SKIP_LOCKING).removeAsync(chunkKey);
         }
      }
View Full Code Here

Examples of org.infinispan.lucene.FileMetadata

   private void assertFileAfterDeletion(Cache cache) {
      Set<String> fileList = (Set<String>) cache.get(new FileListCacheKey(INDEX_NAME));
      AssertJUnit.assertNotNull(fileList);
      AssertJUnit.assertFalse(fileList.contains(filename));

      FileMetadata metadata = (FileMetadata) cache.get(new FileCacheKey(INDEX_NAME, filename));
      AssertJUnit.assertNotNull(metadata);
      long totalFileSize = metadata.getSize();
      int chunkNumbers = (int)(totalFileSize / CHUNK_SIZE);

      for(int i = 0; i < chunkNumbers; i++) {
         AssertJUnit.assertNotNull(cache.get(new ChunkCacheKey(INDEX_NAME, filename, i, CHUNK_SIZE)));
      }
View Full Code Here

Examples of org.infinispan.lucene.FileMetadata

            AssertJUnit.assertEquals(fileCacheKey.getIndexName(), INDEX_NAME);
            String filename = fileCacheKey.getFileName();
            Object value = cache.get(fileCacheKey);
            AssertJUnit.assertNotNull(value);
            AssertJUnit.assertTrue(value instanceof FileMetadata);
            FileMetadata metadata = (FileMetadata) value;
            long totalFileSize = metadata.getSize();
            long actualFileSize = DirectoryIntegrityCheck.deepCountFileSize(fileCacheKey, cache);
            AssertJUnit.assertEquals(actualFileSize, totalFileSize);

            if(filename.contains(this.filename)) {
               AssertJUnit.assertFalse(fileCacheKey + " should not have existed", fileList.contains(filename));
View Full Code Here

Examples of org.infinispan.lucene.FileMetadata

    * @param fileName
    * @return the FileMetadata associated with the fileName, or null if the file wasn't found.
    */
   public FileMetadata getFileMetadata(final String fileName) {
      FileCacheKey key = new FileCacheKey(indexName, fileName);
      FileMetadata metadata = (FileMetadata) cache.get(key);
      return metadata;
   }
View Full Code Here

Examples of org.infinispan.lucene.FileMetadata

   public void testAutoChunkingOnLargeFiles() {
      FileCacheKey k = new FileCacheKey(INDEX_NAME, FILE_NAME);
      DirectoryLoaderAdaptor adaptor = new DirectoryLoaderAdaptor(new InternalDirectoryContractImpl(), INDEX_NAME, AUTO_BUFFER);
      Object loaded = adaptor.load(k);
      AssertJUnit.assertTrue(loaded instanceof FileMetadata);
      FileMetadata metadata = (FileMetadata)loaded;
      AssertJUnit.assertEquals(23, metadata.getLastModified());
      AssertJUnit.assertEquals(TEST_SIZE, metadata.getSize());
      AssertJUnit.assertEquals(AUTO_BUFFER, metadata.getBufferSize());
   }
View Full Code Here

Examples of org.infinispan.lucene.FileMetadata

   private void assertFileAfterDeletion(Cache cache) {
      Set<String> fileList = (Set<String>) cache.get(new FileListCacheKey(INDEX_NAME));
      AssertJUnit.assertNotNull(fileList);
      AssertJUnit.assertFalse(fileList.contains(filename));

      FileMetadata metadata = (FileMetadata) cache.get(new FileCacheKey(INDEX_NAME, filename));
      AssertJUnit.assertNotNull(metadata);
      long totalFileSize = metadata.getSize();
      int chunkNumbers = (int)(totalFileSize / CHUNK_SIZE);

      for(int i = 0; i < chunkNumbers; i++) {
         AssertJUnit.assertNotNull(cache.get(new ChunkCacheKey(INDEX_NAME, filename, i, CHUNK_SIZE)));
      }
View Full Code Here

Examples of org.infinispan.lucene.FileMetadata

            AssertJUnit.assertEquals(fileCacheKey.getIndexName(), INDEX_NAME);
            String filename = fileCacheKey.getFileName();
            Object value = cache.get(fileCacheKey);
            AssertJUnit.assertNotNull(value);
            AssertJUnit.assertTrue(value instanceof FileMetadata);
            FileMetadata metadata = (FileMetadata) value;
            long totalFileSize = metadata.getSize();
            long actualFileSize = DirectoryIntegrityCheck.deepCountFileSize(fileCacheKey, cache);
            AssertJUnit.assertEquals(actualFileSize, totalFileSize);

            if(filename.contains(this.filename)) {
               AssertJUnit.assertFalse(fileCacheKey + " should not have existed", fileList.contains(filename));
View Full Code Here

Examples of org.infinispan.lucene.FileMetadata

   public void testAutoChunkingOnLargeFiles() throws CacheLoaderException {
      FileCacheKey k = new FileCacheKey(INDEX_NAME, FILE_NAME);
      DirectoryLoaderAdaptor adaptor = new DirectoryLoaderAdaptor(new InternalDirectoryContractImpl(), INDEX_NAME, AUTO_BUFFER);
      Object loaded = adaptor.load(k);
      AssertJUnit.assertTrue(loaded instanceof FileMetadata);
      FileMetadata metadata = (FileMetadata)loaded;
      AssertJUnit.assertEquals(23, metadata.getLastModified());
      AssertJUnit.assertEquals(TEST_SIZE, metadata.getSize());
      AssertJUnit.assertEquals(AUTO_BUFFER, metadata.getBufferSize());
   }
View Full Code Here

Examples of org.infinispan.lucene.FileMetadata

      this.fileKey = fileKey;
      this.bufferSize = bufferSize;
      this.fileOps = fileList;
      this.buffer = new byte[this.bufferSize];
      this.firstChunkBuffer = buffer;
      this.file = new FileMetadata(bufferSize);
      if (trace) {
         log.tracef("Opened new IndexOutput for file:%s in index: %s", fileKey.getFileName(), fileKey.getIndexName());
      }
   }
View Full Code Here

Examples of org.infinispan.lucene.FileMetadata

   private FileMetadata loadIntern(final FileCacheKey key) throws IOException {
      final String fileName = key.getFileName();
      final long fileModified = directory.fileModified(fileName);
      final long fileLength = directory.fileLength(fileName);
      // We're forcing the buffer size of a to-be-read segment to the full file size:
      final FileMetadata meta = new FileMetadata((int) fileLength);
      meta.setLastModified(fileModified);
      meta.setSize(fileLength);
      return meta;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.