@Override public CacheEntry get(Long lock, Long oid, WeakReference<? extends Serializer<?>> ref) throws TeiidComponentException { Map<Long, CacheEntry> group = groups.get(ref.get().getId()); if (group != null) { return group.get(oid); } return null; }
public boolean add(CacheEntry entry, Serializer s) { if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "adding object", s.getId(), entry.getId()); //$NON-NLS-1$ int memoryBlocks = this.maxMemoryBlocks; try { Map<Long, PhysicalInfo> map = physicalMapping.get(s.getId()); if (map == null) { return true; //already removed info = new PhysicalInfo(s.getId(), entry.getId(), EMPTY_ADDRESS, readAttempts.get(), entry.getSizeEstimate()); info.adding = true; map.put(entry.getId(), info); memoryWritePermits.acquire(memoryBlocks); hasPermit = true; blockManager = getBlockManager(s.getId(), entry.getId(), EMPTY_ADDRESS); BlockOutputStream bos = new BlockOutputStream(blockManager, memoryBlocks); bos.writeLong(s.getId()); bos.writeLong(entry.getId()); ObjectOutput dos = new ObjectOutputStream(bos); s.serialize(entry.getObject(), dos); dos.close(); if (physicalMapping.containsKey(s.getId()) && map.containsKey(entry.getId())) { synchronized (info) { } else { if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
boolean evict(CacheEntry ce) throws Exception { Serializer<?> s = ce.getSerializer(); if (s == null) { return true; } boolean persist = false; synchronized (ce) { if (!ce.isPersistent()) { persist = true; ce.setPersistent(true); } } if (persist) { long count = writeCount.incrementAndGet(); if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, s.getId(), ce.getId(), "writing batch to storage, total writes: ", count); //$NON-NLS-1$ } } boolean result = cache.add(ce, s); if (s.useSoftCache()) { createSoftReference(ce); } else if (useWeakReferences) { weakReferenceCache.getValue(ce); //a get will set the value } return result; }
memoryBufferEntries.touch(info); if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Getting object at inode", info.inode, serializer.getId(), oid); //$NON-NLS-1$ BlockManager manager = getBlockManager(serializer.getId(), oid, info.inode); is = new BlockInputStream(manager, info.memoryBlockCount); } else if (info.block != EMPTY_ADDRESS) { storageReads.incrementAndGet(); if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Getting object at block", info.block, info.sizeIndex, serializer.getId(), oid); //$NON-NLS-1$ CacheEntry ce = new CacheEntry(new CacheKey(oid, 1, 1), info.sizeEstimate, serializer.deserialize(dis), ref, true); return ce; } catch(IOException e) {
public boolean add(CacheEntry entry, Serializer s) { if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "adding object", s.getId(), entry.getId()); //$NON-NLS-1$ int memoryBlocks = this.maxMemoryBlocks; try { Map<Long, PhysicalInfo> map = physicalMapping.get(s.getId()); if (map == null) { return true; //already removed info = new PhysicalInfo(s.getId(), entry.getId(), EMPTY_ADDRESS, readAttempts.get(), entry.getSizeEstimate()); info.adding = true; map.put(entry.getId(), info); memoryWritePermits.acquire(memoryBlocks); hasPermit = true; blockManager = getBlockManager(s.getId(), entry.getId(), EMPTY_ADDRESS); BlockOutputStream bos = new BlockOutputStream(blockManager, memoryBlocks); bos.writeLong(s.getId()); bos.writeLong(entry.getId()); ObjectOutput dos = new ObjectOutputStream(bos); s.serialize(entry.getObject(), dos); dos.close(); if (physicalMapping.containsKey(s.getId()) && map.containsKey(entry.getId())) { synchronized (info) { s.serialize(entry.getObject(), dos); } catch (IOException e1) {
boolean evict(CacheEntry ce) throws Exception { Serializer<?> s = ce.getSerializer(); if (s == null) { return true; } boolean persist = false; synchronized (ce) { if (!ce.isPersistent()) { persist = true; ce.setPersistent(true); } } if (persist) { long count = writeCount.incrementAndGet(); if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, s.getId(), ce.getId(), "writing batch to storage, total writes: ", count); //$NON-NLS-1$ } } boolean result = cache.add(ce, s); if (s.useSoftCache()) { createSoftReference(ce); } else if (useWeakReferences) { weakReferenceCache.getValue(ce); //a get will set the value } return result; }
memoryBufferEntries.touch(info); if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Getting object at inode", info.inode, serializer.getId(), oid); //$NON-NLS-1$ BlockManager manager = getBlockManager(serializer.getId(), oid, info.inode); is = new BlockInputStream(manager, info.memoryBlockCount); } else if (info.block != EMPTY_ADDRESS) { storageReads.incrementAndGet(); if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Getting object at block", info.block, info.sizeIndex, serializer.getId(), oid); //$NON-NLS-1$ CacheEntry ce = new CacheEntry(new CacheKey(oid, 1, 1), info.sizeEstimate, serializer.deserialize(dis), ref, true); return ce; } catch(IOException e) {
@Override public CacheEntry get(Long lock, Long oid, WeakReference<? extends Serializer<?>> ref) throws TeiidComponentException { Map<Long, CacheEntry> group = groups.get(ref.get().getId()); if (group != null) { return group.get(oid); } return null; }
public boolean add(CacheEntry entry, Serializer s) { if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "adding object", s.getId(), entry.getId()); //$NON-NLS-1$ int memoryBlocks = this.maxMemoryBlocks; try { Map<Long, PhysicalInfo> map = physicalMapping.get(s.getId()); if (map == null) { return true; //already removed info = new PhysicalInfo(s.getId(), entry.getId(), EMPTY_ADDRESS, readAttempts.get(), entry.getSizeEstimate()); info.adding = true; map.put(entry.getId(), info); memoryWritePermits.acquire(memoryBlocks); hasPermit = true; blockManager = getBlockManager(s.getId(), entry.getId(), EMPTY_ADDRESS); BlockOutputStream bos = new BlockOutputStream(blockManager, memoryBlocks); bos.writeLong(s.getId()); bos.writeLong(entry.getId()); ObjectOutput dos = new ObjectOutputStream(bos); s.serialize(entry.getObject(), dos); dos.close(); if (physicalMapping.containsKey(s.getId()) && map.containsKey(entry.getId())) { synchronized (info) { } else { if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
boolean evict(CacheEntry ce) throws Exception { Serializer<?> s = ce.getSerializer(); if (s == null) { return true; } boolean persist = false; synchronized (ce) { if (!ce.isPersistent()) { persist = true; ce.setPersistent(true); } } if (persist) { long count = writeCount.incrementAndGet(); if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, s.getId(), ce.getId(), "writing batch to storage, total writes: ", count); //$NON-NLS-1$ } } boolean result = cache.add(ce, s); if (s.useSoftCache()) { createSoftReference(ce); } else if (useWeakReferences) { weakReferenceCache.getValue(ce); //a get will set the value } return result; }
memoryBufferEntries.touch(info); if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Getting object at inode", info.inode, serializer.getId(), oid); //$NON-NLS-1$ BlockManager manager = getBlockManager(serializer.getId(), oid, info.inode); is = new BlockInputStream(manager, info.memoryBlockCount); } else if (info.block != EMPTY_ADDRESS) { storageReads.incrementAndGet(); if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Getting object at block", info.block, info.sizeIndex, serializer.getId(), oid); //$NON-NLS-1$ CacheEntry ce = new CacheEntry(new CacheKey(oid, 1, 1), info.sizeEstimate, serializer.deserialize(dis), ref, true); return ce; } catch(IOException e) {
@Override public CacheEntry get(Long lock, Long oid, WeakReference<? extends Serializer<?>> ref) throws TeiidComponentException { Map<Long, CacheEntry> group = groups.get(ref.get().getId()); if (group != null) { return group.get(oid); } return null; }
@Override public boolean add(CacheEntry entry, Serializer<?> s) { Map<Long, CacheEntry> group = groups.get(s.getId()); if (group != null) { group.put(entry.getId(), entry); } return true; }
@Override public boolean add(CacheEntry entry, Serializer<?> s) { Map<Long, CacheEntry> group = groups.get(s.getId()); if (group != null) { group.put(entry.getId(), entry); } return true; }
@Override public boolean add(CacheEntry entry, Serializer<?> s) { Map<Long, CacheEntry> group = groups.get(s.getId()); if (group != null) { group.put(entry.getId(), entry); } return true; }
@Override public PhysicalInfo lockForLoad(Long oid, Serializer<?> serializer) { Map<Long, PhysicalInfo> map = physicalMapping.get(serializer.getId()); if (map == null) { return null; } PhysicalInfo info = map.get(oid); if (info == null) { return null; } info.lockForLoad(); return info; }
@Override public PhysicalInfo lockForLoad(Long oid, Serializer<?> serializer) { Map<Long, PhysicalInfo> map = physicalMapping.get(serializer.getId()); if (map == null) { return null; } PhysicalInfo info = map.get(oid); if (info == null) { return null; } info.lockForLoad(); return info; }
@Override public PhysicalInfo lockForLoad(Long oid, Serializer<?> serializer) { Map<Long, PhysicalInfo> map = physicalMapping.get(serializer.getId()); if (map == null) { return null; } PhysicalInfo info = map.get(oid); if (info == null) { return null; } info.lockForLoad(); return info; }
private void remove(CacheEntry ce, boolean inMemory) { if (inMemory) { long result = activeBatchBytes.addAndGet(-ce.getSizeEstimate()); assert result >= 0 || !LrfuEvictionQueue.isSuspectSize(activeBatchBytes); } assert activeBatchBytes.get() >= 0; Serializer<?> s = ce.getSerializer(); if (s != null) { removeFromCache(s.getId(), ce.getId()); } }
private void remove(CacheEntry ce, boolean inMemory) { Serializer<?> s = ce.getSerializer(); if (inMemory) { if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) { LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Removing batch from heap cache", s!=null?s.getId():null, ce.getId()); //$NON-NLS-1$ } long result = activeBatchBytes.addAndGet(-ce.getSizeEstimate()); assert result >= 0 || !LrfuEvictionQueue.isSuspectSize(activeBatchBytes); } assert !LrfuEvictionQueue.isSuspectSize(activeBatchBytes); if (s != null) { removeFromCache(s.getId(), ce.getId()); } }