public void shutDown() { if (reader != null) { try { reader.close(); } catch (IOException e) { LOG.error("Exception while closing Reader", e); } } } }
@Override public void get(ByteBuffer key, ReaderResult result) throws IOException { // we want at least readBufferSize bytes of available space. we might resize // again later. result.requiresBufferSize(readBufferSize); // ask the keyfile for this key keyFileReader.get(key, result); // if the key is found, then we are prepared to do the second lookup. if (result.isFound()) { // now we know where to look readRecord(result.getBuffer(), result); } }
public PartitionAccessorRuntimeStatistics getRuntimeStatistics() { // Copy duration and counts long windowDurationNanos = windowTimer.getDuration(); windowTimer.restart(); // Get atomic counters long[] counters = countersWindow.getAsArrayAndSet(0, 0, 0, 0, 0); long numRequestsInWindow = counters[0]; long numHitsInWindow = counters[1]; long responsesNumBytesInWindow = counters[2]; long numL1CacheHitsInWindow = counters[3]; long numL2CacheHitsInWindow = counters[4]; double throughput = 0; double responseDataThroughput = 0; if (windowDurationNanos != 0) { throughput = numRequestsInWindow / (windowDurationNanos / 1000000000d); responseDataThroughput = responsesNumBytesInWindow / (windowDurationNanos / 1000000000d); } return new PartitionAccessorRuntimeStatistics(numRequestsInWindow, numHitsInWindow, throughput, responseDataThroughput, numL1CacheHitsInWindow, numL2CacheHitsInWindow, reader.getCacheStatistics()); }
keyFileReader.getVersionNumber() != null && !keyFileReader.getVersionNumber().equals(versionNumber)) { throw new IOException("Curly Reader version (" + versionNumber + ") does not match the provided key file Reader version (" + keyFileReader.getVersionNumber() + ")");
public HankResponse get(ByteBuffer key, ReaderResult result) throws IOException { // Increment requests counter LOG.trace("Partition GET"); reader.get(key, result); int l1CacheHit = result.getL1CacheHit() ? 1 : 0; int l2CacheHit = result.getL2CacheHit() ? 1 : 0; if (result.isFound()) { countersWindow.increment(1, 1, result.getBuffer().remaining(), l1CacheHit, l2CacheHit); return HankResponse.value(result.getBuffer()); } else { countersWindow.increment(1, 0, 0, l1CacheHit, l2CacheHit); return NOT_FOUND; } }
@Override public CacheStatistics getCacheStatistics() { CacheStatistics keyReaderCacheStatistics = keyFileReader.getCacheStatistics(); return new CacheStatistics( keyReaderCacheStatistics.getNumItems() + cache.size(), keyReaderCacheStatistics.getMaxNumItems() + cache.getMaxNumItems(), keyReaderCacheStatistics.getNumManagedBytes() + cache.getNumManagedBytes(), keyReaderCacheStatistics.getMaxNumManagedBytes() + cache.getMaxNumManagedBytes()); }
if (reader.getVersionNumber() != null && !reader.getVersionNumber().equals(partition.getCurrentDomainVersion())) { partition.getPartitionNumber(), domain.getName(), reader.getVersionNumber(), partition.getCurrentDomainVersion()); LOG.error(msg); exceptions.add(new IOException(msg));
@Override public void close() throws IOException { if (recordFile != null) { recordFile.close(); } if (keyFileReader != null) { keyFileReader.close(); } cache = null; } }