@Override public FileListCacheKey readObject(final ObjectInput input) throws IOException { String indexName = input.readUTF(); return new FileListCacheKey(indexName); }
public FileListCacheKey(String indexName, final int affinitySegmentId) { this.indexName = indexName; this.affinitySegmentId = affinitySegmentId; this.hashCode = generatedHashCode(); }
@Test public void testFileListCacheKeyComparison() { AssertJUnit.assertFalse("The instance of FileListCacheKey should not be equal to null.", new FileListCacheKey("index-A", -1).equals(null)); AssertJUnit.assertFalse("The instance of FileListCacheKey should not be equal to FileCacheKey instance.", new FileListCacheKey("index-A", -1).equals(new FileCacheKey("index-A", "test.txt", -1))); }
@Override public FileListCacheKey readObject(final ObjectInput input) throws IOException { final String indexName = input.readUTF(); final int affinitySegmentId = UnsignedNumeric.readUnsignedInt(input); return new FileListCacheKey(indexName, affinitySegmentId); }
public FileListCacheKey(String indexName, final int affinitySegmentId) { this.indexName = indexName; this.affinitySegmentId = affinitySegmentId; this.hashCode = generatedHashCode(); }
@Override public FileListCacheKey readObject(final ObjectInput input) throws IOException { final String indexName = input.readUTF(); final int affinitySegmentId = UnsignedNumeric.readUnsignedInt(input); return new FileListCacheKey(indexName, affinitySegmentId); }
public FileListCacheKey(String indexName) { this.indexName = indexName; this.hashCode = generatedHashCode(); }
@SuppressWarnings("unchecked") public FileListOperations(AdvancedCache<?, ?> cache, String indexName, boolean writeAsync, int affinitySegmentId) { this.writeAsync = writeAsync; this.affinitySegmentId = affinitySegmentId; this.cache = (AdvancedCache<FileListCacheKey, Object>) cache; this.cacheNoRetrieve = (AdvancedCache<FileListCacheKey, FileListCacheValue>) cache.withFlags(Flag.IGNORE_RETURN_VALUES); this.indexName = indexName; this.fileListCacheKey = new FileListCacheKey(indexName, affinitySegmentId); ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); readLock = lock.readLock(); writeLock = lock.writeLock(); }
@SuppressWarnings("unchecked") public FileListOperations(AdvancedCache<?, ?> cache, String indexName, boolean writeAsync, int affinitySegmentId) { this.writeAsync = writeAsync; this.affinitySegmentId = affinitySegmentId; this.cache = (AdvancedCache<FileListCacheKey, Object>) cache; this.cacheNoRetrieve = (AdvancedCache<FileListCacheKey, FileListCacheValue>) cache.withFlags(Flag.IGNORE_RETURN_VALUES); this.indexName = indexName; this.fileListCacheKey = new FileListCacheKey(indexName, affinitySegmentId); ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); readLock = lock.readLock(); writeLock = lock.writeLock(); }
public FileListOperations(AdvancedCache<?, ?> cache, String indexName){ this.cache = (AdvancedCache<FileListCacheKey, Object>) cache; this.cacheNoRetrieve = (AdvancedCache<FileListCacheKey, Set<String>>) cache.withFlags(Flag.IGNORE_RETURN_VALUES); this.indexName = indexName; this.fileListCacheKey = new FileListCacheKey(indexName); }
@Test public void testFileListCacheKeyExternalizer() throws IOException { FileListCacheKey key = new FileListCacheKey("myIndex", 7); verifyExternalizerForType(key, FileListCacheKey.Externalizer.class); }
FileListCacheKey rootKey = new FileListCacheKey(indexName, affinitySegmentId); if (keysToExclude == null || !keysToExclude.contains(rootKey)) { //unless it was excluded if (keysCollector.add(rootKey)) { //unless it was already collected
FileListCacheKey rootKey = new FileListCacheKey(indexName); if (keysToExclude==null || ! keysToExclude.contains(rootKey)) { //unless it was excluded if (keysCollector.add(rootKey) ) { //unless it was already collected
FileListCacheKey rootKey = new FileListCacheKey(indexName, affinitySegmentId); if (keysToExclude == null || !keysToExclude.contains(rootKey)) { //unless it was excluded if (keysCollector.add(rootKey)) { //unless it was already collected
@Test public void loadFileListCacheKey() { AssertJUnit.assertEquals(new FileListCacheKey("", -1), mapper.getKeyMapping("*||-1")); AssertJUnit.assertEquals(new FileListCacheKey("the leaves of Amazonia", -1), mapper.getKeyMapping("*|the leaves of Amazonia|-1")); }
return new FileListCacheKey(key.substring(2));
public void testLoadAllKeysWithExclusionOfRootKey() throws Exception { TestHelper.createIndex(rootDir, indexName, elementCount, true); LuceneCacheLoader cacheLoader = (LuceneCacheLoader) TestingUtil.getFirstLoader(cacheManager.getCache()); Set keySet = PersistenceUtil.toKeySet(cacheLoader, null); int initialCount = keySet.size(); HashSet exclusionSet = new HashSet(); exclusionSet.add(new FileListCacheKey(indexName, segmentId)); keySet = PersistenceUtil.toKeySet(cacheLoader, k -> !exclusionSet.contains(k)); String[] fileNamesArr = TestHelper.getFileNamesFromDir(rootDir, indexName); AssertJUnit.assertEquals((initialCount - 1), keySet.size()); Iterator it = keySet.iterator(); while (it.hasNext()) { assert !(it.next() instanceof FileListCacheKey); } }
final String indexName = split[1]; final int affinitySegmentId = toInt(split[2], key); return new FileListCacheKey(indexName, affinitySegmentId);
final String indexName = split[1]; final int affinitySegmentId = toInt(split[2], key); return new FileListCacheKey(indexName, affinitySegmentId);
public static void assertFileNotExists(Cache cache, String indexName, String fileName, long maxWaitForCondition, int affinitySegmentId) throws InterruptedException { FileListCacheValue fileList = (FileListCacheValue) cache.get(new FileListCacheKey(indexName, affinitySegmentId)); 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; FileMetadata metadata = (FileMetadata) cache.get(new FileCacheKey(indexName, fileName, affinitySegmentId)); if (metadata!=null) allok=false; for (int i = 0; i < 100; i++) { //bufferSize set to 0 as metadata might not be available, and it's not part of equals/hashcode anyway. ChunkCacheKey key = new ChunkCacheKey(indexName, fileName, i, 0, affinitySegmentId); if (cache.get(key)!=null) allok=false; } } assertTrue(allok); }