public SharedCloseableImpl(RefCounted.Tidy tidy) { ref = new Ref<Object>(null, tidy); }
private SafeMemory(SafeMemory copyOf) { super(copyOf); ref = copyOf.ref.ref(); /** see {@link Memory#Memory(long)} re: null pointers*/ if (peer == 0 && size != 0) { ref.ensureReleased(); throw new IllegalStateException("Cannot create a sharedCopy of a SafeMemory object that has already been closed"); } }
public boolean isCleanedUp() { return ref.globalCount() == 0; }
@SuppressWarnings("resource") public static Ref<GlobalTidy> get(SSTableReader sstable) { Descriptor descriptor = sstable.descriptor; Ref<GlobalTidy> refc = lookup.get(descriptor); if (refc != null) return refc.ref(); final GlobalTidy tidy = new GlobalTidy(sstable); refc = new Ref<>(tidy, tidy); Ref<?> ex = lookup.putIfAbsent(descriptor, refc); if (ex != null) { refc.close(); //throw new AssertionError(); } return refc; } }
/** * releases the shared reference for all sstables, we acquire this when opening the sstable */ private void releaseReferences() { for (SSTableReader sstable : sstables) { sstable.selfRef().release(); assert sstable.selfRef().globalCount() == 0; } }
void traverse(final RefCounted.Tidy rootObject) path.offer(newInProgressVisit(rootObject, getFields(rootObject.getClass()), null, rootObject.name())); inProgress = newInProgressVisit(child, getFields(child.getClass()), field, null); continue; returnInProgressVisit(inProgress); inProgress = null; continue;
public Ref<SSTableReader> tryRef() { return selfRef.tryRef(); }
public synchronized void addTransferFile(Ref<SSTableReader> ref, long estimatedKeys, List<Pair<Long, Long>> sections, long repairedAt) { assert ref.get() != null && cfId.equals(ref.get().metadata.cfId); OutgoingFileMessage message = new OutgoingFileMessage(ref, sequenceNumber.getAndIncrement(), estimatedKeys, sections, repairedAt); files.put(message.header.sequenceNumber, message); totalSize += message.header.size(); }
public void close() { ref.ensureReleased(); peer = 0; }
public void abort() { parentRef.release(); } }
public static Ref<GlobalTidy> get(SSTableReader sstable) { Descriptor descriptor = sstable.descriptor; Ref<GlobalTidy> refc = lookup.get(descriptor); if (refc != null) return refc.ref(); final GlobalTidy tidy = new GlobalTidy(sstable); refc = new Ref<>(tidy, tidy); Ref<?> ex = lookup.putIfAbsent(descriptor, refc); assert ex == null; return refc; } }
public Ref<SSTableReader> ref() { return selfRef.ref(); }
@Inline protected void checkBounds(long start, long end) { assert peer != 0 || size == 0 : ref.printDebugInfo(); super.checkBounds(start, end); }
static List<Field> getFields(Class<?> clazz) { if (clazz == null || clazz == PhantomReference.class || clazz == Class.class || java.lang.reflect.Member.class.isAssignableFrom(clazz)) return emptyList(); List<Field> fields = fieldMap.get(clazz); if (fields != null) return fields; fieldMap.put(clazz, fields = new ArrayList<>()); for (Field field : clazz.getDeclaredFields()) { if (field.getType().isPrimitive() || Modifier.isStatic(field.getModifiers())) continue; field.setAccessible(true); fields.add(field); } fields.addAll(getFields(clazz.getSuperclass())); return fields; }
@SuppressWarnings("resource") public static Ref<GlobalTidy> get(SSTableReader sstable) { Descriptor descriptor = sstable.descriptor; Ref<GlobalTidy> refc = lookup.get(descriptor); if (refc != null) return refc.ref(); final GlobalTidy tidy = new GlobalTidy(sstable); refc = new Ref<>(tidy, tidy); Ref<?> ex = lookup.putIfAbsent(descriptor, refc); if (ex != null) { refc.close(); throw new AssertionError(); } return refc; } }
/** * releases the shared reference for all sstables, we acquire this when opening the sstable */ private void releaseReferences() { for (SSTableReader sstable : sstables) { sstable.selfRef().release(); assert sstable.selfRef().globalCount() == 0; } }
void traverse(final RefCounted.Tidy rootObject) path.offer(newInProgressVisit(rootObject, getFields(rootObject.getClass()), null, rootObject.name())); inProgress = newInProgressVisit(child, getFields(child.getClass()), field, null); continue; returnInProgressVisit(inProgress); inProgress = null; continue;
public Ref<SSTableReader> tryRef() { return selfRef.tryRef(); }
/** * We stash the chunk in the attachment of a buffer * that was returned by get(), this method simply * retrives the chunk that sliced a buffer, if any. */ static Chunk getParentChunk(ByteBuffer buffer) { Object attachment = MemoryUtil.getAttachment(buffer); if (attachment instanceof Chunk) return (Chunk) attachment; if (attachment instanceof Ref) return ((Ref<Chunk>) attachment).get(); return null; }
public void close() { ref.ensureReleased(); peer = 0; }