protected void debug(String message) { Jvm.debug().on(getClass(), message); }
public StoreFileListener storeFileListener() { return storeFileListener == null ? (cycle, file) -> { if (Jvm.isDebugEnabled(getClass())) Jvm.debug().on(getClass(), "File released " + file); } : storeFileListener; }
private void checkLinearScanTime(final long toIndex, final long fromKnownIndex, final long start) { long end = System.nanoTime(); if (end > start + 50e3) { assert printLinearScanTime(toIndex, fromKnownIndex, start, end, "linearScan by index"); } else if (fromKnownIndex > 0x284d34000000000L) { Jvm.debug().on(getClass(), "Unexpectedly high " + TimeUnit.NANOSECONDS.toMicros(end - start) + "us " + "fromKnownIndex 0x" + Long .toHexString(fromKnownIndex) + " " + "to 0x" + Long.toHexString(toIndex) + "= ( 0x" + Long.toHexString (toIndex) + "- 0x" + Long.toHexString(fromKnownIndex) + ") = " + (toIndex - fromKnownIndex), new StackTrace("This is a profile stack trace, not an ERROR")); } }
@Override public synchronized void release(@NotNull CommonStore store) { store.release(); long refCount = store.refCount(); assert refCount >= 0; if (refCount == 0) { for (Map.Entry<RollDetails, WeakReference<WireStore>> entry : stores.entrySet()) { WeakReference<WireStore> ref = entry.getValue(); if (ref != null && ref.get() == store) { stores.remove(entry.getKey()); storeFileListener.onReleased(entry.getKey().cycle(), store.file()); return; } } if (Jvm.isDebugEnabled(getClass())) Jvm.debug().on(getClass(), "Store was not registered: " + store.file()); } }
@Override public void writeEOF(@NotNull Wire wire, long timeoutMS) { // just in case we are about to release this if (wire.bytes().tryReserve()) { wire.writeEndOfWire(timeoutMS, TimeUnit.MILLISECONDS, writePosition()); wire.bytes().release(); } else { Jvm.debug().on(getClass(), "Tried to writeEOF to as it was being closed"); } }
Jvm.debug().on(getClass(), "Attempt to find " + Long.toHexString(position), e);
ScanResult moveToIndexResult(long index) { final int cycle = queue.rollCycle().toCycle(index); final long sequenceNumber = queue.rollCycle().toSequenceNumber(index); if (LOG.isTraceEnabled()) { Jvm.debug().on(getClass(), "moveToIndex: " + Long.toHexString(cycle) + " " + Long.toHexString(sequenceNumber)); } if (cycle != this.cycle || state != FOUND_CYCLE) { // moves to the expected cycle if (!cycle(cycle)) return ScanResult.NOT_REACHED; } index(index); ScanResult scanResult = this.store().moveToIndexForRead(this, sequenceNumber); Bytes<?> bytes = wire().bytes(); if (scanResult == FOUND) { state = FOUND_CYCLE; moveToState.onSuccessfulLookup(index, direction, bytes.readPosition()); return scanResult; } else if (scanResult == END_OF_FILE) { state = END_OF_CYCLE; return scanResult; } else if (scanResult == NOT_FOUND && this.cycle < this.queue.lastCycle) { state = END_OF_CYCLE; return END_OF_FILE; } return scanResult; }
/** * used by the pretoucher to acquire the next cycle file, but does NOT do the roll. If configured, * we acquire the cycle file early */ private void assignCurrentCycle() { final int qCycle = queue.cycle(pretouchTimeProvider); if (qCycle != currentCycle) { releaseResources(); queue.writeLock().lock(); try { currentCycleWireStore = queue.storeForCycle(qCycle, queue.epoch(), true); } finally { queue.writeLock().unlock(); } currentCycleMappedBytes = currentCycleWireStore.bytes(); currentCycle = qCycle; if (chunkListener != null) currentCycleMappedBytes.setNewChunkListener(chunkListener); cycleChangedListener.accept(qCycle); if (EARLY_ACQUIRE_NEXT_CYCLE) if (Jvm.isDebugEnabled(getClass())) Jvm.debug().on(getClass(), "Pretoucher ROLLING early to next file=" + currentCycleWireStore.file()); } }
@Override public void notifyMessage(Object e) { try { @Nullable E ee = e instanceof BytesStore ? valueReader.apply(e) : (E) e; //SubscriptionConsumer.notifyEachSubscriber(subscribers, s -> s.onMessage(ee)); } catch (ClassCastException e1) { if (LOG.isDebugEnabled()) Jvm.debug().on(getClass(), "Is " + valueReader + " the correct ValueReader?"); throw e1; } }
private static void logNewChunk(String filename, int chunk, long delayMicros) { if (!Jvm.isDebugEnabled(MappedFile.class)) return; // avoid a GC while trying to memory map. String message = BytesInternal.acquireStringBuilder() .append("Allocation of ").append(chunk) .append(" chunk in ").append(filename) .append(" took ").append(delayMicros / 1e3).append(" ms.") .toString(); Jvm.debug().on(MappedFile.class, message); }
@Override public void close() { for (@NotNull Subscriber<E> subscriber : subscribers.keySet()) { try { subscriber.onEndOfSubscription(); } catch (Exception e) { Jvm.debug().on(getClass(), e); } } } }
public StoreFileListener storeFileListener() { return storeFileListener == null ? (cycle, file) -> { if (Jvm.isDebugEnabled(getClass())) Jvm.debug().on(getClass(), "File released " + file); } : storeFileListener; }
@Override public boolean put(K key, V value) { try { return chronicleMap.update(key, value) != UpdateResult.INSERT; } catch (RuntimeException e) { if (LOG.isDebugEnabled()) Jvm.debug().on(getClass(), "Failed to write " + key + ", " + value, e); throw e; } }
@Override public void close() { for (@NotNull Subscriber<TopologicalEvent> subscriber : subscribers) { try { subscriber.onEndOfSubscription(); } catch (Exception e) { Jvm.debug().on(getClass(), e); } } } }
@Override public void onEndOfConnection(boolean heartbeatTimeOut) { for (@NotNull final AbstractHandler abstractHandler : new AbstractHandler[]{mapWireHandler, subscriptionHandler, topologySubscriptionHandler, publisherHandler, replicationHandler}) { try { abstractHandler.onEndOfConnection(); } catch (Exception e) { Jvm.debug().on(getClass(), "Failed while for " + abstractHandler, e); } } }
@Override public void notifyMessage(Object e) { try { @Nullable E ee = e instanceof BytesStore ? valueReader.apply(e) : (E) e; SubscriptionConsumer.notifyEachSubscriber(subscribers, s -> s.onMessage(ee)); } catch (ClassCastException e1) { if (LOG.isDebugEnabled()) Jvm.debug().on(getClass(), "Is " + valueReader + " the correct ValueReader?"); throw e1; } }
private static Boolean toBoolean(String s) { if (s == null) return null; s = s.trim(); if (isTrue(s)) return Boolean.TRUE; if (isFalse(s)) return Boolean.FALSE; if (s.isEmpty()) return null; Jvm.debug().on(ObjectUtils.class, "Treating '" + s + "' as false"); return Boolean.FALSE; }
@Override public void applyReplication(@NotNull final ReplicationEntry entry) { if (LOG.isDebugEnabled()) Jvm.debug().on(getClass(), "applyReplication entry=" + entry); if (entry.isDeleted()) remove(entry); else put(entry); }
public void close() { @NotNull File file = chronicleQueue.file(); chronicleQueue.close(); if (dontPersist) { try { deleteFiles(file); } catch (Exception e) { Jvm.debug().on(getClass(), "Unable to delete " + file, e); } } }
@Override public void onSubscribe(@NotNull WireOut wireOut) { if (LOG.isDebugEnabled()) Jvm.debug().on(getClass(), "onSubscribe - localIdentifier=" + localIdentifier + "," + "remoteIdentifier=" + remoteIdentifier); wireOut.writeEventName(identifier) .marshallable(WriteMarshallable.EMPTY) .writeComment(toString() + ", tcpChannelHub={" + hub.toString() + "}"); }