/** * Closes Stream manager * * @throws IOException If an IO Error occurs */ public void close() throws IOException { if (mData != null) { mData.close(); } if (mPointers != null) { mPointers.close(); } }
protected void ensureFiles() throws IOException { if (mData.currentFileNo() != mIndexedSequenceFileNumber) { if (!mData.openDataFile(mIndexedSequenceFileNumber)) { throw new CorruptSdfException("Expected file missing"); } // we don't do funny things with pointer file } }
protected void openFiles() throws IOException { if (!mPointers.openDataFile(mIndexedSequenceFileNumber)) { throw new CorruptSdfException("Expected file missing"); } if (!mData.openDataFile(mIndexedSequenceFileNumber)) { throw new CorruptSdfException("Expected file missing"); } }
@Override public void store(Snapshot snapshot) { logger.debug("store(): snapshot={}", snapshot); String spansBlockId = null; CharSource spans = snapshot.getSpans(); if (spans != null) { spansBlockId = rollingFile.write(spans).getId(); } String coarseMergedStackTreeBlockId = null; CharSource coarseMergedStackTree = snapshot.getCoarseMergedStackTree(); if (coarseMergedStackTree != null) { coarseMergedStackTreeBlockId = rollingFile.write(coarseMergedStackTree).getId(); } String fineMergedStackTreeBlockId = null; CharSource fineMergedStackTree = snapshot.getFineMergedStackTree(); if (fineMergedStackTree != null) { fineMergedStackTreeBlockId = rollingFile.write(fineMergedStackTree).getId(); } try { dataSource.update( "merge into snapshot (id, stuck, start_time, capture_time, duration," + " background, error, fine, grouping, error_message, user, attributes," + " metrics, jvm_info, spans, coarse_merged_stack_tree," + " fine_merged_stack_tree) values (?, ?, ?, ?, ?," + " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", snapshot.getId(), snapshot.isStuck(), snapshot.getStartTime(), snapshot.getCaptureTime(), snapshot.getDuration(), snapshot.isBackground(), snapshot.getError() != null, fineMergedStackTreeBlockId != null, snapshot.getGrouping(), snapshot.getError(), snapshot.getUser(), snapshot.getAttributes(), snapshot.getMetrics(), snapshot.getJvmInfo(), spansBlockId, coarseMergedStackTreeBlockId, fineMergedStackTreeBlockId); } catch (SQLException e) { logger.error(e.getMessage(), e); } }
/** * Returns the random access file pointing at the last seek position * * @return the file handle */ public SeekableStream getData() { return mData.randomAccessFile(); }