@Override public FileMetadata readObject(ObjectInput input) throws IOException { long size = UnsignedNumeric.readUnsignedLong(input); int bufferSize = UnsignedNumeric.readUnsignedInt(input); return new FileMetadata(size, bufferSize); }
@Override public FileMetadata readObject(ObjectInput input) throws IOException { long size = UnsignedNumeric.readUnsignedLong(input); int bufferSize = UnsignedNumeric.readUnsignedInt(input); return new FileMetadata(size, bufferSize); }
/** * Load implementation for FileCacheKey: must return the metadata of the * requested file. */ private FileMetadata loadIntern(final FileCacheKey key) throws IOException { final String fileName = key.getFileName(); final long fileLength = directory.fileLength(fileName); // We're forcing the buffer size of a to-be-read segment to the full file size: final int bufferSize = (int) Math.min(fileLength, (long)autoChunkSize); final FileMetadata meta = new FileMetadata(bufferSize); meta.setSize(fileLength); return meta; }
/** * Load implementation for FileCacheKey: must return the metadata of the * requested file. */ private FileMetadata loadIntern(final FileCacheKey key) throws IOException { final String fileName = key.getFileName(); final long fileLength = directory.fileLength(fileName); // We're forcing the buffer size of a to-be-read segment to the full file size: final int bufferSize = (int) Math.min(fileLength, (long)autoChunkSize); final FileMetadata meta = new FileMetadata(bufferSize); meta.setSize(fileLength); return meta; }
@Test public void testFileMetadataExternalizer() throws IOException { FileMetadata key = new FileMetadata(23); verifyExternalizerForType(key, FileMetadata.Externalizer.class); }
@Override public FileMetadata readObject(ObjectInput input) throws IOException { long lastModified = UnsignedNumeric.readUnsignedLong(input); long size = UnsignedNumeric.readUnsignedLong(input); int bufferSize = UnsignedNumeric.readUnsignedInt(input); return new FileMetadata(lastModified, size, bufferSize); }
/** * Load implementation for FileCacheKey: must return the metadata of the * requested file. */ 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 int bufferSize = (int) Math.min(fileLength, (long)autoChunkSize); final FileMetadata meta = new FileMetadata(bufferSize); meta.setLastModified(fileModified); meta.setSize(fileLength); return meta; }
public InfinispanIndexOutput(final AdvancedCache<FileCacheKey, FileMetadata> metadataCache, final AdvancedCache<ChunkCacheKey, Object> chunksCache, final FileCacheKey fileKey, final int bufferSize, final FileListOperations fileList) { this.metadataCache = metadataCache; this.chunksCache = chunksCache; this.chunksCacheForStorage = chunksCache.withFlags(Flag.IGNORE_RETURN_VALUES); 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()); } }
public InfinispanIndexOutput(final AdvancedCache<FileCacheKey, FileMetadata> metadataCache, final AdvancedCache<ChunkCacheKey, Object> chunksCache, final FileCacheKey fileKey, final int bufferSize, final FileListOperations fileList,final int affinitySegmentId) { super("InfinispanIndexOutput{metadataCache=" + metadataCache + ", chunksCache=" + chunksCache + ", fileKey=" + fileKey + ", bufferSize=" + bufferSize + '}'); this.metadataCache = metadataCache; this.chunksCache = chunksCache; this.affinitySegmentId = affinitySegmentId; this.chunksCacheForStorage = chunksCache.withFlags(Flag.IGNORE_RETURN_VALUES); 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()); } }
public InfinispanIndexOutput(final AdvancedCache<FileCacheKey, FileMetadata> metadataCache, final AdvancedCache<ChunkCacheKey, Object> chunksCache, final FileCacheKey fileKey, final int bufferSize, final FileListOperations fileList,final int affinitySegmentId) { super("InfinispanIndexOutput{metadataCache=" + metadataCache + ", chunksCache=" + chunksCache + ", fileKey=" + fileKey + ", bufferSize=" + bufferSize + '}'); this.metadataCache = metadataCache; this.chunksCache = chunksCache; this.affinitySegmentId = affinitySegmentId; this.chunksCacheForStorage = chunksCache.withFlags(Flag.IGNORE_RETURN_VALUES); 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()); } }
@Test public void testFileMetaData() { FileMetadata data1 = new FileMetadata(1024); FileMetadata data2 = new FileMetadata(2048); FileMetadata data3 = new FileMetadata(1024); FileMetadata data4 = data1; assert !data1.equals(new FileCacheKey("testIndex", "testFile", -1)); AssertJUnit.assertNotNull(data1); assert data1.equals(data4); assert data1.equals(data3); data3.setSize(2048); assert !data1.equals(data3); assert !data1.equals(data2); AssertJUnit.assertEquals("FileMetadata{ size=" + data1.getSize() + '}', data1.toString()); } }
final Cache<Object, Integer> locks = cacheManager.getCache("locks"); FileMetadata fileMetadata = new FileMetadata(10); fileMetadata.setSize(11); // Make it chunked otherwise no read lock will involved metadata.put(new FileCacheKey("indexName", "fileName", -1), fileMetadata);
@Test public void roundingTest() { FileMetadata m = new FileMetadata(10); AssertJUnit.assertEquals(0, m.getNumberOfChunks()); m.setSize(10); AssertJUnit.assertEquals(1, m.getNumberOfChunks()); m.setSize(11); AssertJUnit.assertEquals(2, m.getNumberOfChunks()); m = new FileMetadata(11); m.setSize(11); AssertJUnit.assertEquals(1, m.getNumberOfChunks()); m.setSize(22); AssertJUnit.assertEquals(2, m.getNumberOfChunks()); m.setSize(31); m = new FileMetadata(10); m.setSize(31); AssertJUnit.assertEquals(4, m.getNumberOfChunks()); }
FileMetadata file1 = new FileMetadata(5); FileCacheKey key1 = new FileCacheKey(INDEXNAME, "Hello.txt", -1); cache.put(key1, file1); FileMetadata file2 = new FileMetadata(5); FileCacheKey key2 = new FileCacheKey(INDEXNAME, "World.txt", -1); cache.put(key2, file2);