示例#1
0
 void deleteSnapshotsBefore(long captureTime) {
   logger.debug("deleteSnapshotsBefore(): captureTime={}", captureTime);
   try {
     dataSource.update("delete from snapshot where capture_time < ?", captureTime);
   } catch (SQLException e) {
     logger.error(e.getMessage(), e);
   }
 }
示例#2
0
 @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);
   }
 }