Package org.infinispan.lucene

Examples of org.infinispan.lucene.FileCacheKey


    IndexOutput createOutput(final String name) {
       if (IndexFileNames.SEGMENTS_GEN.equals(name)) {
          return new CheckSummingIndexOutput(metadataCache, chunksCache, segmentsGenFileKey, chunkSize, fileOps);
       }
       else {
          final FileCacheKey key = new FileCacheKey(indexName, name);
          // creating new file, metadata is added on flush() or close() of
          // IndexOutPut
          return new CheckSummingIndexOutput(metadataCache, chunksCache, key, chunkSize, fileOps);
       }
    }
View Full Code Here


          return new CheckSummingIndexOutput(metadataCache, chunksCache, key, chunkSize, fileOps);
       }
    }

    IndexInputContext openInput(final String name) throws IOException {
       final FileCacheKey fileKey = new FileCacheKey(indexName, name);
       final FileMetadata fileMetadata = metadataCache.get(fileKey);
       if (fileMetadata == null) {
          throw new FileNotFoundException("Error loading metadata for index file: " + fileKey);
       }
       else if (fileMetadata.getSize() <= fileMetadata.getBufferSize()) {
View Full Code Here

   /**
    * @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

            lockValue = cache.withFlags(Flag.SKIP_CACHE_STORE).putIfAbsent(readLockKey, Integer.valueOf(2));
            done = (null == lockValue);
            if (done) {
               // have to check now that the fileKey still exists to prevent the race condition of
               // T1 fileKey exists - T2 delete file and remove readlock - T1 putIfAbsent(readlock, 2)
               final FileCacheKey fileKey = new FileCacheKey(indexName, filename);
               if (cache.get(fileKey) == null) {
                  cache.withFlags(Flag.SKIP_REMOTE_LOOKUP).removeAsync(readLockKey);
                  return false;
               }
            }
View Full Code Here

    * @param cache the cache containing the elements to be deleted
    */
   static void realFileDelete(FileReadLockKey readLockKey, AdvancedCache cache) {
      final String indexName = readLockKey.getIndexName();
      final String filename = readLockKey.getFileName();
      FileCacheKey key = new FileCacheKey(indexName, filename);
      boolean batch = cache.startBatch();
      FileMetadata file = (FileMetadata) cache.withFlags(Flag.SKIP_LOCKING).remove(key);
      for (int i = 0; i < file.getNumberOfChunks(); i++) {
         ChunkCacheKey chunkKey = new ChunkCacheKey(indexName, filename, i);
         cache.withFlags(Flag.SKIP_REMOTE_LOOKUP).removeAsync(chunkKey)
View Full Code Here

      try {
         //Now we collect first all FileCacheKey (keys for file metadata)
         String[] listAll = directory.listAll();
         for (String fileName : listAll) {
            if (collectedKeys >= maxElements) return;
            FileCacheKey key = new FileCacheKey(indexName, fileName);
            if (keysToExclude == null || !keysToExclude.contains(key)) {
               if (keysCollector.add(key)) {
                  if (++collectedKeys >= maxElements) return;
               }
            }
View Full Code Here

   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)));
      }

      boolean fileNameExistsInCache = false;
      for(Object key : cache.keySet()) {
         if(key instanceof FileCacheKey) {
            FileCacheKey keyObj = (FileCacheKey) key;

            if(keyObj.getFileName().contains(filename)) {
               fileNameExistsInCache = true;
            }
         }
      }
View Full Code Here

            AssertJUnit.assertNotNull(value);
            AssertJUnit.assertTrue(value instanceof byte[]);
            byte[] buffer = (byte[]) cache.get(existingChunkKey);
            AssertJUnit.assertTrue(buffer.length != 0);
         } else if (key instanceof FileCacheKey) {
            FileCacheKey fileCacheKey = (FileCacheKey) key;
            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();
View Full Code Here

   private static final String FILE_NAME = "largeFile";
   private static final long TEST_SIZE = ((long)Integer.MAX_VALUE) + 10;//something not fitting in int
   private static final int AUTO_BUFFER = 16;//ridiculously low

   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());
View Full Code Here

   /**
    * Simple delegation constructor
    */
   public DirectoryImplementorV4(Cache<?, ?> metadataCache, Cache<?, ?> chunksCache, String indexName, int chunkSize, SegmentReadLocker readLocker) {
      super(metadataCache, chunksCache, indexName, chunkSize, readLocker);
      segmentsGenFileKey = new FileCacheKey(indexName, IndexFileNames.SEGMENTS_GEN);
   }
View Full Code Here

TOP

Related Classes of org.infinispan.lucene.FileCacheKey

Copyright © 2018 www.massapicom. 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.