Package org.infinispan.lucene.impl

Examples of org.infinispan.lucene.impl.FileListCacheValue


    * Load implementation for FileListCacheKey; must return a
    * ConcurrentHashSet containing the names of all files in this Directory.
    */
   private Object loadIntern() throws IOException {
      final String[] listAll = directory.listAll();
      return new FileListCacheValue(listAll);
   }
View Full Code Here


   public static void verifyDirectoryStructure(Cache cache, String indexName) {
      verifyDirectoryStructure(cache, indexName, false);
   }

   public static void verifyDirectoryStructure(Cache cache, String indexName, boolean wasAStressTest) {
      FileListCacheValue fileList = (FileListCacheValue) cache.get(new FileListCacheKey(indexName));
      AssertJUnit.assertNotNull(fileList);
      int fileListCacheKeyInstances = 0;
      for (Object key : cache.keySet()) {
         if (key instanceof ChunkCacheKey) {
            ChunkCacheKey existingChunkKey = (ChunkCacheKey) key;
            String filename = existingChunkKey.getFileName();
            AssertJUnit.assertEquals(existingChunkKey.getIndexName(), indexName);
            // the chunk must either match an entry in fileList or have a pending readLock:
//            if (fileList.contains(filename) == false) {
//               verifyReadlockExists(cache, indexName, filename);
//            }
            Object value = cache.get(existingChunkKey);
            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(), indexName);
            String filename = fileCacheKey.getFileName();
//            if (fileList.contains(filename) == false) {
//               // if the file is not registered, assert that a readlock prevented it from being
//               // deleted:
//               verifyReadlockExists(cache, indexName, filename);
//            }
            Object value = cache.get(fileCacheKey);
            AssertJUnit.assertNotNull(value);
            AssertJUnit.assertTrue(value instanceof FileMetadata);
            FileMetadata metadata = (FileMetadata) value;
            long totalFileSize = metadata.getSize();
            long actualFileSize = deepCountFileSize(fileCacheKey, cache);
            AssertJUnit.assertEquals(actualFileSize, totalFileSize);
            AssertJUnit.assertTrue(fileCacheKey + " should not have existed", fileList.contains(fileCacheKey.getFileName()));
         } else if (key instanceof FileListCacheKey) {
            fileListCacheKeyInstances++;
            AssertJUnit.assertEquals(1, fileListCacheKeyInstances);
         } else if (key instanceof FileReadLockKey) {
            /*//FIXME testcase to be fixed after ISPN-616
View Full Code Here

         }
      }
   }

   public static void assertFileNotExists(Cache cache, String indexName, String fileName, long maxWaitForCondition) throws InterruptedException {
      FileListCacheValue fileList = (FileListCacheValue) cache.get(new FileListCacheKey(indexName));
      AssertJUnit.assertNotNull(fileList);
      AssertJUnit.assertFalse(fileList.contains(fileName)); //check is in sync: no waiting allowed in this case
      boolean allok = false;
      while (maxWaitForCondition >= 0 && !allok) {
         Thread.sleep(10);
         maxWaitForCondition -= 10;
         allok=true;
View Full Code Here

   /**
    * Verified the file exists and has a specified value for readLock;
    * Consider that null should be interpreted as value 1;
    */
   public static void assertFileExistsHavingRLCount(Cache cache, String fileName, String indexName, int expectedReadcount, int chunkSize, boolean expectRegisteredInFat) {
      FileListCacheValue fileList = (FileListCacheValue) cache.get(new FileListCacheKey(indexName));
      AssertJUnit.assertNotNull(fileList);
      AssertJUnit.assertTrue(fileList.contains(fileName) == expectRegisteredInFat);
      FileMetadata metadata = (FileMetadata) cache.get(new FileCacheKey(indexName, fileName));
      AssertJUnit.assertNotNull(metadata);
      long totalFileSize = metadata.getSize();
      int chunkNumbers = (int)(totalFileSize / chunkSize);
      for (int i = 0; i < chunkNumbers; i++) {
View Full Code Here

      verifyDirectoryStructure(cache0);
      verifyDirectoryStructure(cache1);
   }

   private void assertFileAfterDeletion(Cache cache) {
      FileListCacheValue fileList = (FileListCacheValue) 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);
View Full Code Here

      AssertJUnit.assertTrue(fileNameExistsInCache);
   }

   private void verifyDirectoryStructure(Cache cache) {
      FileListCacheValue fileList = (FileListCacheValue) cache.get(new FileListCacheKey(INDEX_NAME));
      AssertJUnit.assertNotNull(fileList);
      int fileListCacheKeyInstances = 0;

      for (Object key : cache.keySet()) {
         if (key instanceof ChunkCacheKey) {
            ChunkCacheKey existingChunkKey = (ChunkCacheKey) key;
            AssertJUnit.assertEquals(existingChunkKey.getIndexName(), INDEX_NAME);
            Object value = cache.get(existingChunkKey);
            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();
            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));
            } else {
               AssertJUnit.assertTrue(fileCacheKey + " should not have existed", fileList.contains(filename));
            }
         } else if (key instanceof FileListCacheKey) {
            fileListCacheKeyInstances++;
            AssertJUnit.assertEquals(1, fileListCacheKeyInstances);
         }
View Full Code Here

TOP

Related Classes of org.infinispan.lucene.impl.FileListCacheValue

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.